2 commits - plugins/calendar
Thomas Brüderli
bruederli at kolabsys.com
Wed Mar 11 12:34:42 CET 2015
plugins/calendar/calendar.php | 10 -
plugins/calendar/calendar_ui.js | 63 ++++++-----
plugins/calendar/drivers/calendar_driver.php | 9 -
plugins/calendar/drivers/database/database_driver.php | 4
plugins/calendar/drivers/kolab/kolab_calendar.php | 14 +-
plugins/calendar/drivers/kolab/kolab_driver.php | 30 +++--
plugins/calendar/drivers/kolab/kolab_invitation_calendar.php | 2
plugins/calendar/drivers/kolab/kolab_user_calendar.php | 2
plugins/calendar/lib/calendar_ui.php | 4
9 files changed, 80 insertions(+), 58 deletions(-)
New commits:
commit 2ad5eeb5707c7fc486c5d72251cdd26882796031
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Mar 11 12:34:38 2015 +0100
Fix JS syntax to be compliant with IE < 9 (new is a reserved word)
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index 9dd4014..f3f41dd 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -1162,8 +1162,8 @@ function rcube_calendar_ui(settings)
// special case: title
if (prop == 'title') {
- $('.event-title', $dialog).addClass('event-text-old').text(change.old || '--');
- $('.event-title-new', $dialog).text(change.new || '--').show();
+ $('.event-title', $dialog).addClass('event-text-old').text(change['old'] || '--');
+ $('.event-title-new', $dialog).text(change['new'] || '--').show();
}
// no display container for this property
@@ -1179,40 +1179,40 @@ function rcube_calendar_ui(settings)
// format dates
if (['start','end','changed'].indexOf(prop) >= 0) {
- if (change.old) change.old_ = me.format_datetime(parseISO8601(change.old));
- if (change.new) change.new_ = me.format_datetime(parseISO8601(change.new));
+ if (change['old']) change.old_ = me.format_datetime(parseISO8601(change['old']));
+ if (change['new']) change.new_ = me.format_datetime(parseISO8601(change['new']));
}
// render description text
else if (prop == 'description') {
// TODO: show real text diff
- if (!change.diff_ && change.old) change.old_ = text2html(change.old);
- if (!change.diff_ && change.new) change.new_ = text2html(change.new);
+ if (!change.diff_ && change['old']) change.old_ = text2html(change['old']);
+ if (!change.diff_ && change['new']) change.new_ = text2html(change['new']);
html = true;
}
// format attendees struct
else if (prop == 'attendees') {
- if (change.old) change.old_ = event_attendee_html(change.old);
- if (change.new) change.new_ = event_attendee_html($.extend({}, change.old || {}, change.new));
+ if (change['old']) change.old_ = event_attendee_html(change['old']);
+ if (change['new']) change.new_ = event_attendee_html($.extend({}, change['old'] || {}, change['new']));
html = true;
}
// localize priority values
else if (prop == 'priority') {
var priolabels = [ '', rcmail.gettext('highest'), rcmail.gettext('high'), '', '', rcmail.gettext('normal'), '', '', rcmail.gettext('low'), rcmail.gettext('lowest') ];
- if (change.old) change.old_ = change.old + ' ' + (priolabels[change.old] || '');
- if (change.new) change.new_ = change.new + ' ' + (priolabels[change.new] || '');
+ if (change['old']) change.old_ = change['old'] + ' ' + (priolabels[change['old']] || '');
+ if (change['new']) change.new_ = change['new'] + ' ' + (priolabels[change['new']] || '');
}
// localize status
else if (prop == 'status') {
var status_lc = String(event.status).toLowerCase();
- if (change.old) change.old_ = rcmail.gettext(String(change.old).toLowerCase(), 'calendar');
- if (change.new) change.new_ = rcmail.gettext(String(change.new).toLowerCase(), 'calendar');
+ if (change['old']) change.old_ = rcmail.gettext(String(change['old']).toLowerCase(), 'calendar');
+ if (change['new']) change.new_ = rcmail.gettext(String(change['new']).toLowerCase(), 'calendar');
}
// format attachments struct
if (prop == 'attachments') {
- if (change.old) event_show_attachments([change.old], row.children('.event-text-old'), event, false);
+ if (change['old']) event_show_attachments([change['old']], row.children('.event-text-old'), event, false);
else row.children('.event-text-old').text('--');
- if (change.new) event_show_attachments([$.extend({}, change.old || {}, change.new)], row.children('.event-text-new'), event, false);
+ if (change['new']) event_show_attachments([$.extend({}, change['old'] || {}, change['new'])], row.children('.event-text-new'), event, false);
else row.children('.event-text-new').text('--');
// remove click handler as we're currentyl not able to display the according attachment contents
$('.attachmentslist li a', row).unbind('click').removeAttr('href');
@@ -1224,11 +1224,11 @@ function rcube_calendar_ui(settings)
else {
if (!html) {
// escape HTML characters
- change.old_ = Q(change.old_ || change.old || '--')
- change.new_ = Q(change.new_ || change.new || '--')
+ change.old_ = Q(change.old_ || change['old'] || '--')
+ change.new_ = Q(change.new_ || change['new'] || '--')
}
- row.children('.event-text-old').html(change.old_ || change.old || '--');
- row.children('.event-text-new').html(change.new_ || change.new || '--');
+ row.children('.event-text-old').html(change.old_ || change['old'] || '--');
+ row.children('.event-text-new').html(change.new_ || change['new'] || '--');
}
// display index number
commit 6f97b9ff71fb384e19572bd7403e7d391e4e319f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Mar 11 12:22:01 2015 +0100
- Require delete permission for a calendar to be writeable (#4827)
- Introduce 'insert' permission which allows the creation of new events but no subsequent editing
- Replace 'readonly' with '!writeable' properties for consistency reasons
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 0e2e86e..5c45518 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -265,7 +265,7 @@ class calendar extends rcube_plugin
$default_id = $this->rc->config->get('calendar_default_calendar');
$calendars = $this->driver->list_calendars(calendar_driver::FILTER_PERSONAL);
$calendar = $calendars[$default_id] ?: null;
- if (!$calendar || $confidential || ($writeable && $calendar['readonly'])) {
+ if (!$calendar || $confidential || ($writeable && !$calendar['writeable'])) {
foreach ($calendars as $cal) {
if ($confidential && $cal['subtype'] == 'confidential') {
$calendar = $cal;
@@ -276,7 +276,7 @@ class calendar extends rcube_plugin
if (!$confidential)
break;
}
- if (!$writeable || !$cal['readonly']) {
+ if (!$writeable || $cal['writeable']) {
$first = $cal;
}
}
@@ -2459,7 +2459,7 @@ class calendar extends rcube_plugin
$calendar_select->add('--', '');
$numcals = 0;
foreach ($calendars as $calendar) {
- if (!$calendar['readonly']) {
+ if ($calendar['writeable']) {
$calendar_select->add($calendar['name'], $calendar['id']);
$numcals++;
}
@@ -2840,7 +2840,7 @@ class calendar extends rcube_plugin
}
// save to calendar
- if ($calendar && !$calendar['readonly']) {
+ if ($calendar && $calendar['writeable']) {
// check for existing event with the same UID
$existing = $this->driver->get_event($event, calendar_driver::FILTER_WRITEABLE | calendar_driver::FILTER_PERSONAL);
@@ -3107,7 +3107,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');
- if ($calendar && !$calendar['readonly'] && $event['_type'] == 'event') {
+ if ($calendar && $calendar['writeable'] && $event['_type'] == 'event') {
$event['calendar'] = $calendar['id'];
if (!$this->driver->get_event($event['uid'], calendar_driver::FILTER_WRITEABLE)) {
diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js
index 06e8759..9dd4014 100644
--- a/plugins/calendar/calendar_ui.js
+++ b/plugins/calendar/calendar_ui.js
@@ -63,7 +63,7 @@ function rcube_calendar_ui(settings)
var resources_data = {};
var resources_index = [];
var resource_owners = {};
- var resources_events_source = { url:null, editable:false };
+ var resources_events_source = { url:null, editable:false, insertable:false };
var freebusy_ui = { workinhoursonly:false, needsupdate:false };
var freebusy_data = {};
var current_view = null;
@@ -392,7 +392,7 @@ function rcube_calendar_ui(settings)
var event_show_dialog = function(event, ev, temp)
{
var $dialog = $("#eventshow");
- var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { editable:false };
+ var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { editable:false, insertable:false };
if (!temp)
me.selected_event = event;
@@ -687,7 +687,7 @@ function rcube_calendar_ui(settings)
$("#eventshow:ui-dialog").data('opener', null).dialog('close');
var $dialog = $('<div>');
- var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { editable:action=='new' };
+ var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { insertable:action=='new' };
me.selected_event = $.extend($.extend({}, event_defaults), event); // clone event object (with defaults)
event = me.selected_event; // change reference to clone
freebusy_ui.needsupdate = false;
@@ -734,6 +734,12 @@ function rcube_calendar_ui(settings)
allday.checked = false;
}
+ // set calendar selection according to permissions
+ calendars.find('option').each(function(i, opt) {
+ var cal = me.calendars[opt.value] || {};
+ $(opt).prop('disabled', !(cal.editable || (action == 'new' && cal.insertable)))
+ });
+
// set alarm(s)
me.set_alarms_edit('#edit-alarms', action != 'new' && event.valarms && calendar.alarms ? event.valarms : []);
@@ -808,7 +814,7 @@ function rcube_calendar_ui(settings)
// attachments
var load_attachments_tab = function()
{
- rcmail.enable_command('remove-attachment', !calendar.readonly && !event.recurrence_id);
+ rcmail.enable_command('remove-attachment', calendar.editable && !event.recurrence_id);
rcmail.env.deleted_attachments = [];
// we're sharing some code for uploads handling with app.js
rcmail.env.attachments = [];
@@ -3553,7 +3559,8 @@ function rcube_calendar_ui(settings)
me.calendars[id] = $.extend({
url: rcmail.url('calendar/load_events', { source: id }),
- editable: !cal.readonly,
+ editable: cal.writeable || false,
+ insertable: cal.insert || false,
className: 'fc-event-cal-'+id,
id: id
}, cal);
@@ -3583,7 +3590,7 @@ function rcube_calendar_ui(settings)
// insert to #calendar-select options if writeable
select = $('#edit-calendar');
- if (fc && !cal.readonly && select.length && !select.find('option[value="'+id+'"]').length) {
+ if (fc && (cal.writeable || cal.insert) && select.length && !select.find('option[value="'+id+'"]').length) {
$('<option>').attr('value', id).html(cal.name).appendTo(select);
}
}
@@ -3618,7 +3625,7 @@ function rcube_calendar_ui(settings)
count_sources.push(id);
}
- if (!cal.readonly && !this.selected_calendar) {
+ if (cal.writeable && !this.selected_calendar) {
this.selected_calendar = id;
rcmail.enable_command('addevent', true);
}
@@ -3640,7 +3647,7 @@ function rcube_calendar_ui(settings)
if (node && node.id && me.calendars[node.id]) {
me.select_calendar(node.id, true);
rcmail.enable_command('calendar-edit', 'calendar-showurl', true);
- rcmail.enable_command('calendar-delete', !me.calendars[node.id].readonly);
+ rcmail.enable_command('calendar-delete', me.calendars[node.id].editable);
rcmail.enable_command('calendar-remove', me.calendars[node.id] && me.calendars[node.id].removable);
}
});
@@ -3751,7 +3758,7 @@ function rcube_calendar_ui(settings)
});
// select default calendar
- if (settings.default_calendar && this.calendars[settings.default_calendar] && !this.calendars[settings.default_calendar].readonly)
+ if (settings.default_calendar && this.calendars[settings.default_calendar] && this.calendars[settings.default_calendar].editable)
this.selected_calendar = settings.default_calendar;
if (this.selected_calendar)
@@ -3769,6 +3776,8 @@ function rcube_calendar_ui(settings)
color: '#fff',
textColor: '#333',
editable: false,
+ writeable: false,
+ insertable: false,
attendees: true
};
event_sources.push(me.calendars['--invitation--itip']);
diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php
index da13ce6..b25f1c5 100644
--- a/plugins/calendar/drivers/calendar_driver.php
+++ b/plugins/calendar/drivers/calendar_driver.php
@@ -96,10 +96,11 @@ abstract class calendar_driver
{
const FILTER_ALL = 0;
const FILTER_WRITEABLE = 1;
- const FILTER_ACTIVE = 2;
- const FILTER_PERSONAL = 4;
- const FILTER_PRIVATE = 8;
- const FILTER_CONFIDENTIAL = 16;
+ const FILTER_INSERTABLE = 2;
+ const FILTER_ACTIVE = 4;
+ const FILTER_PERSONAL = 8;
+ const FILTER_PRIVATE = 16;
+ const FILTER_CONFIDENTIAL = 32;
const BIRTHDAY_CALENDAR_ID = '__bdays__';
// features supported by backend
diff --git a/plugins/calendar/drivers/database/database_driver.php b/plugins/calendar/drivers/database/database_driver.php
index 10eae03..e3f7fc8 100644
--- a/plugins/calendar/drivers/database/database_driver.php
+++ b/plugins/calendar/drivers/database/database_driver.php
@@ -89,6 +89,8 @@ class database_driver extends calendar_driver
$arr['active'] = !in_array($arr['id'], $hidden);
$arr['name'] = html::quote($arr['name']);
$arr['listname'] = html::quote($arr['name']);
+ $arr['insert'] = true;
+ $arr['writeable'] = true;
$this->calendars[$arr['calendar_id']] = $arr;
$calendar_ids[] = $this->rc->db->quote($arr['calendar_id']);
}
@@ -139,7 +141,7 @@ class database_driver extends calendar_driver
'showalarms' => (bool)$this->rc->config->get('calendar_birthdays_alarm_type'),
'active' => !in_array($id, $hidden),
'group' => 'x-birthdays',
- 'readonly' => true,
+ 'writeable' => false,
'default' => false,
'children' => false,
);
diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index ae96efa..3ea8094 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -27,7 +27,8 @@
class kolab_calendar extends kolab_storage_folder_api
{
public $ready = false;
- public $readonly = true;
+ public $writeable = false;
+ public $insert = false;
public $attachments = true;
public $alarms = false;
public $history = false;
@@ -78,17 +79,20 @@ class kolab_calendar extends kolab_storage_folder_api
$this->storage = kolab_storage::get_folder($this->name);
$this->ready = $this->storage && $this->storage->valid;
- // Set readonly and alarms flags according to folder permissions
+ // Set writeable and alarms flags according to folder permissions
if ($this->ready) {
if ($this->storage->get_namespace() == 'personal') {
- $this->readonly = false;
+ $this->writeable = true;
+ $this->insert = true;
$this->alarms = true;
}
else {
$rights = $this->storage->get_myrights();
if ($rights && !PEAR::isError($rights)) {
- if (strpos($rights, 'i') !== false)
- $this->readonly = false;
+ if (strpos($rights, 'i') !== false || strpos($rights, 'w') !== false)
+ $this->insert = true;
+ if (strpos($rights, 't') !== false || strpos($rights, 'd') !== false)
+ $this->writeable = $this->insert;
}
}
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index db8d0f8..3a111ab 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -103,7 +103,7 @@ class kolab_driver extends calendar_driver
if ($calendar->ready) {
$this->calendars[$calendar->id] = $calendar;
- if (!$calendar->readonly)
+ if ($calendar->writeable)
$this->has_writeable = true;
}
}
@@ -173,9 +173,9 @@ class kolab_driver extends calendar_driver
'owner' => $cal->get_owner(),
'history' => false,
'virtual' => false,
- 'readonly' => true,
- 'group' => 'other',
- 'class' => 'user',
+ 'writeable' => false,
+ 'group' => 'other',
+ 'class' => 'user',
'removable' => true,
);
}
@@ -185,10 +185,10 @@ class kolab_driver extends calendar_driver
'name' => $fullname,
'listname' => $listname,
'editname' => $cal->get_foldername(),
- 'virtual' => true,
- 'readonly' => true,
- 'group' => $cal->get_namespace(),
- 'class' => 'folder',
+ 'virtual' => true,
+ 'writeable' => false,
+ 'group' => $cal->get_namespace(),
+ 'class' => 'folder',
);
}
else {
@@ -199,7 +199,8 @@ class kolab_driver extends calendar_driver
'editname' => $cal->get_foldername(),
'title' => $cal->get_title(),
'color' => $cal->get_color(),
- 'readonly' => $cal->readonly,
+ 'writeable' => $cal->writeable,
+ 'insert' => $cal->insert,
'showalarms' => $cal->alarms,
'history' => !empty($this->bonnie_api),
'group' => $cal->get_namespace(),
@@ -232,7 +233,8 @@ class kolab_driver extends calendar_driver
'editname' => $cal->get_foldername(),
'title' => $cal->get_title(),
'color' => $cal->get_color(),
- 'readonly' => $cal->readonly,
+ 'writeable' => $cal->writeable,
+ 'insert' => $cal->insert,
'showalarms' => $cal->alarms,
'history' => !empty($this->bonnie_api),
'group' => 'x-invitations',
@@ -266,7 +268,7 @@ class kolab_driver extends calendar_driver
'active' => (bool)$prefs[$id]['active'],
'showalarms' => (bool)$this->rc->config->get('calendar_birthdays_alarm_type'),
'group' => 'x-birthdays',
- 'readonly' => true,
+ 'writeable' => false,
'default' => false,
'children' => false,
'history' => false,
@@ -293,6 +295,7 @@ class kolab_driver extends calendar_driver
'calendars' => $calendars,
'filter' => $filter,
'writeable' => ($filter & self::FILTER_WRITEABLE),
+ 'insert' => ($filter & self::FILTER_INSERTABLE),
'active' => ($filter & self::FILTER_ACTIVE),
'personal' => ($filter & self::FILTER_PERSONAL),
));
@@ -305,7 +308,10 @@ class kolab_driver extends calendar_driver
if (!$cal->ready) {
continue;
}
- if (($filter & self::FILTER_WRITEABLE) && $cal->readonly) {
+ if (($filter & self::FILTER_WRITEABLE) && !$cal->writeable) {
+ continue;
+ }
+ if (($filter & self::FILTER_INSERTABLE) && !$cal->insert) {
continue;
}
if (($filter & self::FILTER_ACTIVE) && !$cal->is_active()) {
diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
index 2d2a63c..a5c32c4 100644
--- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
@@ -26,7 +26,7 @@ class kolab_invitation_calendar
public $id = '__invitation__';
public $ready = true;
public $alarms = false;
- public $readonly = true;
+ public $writeable = false;
public $attachments = false;
public $subscriptions = false;
public $partstats = array('unknown');
diff --git a/plugins/calendar/drivers/kolab/kolab_user_calendar.php b/plugins/calendar/drivers/kolab/kolab_user_calendar.php
index 7846188..17656a2 100644
--- a/plugins/calendar/drivers/kolab/kolab_user_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_user_calendar.php
@@ -25,7 +25,7 @@ class kolab_user_calendar extends kolab_calendar
{
public $id = 'unknown';
public $ready = false;
- public $readonly = true;
+ public $writeable = false;
public $attachments = false;
public $subscriptions = false;
diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php
index 00b74cd..825f42c 100644
--- a/plugins/calendar/lib/calendar_ui.php
+++ b/plugins/calendar/lib/calendar_ui.php
@@ -294,7 +294,7 @@ class calendar_ui
if ($prop['virtual'])
$classes[] = 'virtual';
- else if ($prop['readonly'])
+ else if (!$prop['writeable'])
$classes[] = 'readonly';
if ($prop['subscribed'])
$classes[] = 'subscribed';
@@ -361,7 +361,7 @@ class calendar_ui
$select = new html_select($attrib);
foreach ((array)$this->cal->driver->list_calendars() as $id => $prop) {
- if (!$prop['readonly'])
+ if (!empty($prop['insert']))
$select->add($prop['name'], $id);
}
More information about the commits
mailing list