Add option for the user to enter a comment text for iTip REPLY messages

This commit is contained in:
Thomas Bruederli 2014-03-20 18:06:35 +01:00
parent 65cd18c1b7
commit 6fbd652bac
6 changed files with 47 additions and 7 deletions

View file

@ -2403,6 +2403,7 @@ class calendar extends rcube_plugin
// send iTip reply
if ($this->ical->method == 'REQUEST' && $organizer && !in_array(strtolower($organizer['email']), $emails) && !$error_msg) {
$event['comment'] = get_input_value('_comment', RCUBE_INPUT_POST);
$itip = $this->load_itip();
$itip->set_sender_email($reply_sender);
if ($itip->send_itip_message($event, 'REPLY', $organizer, 'itipsubject' . $status, 'itipmailbody' . $status))

View file

@ -149,7 +149,7 @@ $labels['itipobjectnotfound'] = 'The event referred by this message was not foun
$labels['itipmailbodyaccepted'] = "\$sender has accepted the invitation to the following event:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
$labels['itipmailbodytentative'] = "\$sender has tentatively accepted the invitation to the following event:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
$labels['itipmailbodydeclined'] = "\$sender has declined the invitation to the following event:\n\n*\$title*\n\nWhen: \$date\n\nInvitees: \$attendees";
$labels['itipmailbodycancel'] = "\$sender has rejected your participation in the following event:\n\n*\$title*\n\nWhen: \$date\n\n\$comment";
$labels['itipmailbodycancel'] = "\$sender has rejected your participation in the following event:\n\n*\$title*\n\nWhen: \$date";
$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?';

View file

@ -115,10 +115,14 @@ class libcalendaring_itip
'attendees' => join(', ', $attendees_list),
'sender' => $this->sender['name'],
'organizer' => $this->sender['name'],
'comment' => $event['comment'],
)
));
// append sender's comment
if (!empty($event['comment'])) {
$mailbody .= "\n\n" . $this->gettext('itipsendercomment') . $event['comment'];
}
// append links for direct invitation replies
if ($method == 'REQUEST' && ($token = $this->store_invitation($event, $recipient['email']))) {
$mailbody .= "\n\n" . $this->gettext(array(
@ -398,7 +402,7 @@ class libcalendaring_itip
$rsvp_buttons .= html::tag('input', array(
'type' => 'button',
'class' => "button $method",
'onclick' => "rcube_libcalendaring.add_from_itip_mail('" . JQ($mime_id) . "', '$task', '$method')",
'onclick' => "rcube_libcalendaring.add_from_itip_mail('" . JQ($mime_id) . "', '$task', '$method', '$dom_id')",
'value' => $this->gettext('itip' . $method),
));
}
@ -421,6 +425,12 @@ class libcalendaring_itip
}
}
// add input field for reply comment
$rsvp_buttons .= html::a(array('href' => '#toggle', 'class' => 'reply-comment-toggle'), $this->gettext('itipeditresponse'));
$rsvp_buttons .= html::div('itip-reply-comment',
html::tag('textarea', array('id' => 'reply-comment-'.$dom_id, 'cols' => 40, 'rows' => 6, 'style' => 'display:none', 'placeholder' => $this->gettext('itipcomment')), '')
);
$buttons[] = html::div(array('id' => 'rsvp-'.$dom_id, 'class' => 'rsvp-buttons', 'style' => 'display:none'), $rsvp_buttons);
}
// for CANCEL messages, we can:

View file

@ -440,7 +440,7 @@ function rcube_libcalendaring(settings)
/**
*
*/
rcube_libcalendaring.add_from_itip_mail = function(mime_id, task, status)
rcube_libcalendaring.add_from_itip_mail = function(mime_id, task, status, dom_id)
{
// ask user to delete the declined event from the local calendar (#1670)
var del = false;
@ -448,13 +448,19 @@ rcube_libcalendaring.add_from_itip_mail = function(mime_id, task, status)
del = confirm(rcmail.gettext('itip.declinedeleteconfirm'));
}
var comment = '';
if (dom_id) {
comment = $('#reply-comment-'+dom_id).val();
}
rcmail.http_post(task + '/mailimportitip', {
_uid: rcmail.env.uid,
_mbox: rcmail.env.mailbox,
_part: mime_id,
_folder: $('#itip-saveto').val(),
_status: status,
_del: del?1:0
_del: del?1:0,
_comment: comment
}, rcmail.set_busy(true, 'itip.savingdata'));
return false;
@ -544,9 +550,9 @@ rcube_libcalendaring.update_itip_object_status = function(p)
$('#rsvp-'+p.id+' input.button').prop('disabled', false)
.filter('.'+String(p.status||'unknown').toLowerCase()).prop('disabled', p.latest);
}
// show rsvp/import buttons (with calendar selector)
$('#'+p.action+'-'+p.id).show().append(p.select);
$('#'+p.action+'-'+p.id).show().find('input.button').last().after(p.select);
};
@ -571,4 +577,8 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
rcmail.addEventListener('plugin.update_itip_object_status', rcube_libcalendaring.update_itip_object_status);
rcmail.addEventListener('plugin.fetch_itip_object_status', rcube_libcalendaring.fetch_itip_object_status);
$('.rsvp-buttons').on('click', 'a.reply-comment-toggle', function(e){
$(this).hide().parent().find('textarea').show().focus();
});
});

View file

@ -36,6 +36,9 @@ $labels['itipreply'] = 'Reply to';
$labels['itipaccepted'] = 'Accept';
$labels['itiptentative'] = 'Maybe';
$labels['itipdeclined'] = 'Decline';
$labels['itipcomment'] = 'Your response';
$labels['itipeditresponse'] = 'Enter a response text';
$labeöls['itipsendercomment'] = 'Sender\'s comment: ';
$labels['itipobjectnotfound'] = 'The object referred by this message was not found in your account.';
$labels['itipsubjectaccepted'] = '"$title" has been accepted by $name';

View file

@ -53,6 +53,22 @@ span.edit-alarm-set {
height: 16px;
}
.itip-reply-comment {
padding-left: 2px;
}
a.reply-comment-toggle {
display: inline-block;
margin-left: 1em;
color: #333;
}
.itip-reply-comment textarea {
display: block;
width: 90%;
margin-top: 0.5em;
}
.itip-dialog-confirm-text {
margin-bottom: 1em;
}