Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Calendar / Convert / Event / VCalendar / Abstract.php
index 32098c2..6cd11f0 100644 (file)
@@ -232,7 +232,7 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
             if ($event->is_all_day_event == true) {
                 $vevent->add('RRULE', preg_replace_callback('/UNTIL=([\d :-]{19})(?=;?)/', function($matches) {
                     $dtUntil = new Tinebase_DateTime($matches[1]);
-                    $dtUntil->setTimezone((string) Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
+                    $dtUntil->setTimezone((string) Tinebase_Core::getUserTimezone());
                     
                     return 'UNTIL=' . $dtUntil->format('Ymd');
                 }, $event->rrule));
@@ -862,7 +862,7 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
                         foreach ($vevent->EXDATE as $exdate) {
                             foreach ($exdate->getDateTimes() as $exception) {
                                 if (isset($exdate['VALUE']) && strtoupper($exdate['VALUE']) == 'DATE') {
-                                    $recurid = new Tinebase_DateTime($exception->format(Tinebase_Record_Abstract::ISO8601LONG), (string) Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
+                                    $recurid = new Tinebase_DateTime($exception->format(Tinebase_Record_Abstract::ISO8601LONG), (string) Tinebase_Core::getUserTimezone());
                                 } else {
                                     $recurid = new Tinebase_DateTime($exception->format(Tinebase_Record_Abstract::ISO8601LONG), $exception->getTimezone());
                                 }
@@ -979,11 +979,10 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
                     if ($readFromURL) {
                         if (preg_match('#^(https?://)(.*)$#', str_replace(array("\n","\r"), '', $url), $matches)) {
                             // we are client and found an external hosted attachment that we need to import
-                            $user = Tinebase_Core::getUser();
-                            $userCredentialCache = Tinebase_Core::get(Tinebase_Core::USERCREDENTIALCACHE);
+                            $userCredentialCache = Tinebase_Core::getUserCredentialCache();
                             $url = $matches[1] . $userCredentialCache->username . ':' . $userCredentialCache->password . '@' . $matches[2];
                             $attachmentInfo = $matches[1] . $matches[2]. ' ' . $name . ' ' . $managedId;
-                            if (urlExists($url)) {
+                            if (Tinebase_Helper::urlExists($url)) {
                                 if (Tinebase_Core::isLogLevel(Zend_Log::INFO))
                                     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
                                             . ' Downloading attachment: ' . $attachmentInfo);
@@ -1060,6 +1059,10 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
         $this->_manageAttachmentsFromClient($event, $attachments);
         
         if (empty($event->dtend)) {
+            if (empty($event->dtstart)) {
+                throw new Tinebase_Exception_UnexpectedValue("Got event without dtstart and dtend");
+            }
+            
             // TODO find out duration (see TRIGGER DURATION)
 //             if (isset($vevent->DURATION)) {
 //             }
@@ -1069,6 +1072,8 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
             $event->dtend->addMinute(30);
         }
         
+        $this->_manageAttachmentsFromClient($event, $attachments);
+        
         // convert all datetime fields to UTC
         $event->setTimezone('UTC');
     }
@@ -1083,7 +1088,7 @@ class Calendar_Convert_Event_VCalendar_Abstract extends Tinebase_Convert_VCalend
     static public function getUTCDateFromStringInUsertime($dateString)
     {
         if (strlen($dateString) < 10) {
-            $date = date_create($dateString, new DateTimeZone ((string) Tinebase_Core::get(Tinebase_Core::USERTIMEZONE)));
+            $date = date_create($dateString, new DateTimeZone ((string) Tinebase_Core::getUserTimezone()));
         } else {
             $date = date_create($dateString);
         }