Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Jan 2016 14:29:37 +0000 (15:29 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 20 Jan 2016 14:29:37 +0000 (15:29 +0100)
Conflicts:
tests/tine20/Calendar/Controller/RecurTest.php
tine20/Calendar/Setup/setup.xml

Change-Id: I2ba9af2c9b5d45b7df8814b4afd87ce26462b839

tests/tine20/Calendar/Controller/RecurTest.php
tests/tine20/Calendar/Frontend/ActiveSyncTest.php
tine20/ActiveSync/Controller.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Frontend/ActiveSync.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Calendar/Setup/setup.xml

index fae9c83..e6bea9a 100644 (file)
@@ -466,7 +466,7 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
             'dtstart'       => '2011-04-21 10:00:00',
             'dtend'         => '2011-04-21 12:00:00',
             'originator_tz' => 'Europe/Berlin',
-            'rrule'         => 'FREQ=DAILY;INTERVAL=1;UNTIL=2011-04-27 21:59:59',
+            'rrule'         => 'FREQ=DAILY;INTERVAL=1;UNTIL=2011-04-28 21:59:59',
             'container_id'  => $this->_getTestCalendar()->getId()
         ));
         
@@ -479,6 +479,9 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
         $recurSet->summary = 'Limo bei Schweinske';
         $recurSet[5]->dtstart->addHour(2);
         $recurSet[5]->dtend->addHour(2);
+
+        $recurSet[6]->dtstart->subDay(6);
+        $recurSet[6]->dtend->subDay(6);
         
         $this->_controller->createRecurException($recurSet[1], TRUE);  // (23) delete instance
         
@@ -493,6 +496,10 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
         $updatedBaseEvent = $this->_controller->getRecurBaseEvent($recurSet[5]);
         $recurSet[5]->last_modified_time = $updatedBaseEvent->last_modified_time;
         $this->_controller->createRecurException($recurSet[5], FALSE); // (27) move instance
+
+        $updatedBaseEvent = $this->_controller->getRecurBaseEvent($recurSet[6]);
+        $recurSet[6]->last_modified_time = $updatedBaseEvent->last_modified_time;
+        $this->_controller->createRecurException($recurSet[6], FALSE); // (28) move instance to 22
         
         // now test update allfollowing
         $recurSet[3]->summary = 'Spezi bei Schwinske';
@@ -501,7 +508,7 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
         
         $updatedBaseEvent = $this->_controller->getRecurBaseEvent($recurSet[3]);
         $recurSet[3]->last_modified_time = $updatedBaseEvent->last_modified_time;
-        $newBaseEvent = $this->_controller->createRecurException($recurSet[3], FALSE, TRUE);
+        $newBaseEvent = $this->_controller->createRecurException($recurSet[3], FALSE, TRUE); // split at 25
         
         $events = $this->_controller->search(new Calendar_Model_EventFilter(array(
             array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId()),
@@ -509,18 +516,18 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
         ))));
         
         Calendar_Model_Rrule::mergeRecurrenceSet($events, $from, $until);
-        $this->assertEquals(6, count($events), 'there should be exactly 6 events');
+        $this->assertEquals(7, count($events), 'there should be exactly 6 events');
         
         $oldSeries = $events->filter('uid', $persistentEvent->uid);
         $newSeries = $events->filter('uid', $newBaseEvent->uid);
         $this->assertEquals(3, count($oldSeries), 'there should be exactly 3 events with old uid');
-        $this->assertEquals(3, count($newSeries), 'there should be exactly 3 events with new uid');
+        $this->assertEquals(4, count($newSeries), 'there should be exactly 3 events with new uid');
         
         $this->assertEquals(1, count($oldSeries->filter('recurid', "/^$/", TRUE)), 'there should be exactly one old base event');
         $this->assertEquals(1, count($newSeries->filter('recurid', "/^$/", TRUE)), 'there should be exactly one new base event');
         
         $this->assertEquals(1, count($oldSeries->filter('recurid', "/^.+/", TRUE)->filter('rrule', '/^$/', TRUE)), 'there should be exactly one old persitent event exception');
-        $this->assertEquals(1, count($newSeries->filter('recurid', "/^.+/", TRUE)->filter('rrule', '/^$/', TRUE)), 'there should be exactly one new persitent event exception');
+        $this->assertEquals(2, count($newSeries->filter('recurid', "/^.+/", TRUE)->filter('rrule', '/^$/', TRUE)), 'there should be exactly one new persitent event exception');
         
         $this->assertEquals(1, count($oldSeries->filter('id', "/^fake.*/", TRUE)), 'there should be exactly one old fake event');
         $this->assertEquals(1, count($newSeries->filter('id', "/^fake.*/", TRUE)), 'there should be exactly one new fake event'); //26 (reset)
