Revision [20558]
This is an old revision of AddCommentHandler made by AxelMulder on 2009-04-18 14:50:04.
Add Comment
Working for 1.1.6.4 (latest)
I've added some basic code to be able to email the comment to a user, as a notification mechanism. You should change "yourdomain.com" to the the domain you want to have appear in the From: field in the email. The user names of the people that need to receive the comment have to be entered at the beginning of the comment, followed by a double colon (this can simply be changed in the code if desired).
How to modify addcomment.php:
1. In addcomment.php find
$this->SaveComment($this->tag, $body);
2. Insert the following code
// notify watchers by email
if (function_exists('mail') && $this->config["notify_users"]) {
$Watchers = explode("::",$body,-1);
foreach ($Watchers as $Watcher) {
$MailAdr = $this->LoadSingle("select email from " .$this->config["table_prefix"]."users where name = '".mysql_escape_string($Watcher)."'");
$subject = "[".$this->config["wakka_name"]."] The page \"" . $this->GetPageTag() . "\" has been commented by " . $this->GetUserName();
//$message = "<p>Hi " . $Watcher . ",</p>";
$message = "<p><a href=\"".$this->Href("",$tag,"")."\">".$this->Href("",$tag,"")."<a> has received the following comment:</p>";
$message .= "<p><i>" . $body . "</i></p>";
$message .= "<p>Do not reply to this message, go to the Wiki page instead for follow-up Wiki action.</p>";
$message .= "<p>-- The ".$this->config["wakka_name"]." robot</p>";
// $headers = "From: " . $this->config["wakka_name"] . "_notifier\n";
$headers = "From: wiki@yourdomain.com\n";
$headers .= "X-Mailer: PHP/".phpversion()."\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
//comment this to send text format
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
mail($MailAdr["email"], $subject, $message, $headers);
}
}
if (function_exists('mail') && $this->config["notify_users"]) {
$Watchers = explode("::",$body,-1);
foreach ($Watchers as $Watcher) {
$MailAdr = $this->LoadSingle("select email from " .$this->config["table_prefix"]."users where name = '".mysql_escape_string($Watcher)."'");
$subject = "[".$this->config["wakka_name"]."] The page \"" . $this->GetPageTag() . "\" has been commented by " . $this->GetUserName();
//$message = "<p>Hi " . $Watcher . ",</p>";
$message = "<p><a href=\"".$this->Href("",$tag,"")."\">".$this->Href("",$tag,"")."<a> has received the following comment:</p>";
$message .= "<p><i>" . $body . "</i></p>";
$message .= "<p>Do not reply to this message, go to the Wiki page instead for follow-up Wiki action.</p>";
$message .= "<p>-- The ".$this->config["wakka_name"]." robot</p>";
// $headers = "From: " . $this->config["wakka_name"] . "_notifier\n";
$headers = "From: wiki@yourdomain.com\n";
$headers .= "X-Mailer: PHP/".phpversion()."\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
//comment this to send text format
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
mail($MailAdr["email"], $subject, $message, $headers);
}
}
CategoryDevelopmentHandlers