function onEndShowNoticeOptionItems($nli) { $profile = Profile::current(); if (!empty($profile) && $profile->hasRight(self::TRAINSPAM)) { $notice = $nli->getNotice(); $out = $nli->getOut(); if (!empty($notice)) { $score = Spam_score::getKV('notice_id', $notice->id); if (empty($score)) { // If it's empty, we can train it. $form = new TrainSpamForm($out, $notice); $form->show(); } else { if ($score->is_spam) { $form = new TrainHamForm($out, $notice); $form->show(); } else { if (!$score->is_spam) { $form = new TrainSpamForm($out, $notice); $form->show(); } } } } } return true; }
/** * Handler method * * @param array $argarray is ignored since it's now passed in in prepare() * * @return void */ function handle($argarray = null) { // Train $this->filter->trainOnError($this->notice, $this->category); // Re-test $result = $this->filter->test($this->notice); // Update or insert $score = Spam_score::save($this->notice, $result); // Show new toggle form if ($this->category === SpamFilter::SPAM) { $form = new TrainHamForm($this, $this->notice); } else { $form = new TrainSpamForm($this, $this->notice); } if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title for page on which we train the spam filter for ham or spam $this->element('title', null, _('Train spam filter')); $this->elementEnd('head'); $this->elementStart('body'); $form->show(); $this->elementEnd('body'); $this->endHTML(); } else { common_redirect(common_local_url('spam'), 303); } }