From: Michael M Slusarz Date: Wed, 5 Aug 2009 06:18:31 +0000 (-0600) Subject: Rework prefsStatus() API call so it works on all prefs pages X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1dedd2489a5a0bdaa0103e8034d228f0a18ee5b4;p=horde.git Rework prefsStatus() API call so it works on all prefs pages --- diff --git a/imp/lib/Api.php b/imp/lib/Api.php index 0b050e4fe..c5e47d5eb 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -475,20 +475,17 @@ class IMP_Api extends Horde_Registry_Api } /** - * Output notifications on the preferences page. + * Setup notifications handler for the preferences page. This will only + * be called if in dimp view mode. */ public function prefsStatus() { - try { - $GLOBALS['imp_authentication'] = 'throw'; - require_once dirname(__FILE__) . '/base.php'; - if (IMP::getViewMode() == 'dimp') { - Horde::addInlineScript(array(IMP_Dimp::notify(true)), 'dom'); - return; - } - } catch (Horde_Exception $e) {} + $GLOBALS['imp_authentication'] = 'none'; + require_once dirname(__FILE__) . '/base.php'; - IMP::status(); + $notification = Horde_Notification::singleton(); + $notification->detach('status'); + $notification->attach('status', array('prefs' => true, 'viewmode' => 'dimp'), 'IMP_Notification_Listener_Status'); } /** diff --git a/imp/lib/Auth.php b/imp/lib/Auth.php index a0b38641a..8b2a3af9f 100644 --- a/imp/lib/Auth.php +++ b/imp/lib/Auth.php @@ -474,9 +474,11 @@ class IMP_Auth $conf['cookie']['path'], $conf['cookie']['domain']); - /* Suppress menus in options screen. */ + /* Suppress menus in options screen, and indicate that it should + * use the IMP notification listener. */ if ($sess['view'] == 'dimp') { $_SESSION['horde_prefs']['nomenu'] = true; + $_SESSION['horde_prefs']['status'] = 'imp'; } /* Set up search information for the session. */ diff --git a/imp/lib/Dimp.php b/imp/lib/Dimp.php index b9c272244..ffef8aeb1 100644 --- a/imp/lib/Dimp.php +++ b/imp/lib/Dimp.php @@ -97,17 +97,15 @@ class IMP_Dimp /** * Return the javascript code necessary to display notification popups. * - * @param boolean $parent Send notifications to parent window? - * * @return string The notification JS code. */ - static public function notify($parent = false) + static public function notify() { $GLOBALS['notification']->notify(array('listeners' => 'status')); $msgs = $GLOBALS['imp_notify']->getStack(); return count($msgs) - ? ($parent ? 'parent.' : '') . 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' + ? 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' : ''; } diff --git a/imp/lib/Notification/Listener/Status.php b/imp/lib/Notification/Listener/Status.php index 9c3da48ec..825dc088c 100644 --- a/imp/lib/Notification/Listener/Status.php +++ b/imp/lib/Notification/Listener/Status.php @@ -12,6 +12,13 @@ class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Status { /** + * Is this the prefs screen? + * + * @var boolean + */ + protected $_isPrefs = false; + + /** * The view mode. * * @var string @@ -21,13 +28,16 @@ class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Statu /** * Constructor. * - * @param array $options One option required: 'viewmode'. + * @param array $options Optional: 'prefs', 'viewmode'. */ - public function __construct($options) + public function __construct($options = array()) { parent::__construct(); - $this->_viewmode = $options['viewmode']; + $this->_isPrefs = !empty($options['prefs']); + $this->_viewmode = empty($options['viewmode']) + ? IMP::getViewMode() + : $options['viewmode']; $image_dir = $GLOBALS['registry']->getImageDir(); @@ -65,7 +75,15 @@ class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Statu if (($this->_viewmode == 'dimp') && Horde_Auth::getAuth()) { $options['store'] = true; } + parent::notify($messageStack, $options); + + /* Preferences display. */ + if ($this->_isPrefs && ($msgs = $this->getStack())) { + Horde::addInlineScript(array( + 'parent.DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' + ), 'dom'); + } } }