Changeset View
Standalone View
plugins/calendar/calendar.php
Show First 20 Lines • Show All 1,233 Lines • ▼ Show 20 Lines | function event_action() | ||||
$attendees | $attendees | ||||
)); | )); | ||||
if ($success = $this->driver->edit_rsvp($event, $status, $updated_attendees)) { | if ($success = $this->driver->edit_rsvp($event, $status, $updated_attendees)) { | ||||
$noreply = rcube_utils::get_input_value('noreply', rcube_utils::INPUT_GPC); | $noreply = rcube_utils::get_input_value('noreply', rcube_utils::INPUT_GPC); | ||||
$noreply = intval($noreply) || $status == 'needs-action' || $itip_sending === 0; | $noreply = intval($noreply) || $status == 'needs-action' || $itip_sending === 0; | ||||
$reload = $event['calendar'] != $ev['calendar'] || !empty($event['recurrence']) ? 2 : 1; | $reload = $event['calendar'] != $ev['calendar'] || !empty($event['recurrence']) ? 2 : 1; | ||||
$emails = $this->get_user_emails(); | $emails = $this->get_user_emails(); | ||||
$ownedResourceEmails = $this->owned_resources_emails(); | |||||
$organizer = null; | $organizer = null; | ||||
$resourceConfirmation = false; | |||||
foreach ($event['attendees'] as $i => $attendee) { | foreach ($event['attendees'] as $i => $attendee) { | ||||
if ($attendee['role'] == 'ORGANIZER') { | if ($attendee['role'] == 'ORGANIZER') { | ||||
$organizer = $attendee; | $organizer = $attendee; | ||||
} | } | ||||
else if (!empty($attendee['email']) && in_array(strtolower($attendee['email']), $emails)) { | else if (!empty($attendee['email']) && in_array_nocase($attendee['email'], $emails)) { | ||||
$reply_sender = $attendee['email']; | $reply_sender = $attendee['email']; | ||||
} | } | ||||
else if (!empty($attendee['cutype']) && $attendee['cutype'] == 'RESOURCE' && !empty($attendee['email']) && in_array_nocase($attendee['email'], $ownedResourceEmails)) { | |||||
machniak: You need to add `!empty($attendee['cutype'])` to prevent from a warning in newer PHP versions. | |||||
$resourceConfirmation = true; | |||||
// Note on behalf of which resource this update is going to be sent out | |||||
$event['_resource'] = $attendee['email']; | |||||
Not Done Inline ActionsThis will not gonna work when there's multiple resources (with the same owner) in the event. machniak: This will not gonna work when there's multiple resources (with the same owner) in the event. | |||||
Done Inline ActionsFor the case of multiple resources we'll have to show individual RSVP buttons per matching attendee, that will be processed individually, so I think also in that case we can set _resource to the correct $attendee. For the time being the entire codebase just does not deal with multiple matching attendees AFAIK, so nothing that I can reasonably fix in this patch I think. mollekopf: For the case of multiple resources we'll have to show individual RSVP buttons per matching… | |||||
} | |||||
} | } | ||||
if (!$noreply) { | if (!$noreply) { | ||||
$itip = $this->load_itip(); | $itip = $this->load_itip(); | ||||
$itip->set_sender_email($reply_sender); | $itip->set_sender_email($reply_sender); | ||||
$event['thisandfuture'] = $event['_savemode'] == 'future'; | $event['thisandfuture'] = $event['_savemode'] == 'future'; | ||||
$bodytextprefix = $resourceConfirmation ? 'itipmailbodyresource' : 'itipmailbody'; | |||||
if ($organizer && $itip->send_itip_message($event, 'REPLY', $organizer, 'itipsubject' . $status, 'itipmailbody' . $status)) { | if ($organizer && $itip->send_itip_message($event, 'REPLY', $organizer, 'itipsubject' . $status, $bodytextprefix . $status)) { | ||||
Done Inline ActionsThe only difference is the body label argument, so instead of adding a whole if block I would just change the argument depending on the $resourceConfirmation state. machniak: The only difference is the body label argument, so instead of adding a whole `if` block I would… | |||||
$mailto = !empty($organizer['name']) ? $organizer['name'] : $organizer['email']; | $mailto = !empty($organizer['name']) ? $organizer['name'] : $organizer['email']; | ||||
$msg = $this->gettext(['name' => 'sentresponseto', 'vars' => ['mailto' => $mailto]]); | $msg = $this->gettext(['name' => 'sentresponseto', 'vars' => ['mailto' => $mailto]]); | ||||
$this->rc->output->command('display_message', $msg, 'confirmation'); | $this->rc->output->command('display_message', $msg, 'confirmation'); | ||||
} | } | ||||
else { | else { | ||||
$this->rc->output->command('display_message', $this->gettext('itipresponseerror'), 'error'); | $this->rc->output->command('display_message', $this->gettext('itipresponseerror'), 'error'); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 734 Lines • ▼ Show 20 Lines | function load_settings() | ||||
$identity = $rec; | $identity = $rec; | ||||
} | } | ||||
$identity['emails'][] = $rec['email']; | $identity['emails'][] = $rec['email']; | ||||
$settings['identities'][$rec['identity_id']] = $rec['email']; | $settings['identities'][$rec['identity_id']] = $rec['email']; | ||||
} | } | ||||
$identity['emails'][] = $this->rc->user->get_username(); | $identity['emails'][] = $this->rc->user->get_username(); | ||||
$identity['ownedResources'] = $this->owned_resources_emails(); | |||||
$settings['identity'] = [ | $settings['identity'] = [ | ||||
Done Inline ActionsThe foreach is redundant. machniak: The foreach is redundant. | |||||
'name' => $identity['name'], | 'name' => $identity['name'], | ||||
'email' => strtolower($identity['email']), | 'email' => strtolower($identity['email']), | ||||
'emails' => ';' . strtolower(join(';', $identity['emails'])) | 'emails' => ';' . strtolower(join(';', $identity['emails'])), | ||||
'ownedResources' => ';' . strtolower(join(';', $identity['ownedResources'])) | |||||
]; | ]; | ||||
} | } | ||||
// freebusy token authentication URL | // freebusy token authentication URL | ||||
if (($url = $this->rc->config->get('calendar_freebusy_session_auth_url')) | if (($url = $this->rc->config->get('calendar_freebusy_session_auth_url')) | ||||
&& ($uniqueid = $this->rc->config->get('kolab_uniqueid')) | && ($uniqueid = $this->rc->config->get('kolab_uniqueid')) | ||||
) { | ) { | ||||
if ($url === true) { | if ($url === true) { | ||||
▲ Show 20 Lines • Show All 842 Lines • ▼ Show 20 Lines | function resources_calendar() | ||||
$events = $directory->get_resource_calendar($id, $start, $end); | $events = $directory->get_resource_calendar($id, $start, $end); | ||||
} | } | ||||
echo $this->encode($events); | echo $this->encode($events); | ||||
exit; | exit; | ||||
} | } | ||||
/** | |||||
* List email addressed of owned resources | |||||
*/ | |||||
private function owned_resources_emails() | |||||
{ | |||||
$results = []; | |||||
if ($directory = $this->resources_directory()) { | |||||
foreach ($directory->load_resources($_SESSION['kolab_dn'], 5000, 'owner') as $rec) { | |||||
$results[] = $rec['email']; | |||||
} | |||||
} | |||||
Done Inline ActionsThis if condition is not good enough for this purpose. And it assumes that the owner DN contains email address, I'm not sure this is always true with old Kolab. machniak: This if condition is not good enough for this purpose. And it assumes that the owner DN… | |||||
return $results; | |||||
} | |||||
/**** Event invitation plugin hooks ****/ | /**** Event invitation plugin hooks ****/ | ||||
/** | /** | ||||
* Find an event in user calendars | * Find an event in user calendars | ||||
*/ | */ | ||||
protected function find_event($event, &$mode) | protected function find_event($event, &$mode) | ||||
{ | { | ||||
$this->load_driver(); | $this->load_driver(); | ||||
▲ Show 20 Lines • Show All 1,099 Lines • Show Last 20 Lines |
You need to add !empty($attendee['cutype']) to prevent from a warning in newer PHP versions. Also, Roundcube has in_array_nocase() function which we should just use here.