/** * * @param integer Date range start (unix timestamp) * @param integer Date range end (unix timestamp) * @return integer Count */ public function count_events($start, $end = null) { // get email addresses of the current user $user_emails = $this->cal->get_user_emails(); $subquery = array(); foreach ($user_emails as $email) { foreach ($this->partstats as $partstat) { $subquery[] = array('tags', '=', 'x-partstat:' . $email . ':' . strtolower($partstat)); } } // aggregate counts from all calendar folders $count = 0; foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { $cal = new kolab_calendar($foldername, $this->cal); if ($cal->get_namespace() == 'other') { continue; } $count += $cal->count_events($start, $end, array(array($subquery, 'OR'))); } return $count; }
/** * Set active/subscribed state of a calendar * * @see calendar_driver::subscribe_calendar() */ public function subscribe_calendar($prop) { if ($prop['id'] && ($cal = $this->get_calendar($prop['id'])) && is_object($cal->storage)) { $ret = false; if (isset($prop['permanent'])) { $ret |= $cal->storage->subscribe(intval($prop['permanent'])); } if (isset($prop['active'])) { $ret |= $cal->storage->activate(intval($prop['active'])); } // apply to child folders, too if ($prop['recursive']) { foreach ((array) kolab_storage::list_folders($cal->storage->name, '*', 'event') as $subfolder) { if (isset($prop['permanent'])) { $prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder); } if (isset($prop['active'])) { $prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder); } } } return $ret; } else { // save state in local prefs $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', array()); $prefs['kolab_calendars'][$prop['id']]['active'] = (bool) $prop['active']; $this->rc->user->save_prefs($prefs); return true; } return false; }
/** * Set active/subscribed state of a list * * @param array Hash array with list properties * id: List Identifier * active: True if list is active, false if not * permanent: True if list is to be subscribed permanently * @return boolean True on success, Fales on failure */ public function subscribe_list($prop) { if ($prop['id'] && ($folder = $this->get_folder($prop['id']))) { $ret = false; if (isset($prop['permanent'])) { $ret |= $folder->subscribe(intval($prop['permanent'])); } if (isset($prop['active'])) { $ret |= $folder->activate(intval($prop['active'])); } // apply to child folders, too if ($prop['recursive']) { foreach ((array) kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) { if (isset($prop['permanent'])) { $prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder); } if (isset($prop['active'])) { $prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder); } } } return $ret; } return false; }