From 0d2b1261e21751217b3ca0619c94b74aceabfaf1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 9 Dec 2008 10:40:27 -0700 Subject: [PATCH] Clean up spam reporting code. Consistently return 0 on failure. Don't delete if no reporting mechanism is performed. --- imp/lib/Spam.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index df600a141..f3c23a8af 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -69,7 +69,7 @@ class IMP_Spam ), $pipes); if (!is_resource($proc)) { Horde::logMessage('Cannot open process ' . $prog, __FILE__, __LINE__, PEAR_LOG_ERR); - return; + return 0; } fwrite($pipes[0], $raw_msg); fclose($pipes[0]); @@ -133,25 +133,27 @@ class IMP_Spam } } + if (!$report_count) { + return 0; + } + /* Report what we've done. */ - if ($report_count) { - switch ($action) { - case 'spam': - if ($report_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as spam."), $report_count), 'horde.message'); - } else { - $notification->push(_("The message has been reported as spam."), 'horde.message'); - } - break; + switch ($action) { + case 'spam': + if ($report_count > 1) { + $notification->push(sprintf(_("%d messages have been reported as spam."), $report_count), 'horde.message'); + } else { + $notification->push(_("The message has been reported as spam."), 'horde.message'); + } + break; - case 'notspam': - if ($report_count > 1) { + case 'notspam': + if ($report_count > 1) { $notification->push(sprintf(_("%d messages have been reported as not spam."), $report_count), 'horde.message'); - } else { + } else { $notification->push(_("The message has been reported as not spam."), 'horde.message'); - } - break; } + break; } /* Delete spam after report. */ -- 2.11.0