$gallery->app->adminOtherChangesEmail was not working -- fixed Album.php

rbeuker

Joined: 2006-01-26
Posts: 3
Posted: Thu, 2006-01-26 20:07

After upgrading to 1.5.2 I noticed that I was no longer receiving emails whenever there were *other* changes. So I was receiving emails for picture comments, but NOT for other changes.

I think there's a small error in this code (from Album.php in the classes folder):

        // send email
        if ($gallery->app->emailOn == 'yes' && $success && $msg) {
            if (!is_array($msg)) {
                echo gallery_error(_("msg should be an array!"));
                vd($msg);
                return $success;
            }

              if (!empty($to)) {
                $to = $this->getEmailMeList('other');
                $text = '';
                $msg_str = call_user_func_array('sprintf', $msg);
                $subject = sprintf(_("Changes to Album: %s"), $this->fields['name']);
                $logmsg = sprintf("Change to %s: %s.", makeAlbumHeaderUrl($this->fields['name']), $msg_str);

                $text .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
                $text .= "\n\n<html>";
                $text .= "\n  <head>";
                $text .= "\n  <title>$subject</title>";
                $text .= "\n  </head>\n<body>\n<p>";
                $text .= sprintf(_("A change has been made to Album: %s by %s (IP %s).  The change is: %s"),
                  '<a href="'. makeAlbumHeaderUrl($this->fields['name']) .'">'. $this->fields['name'] .'</a>',
                $gallery->user->printableName($gallery->app->comments_display_name),
                  $_SERVER['REMOTE_ADDR'],
                $msg_str);

                $text .= "\n<p>". _("If you no longer wish to receive emails about this image, follow the links above and ensure that 'Email me when other changes are made' is unchecked (You'll need to login first).");
                $text .= "\n</p>\n</body>\n</html>";


                gallery_mail($to, $subject, $text, $logmsg, true, NULL, false, true);

            } else if (isDebugging()) {
                print "\n<br>". _("Operation was done successfully. Emailing is on, but no email was sent as no valid email address was found");
            }
        }

I've changed

if (!empty($to)) {

to

if (empty($to)) {

and then I started receiving these emails as well! :-)

 
Tim_j
Tim_j's picture

Joined: 2002-08-15
Posts: 6818
Posted: Fri, 2006-01-27 12:40

Hello,

thanks for the report. You found indeed a bug, but your fix is wrong.

Correct fix were to move:$to = $this->getEmailMeList('other'); above the (correct) if (!empty($to)) {

Fixed in Gallery 1.5.3-cvs-b4

thanks,
Jens

--
Last Gallery v1 developer and translation manager.

 
rbeuker

Joined: 2006-01-26
Posts: 3
Posted: Fri, 2006-01-27 17:37

Thank you! :-)