From cfef7af2ae69322eb65394dbe493d242bb632903 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Mar 2012 10:30:54 -0400 Subject: [PATCH] Only show training buttons if you can train --- ActivitySpamPlugin.php | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ActivitySpamPlugin.php b/ActivitySpamPlugin.php index 35e12dc33d..5e13d3610f 100644 --- a/ActivitySpamPlugin.php +++ b/ActivitySpamPlugin.php @@ -168,22 +168,27 @@ class ActivitySpamPlugin extends Plugin function onEndShowNoticeOptionItems($nli) { - $notice = $nli->getNotice(); - $out = $nli->getOut(); - - if (!empty($notice)) { - - $score = $this->getScore($notice); - - if (empty($score)) { - $this->debug("No score for notice " . $notice->id); - // XXX: show a question-mark or something - } else if ($score->is_spam) { - $form = new TrainHamForm($out, $notice); - $form->show(); - } else if (!$score->is_spam) { - $form = new TrainSpamForm($out, $notice); - $form->show(); + $profile = Profile::current(); + + if (!empty($profile) && $profile->hasRight(self::TRAINSPAM)) { + + $notice = $nli->getNotice(); + $out = $nli->getOut(); + + if (!empty($notice)) { + + $score = $this->getScore($notice); + + if (empty($score)) { + $this->debug("No score for notice " . $notice->id); + // XXX: show a question-mark or something + } else if ($score->is_spam) { + $form = new TrainHamForm($out, $notice); + $form->show(); + } else if (!$score->is_spam) { + $form = new TrainSpamForm($out, $notice); + $form->show(); + } } } -- 2.39.5