0011942: MacOSX - GROUP rewrite to INTELLIGROUP
authorPaul Mehrer <p.mehrer@metaways.de>
Thu, 2 Jun 2016 10:33:16 +0000 (12:33 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 16 Jun 2016 08:41:22 +0000 (10:41 +0200)
rewrite attendee cutype 'GROUP' to 'INTELLIGROUP' for export
and vice versa for import due to malbehaviour of ical

https://forge.tine20.org/view.php?id=11942

Change-Id: I83651323a682dae2688a9b34508cbd366bb906eb
Reviewed-on: http://gerrit.tine20.com/customers/3187
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Convert/Event/VCalendar/MacOSX.php

index 4a3e99d..353e84d 100644 (file)
@@ -23,6 +23,8 @@ class Calendar_Convert_Event_VCalendar_MacOSX extends Calendar_Convert_Event_VCa
     // Mac_OS_X/10.9 (13A603) CalendarAgent/174
     // Mac+OS+X/10.10 (14A389) CalendarAgent/315"
     const HEADER_MATCH = '/(?J)((CalendarStore.*Mac OS X\/(?P<version>\S+) )|(^Mac[ _+]OS[ _+]X\/(?P<version>\S+).*CalendarAgent))/';
+
+    const INTELLIGROUP = 'INTELLIGROUP';
     
     protected $_supportedFields = array(
         'seq',
@@ -45,7 +47,28 @@ class Calendar_Convert_Event_VCalendar_MacOSX extends Calendar_Convert_Event_VCa
         #'rrule_until',
         'originator_tz',
     );
-    
+
+    /**
+     * convert Tinebase_Record_RecordSet to Sabre\VObject\Component
+     *
+     * @param  Tinebase_Record_RecordSet  $_records
+     * @return Sabre\VObject\Component
+     */
+    public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records)
+    {
+        $oldGroupValue = static::$cutypeMap[Calendar_Model_Attender::USERTYPE_GROUP];
+
+        // rewrite GROUP TO INTELLIGROUP
+        static::$cutypeMap[Calendar_Model_Attender::USERTYPE_GROUP] = self::INTELLIGROUP;
+
+        $result = parent::fromTine20RecordSet($_records);
+
+        // restore old value
+        static::$cutypeMap[Calendar_Model_Attender::USERTYPE_GROUP] = $oldGroupValue;
+
+        return $result;
+    }
+
     /**
      * get attendee array for given contact
      * 
@@ -70,6 +93,11 @@ class Calendar_Convert_Event_VCalendar_MacOSX extends Calendar_Convert_Event_VCa
                 return NULL;
             }
         }
+
+        // rewrite INTELLIGROUP TO GROUP
+        if (self::INTELLIGROUP === $newAttendee['userType']) {
+            $newAttendee['userType'] = static::$cutypeMap[Calendar_Model_Attender::USERTYPE_GROUP];
+        }
         
         return $newAttendee;
     }