Save event in user's calendar when accepting it via web link (#560)
This commit is contained in:
parent
8f7e7408d4
commit
054b3902b2
4 changed files with 42 additions and 13 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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]); })
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue