From 69c1fb8493f2959368ecc7f317f61764e11f5557 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 9 Jul 2009 16:55:45 -0600 Subject: [PATCH] Better notification message when reporting spam --- imp/lib/Spam.php | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index cc6c2e913..f485090e6 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -109,7 +109,7 @@ class IMP_Spam try { $from_line = $identity->getFromLine(); } catch (Horde_Exception $e) { - $from = ''; + $from_line = null; } } @@ -126,7 +126,9 @@ class IMP_Spam $spam_headers->addMessageIdHeader(); $spam_headers->addHeader('Date', date('r')); $spam_headers->addHeader('To', $to); - $spam_headers->addHeader('From', $from_line); + if (!is_null($from_line)) { + $spam_headers->addHeader('From', $from_line); + } $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action, $_SESSION['imp']['uniquser'])); /* Send the message. */ @@ -149,23 +151,25 @@ class IMP_Spam } /* Report what we've done. */ - 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; + if ($report_count == 1) { + $hdrs = $imp_contents->getHeaderOb(); + $subject = Horde_String::truncate($hdrs->getValue('subject')); - case 'notspam': - if ($report_count > 1) { - $notification->push(sprintf(_("%d messages have been reported as not spam."), $report_count), 'horde.message'); - } else { - $notification->push(_("The message has been reported as not spam."), 'horde.message'); + switch ($action) { + case 'spam': + $msg = sprintf(_("The message \"%s\" has been reported as spam."), $subject); + break; + + case 'notspam': + $msg = sprintf(_("The message \"%s\" has been reported as spam."), $subject); + break; } - break; + } elseif ($action == 'spam') { + $msg = sprintf(_("%d messages have been reported as spam."), $report_count); + } else { + $msg = sprintf(_("%d messages have been reported as not spam."), $report_count); } + $notification->push($msg, 'horde.message'); /* Delete spam after report. */ $delete_spam = $GLOBALS['prefs']->getValue('delete_spam_after_report'); -- 2.11.0