From d2dc721d4a382c9c45c7687925bbb95469eab204 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 5 Oct 2011 12:16:43 +0200 Subject: [PATCH] Change event priority values to be compatible with RFC 5545 and RFC 5546 as suggested in KEP #8 --- plugins/calendar/calendar.php | 4 ++-- plugins/calendar/calendar_ui.js | 6 +++--- plugins/calendar/drivers/calendar_driver.php | 2 +- plugins/calendar/drivers/database/sql/mysql.sql | 2 +- .../calendar/drivers/database/sql/postgresql.sql | 2 +- plugins/calendar/drivers/database/sql/sqlite.sql | 2 +- plugins/calendar/drivers/kolab/kolab_calendar.php | 10 ++++------ plugins/calendar/lib/calendar_ical.php | 9 ++++----- plugins/calendar/lib/calendar_ui.php | 13 ++++++++++--- 9 files changed, 27 insertions(+), 23 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index c86a9b56..a767a223 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -246,7 +246,7 @@ class calendar extends rcube_plugin $this->ui->addJS(); $this->ui->init_templates(); - $this->rc->output->add_label('low','normal','high','delete','cancel','uploading','noemailwarning'); + $this->rc->output->add_label('lowest','low','normal','high','highest','delete','cancel','uploading','noemailwarning'); // initialize attendees autocompletion rcube_autocomplete_init(); @@ -1232,7 +1232,7 @@ class calendar extends rcube_plugin 'categories' => $cats[array_rand($cats)], 'calendar' => array_rand($cals), 'alarms' => $alarm > 0 ? "-{$alarm}M:DISPLAY" : '', - 'priority' => 1, + 'priority' => rand(0,9), )); } diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 6f054017..579bbb9b 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -325,9 +325,9 @@ function rcube_calendar_ui(settings) $('#event-category').show().children('.event-text').html(Q(event.categories)).removeClass().addClass('event-text cat-'+String(event.categories).replace(rcmail.identifier_expr, '')); if (event.free_busy) $('#event-free-busy').show().children('.event-text').html(Q(rcmail.gettext(event.free_busy, 'calendar'))); - if (event.priority != 1) { - 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])); + if (event.priority > 0) { + var priolabels = [ '', rcmail.gettext('high'), rcmail.gettext('highest'), '', '', rcmail.gettext('normal'), '', '', rcmail.gettext('low'), rcmail.gettext('lowest') ]; + $('#event-priority').show().children('.event-text').html(Q(event.priority+' '+priolabels[event.priority])); } if (event.sensitivity != 0) { var sensitivityclasses = { 0:'public', 1:'private', 2:'confidential' }; diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php index 3dd7806b..15221a76 100644 --- a/plugins/calendar/drivers/calendar_driver.php +++ b/plugins/calendar/drivers/calendar_driver.php @@ -50,7 +50,7 @@ * 'recurrence_id' => 'ID of the recurrence group', // usually the ID of the starting event * 'categories' => 'Event category', * 'free_busy' => 'free|busy|outofoffice|tentative', // Show time as - * 'priority' => 1|0|2, // Event priority (0=low, 1=normal, 2=high) + * 'priority' => 0-9, // Event priority (0=undefined, 1=highest, 9=lowest) * 'sensitivity' => 0|1|2, // Event sensitivity (0=public, 1=private, 2=confidential) * 'alarms' => '-15M:DISPLAY', // Reminder settings inspired by valarm definition (e.g. display alert 15 minutes before event) * 'attachments' => array( // List of attachments diff --git a/plugins/calendar/drivers/database/sql/mysql.sql b/plugins/calendar/drivers/database/sql/mysql.sql index e0db2359..ea3ff028 100644 --- a/plugins/calendar/drivers/database/sql/mysql.sql +++ b/plugins/calendar/drivers/database/sql/mysql.sql @@ -39,7 +39,7 @@ CREATE TABLE `events` ( `categories` varchar(255) NOT NULL DEFAULT '', `all_day` 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 '0', `sensitivity` tinyint(1) NOT NULL DEFAULT '0', `alarms` varchar(255) DEFAULT NULL, `attendees` text DEFAULT NULL, diff --git a/plugins/calendar/drivers/database/sql/postgresql.sql b/plugins/calendar/drivers/database/sql/postgresql.sql index fd6ec830..25358041 100644 --- a/plugins/calendar/drivers/database/sql/postgresql.sql +++ b/plugins/calendar/drivers/database/sql/postgresql.sql @@ -54,7 +54,7 @@ CREATE TABLE events ( categories character varying(255) NOT NULL, all_day smallint NOT NULL DEFAULT 0, free_busy smallint NOT NULL DEFAULT 0, - priority smallint NOT NULL DEFAULT 1, + priority smallint NOT NULL DEFAULT 0, sensitivity smallint NOT NULL DEFAULT 0, alarms varchar(255) DEFAULT NULL, attendees text DEFAULT NULL, diff --git a/plugins/calendar/drivers/database/sql/sqlite.sql b/plugins/calendar/drivers/database/sql/sqlite.sql index 7c114e65..a9fbccda 100644 --- a/plugins/calendar/drivers/database/sql/sqlite.sql +++ b/plugins/calendar/drivers/database/sql/sqlite.sql @@ -39,7 +39,7 @@ CREATE TABLE events ( categories varchar(255) NOT NULL default '', all_day 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 '0', sensitivity tinyint(1) NOT NULL default '0', alarms varchar(255) default NULL, attendees text default NULL, diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php index 19dceffd..6744cf1b 100644 --- a/plugins/calendar/drivers/kolab/kolab_calendar.php +++ b/plugins/calendar/drivers/kolab/kolab_calendar.php @@ -41,7 +41,7 @@ class kolab_calendar private $namespace; private $search_fields = array('title', 'description', 'location', '_attendees'); private $sensitivity_map = array('public', 'private', 'confidential'); - private $priority_map = array('low', 'normal', 'high'); + private $priority_map = array('low' => 9, 'normal' => 5, 'high' => 1); private $role_map = array('REQ-PARTICIPANT' => 'required', 'OPT-PARTICIPANT' => 'optional', 'CHAIR' => 'resource'); private $status_map = array('NEEDS-ACTION' => 'none', 'TENTATIVE' => 'tentative', 'CONFIRMED' => 'accepted', 'ACCEPTED' => 'accepted', 'DECLINED' => 'declined'); private $month_map = array('', 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'); @@ -154,8 +154,7 @@ class kolab_calendar public function get_color() { // color is defined in folder METADATA - // FIXME: Kolab_Folder::getKolabAttribute() only reads value.shared; value.priv should be considered first - if ($color = $this->storage->_folder->getKolabAttribute('color')) { + if ($color = $this->storage->_folder->getKolabAttribute('color', HORDE_ANNOT_READ_PRIVATE_SHARED)) { return $color; } @@ -552,7 +551,6 @@ class kolab_calendar } $sensitivity_map = array_flip($this->sensitivity_map); - $priority_map = array_flip($this->priority_map); $status_map = array_flip($this->status_map); $role_map = array_flip($this->role_map); @@ -608,7 +606,7 @@ class kolab_calendar 'attendees' => $attendees, '_attendees' => $_attendees, 'free_busy' => $rec['show-time-as'], - 'priority' => isset($priority_map[$rec['priority']]) ? $priority_map[$rec['priority']] : 1, + 'priority' => is_numeric($rec['priority']) ? intval($rec['priority']) : (isset($this->priority_map[$rec['priority']]) ? $this->priority_map[$rec['priority']] : 0), 'sensitivity' => $sensitivity_map[$rec['sensitivity']], 'changed' => $rec['last-modification-date'], 'calendar' => $this->id, @@ -635,7 +633,7 @@ class kolab_calendar 'end-date' => $event['end'], 'sensitivity' =>$this->sensitivity_map[$event['sensitivity']], 'show-time-as' => $event['free_busy'], - 'priority' => isset($priority_map[$event['priority']]) ? $priority_map[$event['priority']] : 1, + 'priority' => $event['priority'], ); //handle alarms diff --git a/plugins/calendar/lib/calendar_ical.php b/plugins/calendar/lib/calendar_ical.php index ca6c6d43..05708abd 100644 --- a/plugins/calendar/lib/calendar_ical.php +++ b/plugins/calendar/lib/calendar_ical.php @@ -99,7 +99,7 @@ class calendar_ical 'end' => $ve->getAttribute('DTEND'), // set defaults 'free_busy' => 'busy', - 'priority' => 1, + 'priority' => 0, ); // check for all-day dates @@ -155,8 +155,7 @@ class calendar_ical case 'PRIORITY': if (is_numeric($attr['value'])) { - $event['priority'] = $attr['value'] <= 4 ? 2 /* high */ : - ($attr['value'] == 5 ? 1 /* normal */ : 0 /* low */); + $event['priority'] = $attr['value']; } break; @@ -303,8 +302,8 @@ class calendar_ical $vevent .= "TRANSP:" . ($event['free_busy'] == 'free' ? 'TRANSPARENT' : 'OPAQUE') . self::EOL; - if ($event['priority'] != 1) { - $vevent .= "PRIORITY:" . ($event['priority'] == 2 ? '1' : '9') . self::EOL; + if ($event['priority']) { + $vevent .= "PRIORITY:" . $event['priority'] . self::EOL; } if ($event['cancelled']) diff --git a/plugins/calendar/lib/calendar_ui.php b/plugins/calendar/lib/calendar_ui.php index c5ed6774..45c196d3 100644 --- a/plugins/calendar/lib/calendar_ui.php +++ b/plugins/calendar/lib/calendar_ui.php @@ -288,9 +288,16 @@ class calendar_ui { $attrib['name'] = 'priority'; $select = new html_select($attrib); - $select->add($this->cal->gettext('normal'), '1'); - $select->add($this->cal->gettext('low'), '0'); - $select->add($this->cal->gettext('high'), '2'); + $select->add('---', '0'); + $select->add('1 '.$this->cal->gettext('highest'), '1'); + $select->add('2 '.$this->cal->gettext('high'), '2'); + $select->add('3 ', '3'); + $select->add('4 ', '4'); + $select->add('5 '.$this->cal->gettext('normal'), '5'); + $select->add('6 ', '6'); + $select->add('7 ', '7'); + $select->add('8 '.$this->cal->gettext('low'), '8'); + $select->add('9 '.$this->cal->gettext('lowest'), '9'); return $select->show(null); }