/**
  * Default constructor
  */
 public function __construct($user_or_folder, $calendar)
 {
     $this->cal = $calendar;
     // full user record is provided
     if (is_array($user_or_folder)) {
         $this->userdata = $user_or_folder;
         $this->storage = new kolab_storage_folder_user($this->userdata['kolabtargetfolder'], '', $this->userdata);
     } else {
         // get user record from LDAP
         $this->storage = new kolab_storage_folder_user($user_or_folder);
         $this->userdata = $this->storage->ldaprec;
     }
     $this->ready = !empty($this->userdata['kolabtargetfolder']);
     $this->storage->type = 'event';
     if ($this->ready) {
         // ID is derrived from the user's kolabtargetfolder attribute
         $this->id = kolab_storage::folder_id($this->userdata['kolabtargetfolder'], true);
         $this->imap_folder = $this->userdata['kolabtargetfolder'];
         $this->name = $this->storage->get_name();
         $this->parent = '';
         // user calendars are top level
         // 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'];
         }
     }
 }
Exemple #2
0
 /**
  * Create a new calendar assigned to the current user
  *
  * @param array Hash array with calendar properties
  *    name: Calendar name
  *   color: The color of the calendar
  * @return mixed ID of the calendar on success, False on error
  */
 public function create_calendar($prop)
 {
     $prop['type'] = 'event';
     $prop['active'] = true;
     $prop['subscribed'] = true;
     $folder = kolab_storage::folder_update($prop);
     if ($folder === false) {
         $this->last_error = $this->cal->gettext(kolab_storage::$last_error);
         return false;
     }
     // create ID
     $id = kolab_storage::folder_id($folder);
     // save color in user prefs (temp. solution)
     $prefs['kolab_calendars'] = $this->rc->config->get('kolab_calendars', array());
     if (isset($prop['color'])) {
         $prefs['kolab_calendars'][$id]['color'] = $prop['color'];
     }
     if (isset($prop['showalarms'])) {
         $prefs['kolab_calendars'][$id]['showalarms'] = $prop['showalarms'] ? true : false;
     }
     if ($prefs['kolab_calendars'][$id]) {
         $this->rc->user->save_prefs($prefs);
     }
     return $id;
 }
 /**
  * Update properties of an existing tasklist
  *
  * @param array Hash array with list properties
  *          id: List Identifier
  *        name: List name
  *       color: The color of the list
  *  showalarms: True if alarms are enabled (if supported)
  * @return boolean True on success, Fales on failure
  */
 public function edit_list($prop)
 {
     if ($prop['id'] && ($folder = $this->folders[$prop['id']])) {
         $prop['oldname'] = $folder->name;
         $prop['type'] = 'task';
         $newfolder = kolab_storage::folder_update($prop);
         if ($newfolder === false) {
             $this->last_error = kolab_storage::$last_error;
             return false;
         }
         // create ID
         $id = kolab_storage::folder_id($newfolder);
         // fallback to local prefs
         $prefs['kolab_tasklists'] = $this->rc->config->get('kolab_tasklists', array());
         unset($prefs['kolab_tasklists'][$prop['id']]);
         if (isset($prop['showalarms'])) {
             $prefs['kolab_tasklists'][$id]['showalarms'] = $prop['showalarms'] ? true : false;
         }
         if ($prefs['kolab_tasklists'][$id]) {
             $this->rc->user->save_prefs($prefs);
         }
         return $id;
     }
     return false;
 }
 /**
  * Update properties of this calendar folder
  *
  * @see calendar_driver::edit_calendar()
  */
 public function update(&$prop)
 {
     $prop['oldname'] = $this->get_realname();
     $newfolder = kolab_storage::folder_update($prop);
     if ($newfolder === false) {
         $this->cal->last_error = $this->cal->gettext(kolab_storage::$last_error);
         return false;
     }
     // create ID
     return kolab_storage::folder_id($newfolder);
 }
 /**
  * Find tasks assigned to a specified message
  *
  * @see tasklist_driver::get_message_related_tasks()
  */
 public function get_message_related_tasks($headers, $folder)
 {
     $config = kolab_storage_config::get_instance();
     $result = $config->get_message_relations($headers, $folder, 'task');
     foreach ($result as $idx => $rec) {
         $result[$idx] = $this->_to_rcube_task($rec, kolab_storage::folder_id($rec['_mailbox']));
     }
     return $result;
 }