/**
  * Default constructor
  */
 public function __construct($imap_folder, $calendar)
 {
     $this->cal = $calendar;
     $this->imap = $calendar->rc->get_storage();
     $this->name = $imap_folder;
     // ID is derrived from folder name
     $this->id = kolab_storage::folder_id($this->name, true);
     $old_id = kolab_storage::folder_id($this->name, false);
     // fetch objects from the given IMAP folder
     $this->storage = kolab_storage::get_folder($this->name);
     $this->ready = $this->storage && $this->storage->valid;
     // Set writeable and alarms flags according to folder permissions
     if ($this->ready) {
         if ($this->storage->get_namespace() == 'personal') {
             $this->editable = true;
             $this->rights = 'lrswikxteav';
             $this->alarms = true;
         } else {
             $rights = $this->storage->get_myrights();
             if ($rights && !PEAR::isError($rights)) {
                 $this->rights = $rights;
                 if (strpos($rights, 't') !== false || strpos($rights, 'd') !== false) {
                     $this->editable = strpos($rights, 'i');
                 }
             }
         }
         // user-specific alarms settings win
         $prefs = $this->cal->rc->config->get('kolab_calendars', array());
         if (isset($prefs[$this->id]['showalarms'])) {
             $this->alarms = $prefs[$this->id]['showalarms'];
         } else {
             if (isset($prefs[$old_id]['showalarms'])) {
                 $this->alarms = $prefs[$old_id]['showalarms'];
             }
         }
     }
     $this->default = $this->storage->default;
     $this->subtype = $this->storage->subtype;
 }
 /**
  * Create a new list assigned to the current user
  *
  * @param array Hash array with list properties
  *        name: List name
  *       color: The color of the list
  *  showalarms: True if alarms are enabled
  * @return mixed ID of the new list on success, False on error
  */
 public function create_list(&$prop)
 {
     $prop['type'] = 'task' . ($prop['default'] ? '.default' : '');
     $prop['active'] = true;
     // activate folder by default
     $prop['subscribed'] = true;
     $folder = kolab_storage::folder_update($prop);
     if ($folder === false) {
         $this->last_error = kolab_storage::$last_error;
         return false;
     }
     // create ID
     $id = kolab_storage::folder_id($folder);
     $prefs['kolab_tasklists'] = $this->rc->config->get('kolab_tasklists', array());
     if (isset($prop['showalarms'])) {
         $prefs['kolab_tasklists'][$id]['showalarms'] = $prop['showalarms'] ? true : false;
     }
     if ($prefs['kolab_tasklists'][$id]) {
         $this->rc->user->save_prefs($prefs);
     }
     // force page reload to properly render folder hierarchy
     if (!empty($prop['parent'])) {
         $prop['_reload'] = true;
     } else {
         $folder = kolab_storage::get_folder($folder);
         $prop += $this->folder_props($folder, array());
     }
     return $id;
 }