Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Calendar / Frontend / ActiveSync.php
similarity index 97%
rename from tine20/ActiveSync/Controller/Calendar.php
rename to tine20/Calendar/Frontend/ActiveSync.php
index cd16392..50075c7 100644 (file)
@@ -2,20 +2,20 @@
 /**
  * Tine 2.0
  *
- * @package     ActiveSync
- * @subpackage  Controller
+ * @package     Calendar
+ * @subpackage  Frontend
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2014 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
 /**
- * controller events class
+ * ActiveSync frontend class
  * 
- * @package     ActiveSync
- * @subpackage  Controller
+ * @package     Calendar
+ * @subpackage  Frontend
  */
-class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract implements Syncroton_Data_IDataCalendar
+class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implements Syncroton_Data_IDataCalendar
 {
     /**
      * available filters
@@ -123,7 +123,7 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
         'endTime'           => 'dtend',
         'location'          => 'location',
         'reminder'          => 'alarms',
-        //'Sensitivity'       => 'class',
+        'sensitivity'       => 'class',
         'subject'           => 'summary',
         'body'              => 'description',
         'startTime'         => 'dtstart',
@@ -206,7 +206,7 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
 
     /**
      * (non-PHPdoc)
-     * @see ActiveSync_Controller_Abstract::__construct()
+     * @see ActiveSync_Frontend_Abstract::__construct()
      */
     public function __construct(Syncroton_Model_IDevice $_device, DateTime $_syncTimeStamp)
     {
@@ -250,7 +250,7 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
     
     /**
      * (non-PHPdoc)
-     * @see ActiveSync_Controller_Abstract::toSyncrotonModel()
+     * @see ActiveSync_Frontend_Abstract::toSyncrotonModel()
      * @todo handle BusyStatus
      */
     public function toSyncrotonModel($entry, array $options = array())
@@ -317,14 +317,19 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
                     
                     break;
                     
+                case 'class':
+                    $syncrotonEvent->$syncrotonProperty = $entry->$tine20Property == Calendar_Model_Event::CLASS_PRIVATE ? 2 : 0;
+                    
+                    break;
+                    
                 case 'description':
                     $syncrotonEvent->$syncrotonProperty = new Syncroton_Model_EmailBody(array(
                         'type' => Syncroton_Model_EmailBody::TYPE_PLAINTEXT,
                         'data' => $entry->$tine20Property
                     ));
-                
+                    
                     break;
-                
+                    
                 case 'dtend':
                     if($entry->$tine20Property instanceof DateTime) {
                         if ($entry->is_all_day_event == true) {
@@ -467,10 +472,9 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
             Tinebase_Core::get(Tinebase_Core::CACHE)
         );
         
-        $syncrotonEvent->timezone = $timeZoneConverter->encodeTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
+        $syncrotonEvent->timezone = $timeZoneConverter->encodeTimezone(Tinebase_Core::getUserTimezone());
         
         $syncrotonEvent->meetingStatus = 1;
-        $syncrotonEvent->sensitivity = 0;
         $syncrotonEvent->dtStamp = $entry->creation_time;
         $syncrotonEvent->uID = $entry->uid;
         
@@ -521,7 +525,7 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
     
     /**
      * (non-PHPdoc)
-     * @see ActiveSync_Controller_Abstract::toTineModel()
+     * @see ActiveSync_Frontend_Abstract::toTineModel()
      */
     public function toTineModel(Syncroton_Model_IEntry $data, $entry = null)
     {
@@ -612,7 +616,12 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
                     Calendar_Model_Attender::emailsToAttendee($event, $newAttendees);
                     
                     break;
-
+                    
+                case 'class':
+                    $event->$tine20Property = $data->$syncrotonProperty == 2 ? Calendar_Model_Event::CLASS_PRIVATE : Calendar_Model_Event::CLASS_PUBLIC;
+                    
+                    break;
+                    
                 case 'exdate':
                     // handle exceptions from recurrence
                     $exdates = new Tinebase_Record_RecordSet('Calendar_Model_Event');
@@ -748,12 +757,12 @@ class ActiveSync_Controller_Calendar extends ActiveSync_Controller_Abstract impl
             try {
                 $timezone = $timeZoneConverter->getTimezone(
                     $data->timezone,
-                    Tinebase_Core::get(Tinebase_Core::USERTIMEZONE)
+                    Tinebase_Core::getUserTimezone()
                 );
                 $event->originator_tz = $timezone;
             } catch (ActiveSync_TimezoneNotFoundException $e) {
                 Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . " timezone data not found " . $data->timezone);
-                $event->originator_tz = Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
+                $event->originator_tz = Tinebase_Core::getUserTimezone();
             }
         
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(