Changeset View
Changeset View
Standalone View
Standalone View
plugins/calendar/drivers/kolab/kolab_user_calendar.php
<?php | <?php | ||||
/** | /** | ||||
* Kolab calendar storage class simulating a virtual user calendar | * Kolab calendar storage class simulating a virtual user calendar | ||||
* | * | ||||
* @author Thomas Bruederli <bruederli@kolabsys.com> | * @author Thomas Bruederli <bruederli@kolabsys.com> | ||||
* | * | ||||
* Copyright (C) 2014-2015, Kolab Systems AG <contact@kolabsys.com> | * Copyright (C) 2014-2016, Kolab Systems AG <contact@kolabsys.com> | ||||
* | * | ||||
* This program is free software: you can redistribute it and/or modify | * This program is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU Affero General Public License as | * it under the terms of the GNU Affero General Public License as | ||||
* published by the Free Software Foundation, either version 3 of the | * published by the Free Software Foundation, either version 3 of the | ||||
* License, or (at your option) any later version. | * License, or (at your option) any later version. | ||||
* | * | ||||
* This program is distributed in the hope that it will be useful, | * This program is distributed in the hope that it will be useful, | ||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
Show All 23 Lines | class kolab_user_calendar extends kolab_calendar | ||||
{ | { | ||||
$this->cal = $calendar; | $this->cal = $calendar; | ||||
// full user record is provided | // full user record is provided | ||||
if (is_array($user_or_folder)) { | if (is_array($user_or_folder)) { | ||||
$this->userdata = $user_or_folder; | $this->userdata = $user_or_folder; | ||||
$this->storage = new kolab_storage_folder_user($this->userdata['kolabtargetfolder'], '', $this->userdata); | $this->storage = new kolab_storage_folder_user($this->userdata['kolabtargetfolder'], '', $this->userdata); | ||||
} | } | ||||
else if ($user_or_folder instanceof kolab_storage_folder_user) { | |||||
$this->storage = $user_or_folder; | |||||
$this->userdata = $this->storage->ldaprec; | |||||
} | |||||
else { // get user record from LDAP | else { // get user record from LDAP | ||||
$this->storage = new kolab_storage_folder_user($user_or_folder); | $this->storage = new kolab_storage_folder_user($user_or_folder); | ||||
$this->userdata = $this->storage->ldaprec; | $this->userdata = $this->storage->ldaprec; | ||||
} | } | ||||
$this->ready = !empty($this->userdata['kolabtargetfolder']); | $this->ready = !empty($this->userdata['kolabtargetfolder']); | ||||
$this->storage->type = 'event'; | $this->storage->type = 'event'; | ||||
if ($this->ready) { | if ($this->ready) { | ||||
// ID is derrived from the user's kolabtargetfolder attribute | // ID is derrived from the user's kolabtargetfolder attribute | ||||
$this->id = kolab_storage::folder_id($this->userdata['kolabtargetfolder'], true); | $this->id = kolab_storage::folder_id($this->userdata['kolabtargetfolder'], true); | ||||
$this->imap_folder = $this->userdata['kolabtargetfolder']; | $this->imap_folder = $this->userdata['kolabtargetfolder']; | ||||
$this->name = $this->storage->get_name(); | $this->name = $this->storage->name; | ||||
$this->parent = ''; // user calendars are top level | $this->parent = ''; // user calendars are top level | ||||
// user-specific alarms settings win | // user-specific alarms settings win | ||||
$prefs = $this->cal->rc->config->get('kolab_calendars', array()); | $prefs = $this->cal->rc->config->get('kolab_calendars', array()); | ||||
if (isset($prefs[$this->id]['showalarms'])) | if (isset($prefs[$this->id]['showalarms'])) | ||||
$this->alarms = $prefs[$this->id]['showalarms']; | $this->alarms = $prefs[$this->id]['showalarms']; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Getter for a nice and human readable name for this calendar | * Getter for a nice and human readable name for this calendar | ||||
* | * | ||||
* @return string Name of this calendar | * @return string Name of this calendar | ||||
*/ | */ | ||||
public function get_name() | public function get_name() | ||||
{ | { | ||||
return $this->userdata['displayname'] ?: ($this->userdata['name'] ?: $this->userdata['mail']); | return $this->userdata['displayname'] ?: ($this->userdata['name'] ?: $this->userdata['mail']); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the IMAP folder owner | * Getter for the IMAP folder owner | ||||
* | * | ||||
* @return string Name of the folder owner | * @return string Name of the folder owner | ||||
*/ | */ | ||||
public function get_owner() | public function get_owner() | ||||
{ | { | ||||
return $this->userdata['mail']; | return $this->userdata['mail']; | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public function get_title() | public function get_title() | ||||
{ | { | ||||
return trim($this->userdata['displayname'] . '; ' . $this->userdata['mail'], '; '); | return trim($this->userdata['displayname'] . '; ' . $this->userdata['mail'], '; '); | ||||
} | } | ||||
/** | /** | ||||
* Getter for the name of the namespace to which the IMAP folder belongs | * Getter for the name of the namespace to which the IMAP folder belongs | ||||
* | * | ||||
* @return string Name of the namespace (personal, other, shared) | * @return string Name of the namespace (personal, other, shared) | ||||
*/ | */ | ||||
public function get_namespace() | public function get_namespace() | ||||
{ | { | ||||
return 'other user'; | return 'other user'; | ||||
} | } | ||||
/** | /** | ||||
* Getter for the top-end calendar folder name (not the entire path) | * Getter for the top-end calendar folder name (not the entire path) | ||||
* | * | ||||
* @return string Name of this calendar | * @return string Name of this calendar | ||||
*/ | */ | ||||
public function get_foldername() | public function get_foldername() | ||||
{ | { | ||||
return $this->get_name(); | return $this->get_name(); | ||||
Show All 38 Lines | class kolab_user_calendar extends kolab_calendar | ||||
*/ | */ | ||||
public function update(&$prop) | public function update(&$prop) | ||||
{ | { | ||||
// don't change anything. | // don't change anything. | ||||
// let kolab_driver save props in local prefs | // let kolab_driver save props in local prefs | ||||
return $prop['id']; | return $prop['id']; | ||||
} | } | ||||
/** | /** | ||||
* Getter for a single event object | * Getter for a single event object | ||||
*/ | */ | ||||
public function get_event($id) | public function get_event($id) | ||||
{ | { | ||||
// TODO: implement this | // TODO: implement this | ||||
return $this->events[$id]; | return $this->events[$id]; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | class kolab_user_calendar extends kolab_calendar | ||||
/** | /** | ||||
* Helper to build a key for the absolute time slot the given event convers | * Helper to build a key for the absolute time slot the given event convers | ||||
*/ | */ | ||||
private function time_key($event) | private function time_key($event) | ||||
{ | { | ||||
return sprintf('%s/%s', $event['start']->format('U'), is_object($event['end']->format('U')) ?: '0'); | return sprintf('%s/%s', $event['start']->format('U'), is_object($event['end']->format('U')) ?: '0'); | ||||
} | } | ||||
/** | /** | ||||
* Create a new event record | * Create a new event record | ||||
* | * | ||||
* @see calendar_driver::new_event() | * @see calendar_driver::new_event() | ||||
* | * | ||||
* @return mixed The created record ID on success, False on error | * @return mixed The created record ID on success, False on error | ||||
*/ | */ | ||||
public function insert_event($event) | public function insert_event($event) | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Update a specific event record | * Update a specific event record | ||||
* | * | ||||
* @see calendar_driver::new_event() | * @see calendar_driver::new_event() | ||||
* @return boolean True on success, False on error | * @return boolean True on success, False on error | ||||
*/ | */ | ||||
public function update_event($event, $exception_id = null) | public function update_event($event, $exception_id = null) | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Delete an event record | * Delete an event record | ||||
* | * | ||||
Show All 11 Lines | class kolab_user_calendar extends kolab_calendar | ||||
* @see calendar_driver::undelete_event() | * @see calendar_driver::undelete_event() | ||||
* @return boolean True on success, False on error | * @return boolean True on success, False on error | ||||
*/ | */ | ||||
public function restore_event($event) | public function restore_event($event) | ||||
{ | { | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Convert from Kolab_Format to internal representation | * Convert from Kolab_Format to internal representation | ||||
*/ | */ | ||||
private function _to_rcube_event($record) | private function _to_rcube_event($record) | ||||
{ | { | ||||
$record['id'] = $record['uid']; | $record['id'] = $record['uid']; | ||||
$record['calendar'] = $this->id; | $record['calendar'] = $this->id; | ||||
return kolab_driver::to_rcube_event($record); | return kolab_driver::to_rcube_event($record); | ||||
} | } | ||||
} | } |