forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Emails/Notifications => Topic started by: peakoverload on June 18, 2004, 11:56:49 pm

Title: E-Mail Notification To Members On Comments
Post by: peakoverload on June 18, 2004, 11:56:49 pm
I know that people have requested similar things to this in the past but I don't think anyone has requested exactly what I am after (apologies if they have but I couldnt find it).

I run a community site and as such I don't have any private albums so all my members can upload to any of the galleries, vote and comment etc.

What I would love to see is a feature that many other galleries have where the owner of the photo regardless of what user group they are a member of can choose to be e-mailed when their photo is commented on.

This is something many of my members have requested and on several other sites that I am a member of that use other gallery software that has this feature it is very popular.

The way it usually works is very similar to the way it works in a lot of forums that e-mail you when a reply is made to your post. In other words you are presented with a tickbox that says "E-Mail me when someone comments on my photo" when you upload your photo. However you would also need a way of turnng off these reminders as well.

What do you think? Any chance of having this added?
Title: Re: E-Mail Notification To Members On Comments
Post by: GGallery on June 23, 2004, 08:12:08 pm
I just hacked something together... just for YOU!

(needs to be in db_input in the  case 'comment': section at around line 145 after the             if ($CONFIG['email_comment_notification']) { ... } )


Code: [Select]
           // send an email to the owner of the picture
            $result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
            if (mysql_num_rows($result)) {
              $picture_owner_data = mysql_fetch_array($result);
              $subject = "New GJPix Comment by ".USER_NAME;
              $mail_body  = "Hi ".$user_name."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
              $mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
              cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

            }


Of course the language should be extracted and put into the lang/ files... but it works as a quick hack.

Moderators: I tried to add that to the mod forum but there's no 'new topic' button anymore for me.

ADDED: the mod above _always_ sends notifications - you would need to add some field to your user table or lookup a forum table to note/check if the users wants to get notified (with hundreds of spam messages every day they usually don't mind :)
Title: Re: E-Mail Notification To Members On Comments
Post by: Joachim Müller on June 24, 2004, 12:01:08 am
we won't allow "regular users" to create new threads on the mods board, because it would soon be flooded with mod requests instead of actual mods (people just don't read board topics). You were right to post here, I'll move the thread to the mods board for you.

GauGau

P.S. Changed your status to "contributor"  ;)
Title: Re: E-Mail Notification To Members On Comments
Post by: Joachim Müller on June 24, 2004, 12:10:10 am
A nice first step, but to include this into the mainstream release, the option has to be admin settable (not so hard, just an additional entry in cpg_config and a plain if/then switch in front of your code) and has to be switched on/off by the individual user as well, as some active users won't like to get flooded with emails, while others will like the option. The main issue here is bbs integration: it'll be easy to add an option to the regular coppermine profile page, but it's impossible to add it to the profile if coppermine get's bridged. As a workaround, this could be an additional entry in the user admin menu labelled "notification" where the user could switch this on/off outside of the profile (the question remains: where do you store this data?).
Would be very nice if you could come up with an elegant solution for this issue.

GauGau
Title: Re: E-Mail Notification To Members On Comments
Post by: GGallery on July 01, 2004, 04:40:40 am
I think I would provide the switch to the user in profile.php that's where it belongs to
Title: Re: E-Mail Notification To Members On Comments
Post by: Joachim Müller on July 01, 2004, 07:40:00 am
sure, I wasn't making this clear, sorry: one switch for the admin (enable eMail notification on comments - YES/NO) in coppermine config, one for each user in profile.php (that only turns up if the admin has enabled this feature in coppermine config). Reason: there are users (coppermine site admins) who like their version of coppermine to keep exactly the same features as the old version when upgrading, so we decided all new features must have an admin switch.

GauGau
Title: Re: E-Mail Notification To Members On Comments
Post by: peakoverload on July 26, 2004, 12:10:47 am
Just wanted to say a big thank you for coming up with this code!!!

Sorry I didnt reply before but I only just refound this thread (I got side tracked with another issue and forgot about this thread  ::) )

I shall try out this mod in the next couple of days and feed back the results.
Title: Re: E-Mail Notification To Members On Comments
Post by: Allo on August 18, 2004, 06:26:13 am
Nice work. But i have a question:
Will this feature slow down the server ? I think yes.
I was looking for a similar feature and i realized that the best solution to alert an user of a comment is to create a page where to show the alert of the comments like in www.deviantart.com. This will be not an hard work for the server.
Title: Re: E-Mail Notification To Members On Comments
Post by: willemt on March 02, 2005, 06:10:35 am
Hello,

