/** * Read available calendars from server */ private function _read_calendars() { // already read sources if (isset($this->calendars)) { return $this->calendars; } // get all folders that have "event" type, sorted by namespace/name $folders = kolab_storage::sort_folders(kolab_storage::get_folders('event') + kolab_storage::get_user_folders('event', true)); $this->calendars = array(); foreach ($folders as $folder) { if ($folder instanceof kolab_storage_folder_user) { $calendar = new kolab_user_calendar($folder->name, $this->cal); $calendar->subscriptions = count($folder->children) > 0; } else { $calendar = new kolab_calendar($folder->name, $this->cal); } if ($calendar->ready) { $this->calendars[$calendar->id] = $calendar; if ($calendar->editable) { $this->has_writeable = true; } } } return $this->calendars; }
/** * Read available calendars for the current user and store them internally */ private function _read_lists($force = false) { // already read sources if (isset($this->lists) && !$force) { return $this->lists; } // get all folders that have type "task" $folders = kolab_storage::sort_folders(kolab_storage::get_folders('task')); $this->lists = $this->folders = array(); $delim = $this->rc->get_storage()->get_hierarchy_delimiter(); // find default folder $default_index = 0; foreach ($folders as $i => $folder) { if ($folder->default && strpos($folder->name, $delim) === false) { $default_index = $i; } } // put default folder (aka INBOX) on top of the list if ($default_index > 0) { $default_folder = $folders[$default_index]; unset($folders[$default_index]); array_unshift($folders, $default_folder); } $prefs = $this->rc->config->get('kolab_tasklists', array()); foreach ($folders as $folder) { $tasklist = $this->folder_props($folder, $prefs); $this->lists[$tasklist['id']] = $tasklist; $this->folders[$tasklist['id']] = $folder; $this->folders[$folder->name] = $folder; } }
/** * Read available calendars for the current user and store them internally */ private function _read_lists($force = false) { // already read sources if (isset($this->lists) && !$force) { return $this->lists; } // get all folders that have type "task" $this->folders = kolab_storage::get_folders('task'); $this->lists = array(); // convert to UTF8 and sort $names = array(); $default_folder = null; foreach ($this->folders as $folder) { $names[$folder->name] = rcube_charset::convert($folder->name, 'UTF7-IMAP'); $this->folders[$folder->name] = $folder; if ($folder->default) { $default_folder = $folder->name; } } asort($names, SORT_LOCALE_STRING); // put default folder (aka INBOX) on top of the list if ($default_folder) { $default_name = $names[$default_folder]; unset($names[$default_folder]); $names = array_merge(array($default_folder => $default_name), $names); } $delim = $this->rc->get_storage()->get_hierarchy_delimiter(); $listnames = array(); $prefs = $this->rc->config->get('kolab_tasklists', array()); foreach ($names as $utf7name => $name) { $folder = $this->folders[$utf7name]; $path_imap = explode($delim, $name); $editname = array_pop($path_imap); // pop off raw name part $path_imap = join($delim, $path_imap); $name = kolab_storage::folder_displayname(kolab_storage::object_name($utf7name), $listnames); if ($folder->get_namespace() == 'personal') { $readonly = false; $alarms = true; } else { $alarms = false; $readonly = true; if (($rights = $folder->get_myrights()) && !PEAR::isError($rights)) { if (strpos($rights, 'i') !== false) { $readonly = false; } } } $list_id = kolab_storage::folder_id($utf7name); $tasklist = array('id' => $list_id, 'name' => $name, 'editname' => $editname, 'color' => $folder->get_color('0000CC'), 'showalarms' => isset($prefs[$list_id]['showalarms']) ? $prefs[$list_id]['showalarms'] : $alarms, 'editable' => !$readonly, 'active' => $folder->is_active(), 'parentfolder' => $path_imap, 'default' => $folder->default, 'children' => true, 'class_name' => trim($folder->get_namespace() . ($folder->default ? ' default' : ''))); $this->lists[$tasklist['id']] = $tasklist; $this->folders[$tasklist['id']] = $folder; } }