Improve invitation handling: only search writeable calendars for already saved events; fix RSVP button display
This commit is contained in:
parent
2b1d48f854
commit
551fe7db2b
4 changed files with 37 additions and 14 deletions
|
@ -602,7 +602,7 @@ class calendar extends rcube_plugin
|
|||
|
||||
// search for event if only UID is given
|
||||
if (!isset($event['calendar']) && $event['uid']) {
|
||||
if (!($event = $this->driver->get_event($event))) {
|
||||
if (!($event = $this->driver->get_event($event, true))) {
|
||||
break;
|
||||
}
|
||||
$undo_time = 0;
|
||||
|
@ -665,7 +665,7 @@ class calendar extends rcube_plugin
|
|||
$status = $event['fallback'];
|
||||
$html = html::div('rsvp-status', $status != 'CANCELLED' ? $this->gettext('acceptinvitation') : '');
|
||||
$this->load_driver();
|
||||
if ($existing = $this->driver->get_event($event)) {
|
||||
if ($existing = $this->driver->get_event($event, true)) {
|
||||
$emails = $this->get_user_emails();
|
||||
foreach ($existing['attendees'] as $i => $attendee) {
|
||||
if ($attendee['email'] && in_array($attendee['email'], $emails)) {
|
||||
|
@ -674,7 +674,7 @@ class calendar extends rcube_plugin
|
|||
}
|
||||
}
|
||||
}
|
||||
else if ($status != 'NEEDS-ACTION')
|
||||
if ($status == 'unknown')
|
||||
$action = 'import';
|
||||
|
||||
if (in_array($status, array('ACCEPTED','TENTATIVE','DECLINED'))) {
|
||||
|
@ -1094,9 +1094,13 @@ class calendar extends rcube_plugin
|
|||
*/
|
||||
public function generate_randomdata()
|
||||
{
|
||||
$cats = array_keys($this->driver->list_categories());
|
||||
$cals = $this->driver->list_calendars();
|
||||
$num = $_REQUEST['_num'] ? intval($_REQUEST['_num']) : 100;
|
||||
$cats = array_keys($this->driver->list_categories());
|
||||
$cals = array();
|
||||
foreach ($this->driver->list_calendars() as $cid => $cal) {
|
||||
if ($cal['active'])
|
||||
$cals[$cid] = $cal;
|
||||
}
|
||||
|
||||
while ($count++ < $num) {
|
||||
$start = round((time() + rand(-2600, 2600) * 1000) / 300) * 300;
|
||||
|
@ -1705,13 +1709,21 @@ class calendar extends rcube_plugin
|
|||
public function mail_message_load($p)
|
||||
{
|
||||
$this->message = $p['object'];
|
||||
$itip_part = null;
|
||||
|
||||
// check all message parts for .ics files
|
||||
foreach ((array)$this->message->mime_parts as $idx => $part) {
|
||||
if ($this->is_vcalendar($part)) {
|
||||
$this->ics_parts[] = $part->mime_id;
|
||||
if ($part->ctype_parameters['method'])
|
||||
$itip_part = $part->mime_id;
|
||||
else
|
||||
$this->ics_parts[] = $part->mime_id;
|
||||
}
|
||||
}
|
||||
|
||||
// priorize part with method parameter
|
||||
if ($itip_part)
|
||||
$this->ics_parts = array($itip_part);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1898,7 +1910,7 @@ class calendar extends rcube_plugin
|
|||
$event['calendar'] = $calendar['id'];
|
||||
|
||||
// check for existing event with the same UID
|
||||
$existing = $this->driver->get_event($event);
|
||||
$existing = $this->driver->get_event($event['uid'], true);
|
||||
|
||||
if ($existing) {
|
||||
// only update attendee status
|
||||
|
|
|
@ -202,10 +202,11 @@ abstract class calendar_driver
|
|||
*
|
||||
* @param mixed UID string or hash array with event properties:
|
||||
* id: Event identifier
|
||||
* calendar: Calendar identifier
|
||||
* calendar: Calendar identifier (optional)
|
||||
* @param boolean If true, only writeable calendars shall be searched
|
||||
* @return array Event object as hash array
|
||||
*/
|
||||
abstract function get_event($event);
|
||||
abstract function get_event($event, $writeable = null);
|
||||
|
||||
/**
|
||||
* Get events from source.
|
||||
|
|
|
@ -637,9 +637,10 @@ class database_driver extends calendar_driver
|
|||
/**
|
||||
* Return data of a specific event
|
||||
* @param mixed Hash array with event properties or event UID
|
||||
* @param boolean Only search in writeable calendars (currently ignored)
|
||||
* @return array Hash array with event properties
|
||||
*/
|
||||
public function get_event($event)
|
||||
public function get_event($event, $writeable = null)
|
||||
{
|
||||
$id = is_array($event) ? ($event['id'] ? $event['id'] : $event['uid']) : $event;
|
||||
$col = $event['id'] && is_numeric($event['id']) ? 'event_id' : 'uid';
|
||||
|
|
|
@ -360,15 +360,24 @@ class kolab_driver extends calendar_driver
|
|||
* @see calendar_driver::get_event()
|
||||
* @return array Hash array with event properties, false if not found
|
||||
*/
|
||||
public function get_event($event)
|
||||
public function get_event($event, $writeable = null)
|
||||
{
|
||||
$id = $event['id'] ? $event['id'] : $event['uid'];
|
||||
if ($event['calendar'] && ($storage = $this->calendars[$event['calendar']])) {
|
||||
if (is_array($event)) {
|
||||
$id = $event['id'] ? $event['id'] : $event['uid'];
|
||||
$cal = $event['calendar'];
|
||||
}
|
||||
else {
|
||||
$id = $event;
|
||||
}
|
||||
|
||||
if ($cal && ($storage = $this->calendars[$cal])) {
|
||||
return $storage->get_event($id);
|
||||
}
|
||||
// iterate over all calendar folders and search for the event ID
|
||||
else if (!$event['calendar']) {
|
||||
else if (!$cal) {
|
||||
foreach ($this->calendars as $storage) {
|
||||
if ($writeable && !rcube_kolab::is_subscribed($storage->get_realname()))
|
||||
continue;
|
||||
if ($result = $storage->get_event($id)) {
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue