]> source.dussan.org Git - nextcloud-server.git/commitdiff
Calendar: Correct calendarcolor format for ical color property
authorBart Visscher <bartv@thisnet.nl>
Tue, 21 Feb 2012 19:10:40 +0000 (20:10 +0100)
committerBart Visscher <bartv@thisnet.nl>
Tue, 21 Feb 2012 19:10:40 +0000 (20:10 +0100)
apps/calendar/ajax/updatecalendar.php
apps/calendar/appinfo/info.xml
apps/calendar/appinfo/update.php [new file with mode: 0644]
apps/calendar/js/calendar.js
apps/calendar/lib/calendar.php

index 5add6d92bfa49bb30e9dc82531ad881cf742bcdb..20c225d8a2968e86042bb370553682ea414a9f9a 100644 (file)
@@ -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);
index 46292af3db1fe1efa8980d8f850a044acbed4578..4ac3c5bf0996db97a1dc307e710fd4341535c5d1 100644 (file)
@@ -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 (file)
index 0000000..375816a
--- /dev/null
@@ -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));
+       }
+}
index 517d2ce128b8903bad6f1e64dd72fa14b71b58a2..ba8e293819a29f59f4708c6ae0c0dd4a78079974 100644 (file)
@@ -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'));
index 679649582d8fb6752351193d5ca26fa73298e28e..277539af97d7cbbeb1010b21a3c921a0759ad2f0 100644 (file)
@@ -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,