Changeset View
Changeset View
Standalone View
Standalone View
plugins/calendar/calendar.php
Show First 20 Lines • Show All 2,500 Lines • ▼ Show 20 Lines | function resources_calendar() | ||||
echo $this->encode($events); | echo $this->encode($events); | ||||
exit; | exit; | ||||
} | } | ||||
/**** Event invitation plugin hooks ****/ | /**** Event invitation plugin hooks ****/ | ||||
/** | /** | ||||
* Find an event in user calendars | |||||
*/ | |||||
protected function find_event($event) | |||||
{ | |||||
$this->load_driver(); | |||||
// We search for writeable calendars in personal namespace by default | |||||
$result = $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL); | |||||
// Some plugins may search in other users calendars, e.g. where delegation is involved | |||||
$plugin = $this->rc->plugins->exec_hook('calendar_event_find', array( | |||||
'search' => $event, | |||||
'result' => $result, | |||||
'calendar' => $this, | |||||
)); | |||||
return $plugin['result']; | |||||
} | |||||
/** | |||||
* Handler for calendar/itip-status requests | * Handler for calendar/itip-status requests | ||||
*/ | */ | ||||
function event_itip_status() | function event_itip_status() | ||||
{ | { | ||||
$data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true); | $data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true); | ||||
// find local copy of the referenced event | |||||
$this->load_driver(); | $this->load_driver(); | ||||
$existing = $this->driver->get_event($data, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL); | |||||
// find local copy of the referenced event | |||||
$existing = $this->find_event($data); | |||||
$itip = $this->load_itip(); | $itip = $this->load_itip(); | ||||
$response = $itip->get_itip_status($data, $existing); | $response = $itip->get_itip_status($data, $existing); | ||||
// get a list of writeable calendars to save new events to | // get a list of writeable calendars to save new events to | ||||
if (!$existing && !$data['nosave'] && $response['action'] == 'rsvp' || $response['action'] == 'import') { | if (!$existing && !$data['nosave'] && $response['action'] == 'rsvp' || $response['action'] == 'import') { | ||||
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL); | $calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL); | ||||
$calendar_select = new html_select(array('name' => 'calendar', 'id' => 'itip-saveto', 'is_escaped' => true)); | $calendar_select = new html_select(array('name' => 'calendar', 'id' => 'itip-saveto', 'is_escaped' => true)); | ||||
$calendar_select->add('--', ''); | $calendar_select->add('--', ''); | ||||
$numcals = 0; | $numcals = 0; | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | if ($event = $this->lib->mail_get_itip_object($mbox, $uid, $mime_id, 'event')) { | ||||
); | ); | ||||
$metadata['attendee'] = $sender_identity['email']; | $metadata['attendee'] = $sender_identity['email']; | ||||
} | } | ||||
} | } | ||||
// save to calendar | // save to calendar | ||||
if ($calendar && $calendar['editable']) { | if ($calendar && $calendar['editable']) { | ||||
// check for existing event with the same UID | // check for existing event with the same UID | ||||
$existing = $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL); | $existing = $this->find_event($event); | ||||
if ($existing) { | if ($existing) { | ||||
// forward savemode for correct updates of recurring events | // forward savemode for correct updates of recurring events | ||||
$existing['_savemode'] = $savemode ?: $event['_savemode']; | $existing['_savemode'] = $savemode ?: $event['_savemode']; | ||||
// only update attendee status | // only update attendee status | ||||
if ($event['_method'] == 'REPLY') { | if ($event['_method'] == 'REPLY') { | ||||
// try to identify the attendee using the email sender address | // try to identify the attendee using the email sender address | ||||
▲ Show 20 Lines • Show All 441 Lines • Show Last 20 Lines |