Author Topic: [Mod] Mail Owner of image when Comment is Posted  (Read 248936 times)

0 Members and 1 Guest are viewing this topic.

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Mail Owner of image when Comment is Posted
« on: November 16, 2002, 03:46:47 PM »
Hi all,

I know that there already are many posting on this topic, but I finally succeeded in getting it to work. So this is more or less a tutorial.

This is what you have to do.

1.  Open Details.php
2. add after:
Code: [Select]
     $site_db->query($sql);
      $commentid = $site_db->get_insert_id();
      update_comment_count($id, $user_info['user_id']);


Add this:
Code: [Select]
   $sql = "SELECT image_name FROM ".IMAGES_TABLE." WHERE image_id = $id";
    $image_name = $site_db->query($sql);
    $sql = "SELECT user_id FROM ".IMAGES_TABLE." WHERE image_id = $id";
    $user_id = $site_db->query($sql);
   
    $recipient_name = $image_row['user_name'];
    $recipient_email = $image_row['user_email'];
    $image_url = $script_url."/details.php?".URL_IMAGE_ID."=".$id."";
   
       // Start Emailer für comments
    include(ROOT_PATH.'includes/email.php');
    $site_email = new Email();
    $site_email->set_to($recipient_email);
    $site_email->set_from($config['site_email'], $config['site_name']);
    $site_email->set_subject("Comment Posted");
    $site_email->register_vars(array(
      "user_name" => $image_row['user_name'],
      "recipient_name" => $recipient_name,
      "image_name" => $image_row['image_name'],
      "comment_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
      "site_name" => $config['site_name'],
      "image_url" => $image_url,
          ));
    $site_email->set_body("comment_email", $config['language_dir']);
    $site_email->send_email();


Make sure that you posted it before:
Code: [Select]
   }
  }
  unset($row);
  unset($spam_row);
}

//-----------------------------------------------------
//--- Show Comments -----------------------------------
//-----------------------------------------------------


3. Now you have to make a mail template called comment_email.html

put this in the comment_email.html:

Code: [Select]
Dear {user_name},

someone posted a comment on {image_name} at {site_name}.
To view the comment go to: {image_url}
Date: {comment_date}

------
Best regards, {site_name}


save this mail template in:  [ROOT]/Lang/[your_language]/email/

This should be all.

Note:
    Always back-up any file you begin to edit.
    I cannot be held responsible for any data loss or any other problem that might  happen after editing files like I explained above.
    I do not have much php knowledge so I expect that there will be some improvements possible in the code I just gave. If you have any additions or improvements to the code I posted, please feel free to reply.[/list:u]

    I hope you all like this addition.

    Cheers,
    Vraxor

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Mail Owner of image when Comment is Posted
« Reply #1 on: November 16, 2002, 05:03:06 PM »
I forgot something important.

Most of the code was provided by Tommy. He posted something about this earlier, but that was in german and I did not really understand what it was about.

Anyways, some credits belong to him too  8)

Vraxor

Offline Mec4D

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.mec4d.com
[Mod] Mail Owner of image when Comment is Posted
« Reply #2 on: November 16, 2002, 06:25:58 PM »
Vraxor and Tommy,

thank you very much!! this is great option and this works SUPER..

one little bug is at :
Quote

3. Now you have to make a mail template called comment_mail.html

put this in the comment_mail.html:


need to: comment_email.html  other you get error in 1.7.V

Thanks Again
Catharina

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Mod] Mail Owner of image when Comment is Posted
« Reply #3 on: November 16, 2002, 06:29:43 PM »
Quote from: Mec4D

one little bug is at :
Quote

3. Now you have to make a mail template called comment_mail.html

put this in the comment_mail.html:


need to: comment_email.html  other you get error in 1.7.V

Actually it's because of this PHP line:
Code: [Select]

    $site_email->set_body("comment_email", $config['language_dir']);

So if you want to use comment_mail.html just change the php line or else use the file name comment_email.html.  I just wanted to point out its a simple little change and not due to any particular 4images version.

Way to go guys!  Nice mod.

Offline Mec4D

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.mec4d.com
[Mod] Mail Owner of image when Comment is Posted
« Reply #4 on: November 16, 2002, 07:04:08 PM »
I have little question about the data of the comments..I posted comments under my own images 2 times and I got e-mail with the same data of posted comments : Date: 31.12.1969 19:00 no matter I asked one member that got comments with the same Date: 31.12.1969 19:00.

how I can fix this?

Thank you for your help,

Cath
Catharina

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Mail Owner of image when Comment is Posted
« Reply #5 on: November 16, 2002, 07:10:32 PM »
@ Mec4D:
I think you can better leave that line out, since I have the same problem. The date is incorrect, should be able to fix, but I did not find it any important.
So just remove the "Date: {comment_date}" out of the template.

About the "Comment_mail.html":  Yes, I made a type error. It should be: 'Comment_email.html", but I already changed it.

Cheers,
Vraxor

Offline Tommy

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.rendertown.de
[Mod] Mail Owner of image when Comment is Posted
« Reply #6 on: November 16, 2002, 09:34:36 PM »
Hi Vraxor,

