diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-02-21 20:10:40 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-02-21 20:10:40 +0100 |
commit | 86d2927c02c09d6642268891e995bf9d0a11782c (patch) | |
tree | 7f0e55afeb29fb453d9b4bfa21c78dd9960cdc6d /apps | |
parent | 987845c31206b3d193e41e65ed6b964efc26f127 (diff) | |
download | nextcloud-server-86d2927c02c09d6642268891e995bf9d0a11782c.tar.gz nextcloud-server-86d2927c02c09d6642268891e995bf9d0a11782c.zip |
Calendar: Correct calendarcolor format for ical color property
Diffstat (limited to 'apps')
-rw-r--r-- | apps/calendar/ajax/updatecalendar.php | 10 | ||||
-rw-r--r-- | apps/calendar/appinfo/info.xml | 2 | ||||
-rw-r--r-- | apps/calendar/appinfo/update.php | 17 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 2 | ||||
-rw-r--r-- | apps/calendar/lib/calendar.php | 24 |
5 files changed, 40 insertions, 15 deletions
diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php index 5add6d92bfa..20c225d8a29 100644 --- a/apps/calendar/ajax/updatecalendar.php +++ b/apps/calendar/ajax/updatecalendar.php @@ -25,8 +25,16 @@ foreach($calendars as $cal){ } $calendarid = $_POST['id']; +$calendarcolor = $_POST['color']; +if (preg_match('/^#?([0-9a-f]{6})/', $calendarcolor, $matches)) { + $calendarcolor = '#'.$matches[1]; +} +else { + $calendarcolor = null; +} + $calendar = OC_Calendar_App::getCalendar($calendarid);//access check -OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']); +OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $calendarcolor); OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); $calendar = OC_Calendar_App::getCalendar($calendarid); diff --git a/apps/calendar/appinfo/info.xml b/apps/calendar/appinfo/info.xml index 46292af3db1..4ac3c5bf099 100644 --- a/apps/calendar/appinfo/info.xml +++ b/apps/calendar/appinfo/info.xml @@ -2,7 +2,7 @@ <info> <id>calendar</id> <name>Calendar</name> - <version>0.2</version> + <version>0.2.1</version> <licence>AGPL</licence> <author>Georg Ehrke, Bart Visscher, Jakob Sack</author> <require>2</require> diff --git a/apps/calendar/appinfo/update.php b/apps/calendar/appinfo/update.php new file mode 100644 index 00000000000..375816a403e --- /dev/null +++ b/apps/calendar/appinfo/update.php @@ -0,0 +1,17 @@ +<?php + +$installedVersion=OC_Appconfig::getValue('calendar', 'installed_version'); +if (version_compare($installedVersion, '0.2.1', '<')) { + $stmt = OC_DB::prepare( 'SELECT id, calendarcolor FROM *PREFIX*calendar_calendars WHERE calendarcolor IS NOT NULL' ); + $result = $stmt->execute(); + while( $row = $result->fetchRow()) { + $id = $row['id']; + $color = $row['calendarcolor']; + if ($color[0] == '#' || strlen($color) < 6) { + continue; + } + $color = '#' .$color; + $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET calendarcolor=? WHERE id=?' ); + $r = $stmt->execute(array($color,$id)); + } +} diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 517d2ce128b..ba8e293819a 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -478,7 +478,7 @@ Calendar={ colors[i].label = $(elm).text(); }); for (var i in colors) { - picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: #' + colors[i].color + ';"></span>'); + picker.append('<span class="calendar-colorpicker-color ' + (colors[i].color == $(obj).children(":selected").val() ? ' active' : '') + '" rel="' + colors[i].label + '" style="background-color: ' + colors[i].color + ';"></span>'); } picker.delegate(".calendar-colorpicker-color", "click", function() { $(obj).val($(this).attr('rel')); diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 679649582d8..277539af97d 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -96,7 +96,7 @@ class OC_Calendar_Calendar{ * @param string $components Default: "VEVENT,VTODO,VJOURNAL" * @param string $timezone Default: null * @param integer $order Default: 1 - * @param string $color Default: null + * @param string $color Default: null, format: '#RRGGBB(AA)' * @return insertid */ public static function addCalendar($userid,$name,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null){ @@ -122,7 +122,7 @@ class OC_Calendar_Calendar{ * @param string $components * @param string $timezone * @param integer $order - * @param string $color + * @param string $color format: '#RRGGBB(AA)' * @return insertid */ public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){ @@ -141,7 +141,7 @@ class OC_Calendar_Calendar{ * @param string $components Default: null * @param string $timezone Default: null * @param integer $order Default: null - * @param string $color Default: null + * @param string $color Default: null, format: '#RRGGBB(AA)' * @return boolean * * Values not null will be set @@ -230,20 +230,20 @@ class OC_Calendar_Calendar{ } public static function getCalendarColorOptions(){ return array( - 'ff0000', // "Red" - 'b3dc6c', // "Green" - 'ffff00', // "Yellow" - '808000', // "Olive" - 'ffa500', // "Orange" - 'ff7f50', // "Coral" - 'ee82ee', // "Violet" - '9fc6e7', // "light blue" + '#ff0000', // "Red" + '#b3dc6c', // "Green" + '#ffff00', // "Yellow" + '#808000', // "Olive" + '#ffa500', // "Orange" + '#ff7f50', // "Coral" + '#ee82ee', // "Violet" + '#9fc6e7', // "light blue" ); } public static function getEventSourceInfo($calendar){ return array( 'url' => 'ajax/events.php?calendar_id='.$calendar['id'], - 'backgroundColor' => '#'.$calendar['calendarcolor'], + 'backgroundColor' => $calendar['calendarcolor'], 'borderColor' => '#888', 'textColor' => 'black', 'cache' => true, |