First thanks a lot for the code you shared with the board. I have a problem implementing it though ???: Getting an error everytime somebody posts a comment:
"There was an error while processing a database query".  :-\\
Could it be related to the fact that I integrated coppermine into a phpbb board and that the db query in your code should be modified because of this? (I did follow the documentation to bridge between the two).

I am really new to sql stuff and did not mess arround with it so fare...
Thanks for your ideas!!

Willem.

I just hacked something together... just for YOU!

(needs to be in db_input in the  case 'comment': section at around line 145 after the             if ($CONFIG['email_comment_notification']) { ... } )


Code: [Select]
           // send an email to the owner of the picture
            $result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
            if (mysql_num_rows($result)) {
              $picture_owner_data = mysql_fetch_array($result);
              $subject = "New GJPix Comment by ".USER_NAME;
              $mail_body  = "Hi ".$user_name."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
              $mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
              cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

            }


Of course the language should be extracted and put into the lang/ files... but it works as a quick hack.

Moderators: I tried to add that to the mod forum but there's no 'new topic' button anymore for me.

ADDED: the mod above _always_ sends notifications - you would need to add some field to your user table or lookup a forum table to note/check if the users wants to get notified (with hundreds of spam messages every day they usually don't mind :)

Title: Re: E-Mail Notification To Members On Comments
Post by: RatKing on March 02, 2005, 11:28:27 am
The error you are getting is because your CPG_CONFIG table does most likely not have a field called: email_comment_notification

So go to your database add this record to your CPG_CONFIG table and the message will be gone. To have the mails send out set the value (second colum in the database) to 'true' and the mails will be send.

If I have some time I'll see if I can write a bit clearer story about how to do this. It's quite simple actualy the only problem is that the writter (GGalery) assumed quite a bit of knowledge on how CPG works internaly the side of the readers.
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on March 02, 2005, 12:08:13 pm
This mod will not work with a bridged install. You would need to rewrite that query to pull the data from the correct table, or find some workaround to get the info some other means.
Title: Re: E-Mail Notification To Members On Comments
Post by: willemt on March 02, 2005, 04:48:49 pm
Hi Ratking,

Thanks a lot for steering me in the right direction, I will give it a try later today!

regards,
Willem.

The error you are getting is because your CPG_CONFIG table does most likely not have a field called: email_comment_notification

So go to your database add this record to your CPG_CONFIG table and the message will be gone. To have the mails send out set the value (second colum in the database) to 'true' and the mails will be send.

If I have some time I'll see if I can write a bit clearer story about how to do this. It's quite simple actualy the only problem is that the writter (GGalery) assumed quite a bit of knowledge on how CPG works internaly the side of the readers.
Title: Re: E-Mail Notification To Members On Comments
Post by: willemt on March 02, 2005, 04:59:34 pm
Anybody who moded this mod  ::) to work on a bridged installation?

thanks!!

Willem.

This mod will not work with a bridged install. You would need to rewrite that query to pull the data from the correct table, or find some workaround to get the info some other means.
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on March 03, 2005, 05:23:45 pm
You can try using this code instead, I haven't tested it though.

Code: [Select]
if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');
Title: WORKS! but...
Post by: willemt on March 03, 2005, 08:01:02 pm
... something goes wrong with the if-else check: the else part is executed not matter what. So I just removed the if-else and call the if-part directly without doing the check.

And it works great!  ;D

Thanks a lot,

Willem.
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on March 04, 2005, 12:36:22 pm
Probably needs quotes around the UDB_INTEGRATION - original post so edited.
Title: Re: E-Mail Notification To Members On Comments
Post by: TerryG on April 02, 2005, 10:44:45 pm
Hey,

Just thought I would point out a potential gotcha -- put this block before  "if (!USER_ID)"  in db_input.php

I put the new code within the THEN clause, and was hitting mostly the ELSE.  d'oh!
Title: Re: E-Mail Notification To Members On Comments
Post by: nanothree on April 10, 2005, 12:57:15 pm
Another suggestion would be to stop emails form being sent when a user comments on their own image.
Title: Re: E-Mail Notification To Members On Comments
Post by: nanothree on April 10, 2005, 01:26:53 pm
i am getting an error, it doenst say what it is though it just has the error box and no text in, so i turned on debug mode and all that appears in the box is:
 File: /home/liam/public_html/Gallery/bridge/phpbb.inc.php - Line: 277
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on April 10, 2005, 02:19:36 pm
That means it couldn't find the user in the database when it did the udb_get_user_infos().
Title: Re: E-Mail Notification To Members On Comments
Post by: nanothree on April 10, 2005, 02:28:02 pm
ermm, any idea how i fix this?
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on April 10, 2005, 02:29:22 pm
Ah, is this a comment on an anonymously uploaded pic ?
Title: Re: E-Mail Notification To Members On Comments
Post by: nanothree on April 10, 2005, 03:47:04 pm
it seems to have stopped now, but that would be a problem, would it be possible to stop that error from happening if that was the case?

BTW i have made it possible to turn this feature on and off from the config page
Code: [Select]
if ($CONFIG['email_user_comment_notification']) {

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

}

then you need to add a new row to the config table, you can use this sql query:
Code: [Select]
INSERT INTO `cpg11d_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)

change cpg11d to what your table prefix is

and finally find, in lang/englsih.php
Code: [Select]
  array('Notify admin of comments by email', 'email_comment_notification', 1), //cpg1.3.0
and after it add
Code: [Select]
array('Allow users to recieve email when comments are posted', 'email_user_comment_notification', 1),
from this it should be very easy to add a check for user approval, but i am yet to implement this
Title: Re: E-Mail Notification To Members On Comments
Post by: protox on April 12, 2005, 05:08:48 pm
I've tryed this mod .. but I don't receive any mail ... and I don't understand why this doesn't work because the code seems to be working ...

Here is the code :

** EDIT :: ok; it's working .. I'm a poor stupid lame .. sorry :-X ;D **
Title: Re: E-Mail Notification To Members On Comments
Post by: Chrigi on May 02, 2005, 08:34:41 pm
hi there

i've made this for my gallery (brigded for phpBB) but it doesn't work. i means, i've changed the code, and it works fine to add an comment, but i recieve no mail.
is there anything wrong in the DB query, if yes, can anybody make for me such an query for the phpBB?

greetz and thx
chrigi
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on May 02, 2005, 08:39:05 pm
http://forum.coppermine-gallery.net/index.php?topic=7102.msg71935#msg71935
Title: Re: E-Mail Notification To Members On Comments
Post by: Chrigi on May 02, 2005, 09:07:32 pm
hi Nibbler,

thank tou you for the answer,  i've tried it, but nothing works.
this is a piece of the code, starting at "//comment"
Code: [Select]
    // Comment

    case 'comment':
        if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        check_comment($HTTP_POST_VARS['msg_body']);
                check_comment($HTTP_POST_VARS['msg_author']);
        $msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
        $msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
        $pid = (int)$HTTP_POST_VARS['pid'];

        if ($msg_author == '' || $msg_body == '') cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);

        $result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'");
        if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
        $album_data = mysql_fetch_array($result);
        mysql_free_result($result);

        if ($album_data['comments'] != 'YES') cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        if (!$CONFIG['disable_comment_flood_protect']){
          $result = db_query("SELECT author_md5_id, author_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid = '$pid' ORDER BY msg_id DESC LIMIT 1");
          if (mysql_num_rows($result)) {
              $last_com_data = mysql_fetch_array($result);
              if ((USER_ID && $last_com_data['author_id'] == USER_ID) || (!USER_ID && $last_com_data['author_md5_id'] == $USER['ID'])) {
                  cpg_die(ERROR, $lang_db_input_php['no_flood'], __FILE__, __LINE__);
              }
          }
        }

        if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
            $USER['name'] = $HTTP_POST_VARS['msg_author'];
            $redirect = "displayimage.php?pos=" . (- $pid);
           if ($CONFIG['email_comment_notification']) {
            $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'webmaster@snaplife.ch');


            }

            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        } else { // Registered users, we can use Location to redirect
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
            $redirect = "displayimage.php?pos=" . (- $pid);
            if ($CONFIG['email_comment_notification']) {

                $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body'] . " " . $CONFIG['ecards_more_pic_target'] . $redirect;
                cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
            }
         $header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
            header($header_location . $redirect);
            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        }
        break;

Can you please tell me, where I make the fault?

greetz n thx
chrigi
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on May 02, 2005, 09:16:17 pm
Wrong place, put it after the other

Code: [Select]
if ($CONFIG['email_comment_notification']) {
Title: Re: E-Mail Notification To Members On Comments
Post by: Chrigi on May 02, 2005, 09:41:38 pm
ough

I felt a bit sheepish about it.
but now it works, thanks a lot  :D ;D

greetz
chrigi
Title: Re: E-Mail Notification To Members On Comments
Post by: Rallemann on May 10, 2005, 07:36:04 pm
then you need to add a new row to the config table, you can use this sql query:
Code: [Select]
INSERT INTO `cpg11d_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)

change cpg11d to what your table prefix is


Which file do I have to edit?
I can't find a similar code in config.php
In which line the text has to been added?

thanks for support =)
Title: Re: E-Mail Notification To Members On Comments
Post by: Nibbler on May 10, 2005, 07:41:15 pm
You need to run the query on your database using phpmyadmin or similar.
Title: Re: E-Mail Notification To Members On Comments
Post by: blobnl on June 14, 2005, 06:26:07 pm
Hi i followed the instruction but i do not recieve any email.. (as admin i will receive the comment emails)
Here is my code can anyone tell me if this is ok ?
Code: [Select]
   // Comment

    case 'comment':
        if (!(USER_CAN_POST_COMMENTS)) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);

        check_comment($HTTP_POST_VARS['msg_body']);
        $msg_author = addslashes(trim($HTTP_POST_VARS['msg_author']));
        $msg_body = addslashes(trim($HTTP_POST_VARS['msg_body']));
        $pid = (int)$HTTP_POST_VARS['pid'];

        if ($msg_author == '' || $msg_body == '') cpg_die(ERROR, $lang_db_input_php['empty_name_or_com'], __FILE__, __LINE__);

        $result = db_query("SELECT comments FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'");
       


        //MATEJ DOPESNU
        if ($pid == 0) {
        } else {
           if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
        }
        //-------------
        $album_data = mysql_fetch_array($result);
        mysql_free_result($result);
       
//MATEJ DOPESNU
        if ($pid == 0) {
        } else {
           if ($album_data['comments'] != 'YES') cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
        }        
        //-------------
       

        if (!$CONFIG['disable_comment_flood_protect']){
          $result = db_query("SELECT author_md5_id, author_id FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid = '$pid' ORDER BY msg_id DESC LIMIT 1");
          if (mysql_num_rows($result)) {
              $last_com_data = mysql_fetch_array($result);
              if ((USER_ID && $last_com_data['author_id'] == USER_ID) || (!USER_ID && $last_com_data['author_md5_id'] == $USER['ID'])) {
                  cpg_die(ERROR, $lang_db_input_php['no_flood'], __FILE__, __LINE__);
              }
          }
        }

        if (!USER_ID) { // Anonymous users, we need to use META refresh to save the cookie
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '$msg_author', '$msg_body', NOW(), '{$USER['ID']}', '0', '$raw_ip', '$hdr_ip')");
            $USER['name'] = $HTTP_POST_VARS['msg_author'];
            //MATEJ DOPESNU
            if ($pid == 0) {
         $redirect = "index.php";
            } else {
              $redirect = "displayimage.php?pos=" . (- $pid);        
            }
            //-------------
            if ($CONFIG['email_comment_notification']) {
                $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body']." http://" . $_SERVER["SERVER_NAME"] . "/" . $redirect;
                cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
            }
            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        } else { // Registered users, we can use Location to redirect
            $insert = db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pid', '" . addslashes(USER_NAME) . "', '$msg_body', NOW(), '', '" . USER_ID . "', '$raw_ip', '$hdr_ip')");
            //MATEJ DOPESNU
            if ($pid == 0) {
         $redirect = "index.php";
            } else {
              $redirect = "displayimage.php?pos=" . (- $pid);        
            }
            //-------------
            if ($CONFIG['email_comment_notification']) {
                $mail_body = $msg_body . "\n\r ".$lang_db_input_php['email_comment_body']." http://" . $_SERVER["SERVER_NAME"] . "/" . $redirect;
                cpg_mail($CONFIG['gallery_admin_email'], $lang_db_input_php['email_comment_subject'], $mail_body);
            }
            $header_location = (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE'))) ? 'Refresh: 0; URL=' : 'Location: ';
            header($header_location . $redirect);
            pageheader($lang_db_input_php['com_added'], "<META http-equiv=\"refresh\" content=\"1;url=$redirect\">");
            msg_box($lang_db_input_php['info'], $lang_db_input_php['com_added'], $lang_continue, $redirect);
            pagefooter();
            ob_end_flush();
            exit;
        }
if ($CONFIG['email_user_comment_notification']) {

if (defined('UDB_INTEGRATION')){
$result = db_query("SELECT owner_id  FROM {$CONFIG['TABLE_PICTURES']} WHERE pid=".$pid);
list($uid) = mysql_fetch_row($result);
$picture_owner_data = udb_get_user_infos($uid);
} else {
// send an email to the owner of the picture
$result = db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
}
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, $mail_body, 'text/plain', "GJPix", 'dontreply@yourdomain.com');

}
        break;

    // Update album
