T1484: Make sure an event organizer is always set
There was already a code to do this, but it didn't work for all cases. E.g. it didn't work when you created an event with resources assigned, but no other attendees.
This commit is contained in:
parent
3a29d32ad6
commit
837c7ab02d
2 changed files with 21 additions and 8 deletions
|
@ -1975,8 +1975,8 @@ class calendar extends rcube_plugin
|
|||
private function write_preprocess(&$event, $action)
|
||||
{
|
||||
// convert dates into DateTime objects in user's current timezone
|
||||
$event['start'] = new DateTime($event['start'], $this->timezone);
|
||||
$event['end'] = new DateTime($event['end'], $this->timezone);
|
||||
$event['start'] = new DateTime($event['start'], $this->timezone);
|
||||
$event['end'] = new DateTime($event['end'], $this->timezone);
|
||||
$event['allday'] = (bool)$event['allday'];
|
||||
|
||||
// start/end is all we need for 'move' action (#1480)
|
||||
|
@ -2026,7 +2026,7 @@ class calendar extends rcube_plugin
|
|||
foreach ((array)$event['attendees'] as $i => $attendee) {
|
||||
if ($attendee['role'] == 'ORGANIZER')
|
||||
$organizer = $i;
|
||||
if ($attendee['email'] == in_array(strtolower($attendee['email']), $emails))
|
||||
if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails))
|
||||
$owner = $i;
|
||||
if (!isset($attendee['rsvp']))
|
||||
$event['attendees'][$i]['rsvp'] = true;
|
||||
|
|
|
@ -763,11 +763,25 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
private function _from_driver_event($event, $old = array())
|
||||
{
|
||||
// set current user as ORGANIZER
|
||||
$identity = $this->cal->rc->user->list_emails(true);
|
||||
if (empty($event['attendees']) && $identity['email'])
|
||||
$event['attendees'] = array(array('role' => 'ORGANIZER', 'name' => $identity['name'], 'email' => $identity['email']));
|
||||
if ($identity = $this->cal->rc->user->list_emails(true)) {
|
||||
$event['attendees'] = (array) $event['attendees'];
|
||||
$found = false;
|
||||
|
||||
$event['_owner'] = $identity['email'];
|
||||
// there can be only resources on attendees list (T1484)
|
||||
// let's check the existence of an organizer
|
||||
foreach ($event['attendees'] as $attendee) {
|
||||
if ($attendee['role'] == 'ORGANIZER') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found) {
|
||||
$event['attendees'][] = array('role' => 'ORGANIZER', 'name' => $identity['name'], 'email' => $identity['email']);
|
||||
}
|
||||
|
||||
$event['_owner'] = $identity['email'];
|
||||
}
|
||||
|
||||
// remove EXDATE values if RDATE is given
|
||||
if (!empty($event['recurrence']['RDATE'])) {
|
||||
|
@ -792,7 +806,6 @@ class kolab_calendar extends kolab_storage_folder_api
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
// remove some internal properties which should not be saved
|
||||
unset($event['_savemode'], $event['_fromcalendar'], $event['_identity'], $event['_folder_id'],
|
||||
$event['recurrence_id'], $event['attachments'], $event['deleted_attachments'], $event['className']);
|
||||
|
|
Loading…
Add table
Reference in a new issue