fixes long event locations found in VEVENTS
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 7 Aug 2014 19:47:12 +0000 (21:47 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:39 +0000 (11:26 +0200)
Change-Id: I5e3305f9ab758283c4c7f594e18f2f2edea3eb04
Reviewed-on: http://gerrit.tine20.com/customers/949
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Convert/Event/VCalendar/GenericTest.php
tests/tine20/Calendar/Import/files/iphone_longlocation.ics [new file with mode: 0644]
tine20/Calendar/Convert/Event/VCalendar/Abstract.php

index 072f507..f94f2cf 100644 (file)
@@ -672,7 +672,7 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
         $this->assertEquals(1, $savedEvent->rrule->bymonthday, print_r($savedEvent->toArray(), true));
         $this->assertTrue(! isset($savedEvent->rrule->byday), print_r($savedEvent->toArray(), true));
     }
-
+    
     /**
      * testLongSummary
      * 
@@ -685,4 +685,15 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
         $this->assertEquals('Finanz-IT anrufen, xxxxxxxxxxxh', $savedEvent->summary, print_r($savedEvent->toArray(), true));
         $this->assertContains("Finanz-IT anrufen, xxxxxxxxxxxh\nFestgelegt für 25. Juli 2012", $savedEvent->description, print_r($savedEvent->toArray(), true));
     }
+    
+    /**
+     * testLongLocation
+     */
+    public function testLongLocation()
+    {
+        $savedEvent = $this->_saveIcsEvent('iphone_longlocation.ics');
+        
+        $this->assertContains('1. Rufen Sie folgende Seite auf: https://xxxxxxxxxxxxxx.webex.', $savedEvent->location, print_r($savedEvent->toArray(), true));
+        $this->assertContains("und Ihre E-Mail-Adresse ein.; geben Sie das Meeting-Passwort ein: xxxx", $savedEvent->description, print_r($savedEvent->toArray(), true));
+    }
 }
diff --git a/tests/tine20/Calendar/Import/files/iphone_longlocation.ics b/tests/tine20/Calendar/Import/files/iphone_longlocation.ics
new file mode 100644 (file)
index 0000000..b2ba7c0
--- /dev/null
@@ -0,0 +1,35 @@
+BEGIN:VCALENDAR
+CALSCALE:GREGORIAN
+PRODID:-//Apple Inc.//iCal 3.0m//EN
+VERSION:2.0
+BEGIN:VTIMEZONE
+TZID:Europe/Berlin
+BEGIN:DAYLIGHT
+DTSTART:19810329T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
+TZNAME:CEST
+TZOFFSETFROM:+0100
+TZOFFSETTO:+0200
+END:DAYLIGHT
+BEGIN:STANDARD
+DTSTART:19961027T030000
+RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
+TZNAME:CET
+TZOFFSETFROM:+0200
+TZOFFSETTO:+0100
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTEND;TZID=Europe/Berlin:20111020T100000
+DTSTAMP:20111020T064721Z
+DTSTART;TZID=Europe/Berlin:20111020T090000
+LOCATION:1. Rufen Sie folgende Seite auf: https://xxxxxxxxxxxxxx.webex.
+ xxxxxxxxxxxxxxxxxxx/j.php?ED=180021367&UID=1242xxxxxx&PW=xxxxxxxxxxxxxxx
+ T=OCMyMg%3D%3D\; 2. Falls erforderlich\; 3. Falls ein Passwort erforderl
+ ich ist\; 4. Klicken Sie auf "Teilnehmen".\; geben Sie bitte Ihren Namen
+  und Ihre E-Mail-Adresse ein.\; geben Sie das Meeting-Passwort ein: xxxx
+SEQUENCE:0
+SUMMARY:Finanz-IT anrufen
+UID:631C01AB-0FE0-4E37-B774-56F05DDAD1E6
+END:VEVENT
+END:VCALENDAR
\ No newline at end of file
index f31d714..8b00433 100644 (file)
@@ -852,9 +852,12 @@ class Calendar_Convert_Event_VCalendar_Abstract implements Tinebase_Convert_Inte
                     $value = $property->getValue();
                     switch ($key) {
                         case 'summary':
+                        case 'location':
                             if (strlen($value) > 255) {
                                 $shortenedFields[$key] = $value;
-                                $endPos = strpos($value, "\n") < 255 ? strpos($value, "\n") : 255;
+                                $endPos = strpos($value, "\n") !== false && strpos($value, "\n") < 255 
+                                    ? strpos($value, "\n") 
+                                    : 255;
                                 $value = substr($value, 0, $endPos);
                             }
                             break;