Thanks for the credits, but you take it by your self and the credits go back to you  :wink:

The code is right and you have make a very good tutorial about this, and it must run with the little corrections from Mec4d very good.

@Mec4d Yes, delete the line with the comment_date (in the code and in the template), it only makes problems  :wink:

But, some little cosmetic changes i will give you here -

for your line:

Code: [Select]

   $site_email->set_subject("Comment Posted");


take this line:

Code: [Select]

$site_email->set_subject($lang['send_comment_emailsubject']);


Now go to your lang/"your language"/main.php/ to the point "Comments":

After this code:

Code: [Select]

//-----------------------------------------------------
//--- Comments ----------------------------------------
//-----------------------------------------------------
.
.
.
$lang['post_comment'] = "post comment";


add this code:
Code: [Select]

$lang['send_comment_emailsubject'] = "Your picture has become a new comment";


For the text "Your picture..." write what you want, i hope in better english as mine. Thats the email subject  :wink:

For your line:

Code: [Select]

      "user_name" => $image_row['user_name'],
      "recipient_name" => $recipient_name,


take this lines:

Code: [Select]

      "user_name" => stripslashes($user_name),
      "recipient_name" => stripslashes($image_row['user_name']),


"user_name" is the name of the person who makes the comment
"recipient_name" is the name of the owner of the picture. He / She becomes this mail.

Now you can take this code in your comment_email.html

Code: [Select]

Dear {recipient_name},

{user_name} posted a comment on {image_name} at {site_name}.
To view the comment go to: {image_url}

------
Best regards, {site_name}


Everybody who has make the Mod-phpbb integration must chance this line:

Code: [Select]

     "recipient_name" => stripslashes($image_row['user_name']),


with this line:

Code: [Select]

     "recipient_name" => stripslashes($image_row['username']),


If you don`t do it you have no recipient_name in your template.

When you test this mod at home (at your local server on your Pc), it is right that you become an error-messages like this: Error in email.php. You cant send on your local Pc emails  :wink: Online (on your webspace) this Mod runs correctly !!!

So I think that was all for the moment  :D
... and sorry for my english its not the best  :wink:

cu

tommy

Offline Mec4D

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.mec4d.com
[Mod] Mail Owner of image when Comment is Posted
« Reply #7 on: November 17, 2002, 12:10:59 AM »
Vraxor and Tommy,

thank you so much..I changed already the codes and everything works perfect!

I was waiting for this module for long time and finaly you got this guys working!!!!!

Big Hugs! to both of you


Catharina
Catharina

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Mail Owner of image when Comment is Posted
« Reply #8 on: November 17, 2002, 08:54:08 AM »
Thanks a lot Tommy,

these last additions work great and I got a little messed up between the 2 diffent usernames ;-)

Cheers,
Vraxor

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Mail Owner of image when Comment is Posted
« Reply #9 on: November 21, 2002, 01:31:20 PM »
Thank you very, very much for this really helpful add-on! I just changed the codes and it works great! I'm raelly glad about it... - and I think my users feel the same...

Wishing you a happy day,

Biggi

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Mail Owner of image when Comment is Posted
« Reply #10 on: December 01, 2002, 10:37:49 AM »
Hi @all,

today I have a further question:

how could I manage it not only to show  the link to the comment, but further the comment itself in the e-mail? Is this possible?

Could someone show the code-changes? That would be great...

Have a nice day,

Biggi

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Mail Owner of image when Comment is Posted
« Reply #11 on: December 01, 2002, 05:37:49 PM »
but then, how would u know for witch picture was that coments?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Mail Owner of image when Comment is Posted
« Reply #12 on: December 01, 2002, 08:18:25 PM »
I want the whole comment just in addition. The title of the image and the link should'nt be replaced. Just additional.

By the way: I'd like to change the notifies. I only need them, if a user commented, but NOT, if I answered to a comment.

My knowledge of PHP isn't good enough, so I would be glad if someone could help to realize my wishes.

Thanks,

Biggi

Offline Vraxor

  • Full Member
  • ***
  • Posts: 134
    • View Profile
    • http://tc-revolution.net
[Mod] Mail Owner of image when Comment is Posted
« Reply #13 on: December 01, 2002, 09:22:06 PM »
HI Biggy,

I know it's not perfect right now and this results in a notify also beeing send when you post a comment on your own image. I could fix this by making an owner check in the comment system, but right now I just don't feel like coding too much and it's still too difficult for me to say it will be done in 10 minutes, in fact I don't know if I could do it at all.

About putting the comment into the mail, this might be possible. Only prob is that my PHP knowledge is too limited at the moment to say how. And right now I'm working on totally different things so I don't have time to figure it out. Maybe somebody else would like to improve the mod.

Cheers,
Vraxor

Offline Biggi

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://www.bibodia.de/
[Mod] Mail Owner of image when Comment is Posted
« Reply #14 on: December 06, 2002, 04:57:38 PM »
Hi Vraxor,
nevertheless I thank you for your answer. I know about the problem working on other projects and not having any time. You may say, I leased it  :wink:

Maybe some day somebody else could solve the problem...

Regards,

Biggi