Title: Re: E-Mail Notification To Members On Comments
Post by: chupa2k on July 11, 2005, 05:29:12 pm
I have a question , Will this work with IPB 1.3 bridge ??? this is just what i need .
Title: Re: E-Mail Notification To Members On Comments
Post by: AWJunkies on January 31, 2006, 12:14:00 am
Edited to work with 1.4.3 stand alone as well as E-mail link becomes clickable now. THIS IS FOR NON BRIDGED VERSIONS the UDB blah balh wasnt working because 1.4.3 doesn't have the function called opon to grab photo infos. If someone wants it for bridged version as well I will find the new function for the same thing if needed.

db_input.php
FIND:
Code: [Select]
if ($CONFIG['email_comment_notification'] && !USER_IS_ADMIN ) {ADD BEFORE:
Code: [Select]
if ($CONFIG['email_user_comment_notification']) {

// send an email to the owner of the picture
$result = cpg_db_query("SELECT user_name,user_email FROM {$CONFIG['TABLE_PICTURES']} AS p, {$CONFIG['TABLE_USERS']} AS u WHERE u.user_id=p.owner_id and p.pid=".$pid);
$picture_owner_data = mysql_fetch_array($result);
$subject = "New GJPix Comment by ".USER_NAME;
$mail_body  = "Hi ".$picture_owner_data['user_name']."!\n\n".USER_NAME." just wrote a comment on one of your photos, click the link below to read and reply to it.\n";
$mail_body .= "http://gallery.greatestjournal.com/displayimage.php?pos=-".$pid;
cpg_mail($picture_owner_data['user_email'], $subject, make_clickable($mail_body), 'text/plain', "GJPix", 'dontreply@yourdomain.com');
}
DONT FORGET TO CHANGE $mail_body url to yours as well as $subject and as well cpg_mail info.


then you need to add a new row to the config table, you can use this sql query:
Code: [Select]
INSERT INTO `cpg143_config` ( `name` , `value` )
VALUES (
'email_user_comment_notification', 1
)

and finally find, in lang/englsih.php
Code: [Select]
  array('Notify admin of comments by email', 'email_comment_
and after it add
Code: [Select]
array('Allow users to recieve email when comments are posted', 'email_user_comment_notification', 1),
Title: Re: E-Mail Notification To Members On Comments
Post by: fcarentz on February 04, 2006, 01:50:43 am
A search would have revealed a working version of this script that i did back in December.

http://forum.coppermine-gallery.net/index.php?topic=25675.0

Go there and follow the instructions it will support a bridge and your users can set the option to be mailed or not. And it will only mail them once until they view the comments so they don't get spammed with Comment emails.

Hope this helps you.
Title: Re: E-Mail Notification To Members On Comments
Post by: angeldevil on May 09, 2006, 02:55:26 pm
hi to you,
i tried your code but didn't work for me. i have coppermine version 1.4.4
is there any edit that i might write on your script?
help me, please!
Title: Re: E-Mail Notification To Members On Comments
Post by: cosmoweb on July 15, 2008, 12:05:49 am
For coppermine 1.4.18, that's all right?  ::)
Title: Re: E-Mail Notification To Members On Comments
Post by: Joachim Müller on July 15, 2008, 06:59:48 am
Should work for all versions of the cpg1.4.x series.