Use ajax notifications from iframe pages.
authorJan Schneider <jan@horde.org>
Tue, 27 Apr 2010 12:45:14 +0000 (14:45 +0200)
committerJan Schneider <jan@horde.org>
Tue, 27 Apr 2010 13:19:30 +0000 (15:19 +0200)
kronolith/index.php
kronolith/lib/Notification/Listener/AjaxStatus.php [new file with mode: 0644]

index 1781e88..7951b13 100644 (file)
@@ -27,7 +27,14 @@ if ($help_link) {
     $help_link = Horde::widget($help_link, _("Help"), 'helplink', 'help', Horde::popupJs($help_link, array('urlencode' => true)) . 'return false;');
 }
 $today = new Horde_Date($_SERVER['REQUEST_TIME']);
+
+/* Suppress menus in options screen and indicate that notifications should use
+ * the ajax mode. */
 Horde_Core_Prefs_Ui::hideMenu(true);
+$_SESSION['horde_notification']['override'] = array(
+    KRONOLITH_BASE . '/lib/Notification/Listener/AjaxStatus.php',
+    'Kronolith_Notification_Listener_AjaxStatus'
+);
 
 $alarm_methods = $alarm_params = '';
 foreach (Horde_Alarm::notificationMethods() as $method => $params) {
diff --git a/kronolith/lib/Notification/Listener/AjaxStatus.php b/kronolith/lib/Notification/Listener/AjaxStatus.php
new file mode 100644 (file)
index 0000000..6107180
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+/**
+ * The Ajax status class provides a method to display Growler messages using
+ * the KronolithCore javascript notification framework.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Notification_Listener_AjaxStatus extends Horde_Notification_Listener_Status
+{
+    /**
+     * Outputs the status line if there are any messages on the 'status'
+     * message stack.
+     *
+     * @param array $events   The list of events to handle.
+     * @param array $options  An array of options. Not used.
+     */
+    public function notify($events, $options = array())
+    {
+        Horde::addInlineScript(array(
+            'if (window.KronolithCore || parent.KronolithCore) { (window.KronolithCore || parent.KronolithCore).showNotifications(' . Horde_Serialize::serialize($events, Horde_Serialize::JSON) . ') }'
+        ), 'dom');
+    }
+
+}