I am actually an ASP Programmierin. For me, everything looks right.
// Notifications
function doNotifySubscribers($commentid=0) {
global $modx;
if ($this->config["subscription"]["enabled"]) {
// Get comment fields
$cObj = $this->provider;
$cObj->Comment($commentid);
$comment = $cObj->getFields();
unset($cObj);
$subscriptions = $this->provider->getSubscriptions($this->config["docid"],$this->config["tagid"]);
$count = count($subscriptions);
for ($i = 0; $i < $count; $i++) {
if ($this->config["user"]["id"] != $subscriptions[$i]["userid"] ) {
$user = $this->getUserInfo($subscriptions[$i]["userid"]);
$tpl = new CChunkie($this->templates["notify"]);
$tpl->AddVar('jot',$this->config);
$tpl->AddVar('comment',$comment);
$tpl->AddVar('siteurl',"http://".$_SERVER["SERVER_NAME"]);
$tpl->AddVar('recipient',$user);
$message = $tpl->Render();
mail($user["email"], $this->config["subject"]["subscribe"], $message, "From: ".$modx->config['emailsender']."\r\n"."X-Mailer: Content Manager - PHP/".phpversion());
}
}
}
}
// Moderator Notification
function doNotifyModerators($commentid=0) {
global $modx;
if ($this->config["moderation"]["notify"]) {
// Get comment fields
$cObj = $this->provider;
$cObj->Comment($commentid);
$comment = $cObj->getFields();
unset($cObj);
$moderators = $this->getMembersOfWebGroup($this->config["permissions"]["moderate"]);
foreach ($moderators as $moderator){
$user = $modx->getWebUserInfo($moderator);
$tpl = new CChunkie($this->templates["notifymoderator"]);
$tpl->AddVar('jot',$this->config);
$tpl->AddVar('comment',$comment);
$tpl->AddVar('siteurl',"http://".$_SERVER["SERVER_NAME"]);
$tpl->AddVar('recipient',$user);
$message = $tpl->Render();
mail($user["email"], $this->config["subject"]["moderate"], $message, "From: ".$modx->config['emailsender']."\r\n"."X-Mailer: Content Manager - PHP/".phpversion());
}
}
}
// Returns comment count
function getCommentCount($view=1) {
return $this->provider->GetCommentCount($this->config["docid"],$this->config["tagid"],$view);
}
// Moderation
function doModerate($action = '',$id = 0) {
$output = NULL;
$pObj = $this->provider;
if ($this->isModerator && $pObj->isValidComment($this->config["docid"],$this->config["tagid"],$id)) {
switch ($action) {
case "delete":
$pObj->Comment($id);
$pObj->Delete();
break;
case "publish":
$pObj->Comment($id);
$pObj->Set("publishedon",$this->_ctime);
$pObj->Set("publishedby",$this->config["user"]["id"]);
$pObj->Set("published",1);
$pObj->Save();
$this->doNotifySubscribers($id);
break;
case "edit":
$this->form["moderation"] = 1;
$this->form["edit"] = 1;
break;
case "save":
$this->form["moderation"] = 1;
$this->form["edit"] = 1;
$this->form["save"] = 1;
break;
case "unpublish":
$pObj->Comment($id);
$pObj->Set("publishedon",$this->_ctime);
$pObj->Set("publishedby",$this->config["user"]["id"]);
$pObj->Set("published",0);
$pObj->Save();
break;
}
}
unset($pObj);
return $output;
}