Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 12-18-2007, 12:31 AM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
I also had an error,


Quote:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at Blog Engage / Published Blog Articles Port 80
when submitting a Comment
Reply With Quote
  #22 (permalink)  
Old 12-18-2007, 08:56 AM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
Anyone get this to work?
Reply With Quote
  #23 (permalink)  
Old 12-30-2007, 12:04 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
[Solution] mail: "there is a new comment in your story"

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 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) {
//If you find that most users do not provide a public email, it would be safer to change the query below to "Select user_email FROM" instead.
$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 impact '" . $link->title . "'\r\n\r\n\t" . "'".$_POST['comment_content']. "\r\n\r\nHere is the link to the story: " . my_base_url . my_pligg_base . "/story.php?title=". $link->title_url . "\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

Last edited by redwine; 02-12-2008 at 05:55 PM.. Reason: Modified the $message in the last step to add a direct link to the story in the sent email
Reply With Quote
The Following 5 Users Say Thank You to redwine For This Useful Post:
  #24 (permalink)  
Old 12-30-2007, 01:14 PM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
This is great. I will try this for sure just not sure when I will have the time
Reply With Quote
  #25 (permalink)  
Old 12-30-2007, 06:20 PM
not2serious's Avatar
Pligg Donor
Pligg Version: v0.96 w/modifications
Pligg Template: Yget w/modifications
 
Join Date: Apr 2007
Location: East Coast, USA
Posts: 226
Thanks: 16
Thanked 16 Times in 15 Posts
Looks great. I am in the process of trying to make some updates and changes to my site and will include this mod.

Please check my PM suggestion for a minor enhancement to this mod.
__________________
My Pligg Site: Critique My Art
My Arts Directory: Links 2 Arts
Reply With Quote
  #26 (permalink)  
Old 12-31-2007, 07:17 AM
New Pligger
 
Join Date: Sep 2007
Posts: 21
Thanks: 3
Thanked 2 Times in 2 Posts
Thank's a lot for this mod, i'll try this, in a couple of days when i have some time and tell you if it works well in my site... Thank's
__________________
La web de las buenas historias -- loquehayquesaber
Como hacer un "no a todo en windows"
Reply With Quote
  #27 (permalink)  
Old 12-31-2007, 09:17 AM
netwb's Avatar
Casual Pligger
Pligg Version: 9.8
Pligg Template: Yget - Convergence - GarrX
 
Join Date: Dec 2006
Location: Bruxelles
Posts: 63
Thanks: 20
Thanked 25 Times in 11 Posts
i'have installed the mod and i not receved the comment!
__________________
Bruxello.com l Europeanpainting.eu l
Reply With Quote
  #28 (permalink)  
Old 12-31-2007, 10:33 AM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
It depends on the server

Sometimes it is not delivered instantly and sometimes it it is. It all depends on the server. I have received around a 100 some of them a couple of hours after they were sent.
Reply With Quote
  #29 (permalink)  
Old 12-31-2007, 11:26 AM
Banned
Pligg Version: 9.9.5
 
Join Date: Oct 2007
Location: Canada
Posts: 914
Thanks: 169
Thanked 17 Times in 17 Posts
Quote:
Originally Posted by redwine View Post
Sometimes it is not delivered instantly and sometimes it it is. It all depends on the server. I have received around a 100 some of them a couple of hours after they were sent.
I don't think this is a server issue rather than a pligg issue. I run many software scripts on many sites and my server only has issues with sending mail from pligg scripts and no other scripts. Maybe I am wrong?
Reply With Quote
  #30 (permalink)  
Old 12-31-2007, 12:08 PM
redwine's Avatar
Pligg Donor
Pligg Version: 9.8
Pligg Template: custom templat
 
Join Date: Jul 2007
Location: Canada
Posts: 216
Thanks: 20
Thanked 102 Times in 65 Posts
As I said, I tried thoroughly and it works well. I received all the emails, some of them instantly and some after a couple of hours but none failed!
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Special character problems in RSS and mail subject ditto Bug Report 8 04-22-2008 04:28 PM
Having problems sending mail with Pligg? Running Postfix by chance? PolPligg General Help 13 03-14-2008 04:14 PM
Editing a reply to a comment? bbrian017 General Help 0 01-10-2008 04:30 PM
A proposal for a more robust way of comment deletion. sefs Bug Report 0 10-12-2007 04:30 PM
Comment Count Update Simon Bug Report 4 06-01-2007 09:45 PM


Search Engine Friendly URLs by vBSEO 3.2.0