function perform()
 {
     // fetch the data and make some arrangements if needed
     $this->_parentId = $this->_request->getValue("parentId");
     $this->_articleId = $this->_request->getValue("articleId");
     if ($this->_parentId < 0 || $this->_parentId == "") {
         $this->_parentId = 0;
     }
     // check if comments are enabled
     $blogSettings = $this->_blogInfo->getSettings();
     if (!$blogSettings->getValue("comments_enabled")) {
         $this->_view = new ErrorView($this->_blogInfo, "error_comments_not_enabled");
         $this->setCommonData();
         return false;
     }
     // fetch the article
     $blogs = new Blogs();
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     // if there was a problem fetching the article, we give an error and quit
     if ($article == false) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "error_fetching_article");
         $this->setCommonData();
         return false;
     }
     $this->_view = new BlogView($this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK, array("articleId" => $this->_articleId, "parentId" => $this->_parentId));
     // do nothing if the view was already cached
     if ($this->_view->isCached()) {
         return true;
     }
     // fetch the comments so far
     $comments = new ArticleComments();
     $postComments = $comments->getPostComments($article->getId());
     if ($this->_parentId > 0) {
         // get a pre-set string for the subject field, for those users interested
         $comment = $comments->getPostComment($article->getId(), $this->_parentId);
         // create the string
         if ($comment) {
             $replyString = $this->_locale->tr("reply_string") . $comment->getTopic();
             $this->_view->setValue("comment", $comment);
         }
     }
     // if everything's fine, we set up the article object for the view
     $this->_view->setValue("post", $article);
     $this->_view->setValue("parentId", $this->_parentId);
     $this->_view->setValue("comments", $postComments);
     $this->_view->setValue("postcomments", $postComments);
     $this->_view->setValue("topic", $replyString);
     $this->setCommonData();
     // and return everything normal
     return true;
 }
 /**
  * deletes comments
  * @private
  */
 function _deleteComments()
 {
     $comments = new ArticleComments();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     // if we can't even load the article, then forget it...
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     if (!$article) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
         $this->setCommonData();
         return false;
     }
     // loop through the comments and remove them
     foreach ($this->_commentIds as $commentId) {
         // fetch the comment
         $comment = $comments->getPostComment($this->_articleId, $commentId);
         if (!$comment) {
             $errorMessage .= $this->_locale->pr("error_deleting_comment2", $commentId);
         } else {
             // fire the pre-event
             $this->notifyEvent(EVENT_PRE_COMMENT_DELETE, array("comment" => &$comment));
             if (!$comments->deletePostComment($article->getId(), $commentId)) {
                 $errorMessage .= $this->_locale->pr("error_deleting_comment", $comment->getTopic()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage .= $this->_locale->pr("comment_deleted_ok", $comment->getTopic()) . "<br/>";
                 } else {
                     $successMessage = $this->_locale->pr("comments_deleted_ok", $totalOk);
                 }
                 // fire the post-event
                 $this->notifyEvent(EVENT_POST_COMMENT_DELETE, array("comment" => &$comment));
             }
         }
     }
     // if everything fine, then display the same view again with the feedback
     $this->_view = new AdminArticleCommentsListView($this->_blogInfo, array("article" => $article));
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId());
     }
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * @private
  */
 function _markCommentAsNonSpam()
 {
     // throw the pre-event
     $this->notifyEvent(EVENT_PRE_MARK_NO_SPAM_COMMENT, array("commentId" => $this->_commentId));
     $this->_view = new AdminArticleCommentsListView($this->_blogInfo, array("article" => $this->_article));
     $comments = new ArticleComments();
     if (!$comments->updateCommentStatus($this->_commentId, COMMENT_STATUS_NONSPAM)) {
         $this->_view->setErrorMessage($this->_locale->tr("error_marking_comment_as_nonspam"));
         $this->setCommonData();
         $res = false;
     } else {
         $this->_view->setSuccessMessage($this->_locale->tr("comment_marked_as_nonspam_ok"));
         $this->setCommonData();
         $res = true;
         // before exiting, we should get the comment and train the filter
         // to recognize this as spam...
         $comment = $comments->getPostComment($this->_articleId, $this->_commentId);
         $bayesian = new BayesianFilterCore();
         $bayesian->untrain($this->_blogInfo->getId(), $comment->getTopic(), $comment->getText(), $comment->getUserName(), $comment->getUserEmail(), $comment->getUserUrl(), true);
         $bayesian->train($this->_blogInfo->getId(), $comment->getTopic(), $comment->getText(), $comment->getUserName(), $comment->getUserEmail(), $comment->getUserUrl(), false);
         // throw the post-event if everythign went fine
         $this->notifyEvent(EVENT_POST_MARK_NO_SPAM_COMMENT, array("commentId" => $this->_commentId));
     }
     return $res;
 }