Commit 7fec7914 authored by Thomas Bruederli's avatar Thomas Bruederli

Select folders annotated 'private' for events/tasks flagged as such (#4789)

parent 548d1d93
......@@ -260,23 +260,21 @@ class calendar extends rcube_plugin
/**
* Get properties of the calendar this user has specified as default
*/
public function get_default_calendar($writeable = false, $confidential = false)
public function get_default_calendar($sensitivity = null)
{
$default_id = $this->rc->config->get('calendar_default_calendar');
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL);
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL | calendar_driver::FILTER_WRITEABLE);
$calendar = $calendars[$default_id] ?: null;
if (!$calendar || $confidential || ($writeable && !$calendar['editable'])) {
if (!$calendar || $sensitivity) {
foreach ($calendars as $cal) {
if ($confidential && $cal['subtype'] == 'confidential') {
if ($sensitivity && $cal['subtype'] == $sensitivity) {
$calendar = $cal;
break;
}
if ($cal['default']) {
if ($cal['default'] && $cal['editable']) {
$calendar = $cal;
if (!$confidential)
break;
}
if (!$writeable || $cal['editable']) {
if ($cal['editable']) {
$first = $cal;
}
}
......@@ -2473,7 +2471,7 @@ class calendar extends rcube_plugin
}
if ($calendar_select) {
$default_calendar = $this->get_default_calendar(true, $data['sensitivity'] == 'confidential');
$default_calendar = $this->get_default_calendar($data['sensitivity']);
$response['select'] = html::span('folder-select', $this->gettext('saveincalendar') . ' ' .
$calendar_select->show($default_calendar['id']));
}
......@@ -2587,7 +2585,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, $invitation['event']['sensitivity'] == 'confidential'))) {
if (!$this->driver->get_event($this->event) && ($calendar = $this->get_default_calendar($invitation['event']['sensitivity']))) {
$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');
......@@ -2798,7 +2796,7 @@ class calendar extends rcube_plugin
// select default calendar except user explicitly selected 'none'
if (!$calendar && !$dontsave)
$calendar = $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
$calendar = $this->get_default_calendar($event['sensitivity']);
$metadata = array(
'uid' => $event['uid'],
......@@ -3110,7 +3108,7 @@ class calendar extends rcube_plugin
foreach ($events as $event) {
// save to calendar
$calendar = $calendars[$cal_id] ?: $this->get_default_calendar(true, $event['sensitivity'] == 'confidential');
$calendar = $calendars[$cal_id] ?: $this->get_default_calendar($event['sensitivity']);
if ($calendar && $calendar['editable'] && $event['_type'] == 'event') {
$event['calendar'] = $calendar['id'];
......
......@@ -294,10 +294,10 @@ class kolab_driver extends calendar_driver
'list' => $this->calendars,
'calendars' => $calendars,
'filter' => $filter,
'editable' => ($filter & self::FILTER_WRITEABLE),
'editable' => ($filter & self::FILTER_WRITEABLE),
'insert' => ($filter & self::FILTER_INSERTABLE),
'active' => ($filter & self::FILTER_ACTIVE),
'personal' => ($filter & self::FILTER_PERSONAL),
'personal' => ($filter & self::FILTER_PERSONAL)
));
if ($plugin['abort']) {
......@@ -317,6 +317,12 @@ class kolab_driver extends calendar_driver
if (($filter & self::FILTER_ACTIVE) && !$cal->is_active()) {
continue;
}
if (($filter & self::FILTER_PRIVATE) && $cal->subtype != 'private') {
continue;
}
if (($filter & self::FILTER_CONFIDENTIAL) && $cal->subtype != 'confidential') {
continue;
}
if (($filter & self::FILTER_PERSONAL) && $cal->get_namespace() != 'personal') {
continue;
}
......
......@@ -29,8 +29,8 @@ class kolab_folders extends rcube_plugin
public $types = array('mail', 'event', 'journal', 'task', 'note', 'contact', 'configuration', 'file', 'freebusy');
public $subtypes = array(
'mail' => array('inbox', 'drafts', 'sentitems', 'outbox', 'wastebasket', 'junkemail'),
'event' => array('default', 'confidential'),
'task' => array('default', 'confidential'),
'event' => array('default', 'confidential', 'private'),
'task' => array('default', 'confidential', 'private'),
'journal' => array('default'),
'note' => array('default'),
'contact' => array('default'),
......
......@@ -3,7 +3,7 @@
/**
* Localizations for the Kolab Folders plugin
*
* Copyright (C) 2014, Kolab Systems AG
* Copyright (C) 2015, Kolab Systems AG
*
* For translation see https://www.transifex.com/projects/p/kolab/resource/kolab_folders/
*/
......@@ -29,6 +29,7 @@ $labels['outbox'] = 'Outbox';
$labels['wastebasket'] = 'Trash';
$labels['junkemail'] = 'Junk';
$labels['confidential'] = 'Confidential';
$labels['private'] = 'Private';
$messages['defaultfolderexists'] = 'There is already default folder of specified type';
......
......@@ -1724,26 +1724,22 @@ class tasklist extends rcube_plugin
/**
* Get properties of the tasklist this user has specified as default
*/
public function get_default_tasklist($writeable = false, $confidential = false)
public function get_default_tasklist($sensitivity = null)
{
$lists = $this->driver->get_lists();
$list = null;
if (!$list || ($writeable && !$list['editable'])) {
foreach ($lists as $l) {
if ($confidential && $l['subtype'] == 'confidential') {
$list = $l;
break;
}
if ($l['default']) {
$list = $l;
if (!$confidential)
break;
}
foreach ($lists as $l) {
if ($sensitivity && $l['subtype'] == $sensitivity) {
$list = $l;
break;
}
if ($l['default']) {
$list = $l;
}
if (!$writeable || $l['editable']) {
$first = $l;
}
if ($l['editable']) {
$first = $l;
}
}
......@@ -1786,7 +1782,7 @@ class tasklist extends rcube_plugin
foreach ($tasks as $task) {
// save to tasklist
$list = $lists[$cal_id] ?: $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
$list = $lists[$cal_id] ?: $this->get_default_tasklist($task['sensitivity']);
if ($list && $list['editable'] && $task['_type'] == 'task') {
$task = $this->from_ical($task);
$task['list'] = $list['id'];
......@@ -1866,7 +1862,7 @@ class tasklist extends rcube_plugin
// select default list except user explicitly selected 'none'
if (!$list && !$dontsave) {
$list = $this->get_default_tasklist(true, $task['sensitivity'] == 'confidential');
$list = $this->get_default_tasklist($task['sensitivity']);
}
$metadata = array(
......@@ -2105,7 +2101,7 @@ class tasklist extends rcube_plugin
}
if ($select) {
$default_list = $this->get_default_tasklist(true, $data['sensitivity'] == 'confidential');
$default_list = $this->get_default_tasklist($data['sensitivity']);
$response['select'] = html::span('folder-select', $this->gettext('saveintasklist') . ' ' .
$select->show($default_list['id']));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment