2 commits - plugins/calendar plugins/libcalendaring

Aleksander Machniak machniak at kolabsys.com
Mon Jul 7 11:05:12 CEST 2014


 plugins/calendar/calendar.php                      |   12 +++++++++---
 plugins/calendar/calendar_ui.js                    |    2 ++
 plugins/calendar/lib/calendar_ui.php               |   11 +++++++----
 plugins/calendar/localization/en_US.inc            |    1 +
 plugins/calendar/skins/larry/calendar.css          |    6 ++++++
 plugins/libcalendaring/lib/libcalendaring_itip.php |    7 +++----
 6 files changed, 28 insertions(+), 11 deletions(-)

New commits:
commit f715264956be4a54a78ad2c497848e29fa03521b
Merge: 3ffa80a 7f7a2ab
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Mon Jul 7 11:05:02 2014 +0200

    Merge branch 'master' of ssh://git.kolabsys.com/git/roundcube



commit 3ffa80a3a7413d44fa9303278a92b82447c8e00f
Author: Aleksander Machniak <machniak at kolabsys.com>
Date:   Mon Jul 7 11:04:00 2014 +0200

    Allow a custom invitation text to be sent to attendees (#1788)
    - Send the text in iTip COMMENT field only

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 0313bb1..a370c22 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -930,7 +930,7 @@ class calendar extends rcube_plugin
 
       // only notify if data really changed (TODO: do diff check on client already)
       if (!$old || $action == 'remove' || self::event_diff($event, $old)) {
-        $sent = $this->notify_attendees($event, $old, $action);
+        $sent = $this->notify_attendees($event, $old, $action, $event['_comment']);
         if ($sent > 0)
           $this->rc->output->show_message('calendar.itipsendsuccess', 'confirmation');
         else if ($sent < 0)
@@ -1599,7 +1599,7 @@ class calendar extends rcube_plugin
   /**
    * Send out an invitation/notification to all event attendees
    */
-  private function notify_attendees($event, $old, $action = 'edit')
+  private function notify_attendees($event, $old, $action = 'edit', $comment = null)
   {
     if ($action == 'remove' || ($event['status'] == 'CANCELLED' && $old['status'] != $event['status'])) {
       $event['cancelled'] = true;
@@ -1609,6 +1609,9 @@ class calendar extends rcube_plugin
     $itip = $this->load_itip();
     $emails = $this->get_user_emails();
 
+    // add comment to the iTip attachment
+    $event['comment'] = $comment;
+
     // compose multipart message using PEAR:Mail_Mime
     $method = $action == 'remove' ? 'CANCEL' : 'REQUEST';
     $message = $itip->compose_itip_message($event, $method);
@@ -1632,7 +1635,9 @@ class calendar extends rcube_plugin
       $is_new = !in_array($attendee['email'], $old_attendees);
       $bodytext = $is_cancelled ? 'eventcancelmailbody' : ($is_new ? 'invitationmailbody' : 'eventupdatemailbody');
       $subject  = $is_cancelled ? 'eventcancelsubject'  : ($is_new ? 'invitationsubject' : ($event['title'] ? 'eventupdatesubject':'eventupdatesubjectempty'));
-      
+
+      $event['comment'] = $comment;
+
       // finally send the message
       if ($itip->send_itip_message($event, $method, $attendee, $subject, $bodytext, $message))
         $sent++;
@@ -1648,6 +1653,7 @@ class calendar extends rcube_plugin
       $vevent = $old;
       $vevent['cancelled'] = $is_cancelled;
       $vevent['attendees'] = array($attendee);
+      $vevent['comment']   = $comment;
       if ($itip->send_itip_message($vevent, 'CANCEL', $attendee, 'eventcancelsubject', 'eventcancelmailbody'))
         $sent++;
       else
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index d10e899..bc95b3e 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -615,6 +615,7 @@ function rcube_calendar_ui(settings)
       var allday = $('#edit-allday').get(0);
       var notify = $('#edit-attendees-donotify').get(0);
       var invite = $('#edit-attendees-invite').get(0);
+      var comment = $('#edit-attendees-comment');
       notify.checked = has_attendees(event), invite.checked = true;
       
       if (event.allDay) {
@@ -750,6 +751,7 @@ function rcube_calendar_ui(settings)
         // tell server to send notifications
         if ((data.attendees.length || (event.id && event.attendees.length)) && allow_invitations && (notify.checked || invite.checked)) {
           data._notify = 1;
+          data._comment = comment.val();
         }
 
         data.calendar = calendars.val();
diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php
index 8da5e38..9e6835e 100644
--- a/plugins/calendar/lib/calendar_ui.php
+++ b/plugins/calendar/lib/calendar_ui.php
@@ -708,15 +708,18 @@ class calendar_ui
    */
   function attendees_form($attrib = array())
   {
-    $input = new html_inputfield(array('name' => 'participant', 'id' => 'edit-attendee-name', 'size' => 30));
+    $input    = new html_inputfield(array('name' => 'participant', 'id' => 'edit-attendee-name', 'size' => 30));
     $checkbox = new html_checkbox(array('name' => 'invite', 'id' => 'edit-attendees-invite', 'value' => 1));
-    
+    $textarea = new html_textarea(array('name' => 'comment', 'id' => 'edit-attendees-comment',
+        'rows' => 4, 'cols' => 55, 'title' => $this->cal->gettext('itipcommenttitle')));
+
     return html::div($attrib,
       html::div(null, $input->show() . " " .
         html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-add', 'value' => $this->cal->gettext('addattendee'))) . " " .
         html::tag('input', array('type' => 'button', 'class' => 'button', 'id' => 'edit-attendee-schedule', 'value' => $this->cal->gettext('scheduletime').'...'))) .
-      html::p('attendees-invitebox', html::label(null, $checkbox->show(1) . $this->cal->gettext('sendinvitations')))
-      );
+      html::p('attendees-invitebox', html::label(null, $checkbox->show(1) . $this->cal->gettext('sendinvitations'))) .
+      html::p('attendees-commentbox', html::label(null, $this->cal->gettext('comment') . $textarea->show()))
+    );
   }
 
   /**
diff --git a/plugins/calendar/localization/en_US.inc b/plugins/calendar/localization/en_US.inc
index 87a3e65..52da746 100644
--- a/plugins/calendar/localization/en_US.inc
+++ b/plugins/calendar/localization/en_US.inc
@@ -168,6 +168,7 @@ $labels['itipmailbodycancel'] = "\$sender has rejected your participation in the
 
 $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['itipcommenttitle'] = 'This comment will be attached to the invitation/notification message send to participants';
 
 $labels['notanattendee'] = 'You\'re not listed as an attendee of this event';
 $labels['eventcancelled'] = 'The event has been cancelled';
diff --git a/plugins/calendar/skins/larry/calendar.css b/plugins/calendar/skins/larry/calendar.css
index 5c7dd53..c79e334 100644
--- a/plugins/calendar/skins/larry/calendar.css
+++ b/plugins/calendar/skins/larry/calendar.css
@@ -1106,6 +1106,12 @@ td.topalign {
 	text-align: center;
 }
 
+#eventedit .attendees-commentbox textarea {
+	width: auto;
+	margin-left: 10px;
+	vertical-align: middle;
+}
+
 a.dropdown-link {
 	font-size: 12px;
 	text-decoration: none;
diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php
index b03900d..ec4eb1a 100644
--- a/plugins/libcalendaring/lib/libcalendaring_itip.php
+++ b/plugins/libcalendaring/lib/libcalendaring_itip.php
@@ -118,10 +118,9 @@ class libcalendaring_itip
             )
         ));
 
-        // append sender's comment
-        if (!empty($event['comment'])) {
-            $mailbody .= "\n\n" . $this->gettext('itipsendercomment') . $event['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']))) {




More information about the commits mailing list