}
/**
- * 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');
}
/**
$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. */
/**
* 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) . ')'
: '';
}
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
/**
* 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();
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');
+ }
}
}