set iCal colors in Tine 2.0 containers
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Aug 2014 14:45:24 +0000 (16:45 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:43 +0000 (11:26 +0200)
* we need to cut off aplha channel to have compatible color strings

Change-Id: I4c2d14488aa73456874d3a70239515aa8eb07ba7
Reviewed-on: http://gerrit.tine20.com/customers/1027
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Import/CalDav/Decorator/Abstract.php
tine20/Calendar/Import/CalDav/Decorator/MacOSX.php

index 1100ec6..8ebea26 100644 (file)
@@ -20,7 +20,9 @@ abstract class Calendar_Import_CalDav_Decorator_Abstract
     
     public function setCalendarProperties(Tinebase_Model_Container $calendarContainer, array $calendar)
     {
-        if (isset($calendar['color']))
+        if (isset($calendar['color']) && $calendarContainer->color !== $calendar['color']) {
             $calendarContainer->color = $calendar['color'];
+            Tinebase_Container::getInstance()->update($calendarContainer);
+        }
     }
 }
\ No newline at end of file
index d192b42..9cd5658 100644 (file)
@@ -16,8 +16,13 @@ class Calendar_Import_CalDav_Decorator_MacOSX extends Calendar_Import_CalDav_Dec
     
     public function processAdditionalCalendarProperties(array &$calendar, array $response)
     {
-        /*if (isset($response['{http://apple.com/ns/ical/}calendar-color']))
-            $calendar['color'] = $response['{http://apple.com/ns/ical/}calendar-color'];*/
+        if (isset($response['{http://apple.com/ns/ical/}calendar-color'])) {
+            $calendar['color'] = $response['{http://apple.com/ns/ical/}calendar-color'];
+            // cut off last two digits as this contains the alpha channel
+            if (strlen($calendar['color']) == 9) {
+                $calendar['color'] = substr($calendar['color'], 0, 7);
+            }
+        }
     }
     
     public function initCalendarImport()