From: Michael M Slusarz Date: Wed, 5 Aug 2009 08:48:30 +0000 (-0600) Subject: Move IMAP alert notifications to a central location. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=25e9e426a4d2e25f90ca3685559df73aaaab02f0;p=horde.git Move IMAP alert notifications to a central location. --- diff --git a/imp/ajax.php b/imp/ajax.php index 9ed06c554..82a0160d0 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -783,12 +783,5 @@ if ($errors) { $errors, __FILE__, __LINE__, PEAR_LOG_DEBUG); } -/* Display IMAP alerts. */ -if ($notify) { - foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) { - $notification->push($alert, 'horde.warning'); - } -} - // Send the final result. Horde::sendHTTPResponse(Horde::prepareResponse($result, $notify ? $GLOBALS['imp_notify'] : null), 'json'); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index bf2ea25e9..ff1a33e8a 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -93,7 +93,7 @@ class IMP $viewmode = self::getViewMode(); if ($viewmode == 'mimp') { - $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', null, 'Horde_Notification_Listener_Mobile'); + $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', null, 'IMP_Notification_Listener_StatusMobile'); } else { $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', array('viewmode' => $viewmode), 'IMP_Notification_Listener_Status'); if ($viewmode == 'imp') { @@ -652,13 +652,7 @@ class IMP */ static public function status() { - global $notification; - - /* Display IMAP alerts. */ - foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) { - $notification->push($alert, 'horde.warning'); - } - + $notification = Horde_Notification::singleton(); $notification->notify(array('listeners' => array('status', 'audio'))); } diff --git a/imp/lib/Notification/Listener/Status.php b/imp/lib/Notification/Listener/Status.php index 825dc088c..f51699104 100644 --- a/imp/lib/Notification/Listener/Status.php +++ b/imp/lib/Notification/Listener/Status.php @@ -76,6 +76,11 @@ class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Statu $options['store'] = true; } + /* Display IMAP alerts. */ + foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) { + $this->push($alert, 'horde.warning'); + } + parent::notify($messageStack, $options); /* Preferences display. */ diff --git a/imp/lib/Notification/Listener/StatusMobile.php b/imp/lib/Notification/Listener/StatusMobile.php new file mode 100644 index 000000000..d777cad73 --- /dev/null +++ b/imp/lib/Notification/Listener/StatusMobile.php @@ -0,0 +1,34 @@ + + * @package Horde_Notification + */ +class IMP_Notification_Listener_StatusMobile extends Horde_Notification_Listener_Mobile +{ + /** + * Returns all status message if there are any on the 'status' message + * stack. + * + * @param array &$messageStack The stack of messages. + * @param array $options An array of options. + */ + public function notify(&$messageStack, $options = array()) + { + /* Display IMAP alerts. */ + foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) { + $this->push($alert, 'horde.warning'); + } + + parent::notify($messageStack, $options); + } + +}