Changeset View
Changeset View
Standalone View
Standalone View
plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
Show All 28 Lines | class kolab_invitation_calendar | ||||
public $rights = 'lrsv'; | public $rights = 'lrsv'; | ||||
public $editable = false; | public $editable = false; | ||||
public $attachments = false; | public $attachments = false; | ||||
public $subscriptions = false; | public $subscriptions = false; | ||||
public $partstats = array('unknown'); | public $partstats = array('unknown'); | ||||
public $categories = array(); | public $categories = array(); | ||||
public $name = 'Invitations'; | public $name = 'Invitations'; | ||||
/** | /** | ||||
* Default constructor | * Default constructor | ||||
*/ | */ | ||||
public function __construct($id, $calendar) | public function __construct($id, $calendar) | ||||
{ | { | ||||
$this->cal = $calendar; | $this->cal = $calendar; | ||||
$this->id = $id; | $this->id = $id; | ||||
Show All 12 Lines | public function __construct($id, $calendar) | ||||
} | } | ||||
// 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->name; | return $this->name; | ||||
} | } | ||||
/** | /** | ||||
* 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->cal->rc->get_user_name(); | return $this->cal->rc->get_user_name(); | ||||
} | } | ||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public function get_title() | public function get_title() | ||||
{ | { | ||||
return $this->get_name(); | return $this->get_name(); | ||||
} | } | ||||
/** | /** | ||||
* 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 'x-special'; | return 'x-special'; | ||||
} | } | ||||
/** | /** | ||||
* 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 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | class kolab_invitation_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) | ||||
{ | { | ||||
// redirect call to kolab_driver::get_event() | // redirect call to kolab_driver::get_event() | ||||
$event = $this->cal->driver->get_event($id, calendar_driver::FILTER_WRITEABLE); | $event = $this->cal->driver->get_event($id, calendar_driver::FILTER_WRITEABLE); | ||||
Show All 14 Lines | class kolab_invitation_calendar | ||||
{ | { | ||||
// find the actual folder this event resides in | // find the actual folder this event resides in | ||||
if (!empty($event['_folder_id'])) { | if (!empty($event['_folder_id'])) { | ||||
$cal = $this->cal->driver->get_calendar($event['_folder_id']); | $cal = $this->cal->driver->get_calendar($event['_folder_id']); | ||||
} | } | ||||
else { | else { | ||||
$cal = null; | $cal = null; | ||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | ||||
$cal = new kolab_calendar($foldername, $this->cal); | $cal = $this->_get_calendar($foldername); | ||||
if ($cal->ready && $cal->storage && $cal->get_event($event['id'])) { | if ($cal->ready && $cal->storage && $cal->get_event($event['id'])) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if ($cal && $cal->storage) { | if ($cal && $cal->storage) { | ||||
return $cal->get_attachment_body($id, $event); | return $cal->get_attachment_body($id, $event); | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* @param integer Event's new start (unix timestamp) | * @param integer Event's new start (unix timestamp) | ||||
* @param integer Event's new end (unix timestamp) | * @param integer Event's new end (unix timestamp) | ||||
* @param string Search query (optional) | * @param string Search query (optional) | ||||
* @param boolean Include virtual events (optional) | * @param boolean Include virtual events (optional) | ||||
* @param array Additional parameters to query storage | * @param array Additional parameters to query storage | ||||
* @return array A list of event records | * @return array A list of event records | ||||
*/ | */ | ||||
public function list_events($start, $end, $search = null, $virtual = 1, $query = array()) | public function list_events($start, $end, $search = null, $virtual = 1, $query = array()) | ||||
{ | { | ||||
// get email addresses of the current user | // get email addresses of the current user | ||||
$user_emails = $this->cal->get_user_emails(); | $user_emails = $this->cal->get_user_emails(); | ||||
$subquery = array(); | $subquery = array(); | ||||
foreach ($user_emails as $email) { | foreach ($user_emails as $email) { | ||||
foreach ($this->partstats as $partstat) { | foreach ($this->partstats as $partstat) { | ||||
$subquery[] = array('tags', '=', 'x-partstat:' . $email . ':' . strtolower($partstat)); | $subquery[] = array('tags', '=', 'x-partstat:' . $email . ':' . strtolower($partstat)); | ||||
} | } | ||||
} | } | ||||
// aggregate events from all calendar folders | // aggregate events from all calendar folders | ||||
$events = array(); | $events = array(); | ||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | ||||
$cal = new kolab_calendar($foldername, $this->cal); | $cal = $this->_get_calendar($foldername); | ||||
if ($cal->get_namespace() == 'other') | if ($cal->get_namespace() == 'other') | ||||
continue; | continue; | ||||
foreach ($cal->list_events($start, $end, $search, 1, $query, array(array($subquery, 'OR'))) as $event) { | foreach ($cal->list_events($start, $end, $search, 1, $query, array(array($subquery, 'OR'))) as $event) { | ||||
$match = false; | $match = false; | ||||
// post-filter events to match out partstats | // post-filter events to match out partstats | ||||
if (is_array($event['attendees'])) { | if (is_array($event['attendees'])) { | ||||
Show All 37 Lines | public function count_events($start, $end = null) | ||||
$filter = array( | $filter = array( | ||||
array('tags','!=','x-status:cancelled'), | array('tags','!=','x-status:cancelled'), | ||||
array($subquery, 'OR') | array($subquery, 'OR') | ||||
); | ); | ||||
// aggregate counts from all calendar folders | // aggregate counts from all calendar folders | ||||
$count = 0; | $count = 0; | ||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) { | ||||
$cal = new kolab_calendar($foldername, $this->cal); | $cal = $this->_get_calendar($foldername); | ||||
if ($cal->get_namespace() == 'other') | if ($cal->get_namespace() == 'other') | ||||
continue; | continue; | ||||
$count += $cal->count_events($start, $end, $filter); | $count += $cal->count_events($start, $end, $filter); | ||||
} | } | ||||
return $count; | return $count; | ||||
} | } | ||||
/** | /** | ||||
* Get calendar object instance (that maybe already initialized) | |||||
*/ | |||||
private function _get_calendar($folder_name) | |||||
{ | |||||
$id = kolab_storage::folder_id($folder_name, true); | |||||
return $this->cal->driver->get_calendar($id); | |||||
} | |||||
/** | |||||
* Helper method to modify some event properties | * Helper method to modify some event properties | ||||
*/ | */ | ||||
private function _mod_event($event) | private function _mod_event($event) | ||||
{ | { | ||||
// set classes according to PARTSTAT | // set classes according to PARTSTAT | ||||
$event = kolab_driver::add_partstat_class($event, $this->partstats); | $event = kolab_driver::add_partstat_class($event, $this->partstats); | ||||
if (strpos($event['className'], 'fc-invitation-') !== false) { | if (strpos($event['className'], 'fc-invitation-') !== false) { | ||||
$event['calendar'] = $this->id; | $event['calendar'] = $this->id; | ||||
} | } | ||||
return $event; | return $event; | ||||
} | } | ||||
/** | /** | ||||
* 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) | ||||
{ | { | ||||
// forward call to the actual storage folder | // forward call to the actual storage folder | ||||
if ($event['_folder_id']) { | if ($event['_folder_id']) { | ||||
$cal = $this->cal->driver->get_calendar($event['_folder_id']); | $cal = $this->cal->driver->get_calendar($event['_folder_id']); | ||||
if ($cal && $cal->ready) { | if ($cal && $cal->ready) { | ||||
return $cal->update_event($event, $exception_id); | return $cal->update_event($event, $exception_id); | ||||
} | } | ||||
Show All 18 Lines | class kolab_invitation_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; | ||||
} | } | ||||
} | } |