Add sensitivity field to event properties (inpsired by the Kolab format)

This commit is contained in:
Thomas Bruederli 2011-05-27 18:41:01 +02:00
parent 2bf657d69d
commit bca398a61c
11 changed files with 45 additions and 3 deletions

View file

@ -98,6 +98,10 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
var priolabels = { 0:rcmail.gettext('low'), 1:rcmail.gettext('normal'), 2:rcmail.gettext('high') }; var priolabels = { 0:rcmail.gettext('low'), 1:rcmail.gettext('normal'), 2:rcmail.gettext('high') };
$('#event-priority').show().children('.event-text').html(Q(priolabels[event.priority])); $('#event-priority').show().children('.event-text').html(Q(priolabels[event.priority]));
} }
if (event.sensitivity != 0) {
var sensitivitylabels = { 0:rcmail.gettext('public'), 1:rcmail.gettext('private'), 2:rcmail.gettext('confidential') };
$('#event-sensitivity').show().children('.event-text').html(Q(sensitivitylabels[event.sensitivity]));
}
var buttons = {}; var buttons = {};
if (calendar.editable) { if (calendar.editable) {
@ -157,6 +161,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
var calendars = $('#edit-calendar').val(event.calendar); var calendars = $('#edit-calendar').val(event.calendar);
var freebusy = $('#edit-free-busy').val(event.free_busy); var freebusy = $('#edit-free-busy').val(event.free_busy);
var priority = $('#edit-priority').val(event.priority); var priority = $('#edit-priority').val(event.priority);
var sensitivity = $('#edit-sensitivity').val(event.sensitivity);
var duration = Math.round((event.end.getTime() - event.start.getTime()) / 1000); var duration = Math.round((event.end.getTime() - event.start.getTime()) / 1000);
var startdate = $('#edit-startdate').val($.fullCalendar.formatDate(event.start, settings['date_format'])).data('duration', duration); var startdate = $('#edit-startdate').val($.fullCalendar.formatDate(event.start, settings['date_format'])).data('duration', duration);
@ -266,6 +271,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
categories: categories.val(), categories: categories.val(),
free_busy: freebusy.val(), free_busy: freebusy.val(),
priority: priority.val(), priority: priority.val(),
sensitivity: sensitivity.val(),
recurrence: '', recurrence: '',
alarms:'', alarms:'',
}; };

View file

@ -130,6 +130,7 @@ class calendar extends rcube_plugin
$this->register_handler('plugin.category_select', array($this->ui, 'category_select')); $this->register_handler('plugin.category_select', array($this->ui, 'category_select'));
$this->register_handler('plugin.freebusy_select', array($this->ui, 'freebusy_select')); $this->register_handler('plugin.freebusy_select', array($this->ui, 'freebusy_select'));
$this->register_handler('plugin.priority_select', array($this->ui, 'priority_select')); $this->register_handler('plugin.priority_select', array($this->ui, 'priority_select'));
$this->register_handler('plugin.sensitivity_select', array($this->ui, 'sensitivity_select'));
$this->register_handler('plugin.alarm_select', array($this->ui, 'alarm_select')); $this->register_handler('plugin.alarm_select', array($this->ui, 'alarm_select'));
$this->register_handler('plugin.snooze_select', array($this->ui, 'snooze_select')); $this->register_handler('plugin.snooze_select', array($this->ui, 'snooze_select'));
$this->register_handler('plugin.recurrence_form', array($this->ui, 'recurrence_form')); $this->register_handler('plugin.recurrence_form', array($this->ui, 'recurrence_form'));

View file

@ -62,6 +62,7 @@ abstract class calendar_driver
* categories: Event categories (comma-separated list) * categories: Event categories (comma-separated list)
* free_busy: Show time as free/busy/outofoffice * free_busy: Show time as free/busy/outofoffice
* priority: Event priority * priority: Event priority
* sensitivity: Event sensitivity (0=public, 1=private, 2=confidential)
* alarms: Reminder settings (TBD.) * alarms: Reminder settings (TBD.)
* @return mixed New event ID on success, False on error * @return mixed New event ID on success, False on error
*/ */

View file

@ -140,8 +140,8 @@ class database_driver extends calendar_driver
$event = $this->_save_preprocess($event); $event = $this->_save_preprocess($event);
$query = $this->rc->db->query(sprintf( $query = $this->rc->db->query(sprintf(
"INSERT INTO " . $this->db_events . " "INSERT INTO " . $this->db_events . "
(calendar_id, created, changed, uid, start, end, all_day, recurrence, title, description, location, categories, free_busy, priority, alarms, notifyat) (calendar_id, created, changed, uid, start, end, all_day, recurrence, title, description, location, categories, free_busy, priority, sensitivity, alarms, notifyat)
VALUES (?, %s, %s, ?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", VALUES (?, %s, %s, ?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
$this->rc->db->now(), $this->rc->db->now(),
$this->rc->db->now(), $this->rc->db->now(),
$this->rc->db->fromunixtime($event['start']), $this->rc->db->fromunixtime($event['start']),
@ -157,6 +157,7 @@ class database_driver extends calendar_driver
strval($event['categories']), strval($event['categories']),
intval($event['free_busy']), intval($event['free_busy']),
intval($event['priority']), intval($event['priority']),
intval($event['sensitivity']),
$event['alarms'], $event['alarms'],
$event['notifyat'] $event['notifyat']
); );
@ -178,7 +179,7 @@ class database_driver extends calendar_driver
$event = $this->_save_preprocess($event); $event = $this->_save_preprocess($event);
$query = $this->rc->db->query(sprintf( $query = $this->rc->db->query(sprintf(
"UPDATE " . $this->db_events . " "UPDATE " . $this->db_events . "
SET changed=%s, start=%s, end=%s, all_day=?, recurrence=?, title=?, description=?, location=?, categories=?, free_busy=?, priority=?, alarms=?, notifyat=? SET changed=%s, start=%s, end=%s, all_day=?, recurrence=?, title=?, description=?, location=?, categories=?, free_busy=?, priority=?, sensitivity=?, alarms=?, notifyat=?
WHERE event_id=? WHERE event_id=?
AND calendar_id IN (" . $this->calendar_ids . ")", AND calendar_id IN (" . $this->calendar_ids . ")",
$this->rc->db->now(), $this->rc->db->now(),
@ -192,6 +193,7 @@ class database_driver extends calendar_driver
strval($event['location']), strval($event['location']),
strval($event['categories']), strval($event['categories']),
intval($event['free_busy']), intval($event['free_busy']),
intval($event['sensitivity']),
intval($event['priority']), intval($event['priority']),
$event['alarms'], $event['alarms'],
$event['notifyat'], $event['notifyat'],

View file

@ -39,6 +39,7 @@ CREATE TABLE `events` (
`all_day` tinyint(1) NOT NULL DEFAULT '0', `all_day` tinyint(1) NOT NULL DEFAULT '0',
`free_busy` tinyint(1) NOT NULL DEFAULT '0', `free_busy` tinyint(1) NOT NULL DEFAULT '0',
`priority` tinyint(1) NOT NULL DEFAULT '1', `priority` tinyint(1) NOT NULL DEFAULT '1',
`sensitivity` tinyint(1) NOT NULL DEFAULT '0',
`alarms` varchar(255) DEFAULT NULL, `alarms` varchar(255) DEFAULT NULL,
`attendees` text DEFAULT NULL, `attendees` text DEFAULT NULL,
`notifyat` datetime DEFAULT NULL, `notifyat` datetime DEFAULT NULL,

View file

@ -54,6 +54,7 @@ CREATE TABLE events (
all_day smallint NOT NULL DEFAULT 0, all_day smallint NOT NULL DEFAULT 0,
free_busy smallint NOT NULL DEFAULT 0, free_busy smallint NOT NULL DEFAULT 0,
priority smallint NOT NULL DEFAULT 1, priority smallint NOT NULL DEFAULT 1,
sensitivity smallint NOT NULL DEFAULT 0,
alarms varchar(255) DEFAULT NULL, alarms varchar(255) DEFAULT NULL,
attendees text DEFAULT NULL, attendees text DEFAULT NULL,
notifyat timestamp without time zone DEFAULT NULL notifyat timestamp without time zone DEFAULT NULL

View file

@ -39,6 +39,7 @@ CREATE TABLE events (
all_day tinyint(1) NOT NULL default '0', all_day tinyint(1) NOT NULL default '0',
free_busy tinyint(1) NOT NULL default '0', free_busy tinyint(1) NOT NULL default '0',
priority tinyint(1) NOT NULL default '1', priority tinyint(1) NOT NULL default '1',
sensitivity tinyint(1) NOT NULL default '0',
alarms varchar(255) default NULL, alarms varchar(255) default NULL,
attendees text default NULL, attendees text default NULL,
notifyat datetime default NULL, notifyat datetime default NULL,

View file

@ -25,6 +25,7 @@ class kolab_calendar
private $events; private $events;
private $id2uid; private $id2uid;
private $imap_folder = 'INBOX/Calendar'; private $imap_folder = 'INBOX/Calendar';
private $sensitivity_map = array('public', 'private', 'confidential');
/** /**
* Default constructor * Default constructor
@ -147,6 +148,8 @@ class kolab_calendar
if ($allday) // in Roundcube all-day events only go until 23:59:59 of the last day if ($allday) // in Roundcube all-day events only go until 23:59:59 of the last day
$rec['end-date']--; $rec['end-date']--;
$sensitivity_map = array_flip($this->sensitivity_map);
return array( return array(
'id' => $rec['uid'], 'id' => $rec['uid'],
'uid' => $rec['uid'], 'uid' => $rec['uid'],
@ -159,6 +162,7 @@ class kolab_calendar
'categories' => $rec['categories'], 'categories' => $rec['categories'],
'free_busy' => $rec['show-time-as'], 'free_busy' => $rec['show-time-as'],
'priority' => 1, // normal 'priority' => 1, // normal
'sensitivity' => $sensitivity_map[$rec['sensitivity']],
'calendar' => $this->id, 'calendar' => $this->id,
); );
} }

View file

@ -202,6 +202,19 @@ class calendar_ui
return $select->show(null); return $select->show(null);
} }
/**
* Render HTML input for sensitivity selection
*/
function sensitivity_select($attrib = array())
{
$attrib['name'] = 'sensitivity';
$select = new html_select($attrib);
$select->add($this->calendar->gettext('public'), '0');
$select->add($this->calendar->gettext('private'), '1');
$select->add($this->calendar->gettext('confidential'), '2');
return $select->show(null);
}
/** /**
* Render HTML form for alarm configuration * Render HTML form for alarm configuration
*/ */

View file

@ -40,6 +40,10 @@ $labels['free'] = 'Free';
$labels['busy'] = 'Busy'; $labels['busy'] = 'Busy';
$labels['outofoffice'] = 'Out of Office'; $labels['outofoffice'] = 'Out of Office';
$labels['priority'] = 'Priority'; $labels['priority'] = 'Priority';
$labels['sensitivity'] = 'Sensitivity';
$labels['public'] = 'public';
$labels['private'] = 'private';
$labels['confidential'] = 'confidential';
$labels['alarms'] = 'Reminder'; $labels['alarms'] = 'Reminder';
$labels['generated'] = 'generated at'; $labels['generated'] = 'generated at';
$labels['selectdate'] = 'Select date'; $labels['selectdate'] = 'Select date';

View file

@ -63,6 +63,10 @@
<label><roundcube:label name="calendar.priority" /></label> <label><roundcube:label name="calendar.priority" /></label>
<span class="event-text"></span> <span class="event-text"></span>
</div> </div>
<div class="event-line" id="event-sensitivity">
<label><roundcube:label name="calendar.sensitivity" /></label>
<span class="event-text"></span>
</div>
</div> </div>
<div id="eventedit"> <div id="eventedit">
@ -121,6 +125,10 @@
<label for="edit-priority"><roundcube:label name="calendar.priority" /></label> <label for="edit-priority"><roundcube:label name="calendar.priority" /></label>
<roundcube:object name="plugin.priority_select" id="edit-priority" /> <roundcube:object name="plugin.priority_select" id="edit-priority" />
</div> </div>
<div class="event-section">
<label for="edit-sensitivity"><roundcube:label name="calendar.sensitivity" /></label>
<roundcube:object name="plugin.sensitivity_select" id="edit-sensitivity" />
</div>
</div> </div>
<!-- recurrence settings --> <!-- recurrence settings -->
<div id="event-tab-2"> <div id="event-tab-2">