Add Comment

Working for (latest)

I've added some basic code to be able to email the comment to a user, as a notification mechanism. You should change "" 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. Replace this line with the following code

        // replace the double colon markup with a nice single comma
        $body2 = str_replace ('::', ',', $body);
        $this->SaveComment($this->tag, $body2);

        // notify by email, code from NotifyOnChange action
        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)."'");
                $SendAdr = $this->LoadSingle("select email from " .$this->config["table_prefix"]."users where name = '".mysql_escape_string($this->GetUserName())."'");
                $subject = "[".$this->config["wakka_name"]."] \"" . $this->GetPageTag() . "\" commented by " . $this->GetUserName();
                // uncomment below if you like to greet the reader with his/her username
                // $message = "<p>Hi ".$Watcher.",</p>";
                $message = "<p>".$this->GetUserName()." has commented on <a href=\"".$this->Href("",$tag,"")."\">".$this->GetPageTag()."</a>:</p>";
                $message .= "<p><i>".$body2."</i></p>";
                $message .= "<p>Do not reply to this message, go to the <a href=\"".$this->Href("",$tag,"")."\">".$this->GetPageTag()."</a> 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";
                // use below from: header if you want to send from dummy address
                // $headers = "From:\n";
                // use below from: header to show who commented, including email address
                $headers = "From: ".$this->GetUserName()." <".$SendAdr["email"].">\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";
                $mailaddr =  "".$Watcher." <".$MailAdr["email"].">";
                mail($mailaddr, $subject, $message, $headers);

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki