From aae87c8954a10288b8cffdbcf937269b465486e5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 7 May 2013 10:58:39 +0200 Subject: [PATCH] Fix so default categories are used when categories aren't configured --- plugins/calendar/calendar.php | 7 ------- plugins/calendar/drivers/calendar_driver.php | 9 ++++++++- plugins/calendar/drivers/kolab/kolab_driver.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index 82f7b3c4..15173064 100644 --- a/plugins/calendar/calendar.php +++ b/plugins/calendar/calendar.php @@ -58,13 +58,6 @@ class calendar extends rcube_plugin 'calendar_time_indicator' => true, ); - private $default_categories = array( - 'Personal' => 'c0c0c0', - 'Work' => 'ff0000', - 'Family' => '00ff00', - 'Holiday' => 'ff6600', - ); - private $ics_parts = array(); diff --git a/plugins/calendar/drivers/calendar_driver.php b/plugins/calendar/drivers/calendar_driver.php index 478a08c0..43e13458 100644 --- a/plugins/calendar/drivers/calendar_driver.php +++ b/plugins/calendar/drivers/calendar_driver.php @@ -91,6 +91,13 @@ abstract class calendar_driver public $alarm_absolute = true; public $last_error; + protected $default_categories = array( + 'Personal' => 'c0c0c0', + 'Work' => 'ff0000', + 'Family' => '00ff00', + 'Holiday' => 'ff6600', + ); + /** * Get a list of available calendars from this source * @@ -328,7 +335,7 @@ abstract class calendar_driver public function list_categories() { $rcmail = rcube::get_instance(); - return $rcmail->config->get('calendar_categories', array()); + return $rcmail->config->get('calendar_categories', $this->default_categories); } /** diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php index 6b980cd8..081f2b0d 100644 --- a/plugins/calendar/drivers/kolab/kolab_driver.php +++ b/plugins/calendar/drivers/kolab/kolab_driver.php @@ -698,7 +698,7 @@ class kolab_driver extends calendar_driver } // add new categories to user prefs - $old_categories = $this->rc->config->get('calendar_categories', array()); + $old_categories = $this->rc->config->get('calendar_categories', $this->default_categories); if ($newcats = array_diff(array_map('strtolower', array_keys($categories)), array_map('strtolower', array_keys($old_categories)))) { foreach ($newcats as $category) $old_categories[$category] = ''; // no color set yet @@ -867,7 +867,7 @@ class kolab_driver extends calendar_driver public function list_categories() { // FIXME: complete list with categories saved in config objects (KEP:12) - return $this->rc->config->get('calendar_categories', array()); + return $this->rc->config->get('calendar_categories', $this->default_categories); } /**