Potential Gallery Feature: E-mail Notification When Comments

gregchet
gregchet's picture

Joined: 2003-01-10
Posts: 105
Posted: Sun, 2003-01-12 10:12

I'm sure this is planned for a future release, but it would be very handy if an e-mail notification could be sent every time someone posts a comment in Gallery.

Some of the galleries I moderate are completely public, so the content has to remain fairly tame. Without getting an e-mail notification, you have to search through each one of the galleries and see if there are any new comments. This is very time consuming, and would become impossible to do when your image gallery gets too big.

Maybe even just have a feature when you login as an admin, you can view a list of the most recently comments, and delete them if the content isn't appropriate.

Below is a small modification I made to "add_comment.php" in the main Gallery directory. It sends out an e-mail notification when a comment is posted, and it's very easy to implement. All the information is hard coded right now, but it would be handy if it could be implemented directly into Gallery, so that you can modify the fields when you're logged in as an admin.

HOW TO IMPLEMENT:

Open "add_comment.php" in the main Gallery directory. Search for the below lines.

$gallery->album->save();
dismissAndReload();

CHANGE TO:

$gallery->album->save();
<NEW CODE - INCLUDED BELOW>
dismissAndReload();

NEW CODE:

// THIS IS THE START OF THE MODIFICATION

// E-mail 'To' Address
$toaddress = "admin@yourdomain.com";

// Subject
$subject = "New Gallery Comment";

// Headers
$headers .= "From: Gallery <gallery@yourdomain.com>n";
$headers .= "X-Sender: <gallery@yourdomain.com>n";
$headers .= "X-Mailer: PHPn"; // mailer
$headers .= "X-Priority: 1n"; // Urgent message!
$headers .= "Return-Path: <gallery_error@yourdomain.com>n"; // Return path
// Message
$message = "nName: $commenter_namen";
$message .= "IP Address: $IPNumbern";
$message .= "Album URL: ";
$message .= makeAlbumUrl($gallery->session->albumName);
$message .= "nn";
$message .= "Message:nn$comment_textnn";
mail($toaddress,$subject,$message, $headers);

// THIS IS THE END OF THE MODIFICATION

And that's all there is to it. I hope someone can get some use out of this.

Best regards,

Greg Chetcuti
C.Development Solutions
http://www.CDSNetwork.com

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Fri, 2003-03-07 15:48

Also, those of you interested could have a look to <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=458&amp;4063" TARGET="_blank">this thread</A><!-- BBCode End -->.
Just cross-referencing.
p

 
midkiff

Joined: 2003-06-27
Posts: 70
Posted: Tue, 2003-09-09 23:01

This works fine for me except in the from address in the email i get this UNEXPECTED_DATA_AFTER_ADDRESS@.SYNTAX-ERROR. along with the from address

Here is my code:
// E-mail 'To' Address
$toaddress = "admin@mydamnpage.com";

// Subject
$subject = "Comment added by ".$commenter_name." to the gallery";

// Headers
$headers .= "From: Mydamn gallery <gallery@mydamnpage.com>";
$headers .= "X-Sender: <gallery@mydamnpage.com>";
$headers .= "X-Mailer: PHP"; // mailer
$headers .= "X-Priority: 1"; // Urgent message!
$headers .= "Return-Path: <admin@mydamnpage.com>"; // Return path
// Message
$message .= "Name: $commenter_name, ";
$message .= "IP Address: $IPNumber, ";
$message .= "Comment: $comment_text, ";
$message .= "Commented pic URL: ";
$id = $gallery->album->getPhotoId($index);
$message .= makeAlbumUrl($gallery->session->albumName, $id);
mail($toaddress,$subject,$message, $headers);

Any one have any ideas?