Pre-select confidential event/tasks folder for iTip invitations marked as confidential (#3451)

+ display privacy classification of iTip attachments in mail invitation view.
This commit is contained in:
Thomas Bruederli 2014-09-23 12:27:57 +02:00
parent f0b205cb2e
commit b278db0ec3
10 changed files with 54 additions and 16 deletions

View file

@ -259,17 +259,22 @@ class calendar extends rcube_plugin
/**
* Get properties of the calendar this user has specified as default
*/
public function get_default_calendar($writeable = false)
public function get_default_calendar($writeable = false, $confidential = false)
{
$default_id = $this->rc->config->get('calendar_default_calendar');
$calendars = $this->driver->list_calendars(false, true);
$calendar = $calendars[$default_id] ?: null;
if (!$calendar || ($writeable && $calendar['readonly'])) {
if (!$calendar || $confidential || ($writeable && $calendar['readonly'])) {
foreach ($calendars as $cal) {
if ($cal['default']) {
if ($confidential && $cal['subtype'] == 'confidential') {
$calendar = $cal;
break;
}
if ($cal['default']) {
$calendar = $cal;
if (!$confidential)
break;
}
if (!$writeable || !$cal['readonly']) {
$first = $cal;
}
@ -2229,9 +2234,9 @@ class calendar extends rcube_plugin
}
if ($calendar_select) {
$default_calendar = $this->get_default_calendar(true);
$default_calendar = $this->get_default_calendar(true, $data['sensitivity'] == 'confidential');
$response['select'] = html::span('folder-select', $this->gettext('saveincalendar') . ' ' .
$calendar_select->show($this->rc->config->get('calendar_default_calendar', $default_calendar['id'])));
$calendar_select->show($default_calendar['id']));
}
else if ($data['nosave']) {
$response['select'] = html::tag('input', array('type' => 'hidden', 'name' => 'calendar', 'id' => 'itip-saveto', 'value' => ''));
@ -2338,7 +2343,7 @@ class calendar extends rcube_plugin
$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(true))) {
if (!$this->driver->get_event($this->event) && ($calendar = $this->get_default_calendar(true, $invitation['event']['sensitivity'] == 'confidential'))) {
$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');
@ -2517,7 +2522,7 @@ class calendar extends rcube_plugin
// select default calendar except user explicitly selected 'none'
if (!$calendar && !$dontsave)
$calendar = $this->get_default_calendar(true);
$calendar = $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
$metadata = array(
'uid' => $event['uid'],
@ -2749,10 +2754,10 @@ class calendar extends rcube_plugin
// find writeable calendar to store event
$cal_id = !empty($_REQUEST['_calendar']) ? get_input_value('_calendar', RCUBE_INPUT_POST) : null;
$calendars = $this->driver->list_calendars(false, true);
$calendar = $calendars[$cal_id] ?: $this->get_default_calendar(true);
foreach ($events as $event) {
// save to calendar
$calendar = $calendars[$cal_id] ?: $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
if ($calendar && !$calendar['readonly'] && $event['_type'] == 'event') {
$event['calendar'] = $calendar['id'];

View file

@ -101,6 +101,7 @@ class kolab_calendar extends kolab_storage_folder_api
}
$this->default = $this->storage->default;
$this->subtype = $this->storage->subtype;
}

View file

@ -209,6 +209,7 @@ class kolab_driver extends calendar_driver
'owner' => $cal->get_owner(),
'children' => true, // TODO: determine if that folder indeed has child folders
'parent' => $parent_id,
'subtype' => $cal->subtype,
'caldavurl' => $cal->get_caldav_url(),
'removable' => !$cal->default,
);

View file

@ -2061,11 +2061,20 @@ div.calendar-invitebox td.ititle {
padding-right: 0.5em;
}
div.calendar-invitebox td {
padding: 2px;
}
div.calendar-invitebox td.label {
color: #666;
padding-right: 1em;
}
div.calendar-invitebox td.sensitivity {
color: #d31400;
font-weight: bold;
}
#event-rsvp .rsvp-buttons,
div.calendar-invitebox .itip-buttons div {
margin-top: 0.5em;

View file

@ -434,6 +434,8 @@ class libcalendaring_itip
$emails = $this->lib->get_user_emails();
$title = $event['sequence'] > 0 ? $this->gettext('itipupdate') : $this->gettext('itipinvitation');
$metadata['rsvp'] = true;
$metadata['sensitivity'] = $event['sensitivity'];
if (is_object($event['start'])) {
$metadata['date'] = $event['start']->format('U');
}
@ -621,6 +623,10 @@ class libcalendaring_itip
$table->add('label', $this->plugin->gettext('location'), $this->domain);
$table->add('location', Q($event['location']));
}
if ($event['sensitivity'] && $event['sensitivity'] != 'public') {
$table->add('label', $this->plugin->gettext('sensitivity'), $this->domain);
$table->add('sensitivity', ucfirst($this->plugin->gettext($event['sensitivity'])) . '!');
}
if ($event['comment']) {
$table->add('label', $this->plugin->gettext('comment'), $this->domain);
$table->add('location', Q($event['comment']));

View file

@ -58,6 +58,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
$oldtype = $this->type;
list($this->type, $suffix) = explode('.', $this->type_annotation);
$this->default = $suffix == 'default';
$this->subtype = $this->default ? '' : $suffix;
$this->name = $name;
$this->id = kolab_storage::folder_id($name);

View file

@ -40,6 +40,12 @@ abstract class kolab_storage_folder_api
*/
public $type;
/**
* The subtype of this folder.
* @var string
*/
public $subtype;
/**
* Is this folder set to be the default for its type
* @var boolean

View file

@ -144,6 +144,7 @@ class tasklist_kolab_driver extends tasklist_driver
'children' => true, // TODO: determine if that folder indeed has child folders
'subscribed' => (bool)$folder->is_subscribed(),
'removable' => !$folder->default,
'subtype' => $folder->subtype,
'group' => $folder->default ? 'default' : $folder->get_namespace(),
'class' => trim($folder->get_namespace() . ($folder->default ? ' default' : '')),
);

View file

@ -1186,6 +1186,10 @@ div.tasklist-invitebox {
background: url(images/tasklist.png) 6px 5px no-repeat #fef893;
}
div.tasklist-invitebox td {
padding: 2px;
}
div.tasklist-invitebox td.ititle {
font-weight: bold;
padding-right: 0.5em;

View file

@ -1459,18 +1459,22 @@ class tasklist extends rcube_plugin
/**
* Get properties of the tasklist this user has specified as default
*/
public function get_default_tasklist($writeable = false)
public function get_default_tasklist($writeable = false, $confidential = false)
{
// $default_id = $this->rc->config->get('tasklist_default_list');
$lists = $this->driver->get_lists();
// $list = $calendars[$default_id] ?: null;
$list = null;
if (!$list || ($writeable && !$list['editable'])) {
foreach ($lists as $l) {
if ($l['default']) {
if ($confidential && $l['subtype'] == 'confidential') {
$list = $l;
break;
}
if ($l['default']) {
$list = $l;
if (!$confidential)
break;
}
if (!$writeable || $l['editable']) {
$first = $l;
@ -1514,10 +1518,10 @@ class tasklist extends rcube_plugin
// find writeable tasklist to store task
$cal_id = !empty($_REQUEST['_list']) ? rcube_utils::get_input_value('_list', rcube_utils::INPUT_POST) : null;
$lists = $this->driver->get_lists();
$list = $lists[$cal_id] ?: $this->get_default_tasklist(true);
foreach ($tasks as $task) {
// save to tasklist
$list = $lists[$cal_id] ?: $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
if ($list && $list['editable'] && $task['_type'] == 'task') {
$task = $this->from_ical($task);
$task['list'] = $list['id'];
@ -1568,7 +1572,7 @@ class tasklist extends rcube_plugin
// find writeable list to store the task
$list_id = !empty($_REQUEST['_folder']) ? rcube_utils::get_input_value('_folder', rcube_utils::INPUT_POST) : null;
$lists = $this->driver->get_lists();
$list = $lists[$list_id] ?: $this->get_default_tasklist(true);
$list = $lists[$list_id] ?: $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
$metadata = array(
'uid' => $task['uid'],
@ -1780,9 +1784,9 @@ class tasklist extends rcube_plugin
}
if ($select) {
$default_list = $this->get_default_tasklist(true);
$default_list = $this->get_default_tasklist(true, $data['sensitivity'] == 'confidential');
$response['select'] = html::span('folder-select', $this->gettext('saveintasklist') . ' ' .
$select->show($this->rc->config->get('tasklist_default_list', $default_list['id'])));
$select->show($default_list['id']));
}
$this->rc->output->command('plugin.update_itip_object_status', $response);