@@ -535,6 +542,7 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
         
         $this->assertFalse(!!array_diff($newBaseEvent->exdate, array(
             new Tinebase_DateTime('2011-04-27 14:00:00'),
+            new Tinebase_DateTime('2011-04-28 14:00:00'),
         )), 'exdate of new series');
         
         $this->assertFalse(!!array_diff($oldSeries->dtstart, array(
@@ -542,11 +550,12 @@ class Calendar_Controller_RecurTest extends Calendar_TestCase
             new Tinebase_DateTime('2011-04-22 10:00:00'),
             new Tinebase_DateTime('2011-04-24 10:00:00'),
         )), 'dtstart of old series');
-        
+
         $this->assertFalse(!!array_diff($newSeries->dtstart, array(
             new Tinebase_DateTime('2011-04-25 14:00:00'),
             new Tinebase_DateTime('2011-04-26 14:00:00'),
             new Tinebase_DateTime('2011-04-27 12:00:00'),
+            new Tinebase_DateTime('2011-04-22 10:00:00'),
         )), 'dtstart of new series');
     }
 
index 1a38e8d..8ea740a 100644 (file)
@@ -1251,7 +1251,7 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMA
 
         // assert attendee are preserved
         $updatedEvent = Calendar_Controller_MSEventFacade::getInstance()->get($serverId);
-        $this->assertNotEmpty($updatedEvent->attendee, 'attendee must be preserved during update');
+        $this->assertNotEmpty($updatedEvent, 'attendee must be preserved during update');
     }
 
     /**
@@ -1259,9 +1259,6 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMA
      *
      * for iOS devices we need to suppress attendee during sync for non default folder (see foldertype in foldersync)
      * iOS can only have one default folder
-     *
-     * NOTE: our implementation in not correct at the moment as we only append attendee if the event is in the default folder.
-     *       correct implementation would be to append attendee when default folder is synced
      */
     public function testUpdateEntriesIPhoneNonDefaultFolder()
     {
@@ -1294,7 +1291,6 @@ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMA
         $this->assertEquals($syncrotonEventtoUpdate->exceptions[0]->startTime->toString(), $updatedSyncrotonEvent->exceptions[0]->startTime->toString());
 
         // assert attendee are preserved
-        $updatedEvent = Calendar_Controller_MSEventFacade::getInstance()->get($serverId);
-        $this->assertNotEmpty($updatedEvent->attendee, 'attendee must be preserved during update');
+        $this->assertNotEmpty($updatedSyncrotonEvent->attendees, 'attendee must be preserved during update');
     }
 }
index 8656613..5bc7343 100644 (file)
@@ -55,20 +55,27 @@ class ActiveSync_Controller extends Tinebase_Controller_Abstract
     /**
      * reset sync for user
      *
-     * @param string $username
+     * @param mixed $user
      * @param array $classesToReset
      * @return boolean
      */
-    public function resetSyncForUser($username, $classesToReset)
+    public function resetSyncForUser($user, $classesToReset)
     {
+
+        if (! $user instanceof Tinebase_Model_User) {
+            try {
+                $user = Tinebase_User::getInstance()->getFullUserById($user);
+            } catch (Tinebase_Exception_NotFound $tenf) {
+                $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $user);
+            }
+        }
+
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
-                . ' Resetting sync for user ' . $username . ' collections: ' . print_r($classesToReset, true));
-        
-        $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $username);
-        
+            . ' Resetting sync for user ' . $user->accountDisplayName . ' collections: ' . print_r($classesToReset, true));
+
         self::initSyncrotonRegistry();
         
-        $devices = $this->_getDevicesForUser($user);
+        $devices = $this->_getDevicesForUser($user->getId());
         
         foreach ($devices as $device) {
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
@@ -92,13 +99,13 @@ class ActiveSync_Controller extends Tinebase_Controller_Abstract
     /**
      * fetch devices for user
      * 
-     * @param Tinebase_Model_FullUser $user
+     * @param string $userId
      */
-    protected function _getDevicesForUser($user)
+    protected function _getDevicesForUser($userId)
     {
         $deviceBackend = new ActiveSync_Backend_Device();
         $deviceFilter = new ActiveSync_Model_DeviceFilter(array(
-            array('field' => 'owner_id', 'operator' => 'equals', 'value' => $user->getId())
+            array('field' => 'owner_id', 'operator' => 'equals', 'value' => $userId)
         ));
         $devices = $deviceBackend->search($deviceFilter);
         return $devices;
index 2ac6d09..beb3e54 100644 (file)
@@ -1049,7 +1049,9 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
             $pastPersistentExceptionEvents = new Tinebase_Record_RecordSet('Calendar_Model_Event');
             $futurePersistentExceptionEvents = new Tinebase_Record_RecordSet('Calendar_Model_Event');
             foreach ($persistentExceptionEvents as $persistentExceptionEvent) {
-                $persistentExceptionEvent->dtstart->isLater($_event->dtstart) ? $futurePersistentExceptionEvents->addRecord($persistentExceptionEvent) : $pastPersistentExceptionEvents->addRecord($persistentExceptionEvent);
+                $persistentExceptionEvent->getOriginalDtStart()->isLater($_event->dtstart) ?
+                    $futurePersistentExceptionEvents->addRecord($persistentExceptionEvent) :
+                    $pastPersistentExceptionEvents->addRecord($persistentExceptionEvent);
             }
             
             // update baseEvent
index b3a48f1..50075c7 100644 (file)
@@ -196,7 +196,14 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
         'samsunggtn7000', // Samsung Galaxy Note 
         'samsunggti9300', // Samsung Galaxy S-3
     );
-    
+
+    /**
+     * folder id which is currenttly synced
+     *
+     * @var string
+     */
+    protected $_syncFolderId = null;
+
     /**
      * (non-PHPdoc)
      * @see ActiveSync_Frontend_Abstract::__construct()
@@ -277,7 +284,7 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
                     
                 case 'attendee':
                     if ($this->_device->devicetype === Syncroton_Model_Device::TYPE_IPHONE &&
-                        $entry->container_id       !== $this->_getDefaultContainerId()) {
+                        $this->_syncFolderId       !== $this->_getDefaultContainerId()) {
                         
                         continue;
                     }
@@ -549,7 +556,7 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
                 } else {
                     if ($tine20Property === 'attendee' && $entry &&
                         $this->_device->devicetype === Syncroton_Model_Device::TYPE_IPHONE &&
-                        $entry->container_id       !== $this->_getDefaultContainerId()) {
+                        $this->_syncFolderId       !== $this->_getDefaultContainerId()) {
                             // keep attendees as the are / they were not sent to the device before
                     } else {
                         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(
@@ -569,7 +576,7 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
                 case 'attendee':
                     if ($entry && 
                         $this->_device->devicetype === Syncroton_Model_Device::TYPE_IPHONE &&
-                        $entry->container_id       !== $this->_getDefaultContainerId()) {
+                        $this->_syncFolderId       !== $this->_getDefaultContainerId()) {
                             // keep attendees as the are / they were not sent to the device before
                             continue;
                     }
@@ -1037,6 +1044,8 @@ class Calendar_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implemen
             $containerId = Tinebase_Core::getPreference('ActiveSync')->{$this->_defaultFolder};
             $container = Tinebase_Container::getInstance()->getContainerById($containerId);
         }
+
+        $this->_syncFolderId = $container->getId();
         Calendar_Controller_MSEventFacade::getInstance()->assertEventFacadeParams($container, false);
     }
 }
index 519afaa..9611bc9 100644 (file)
@@ -450,4 +450,22 @@ class Calendar_Setup_Update_Release8 extends Setup_Update_Abstract
         $this->setTableVersion('cal_events', 11);
         $this->setApplicationVersion('Calendar', '8.10');
     }
+
+    /**
+     * force activesync calendar resync for iOS devices
+     */
+    public function update_10()
+    {
+        $deviceBackend = new ActiveSync_Backend_Device();
+        $usersWithiPhones = $deviceBackend->search(new ActiveSync_Model_DeviceFilter(array(
+            'devicetype' => 'iphone'
+        )), NULL, 'owner_id');
+
+        $activeSyncController = ActiveSync_Controller::getInstance();
+        foreach($usersWithiPhones as $userId) {
+            $activeSyncController->resetSyncForUser($userId, 'Calendar');
+        }
+
+        $this->setApplicationVersion('Calendar', '8.11');
+    }
 }
index c130c56..aea1dd7 100644 (file)
@@ -2,7 +2,7 @@
 <application>
     <name>Calendar</name>
     <!-- gettext('Calendar') -->   
-    <version>8.10</version>
+    <version>8.11</version>
     <order>15</order>
     <status>enabled</status>
     <tables>