This commit is contained in:
parent
c1f5524cec
commit
ca2409e081
4 changed files with 48 additions and 8 deletions
31
calendar.php
31
calendar.php
|
@ -1251,23 +1251,31 @@ $("#rcmfd_new_category").keypress(function(event) {
|
||||||
$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)) {
|
||||||
|
$resourceConfirmation = true;
|
||||||
|
// Note on behalf of which resource this update is going to be sent out
|
||||||
|
$event['_resource'] = $attendee['email'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)) {
|
||||||
$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]]);
|
||||||
|
|
||||||
|
@ -2018,10 +2026,12 @@ $("#rcmfd_new_category").keypress(function(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$identity['emails'][] = $this->rc->user->get_username();
|
$identity['emails'][] = $this->rc->user->get_username();
|
||||||
|
$identity['ownedResources'] = $this->owned_resources_emails();
|
||||||
$settings['identity'] = [
|
$settings['identity'] = [
|
||||||
'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']))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2879,6 +2889,21 @@ $("#rcmfd_new_category").keypress(function(event) {
|
||||||
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'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**** Event invitation plugin hooks ****/
|
/**** Event invitation plugin hooks ****/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -459,7 +459,7 @@ function rcube_calendar_ui(settings)
|
||||||
for (var j=0; j < num_attendees; j++) {
|
for (var j=0; j < num_attendees; j++) {
|
||||||
data = event.attendees[j];
|
data = event.attendees[j];
|
||||||
if (data.email) {
|
if (data.email) {
|
||||||
if (data.role != 'ORGANIZER' && settings.identity.emails.indexOf(';'+data.email) >= 0) {
|
if (data.role != 'ORGANIZER' && is_this_me(data.email)) {
|
||||||
mystatus = (data.status || 'UNKNOWN').toLowerCase();
|
mystatus = (data.status || 'UNKNOWN').toLowerCase();
|
||||||
if (data.status == 'NEEDS-ACTION' || data.status == 'TENTATIVE' || data.rsvp)
|
if (data.status == 'NEEDS-ACTION' || data.status == 'TENTATIVE' || data.rsvp)
|
||||||
rsvp = mystatus;
|
rsvp = mystatus;
|
||||||
|
@ -2379,6 +2379,14 @@ function rcube_calendar_ui(settings)
|
||||||
add_attendee($.extend({ role:'REQ-PARTICIPANT', status:'NEEDS-ACTION', cutype:'RESOURCE' }, resource));
|
add_attendee($.extend({ role:'REQ-PARTICIPANT', status:'NEEDS-ACTION', cutype:'RESOURCE' }, resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var is_this_me = function(email)
|
||||||
|
{
|
||||||
|
if (settings.identity.emails.indexOf(';'+email) >= 0 || settings.identity.ownedResources.indexOf(';'+email) >= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
// when the user accepts or declines an event invitation
|
// when the user accepts or declines an event invitation
|
||||||
var event_rsvp = function(response, delegate, replymode, event)
|
var event_rsvp = function(response, delegate, replymode, event)
|
||||||
{
|
{
|
||||||
|
@ -2414,6 +2422,8 @@ function rcube_calendar_ui(settings)
|
||||||
for (var data, i=0; i < me.selected_event.attendees.length; i++) {
|
for (var data, i=0; i < me.selected_event.attendees.length; i++) {
|
||||||
data = me.selected_event.attendees[i];
|
data = me.selected_event.attendees[i];
|
||||||
if (settings.identity.emails.indexOf(';'+String(data.email).toLowerCase()) >= 0) {
|
if (settings.identity.emails.indexOf(';'+String(data.email).toLowerCase()) >= 0) {
|
||||||
|
//FIXME this can only work if there is a single resource per invitation
|
||||||
|
if (is_this_me(String(data.email).toLowerCase())) {
|
||||||
data.status = response.toUpperCase();
|
data.status = response.toUpperCase();
|
||||||
data.rsvp = 0; // unset RSVP flag
|
data.rsvp = 0; // unset RSVP flag
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,11 @@ class resources_driver_ldap extends resources_driver
|
||||||
*
|
*
|
||||||
* @param string $query Search query (optional)
|
* @param string $query Search query (optional)
|
||||||
* @param int $num Max size of the result
|
* @param int $num Max size of the result
|
||||||
|
* @param string $searchField Field to search with query
|
||||||
*
|
*
|
||||||
* @return array List of resource records available for booking
|
* @return array List of resource records available for booking
|
||||||
*/
|
*/
|
||||||
public function load_resources($query = null, $num = 5000)
|
public function load_resources($query = null, $num = 5000, $searchField = '*')
|
||||||
{
|
{
|
||||||
if (!($ldap = $this->connect())) {
|
if (!($ldap = $this->connect())) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -56,7 +57,7 @@ class resources_driver_ldap extends resources_driver
|
||||||
$ldap->set_pagesize($num);
|
$ldap->set_pagesize($num);
|
||||||
|
|
||||||
if (isset($query)) {
|
if (isset($query)) {
|
||||||
$results = $ldap->search('*', $query, 0, true, true);
|
$results = $ldap->search($searchField, $query, 0, true, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$results = $ldap->list_records();
|
$results = $ldap->list_records();
|
||||||
|
|
|
@ -213,6 +213,10 @@ $labels['itipmailbodycancel'] = "\$sender has rejected your participation in the
|
||||||
$labels['itipmailbodydelegated'] = "\$sender has delegated the participation in the following event:\n\n*\$title*\n\nWhen: \$date";
|
$labels['itipmailbodydelegated'] = "\$sender has delegated the participation in the following event:\n\n*\$title*\n\nWhen: \$date";
|
||||||
$labels['itipmailbodydelegatedto'] = "\$sender has delegated the participation in the following event to you:\n\n*\$title*\n\nWhen: \$date";
|
$labels['itipmailbodydelegatedto'] = "\$sender has delegated the participation in the following event to you:\n\n*\$title*\n\nWhen: \$date";
|
||||||
|
|
||||||
|
$labels['itipmailbodyresourceaccepted'] = "\$sender has accepted the following resource booking:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
|
||||||
|
$labels['itipmailbodyresourcetentative'] = "\$sender has tentatively accepted the following resource booking:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
|
||||||
|
$labels['itipmailbodyresourcedeclined'] = "\$sender has declined the the following resource booking:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
|
||||||
|
|
||||||
$labels['itipdeclineevent'] = 'Do you want to decline your invitation to this event?';
|
$labels['itipdeclineevent'] = 'Do you want to decline your invitation to this event?';
|
||||||
$labels['declinedeleteconfirm'] = 'Do you also want to delete this declined event from your calendar?';
|
$labels['declinedeleteconfirm'] = 'Do you also want to delete this declined event from your calendar?';
|
||||||
$labels['itipcomment'] = 'Invitation/notification comment';
|
$labels['itipcomment'] = 'Invitation/notification comment';
|
||||||
|
|
Loading…
Reference in a new issue