Clean up spam reporting code.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Dec 2008 17:40:27 +0000 (10:40 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Dec 2008 17:40:27 +0000 (10:40 -0700)
Consistently return 0 on failure.
Don't delete if no reporting mechanism is performed.

imp/lib/Spam.php

index df600a1..f3c23a8 100644 (file)
@@ -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. */