set() public method

The alarm will be added if it doesn't exist, and updated otherwise.
public set ( array $alarm, boolean $keep = false )
$alarm array An alarm hash. See self::get() for format.
$keep boolean Whether to keep the snooze value and notification status unchanged. If true, the alarm will get "un-snoozed", and notifications (like mails) are sent again.
Esempio n. 1
0
 /**
  * Retrieves active alarms from all applications and stores them in the
  * backend.
  *
  * The applications will only be called once in the configured time span,
  * by default 5 minutes.
  *
  * @param string $user      Retrieve alarms for this user, or for all users
  *                          if null.
  * @param boolean $preload  Preload alarms that go off within the next
  *                          ttl time span?
  */
 public function load($user = null, $preload = true)
 {
     global $registry, $session;
     if ($this->_ttl && $session->exists('horde', 'alarm_loaded') && time() - $session->get('horde', 'alarm_loaded') < $this->_ttl) {
         return;
     }
     /* Cache alarm handler application method existence. */
     $cache = $session->get('horde', 'factory_alarm');
     if (is_null($cache)) {
         $save = array();
         $changed = $registry->getAuth() !== false;
         try {
             $apps = $registry->listApps(null, false, Horde_Perms::READ);
         } catch (Horde_Exception $e) {
             $apps = array();
         }
     } else {
         $apps = $cache;
         $changed = false;
     }
     foreach ($apps as $app) {
         if ($changed) {
             if (!$registry->hasFeature('alarmHandler')) {
                 continue;
             }
             $save[] = $app;
         }
         /* Preload alarms that happen in the next ttl seconds. */
         $time = $preload ? time() + $this->_ttl : time();
         try {
             foreach ($registry->callAppMethod($app, 'listAlarms', array('args' => array($time, $user), 'noperms' => true)) as $alarm) {
                 $this->_alarm->set($alarm, true);
             }
         } catch (Horde_Exception $e) {
         }
     }
     if ($changed) {
         $session->set('horde', 'factory_alarm', $save);
     }
     $session->set('horde', 'alarm_loaded', time());
 }