Show future alarms in the alarm management screen too.
authorJan Schneider <jan@horde.org>
Tue, 6 Jul 2010 14:03:00 +0000 (16:03 +0200)
committerJan Schneider <jan@horde.org>
Tue, 6 Jul 2010 14:03:00 +0000 (16:03 +0200)
framework/Alarm/lib/Horde/Alarm.php
framework/Alarm/lib/Horde/Alarm/Sql.php
horde/admin/alarms.php
horde/docs/CHANGES

index eeca860..c5a8365 100644 (file)
@@ -200,6 +200,30 @@ abstract class Horde_Alarm
     abstract protected function _list($user, Horde_Date $time);
 
     /**
+     * Returns a list of all global alarms from the backend.
+     *
+     * @return array  A list of alarm hashes.
+     * @throws Horde_Alarm_Exception
+     */
+    public function globalAlarms()
+    {
+        $alarms = $this->_global();
+        foreach (array_keys($alarms) as $alarm) {
+            if (isset($alarms[$alarm]['mail']['body'])) {
+                $alarms[$alarm]['mail']['body'] = $this->_fromDriver($alarms[$alarm]['mail']['body']);
+            }
+        }
+        return $alarms;
+    }
+
+    /**
+     * Returns a list of all global alarms from the backend.
+     *
+     * @return array  A list of alarm hashes.
+     */
+    abstract protected function _global();
+
+    /**
      * Returns an alarm hash from the backend.
      *
      * @param string $id    The alarm's unique id.
index 8e50f1b..bfbaa69 100644 (file)
@@ -92,6 +92,31 @@ class Horde_Alarm_Sql extends Horde_Alarm
     }
 
     /**
+     * Returns a list of all global alarms from the backend.
+     *
+     * @return array  A list of alarm hashes.
+     * @throws Horde_Alarm_Exception
+     */
+    protected function _global()
+    {
+        $query = sprintf('SELECT alarm_id, alarm_uid, alarm_start, alarm_end, alarm_methods, alarm_params, alarm_title, alarm_text, alarm_snooze, alarm_internal FROM %s WHERE alarm_uid IS NULL OR alarm_uid = \'\' ORDER BY alarm_start, alarm_end',
+                         $this->_params['table']);
+
+        try {
+            $result = $this->_db->selectAll($query);
+        } catch (Horde_Db_Exception $e) {
+            throw new Horde_Alarm_Exception($e);
+        }
+
+        $alarms = array();
+        foreach ($result as $val) {
+            $alarms[] = $this->_getHash($val);
+        }
+
+        return $alarms;
+    }
+
+    /**
      */
     protected function _getHash(array $alarm)
     {
index ebd5446..fab67d5 100644 (file)
@@ -109,7 +109,7 @@ if ($id) {
 }
 
 try {
-    $alarms = $horde_alarm->listAlarms('');
+    $alarms = $horde_alarm->globalAlarms();
 } catch (Horde_Alarm_Exception $e) {
     $alarms = $e;
 }
index 6fabb53..69226c7 100644 (file)
@@ -45,6 +45,7 @@ v4.0-cvs
 v3.3.9-cvs
 ----------
 
+[jan] Show future alarms in the alarm management screen too.
 [mjr] Fix bug in Horde_Cache that would prevent cache entries from being
       expired in certain cases, and prevent cache key collisions.