From: Michael M Slusarz Date: Thu, 25 Jun 2009 16:43:41 +0000 (-0600) Subject: Consolidate the imp and dimp notification handler X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0f7b00b7da9ac685dbd7cf454d85609739846bd1;p=horde.git Consolidate the imp and dimp notification handler --- diff --git a/imp/lib/Notification/Listener/Status.php b/imp/lib/Notification/Listener/Status.php new file mode 100644 index 000000000..c5ee57fc2 --- /dev/null +++ b/imp/lib/Notification/Listener/Status.php @@ -0,0 +1,72 @@ + + * @author Chuck Hagenbuch + * @author Michael Slusarz + * @package Horde_Notification + */ +class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Status +{ + /** + * The view mode. + * + * @var string + */ + protected $_viewmode; + + /** + * Constructor. + * + * @param array $options One option required: 'viewmode'. + */ + public function __construct($options) + { + parent::__construct(); + + $this->_viewmode = $options['viewmode']; + + $image_dir = $GLOBALS['registry']->getImageDir(); + + $this->_handles['imp.reply'] = array($image_dir . '/mail_answered.png', _("Reply")); + $this->_handles['imp.forward'] = array($image_dir . '/mail_forwarded.png', _("Reply")); + $this->_handles['imp.redirect'] = array($image_dir . '/mail_forwarded.png', _("Redirect")); + } + + /** + * Handle every message of type dimp.*; otherwise delegate back to + * the parent. + * + * @param string $type The message type in question. + * + * @return boolean Whether this listener handles the type. + */ + public function handles($type) + { + return (($this->_viewmode == 'dimp') && + (substr($type, 0, 5) == 'dimp.')) || + parent::handles($type); + } + + /** + * 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()) + { + /* For dimp, don't capture notification messages if we are logging + * out or accessing the options pages. */ + if (($this->_viewmode == 'dimp') && + Auth::getAuth() && !strstr($_SERVER['PHP_SELF'], '/prefs.php')) { + $options['store'] = true; + } + parent::notify($messageStack, $options); + } + +} diff --git a/imp/lib/Notification/Listener/StatusDimp.php b/imp/lib/Notification/Listener/StatusDimp.php deleted file mode 100644 index 954eda709..000000000 --- a/imp/lib/Notification/Listener/StatusDimp.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @package Horde_Notification - */ -class IMP_Notification_Listener_StatusDimp extends IMP_Notification_Listener_StatusImp -{ - /** - * Handle every message of type dimp.*; otherwise delegate back to - * the parent. - * - * @param string $type The message type in question. - * - * @return boolean Whether this listener handles the type. - */ - public function handles($type) - { - return (substr($type, 0, 5) == 'dimp.') || parent::handles($type); - } - - /** - * 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()) - { - /* Don't capture notification messages if we are logging out are - * accessing the options pages. */ - if (Auth::getAuth() && !strstr($_SERVER['PHP_SELF'], '/prefs.php')) { - $options['store'] = true; - } - parent::notify($messageStack, $options); - } - -} diff --git a/imp/lib/Notification/Listener/StatusImp.php b/imp/lib/Notification/Listener/StatusImp.php deleted file mode 100644 index 9ccd0bf19..000000000 --- a/imp/lib/Notification/Listener/StatusImp.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @package Horde_Notification - */ -class IMP_Notification_Listener_StatusImp extends Horde_Notification_Listener_Status -{ - /** - * Constructor. - */ - public function __construct() - { - parent::__construct(); - - $image_dir = $GLOBALS['registry']->getImageDir(); - - $this->_handles['imp.reply'] = array($image_dir . '/mail_answered.png', _("Reply")); - $this->_handles['imp.forward'] = array($image_dir . '/mail_forwarded.png', _("Reply")); - $this->_handles['imp.redirect'] = array($image_dir . '/mail_forwarded.png', _("Redirect")); - } - -} diff --git a/imp/lib/base.php b/imp/lib/base.php index f0f523ca0..108537942 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -165,11 +165,11 @@ $notification = &Horde_Notification::singleton(); if (($viewmode == 'mimp') || (Horde_Util::nonInputVar('login_page') && $GLOBALS['browser']->isMobile())) { $GLOBALS['imp_notify'] = &$notification->attach('status', null, 'Horde_Notification_Listener_Mobile'); -} elseif ($viewmode == 'dimp') { - $GLOBALS['imp_notify'] = &$notification->attach('status', null, 'IMP_Notification_Listener_StatusDimp'); } else { - $GLOBALS['imp_notify'] = &$notification->attach('status', null, 'IMP_Notification_Listener_StatusImp'); - $notification->attach('audio'); + $GLOBALS['imp_notify'] = &$notification->attach('status', array('viewmode' => $viewmode), 'IMP_Notification_Listener_Status'); + if ($viewmode == 'imp') { + $notification->attach('audio'); + } } // Initialize global $imp_mbox array.