Improve spam message when there is no subject
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 1 Oct 2010 16:07:48 +0000 (10:07 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 1 Oct 2010 19:42:06 +0000 (13:42 -0600)
imp/lib/Spam.php

index c9e3cb2..3e23bb7 100644 (file)
@@ -167,15 +167,25 @@ class IMP_Spam
         /* Report what we've done. */
         if ($report_count == 1) {
             $hdrs = $imp_contents->getHeaderOb();
-            $subject = Horde_String::truncate($hdrs->getValue('subject'), 30);
+            if ($subject = $hdrs->getValue('subject')) {
+                $subject = Horde_String::truncate($subject, 30);
+            } elseif ($from = $hdrs->getValue('from')) {
+                $from = Horde_String::truncate($from, 30);
+            } else {
+                $subject = '[' . _("No Subject") . ']';
+            }
 
             switch ($action) {
             case 'spam':
-                $msg = sprintf(_("The message \"%s\" has been reported as spam."), $subject);
+                $msg = $subject
+                    ? sprintf(_("The message \"%s\" has been reported as spam."), $subject)
+                    : sprintf(_("The message from \"%s\" has been reported as spam."), $from);
                 break;
 
             case 'notspam':
-                $msg = sprintf(_("The message \"%s\" has been reported as innocent."), $subject);
+                $msg = $subject
+                    ? sprintf(_("The message \"%s\" has been reported as innocent."), $subject)
+                    : sprintf(_("The message from \"%s\" has been reported as innocent."), $from);
                 break;
             }
         } elseif ($action == 'spam') {