summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-01-27 17:47:37 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-01-27 17:47:37 (GMT)
commit054b3902b2c6cb6a236b9d339c73f845eddf5341 (patch)
treec5e9134b0cfa3a16b2294cf3b14a91ad23629712
parent8f7e7408d41d2fde2d4f1f902553777b4b98c9d8 (diff)
downloadroundcubemail-plugins-kolab-054b3902b2c6cb6a236b9d339c73f845eddf5341.tar.gz
Save event in user's calendar when accepting it via web link (#560)
-rw-r--r--plugins/calendar/calendar.php39
-rw-r--r--plugins/calendar/calendar_ui.js2
-rw-r--r--plugins/calendar/skins/larry/calendar.css10
-rw-r--r--plugins/calendar/skins/larry/templates/itipattend.html4
4 files changed, 42 insertions, 13 deletions
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 57da403..b7b4280 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -238,6 +238,26 @@ class calendar extends rcube_plugin
return $this->ical;
}
+ /**
+ *
+ */
+ public function get_default_calendar($writeable = false)
+ {
+ $cal_id = $this->rc->config->get('calendar_default_calendar');
+ $calendars = $this->driver->list_calendars();
+ $calendar = $calendars[$cal_id] ? $calendars[$cal_id] : null;
+ if (!$calendar || ($writeable && $calendar['readonly'])) {
+ foreach ($calendars as $cal) {
+ if (!$writeable || !$cal['readonly']) {
+ $calendar = $cal;
+ break;
+ }
+ }
+ }
+
+ return $calendar;
+ }
+
/**
* Render the main calendar view from skin template
@@ -1944,13 +1964,26 @@ class calendar extends rcube_plugin
break;
}
}
-
+
// send itip reply to organizer
if ($status && $itip->update_invitation($invitation, $invitation['attendee'], strtoupper($status))) {
$this->invitestatus = html::div('rsvp-status ' . strtolower($status), $this->gettext('youhave'.strtolower($status)));
}
else
$this->rc->output->command('display_message', $this->gettext('errorsaving'), 'error', -1);
+
+ // if user is logged in...
+ if ($this->rc->user->ID) {
+ $this->load_driver();
+ $invitation = $itip->get_invitation($token);
+
+ // save the event to his/her default calendar if not yet present
+ if (!$this->driver->get_event($this->event) && ($calendar = $this->get_default_calendar())) {
+ $invitation['event']['calendar'] = $calendar['id'];
+ if ($this->driver->new_event($invitation['event']))
+ $this->rc->output->command('display_message', $this->gettext(array('name' => 'importedsuccessfully', 'vars' => array('calendar' => $calendar['name']))), 'confirmation');
+ }
+ }
}
$this->register_handler('plugin.event_inviteform', array($this, 'itip_event_inviteform'));
@@ -1971,10 +2004,10 @@ class calendar extends rcube_plugin
/**
*
*/
- public function itip_event_inviteform($p)
+ public function itip_event_inviteform($attrib)
{
$hidden = new html_hiddenfield(array('name' => "_t", 'value' => $this->token));
- return html::tag('form', array('action' => $this->rc->url(array('task' => 'calendar', 'action' => 'attend')), 'method' => 'post', 'noclose' => true)) . $hidden->show();
+ return html::tag('form', array('action' => $this->rc->url(array('task' => 'calendar', 'action' => 'attend')), 'method' => 'post', 'noclose' => true) + $attrib) . $hidden->show();
}
/**
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index 2e50d43..3b0c5c8 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -2208,7 +2208,7 @@ function rcube_calendar_ui(settings)
var id = $(this).data('id');
rcmail.select_folder(id, 'rcmlical');
rcmail.enable_command('calendar-edit', true);
- rcmail.enable_command('calendar-remove', 'events-import', 'calendar-showurl', !me.calendars[id].readonly);
+ rcmail.enable_command('calendar-remove', 'events-import', 'calendar-showurl', true);
me.selected_calendar = id;
})
.dblclick(function(){ me.calendar_edit_dialog(me.calendars[me.selected_calendar]); })
diff --git a/plugins/calendar/skins/larry/calendar.css b/plugins/calendar/skins/larry/calendar.css
index cd39b3d..df11467 100644
--- a/plugins/calendar/skins/larry/calendar.css
+++ b/plugins/calendar/skins/larry/calendar.css
@@ -534,8 +534,8 @@ td.topalign {
#edit-attendees-notify {
margin: 0.3em 0;
padding: 0.5em;
- background-color: #F7FDCB;
- border: 1px solid #C2D071;
+ border: 1px solid #ffdf0e;
+ background-color: #fef893;
}
#edit-attendees-table {
@@ -1192,11 +1192,7 @@ div.calendar-invitebox .rsvp-status.tentative {
width: 40em;
margin: 80px auto;
padding: 10px 10px 10px 90px;
- border: 1px solid #ccc;
- box-shadow: 1px 1px 24px #ccc;
- -moz-box-shadow: 1px 1px 18px #ccc;
- -webkit-box-shadow: #ccc 1px 1px 18px;
- background: url(images/invitation.png) 10px 10px no-repeat #fbfbfb;
+ background: url(images/invitation.png) 10px 10px no-repeat #fff;
}
.calendaritipattend .calendar-invitebox {
diff --git a/plugins/calendar/skins/larry/templates/itipattend.html b/plugins/calendar/skins/larry/templates/itipattend.html
index e1c7cc7..bfbb08f 100644
--- a/plugins/calendar/skins/larry/templates/itipattend.html
+++ b/plugins/calendar/skins/larry/templates/itipattend.html
@@ -22,14 +22,14 @@
<div id="mainscreen">
-<div class="centerbox">
+<div class="centerbox uibox">
<roundcube:object name="plugin.event_inviteform" />
<roundcube:object name="plugin.event_invitebox" class="calendar-invitebox" />
<roundcube:object name="plugin.event_rsvp_buttons" type="submit" iname="rsvp" id="event-rsvp" />
+ <roundcube:object name="message" id="message" />
</form>
</div>
-<roundcube:object name="message" id="message" />
</div>
</body>