mail: "there is a new comment in your story"

Register an Account
Reply
 
Thread Tools Display Modes
  #31 (permalink)  
Old 01-01-2008, 05:42 PM
New Pligger
 
Join Date: Sep 2007
Posts: 29
I'm having the same problem - the new field is inserted properly (link_subscribe=1), but no emails are sent. I also made sure the "from" email is valid which could cause a problem with some hosts.

I changed "public_email" to "user_email", still doesn't work - I'm def no programmer, but it seems to be at the $mail stage. The "change status" email is received immediately, so I know my server is capable of handling this type of function.

Edit: can someone pls tell me which file contains the code to send an email when link status is changed? This problem may be hosting-related.

Any suggestions much appreciated!

Last edited by teezone; 01-01-2008 at 05:47 PM.
Reply With Quote
  #32 (permalink)  
Old 01-02-2008, 01:35 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Quote:
Originally Posted by redwine View Post
Thanks to inggenia for the idea.

I came up with a fix for providing the user with an option to subscribe or not to a certain news/story that he or she posts. The user can always turn off/on this option by clicking on the “admin links” within the story post and then clicking on “Edit the title or description.”. I tested it thoroughly and it works with no problems.
Start by adding a new column to the links table in your database. This is needed to mark the stories that the user wants to receive emails whenever a comment is added to the story. It is “0” by default, meaning that this option was not selected. If selected, the value would be “1”.
Code:
 
ALTER TABLE `pligg_links` ADD COLUMN `link_subscribe` TINYINT( 1 ) NULL DEFAULT '0';
Open “/libs/lang.conf” and add the following under “SUBMIT - STEP 2” section:

Code:
 
//<SECTION>SUBMIT - STEP 2</SECTION><ADDED>0.5</ADDED>
PLIGG_Visual_Submit2Subscribe_To = "Check this option if you want to receive emails whenever other users comment on your story."
Save and close.
Open “submit_step_2.tpl” in your template folder and add the following right before the “{checkActionsTpl location="submit_step_2_pre_extrafields"}” line:
Code:
 
<br />
<label for"subscribeto"><input type="checkbox" name="subscribeto" id="subscribeto"> {#PLIGG_Visual_Submit2Subscribe_To#}</label><br/>
Save and close.
Open “submit_step_3.tpl” in your template folder (for version 9.9, open /submit.php) and search for “$linkres->category=” and place the following in the same section:
Code:
$linkres->subscribe=$_POST['subscribeto'];

Search for “$main_smarty->assign('submit_content” and add the following to the same section:
Code:
$main_smarty->assign('submit_subscribe', $linkres->subscribe); 
Save and close.
Now we have to provide an option to turn on and off this option. To do so, we modify the “editlink_edit_center.tpl” in your template folder by adding a checkbox like we did in the “submit_step_2.tpl”. However, we have to check the database for the value of the link_subscribe to set the checkbox as CHECKED or not. Remember that the author of the story can edit/modify the story by clicking on the “admin links” within the story post and then clicking on “Edit the title or description.”.
Open “editlink_edit_center.tpl” in your template folder and add the following anywhere you want before the submit button:
Notice the conditions (in red) to accurately set the checkbox state.
Code:
 
<br />            
<label for"subscribeto">{if $submit_subscribe eq 1}<input type="checkbox" name="subscribeto" id="subscribeto" CHECKED> {else} <input type="checkbox" name="subscribeto" id="subscribeto">{/if}{#PLIGG_Visual_Submit2Subscribe_To#}</label>
<br/><br/>
Save and close.
Now, we have to edit the “/libs/link.php” file to accommodate the new changes we have made.
Open “/libs/link.php” and add the following code:
In the “class link {“ section.
Add:
Code:
var $subscribe = 0;

Right after the global declaration in the store() function, add:
Code:
if(isset($_POST['subscribeto'])){
$this->subscribe = "1";
}
Within the same store() function:
anywhere before the “$sql = "UPDATE " line add:
Code:
$link_subscribe = $db->escape($this->subscribe);

Add the following to the “$sql = "UPDATE " line right before the “WHERE” condition:
Code:
, link_subscribe='$link_subscribe'
Look for “if($link) {“ section and add:

Code:
$this->subscribe = $link->link_subscribe;

Look for the “function fill_smarty” section and add the following (make sure not to add it within an IF statement:
Code:
$smarty->assign('subscribe', $this->subscribe);

Save and close.
Now open the “editlink.php” and look for “$edit = false;” then go down few lines and add the following after the “$linkres->read();”:
Code:
$link_subscribe=$linkres->subscribe;

Go down few more lines to where the “$main_smarty->assign” begin and add:
Code:
$main_smarty->assign('submit_subscribe', $link_subscribe);

Save and close.

Now the last step is to add the code to send the email if the option is selected.

Open “story.php”

Change this:

Code:
if(isset($_POST['process'])){
       if ($_POST['process']=='newcomment') {
                   insert_comment();
       }
}
Change it to:

Code:
if(isset($_POST['process'])){
       if ($_POST['process']=='newcomment') {
                   if ($link->subscribe==1) {
$authormail = $db->get_var("SELECT public_email FROM " .table_users ." WHERE user_id = $link->author;");
 
$subject= 'You have a new comment about your story ' . $link->title;
$message = "The following user '". $current_user->user_login . "' commented on your story '" . $link->title . "'\r\n\r\n\t" . "'".$_POST['comment_content']. "'\r\n\r\nRegards,\r\nAdministrator";
                               $headers = "From: admin@yoursite.com"  . "\r\nReply-To: admin@yoursite.com " . "\r\nX-Priority: 1\r\n";
                                           $to=$authormail;
                                           @mail($to, $subject, $message, $headers);
                               }
 
                               insert_comment();
                   }
       }
The files that you need to upload:
  1. /libs/lang.conf
  2. /libs/link.php
  3. story.php
  4. editlink.php
  5. /templates/yourtemplate/editlink_edit_center.tpl
  6. /templates/yourtemplate/submit_step_2.tpl
  7. /templates/yourtemplate/submit_step_3.tpl
I just want to make sure that you're not missing any step.

First, did you change the email where it is in blue?
Code:
$message = "The following user '". $current_user->user_login . "' commented on your story '" . $link->title . "'\r\n\r\n\t" . "'".$_POST['comment_content']. "'\r\n\r\nRegards,\r\nAdministrator";
                                  $headers = "From: admin@yoursite.com"  . "\r\nReply-To: admin@yoursite.com" . "\r\nX-Priority: 1\r\n";
                                              $to=$authormail;
                                              @mail($to, $subject, $message, $headers);
                                  }
Secondly, have you checked the checkbox in the story for which you want to receive an email when a comment is added to it? To do so, click on the "Admin Links" in the story post and then click on "Edit the title or description" and check the checkbox "Check this option if you want to receive emails whenever other users comment on your story." (See the attached snapshot)
Attached Thumbnails
mail: "there is a new comment in your story"-story.gif  

Last edited by redwine; 02-13-2008 at 12:31 PM. Reason: Added a note for version 9.9 users.
Reply With Quote
  #33 (permalink)  
Old 01-02-2008, 02:24 PM
netwb's Avatar
Casual Pligger/Coder
Pligg Version: 1.0
Pligg Template: wistie
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 86
Quote:
Originally Posted by teezone View Post
I'm having the same problem - the new field is inserted properly (link_subscribe=1), but no emails are sent. I also made sure the "from" email is valid which could cause a problem with some hosts.

I changed "public_email" to "user_email", still doesn't work - I'm def no programmer, but it seems to be at the $mail stage. The "change status" email is received immediately, so I know my server is capable of handling this type of function.

Edit: can someone pls tell me which file contains the code to send an email when link status is changed? This problem may be hosting-related.

Any suggestions much appreciated!
yes!!! is this very good but the lettering is special to utf8
Reply With Quote
  #34 (permalink)  
Old 01-02-2008, 03:43 PM
New Pligger
 
Join Date: Sep 2007
Posts: 29
Yup, just double-checked, all steps were completed (including the change to header email addresses, ie. admin@yoursite.com). And the new stories have the checkbox selected..

The database & file edits went smoothly as I can see the link_subscribe value "1" when I use phpMyAdmin (the rest default to 0).

I think it's the mail function, which would be related to my host. Do you know how to "discard" email is sent out..? If I can replicate that command, I think it will work.
Reply With Quote
  #35 (permalink)  
Old 01-02-2008, 07:23 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
It worked for netwb and it is working for me. Is everything is placed where it is supposed to be as I indicated in my original post? Otherwise, I don't see any reason why it is not working, unless if it is related to your server and configuration. Let me know if you want to go through the steps together.

Quote:
Originally Posted by netwb View Post
yes!!! is this very good but the lettering is special to utf8
Reply With Quote
  #36 (permalink)  
Old 01-06-2008, 02:19 AM
New Pligger
 
Join Date: Sep 2007
Posts: 29
Ahhh.. fixed at last!

It took some time, but I found the problem.. I had implemented part of the original thread months ago (how to send an email when a comment is posted), and inserted a statement in story.php. In effect, I had TWO sections of if(isset($_POST['process']. Removed the original modification, and the new version works great.

Redwine, thanks for the code & assistance!
Reply With Quote
  #37 (permalink)  
Old 01-07-2008, 06:15 PM
netwb's Avatar
Casual Pligger/Coder
Pligg Version: 1.0
Pligg Template: wistie
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 86
Quote:
Originally Posted by redwine View Post
I just want to make sure that you're not missing any step.

First, did you change the email where it is in blue?
Code:
$message = "The following user '". $current_user->user_login . "' commented on your story '" . $link->title . "'\r\n\r\n\t" . "'".$_POST['comment_content']. "'\r\n\r\nRegards,\r\nAdministrator";
                                  $headers = "From: admin@yoursite.com"  . "\r\nReply-To: admin@yoursite.com" . "\r\nX-Priority: 1\r\n";
                                              $to=$authormail;
                                              @mail($to, $subject, $message, $headers);
                                  }
Secondly, have you checked the checkbox in the story for which you want to receive an email when a comment is added to it? To do so, click on the "Admin Links" in the story post and then click on "Edit the title or description" and check the checkbox "Check this option if you want to receive emails whenever other users comment on your story." (See the attached snapshot)
remplace admin@yoursite to Send_From_Email for the spam problem
example
HTML Code:
if(isset($_POST['process'])){
          if ($_POST['process']=='newcomment') {
                      if ($link->subscribe==1) {
$authormail = $db->get_var("SELECT user_email FROM " .table_users ." WHERE user_id = $link->author;");
 
$subject= 'You have a new comment about your story ' . $link->title;
$message = "The following user '". $current_user->user_login . "' commented on your story '" . $link->title . "'\r\n\r\n\t" . "'".$_POST['comment_content']. "'\r\n\r\nRegards,\r\nAdministrator";
                                  $headers = 'From: ' . Send_From_Email . "\r\nReply-To: Send_From_Email" . "\r\nX-Priority: 1\r\n";
                                              $to=$authormail;
                                              @mail($to, $subject, $message, $headers);
                                  }
 
                                  insert_comment();
                      }
          }
Reply With Quote
  #38 (permalink)  
Old 01-07-2008, 06:55 PM
nzbullet's Avatar
Constant Pligger/Coder
 
Join Date: Jun 2007
Location: New Zealand
Posts: 115
Works for me, I also changed it so it was selected by default and if users don't want emails they must uncheck the box.
Reply With Quote
  #39 (permalink)  
Old 02-08-2008, 12:23 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks for your hard work on this redwine. I've read this whole thread a dozen times and traced my steps again and again, but I'm still not receiving any emails. I know there's sometimes a delay, but it's been 12 hours and still nothing. Is there any way to check that emails are actually being sent?

Am I alone with this problem? Any suggestions?

Note: I do get emails from Ajax contact form.
Reply With Quote
  #40 (permalink)  
Old 02-09-2008, 06:02 AM
longcountdown's Avatar
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: moderno-orange
 
Join Date: Nov 2007
Location: Japan
Posts: 75
Thanks to redwine, it's working now. The problem I encountered had been mentioned before, but in case anyone else missed it:

In story.php, change:

Code:
$authormail = $db->get_var("SELECT public_email FROM " .table_users ." WHERE user_id = $link->author;");
to:

Code:
$authormail = $db->get_var("SELECT user_email FROM " .table_users ." WHERE user_id = $link->author;");
Using "public_email" means that users who don't make their email public during or after registration won't receive notification. Changing it to "user_email" works regardless of whether their email address is public or not.

Also note that my server took about 18 hours before delivering the email, so you might have to be patient.

Include link to the story - Help Please

Moving on, can someone post the changes necessary to make the story title in the email a link to the actual story? Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail not working from local system mrigank Questions and Comments 3 02-23-2009 03:06 AM
Special character problems in RSS and mail subject ditto Questions and Comments 8 04-22-2008 05:28 PM
Editing a reply to a comment? bbrian017 Questions and Comments 0 01-10-2008 05:30 PM
A proposal for a more robust way of comment deletion. sefs Questions and Comments 0 10-12-2007 05:30 PM
Comment Count Update Simon Questions and Comments 4 06-01-2007 10:45 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development