Ejemplo n.º 1
0
 /**
  * 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;
     }
 }