コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
 /** 
  * untrains the filter based on information from the given Article object
  *
  * @param Article and Article object
  * @return always true
  * @static
  * @see untrain
  */
 function untrainWithArticle($article)
 {
     return BayesianFilterCore::untrain($article->getBlog(), $article->getTopic(), $article->getText(), "", "", "", false);
 }