From: Bart Visscher Date: Tue, 21 Feb 2012 19:10:40 +0000 (+0100) Subject: Calendar: Correct calendarcolor format for ical color property X-Git-Tag: v4.0.0beta~201^2~23 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=86d2927c02c09d6642268891e995bf9d0a11782c;p=nextcloud-server.git Calendar: Correct calendarcolor format for ical color property --- 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 @@ calendar Calendar - 0.2 + 0.2.1 AGPL Georg Ehrke, Bart Visscher, Jakob Sack 2 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 @@ +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(''); + picker.append(''); } 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,