Merge branch 'pu/2013.10-caldav'
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 12:40:38 +0000 (14:40 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 12:40:38 +0000 (14:40 +0200)
Conflicts:
tests/tine20/Calendar/Frontend/WebDAV/EventTest.php
tests/tine20/Calendar/Frontend/iMIPTest.php
tests/tine20/Calendar/Import/CalDAV/ClientMock.php
tests/tine20/Calendar/Import/CalDAVTest.php
tests/tine20/Calendar/JsonTests.php
tests/tine20/Calendar/Model/AttenderTests.php
tests/tine20/Calendar/TestCase.php
tests/tine20/Felamimail/Frontend/WebDAVTest.php
tine20/Calendar/Frontend/WebDAV/Container.php
tine20/Calendar/Import/CalDav/Client.php
tine20/Calendar/Model/Event.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Calendar/Setup/setup.xml
tine20/Tinebase/Container.php

Change-Id: Ic1fdac05e2ffb5cd300771639a905586bba90949

14 files changed:
1  2 
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Controller/MSEventFacadeTest.php
tests/tine20/Calendar/Frontend/WebDAV/EventTest.php
tests/tine20/Calendar/Frontend/iMIPTest.php
tests/tine20/Calendar/JsonTests.php
tests/tine20/Calendar/TestCase.php
tests/tine20/Phone/JsonTest.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Convert/Event/VCalendar/Abstract.php
tine20/Calendar/Frontend/WebDAV/Container.php
tine20/Calendar/Model/Event.php
tine20/Calendar/Setup/Update/Release8.php
tine20/Calendar/Setup/setup.xml
tine20/Tinebase/Container.php

@@@ -572,10 -568,9 +572,10 @@@ class Calendar_JsonTests extends Calend
          
          // create persistent exception
          $createdException = $this->_uit->createRecurException($persistentException, FALSE, FALSE);
-         Tinebase_Core::set(Tinebase_Core::USER, $unittestUser);
+         Tinebase_Core::set(Tinebase_Core::USER, $this->_originalTestUser);
          
          $sclever = $this->_findAttender($createdException['attendee'], 'sclever');
 +        $defaultCal = $this->_getPersonasDefaultCals('sclever');
          $this->assertEquals('Susan Clever', $sclever['user_id']['n_fn']);
          $this->assertEquals(Calendar_Model_Attender::STATUS_ACCEPTED, $sclever['status'], 'status mismatch: ' . print_r($sclever, TRUE));
          $this->assertTrue(is_array($sclever['displaycontainer_id']));
@@@ -28,17 -28,12 +28,12 @@@ abstract class Calendar_TestCase extend
      /**
       * @var Tinebase_Record_RecordSet test calendars to be deleted on tearDown
       */
 -    protected $_testCalendars;
 +    protected $_testCalendars = NULL;
      
      /**
-      * @var Tinebase_Model_FullUser
-      */
-     protected $_testUser = NULL;
-     
-     /**
       * @var Addressbook_Model_Contact
       */
 -    protected $_testUserContact;
 +    protected $_testUserContact = NULL;
      
      /**
       * personas
                  Tinebase_Container::getInstance()->deleteContainer($cal, true);
              }
          }
-         if ($this->_testUser->getId() !== Tinebase_Core::getUser()->getId()) {
-             // reset test user
-             Tinebase_Core::set(Tinebase_Core::USER, $this->_testUser);
-         }
-         
-         // do NOT unset _testUser,the tear down of Calendar_Frontend_WebDAV_EventTest still requires _testUser
 +        
-         return $this->_testUser;
 +        $this->_testUserContact = NULL;
 +        $this->_testCalendar = NULL;
 +        $this->_testCalendars = NULL;
 +        $this->_personas = NULL;
 +        $this->_personasContacts = array();
 +        $this->_personasDefaultCals = array();
 +    }
 +    
 +    /**
 +     * returns test persons contacts
 +     * 
 +     * @param string $loginName
 +     * @return Addressbook_Model_Contact
 +     */
 +    protected function _getPersonasContacts($loginName)
 +    {
 +        if (!isset($this->_personasContacts[$loginName])) {
 +            $user = $this->_getPersona($loginName);
 +            $this->_personasContacts[$loginName] = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId());
 +        }
 +        return $this->_personasContacts[$loginName];
 +    }
 +    
 +    /**
 +     * returns test persons default calendar
 +     * 
 +     * @param string $loginName
 +     * @return Tinebase_Model_Container
 +     */
 +    protected function _getPersonasDefaultCals($loginName)
 +    {
 +        if (!isset($this->_personasDefaultCals[$loginName])) {
 +            $user = $this->_getPersona($loginName);
 +            $defaultCalendarId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $user->getId());
 +            $this->_personasDefaultCals[$loginName] = Tinebase_Container::getInstance()->getContainerById($defaultCalendarId);
 +        }
 +        return $this->_personasDefaultCals[$loginName];
 +    }
 +    
 +    /**
 +     * returns all test persons default calendar
 +     * 
 +     * @return array
 +     */
 +    protected function _getAllPersonasDefaultCals()
 +    {
 +        foreach ($this->_getPersonas() as $loginName => $user)
 +        {
 +            $this->_getPersonasDefaultCals($loginName);
 +        }
 +        return $this->_personasDefaultCals;
 +    }
 +    
 +    /** return a test person
 +     * @return 
 +     */
 +    protected function _getPersona($loginName)
 +    {
 +        if ($this->_personas === NULL) {
 +            $this->_getPersonas();
 +        }
 +        return $this->_personas[$loginName];
 +    }
 +    
 +    /**
 +     * returns an array of test persons
 +     * 
 +     * @return array
 +     */
 +    protected function _getPersonas()
 +    {
 +        if ($this->_personas === NULL) {
 +            $this->_personas = Zend_Registry::get('personas');
 +        }
 +        return $this->_personas;
 +    }
 +    
 +    /**
 +     * returns a test user
 +     * 
 +     * @return Tinebase_Model_FullUser
 +     */
 +    protected function _getTestUser()
 +    {
++        return $this->_originalTestUser;
 +    }
 +    
 +    /**
 +     * returns the test users contact
 +     * 
 +     * @return
 +     */
 +    protected function _getTestUserContact()
 +    {
 +        if ($this->_testUserContact === NULL) {
 +            $this->_testUserContact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($this->_getTestUser()->getId());
 +        }
 +        return $this->_testUserContact;
 +    }
 +    /**
 +     * returns a test calendar set
 +     * 
 +     * @return Tinebase_Record_RecordSet\r
 +     */
 +    protected function _getTestCalendars()
 +    {
 +        if ($this->_testCalendars === NULL) {
 +            $this->_getTestCalendar();
 +        }
 +        return $this->_testCalendars;
 +    }
 +    /**
 +     * returns a test calendar
 +     * 
 +     * @return Tinebase_Model_Container
 +     */
 +    protected function _getTestCalendar()
 +    {
 +        if ($this->_testCalendar === NULL) {
 +            $this->_testCalendar = $this->_getTestContainer('Calendar');
 +            
 +            $this->_testCalendars = new Tinebase_Record_RecordSet('Tinebase_Model_Container');
 +            $this->_testCalendars->addRecord($this->_testCalendar);
 +        }
 +        return $this->_testCalendar;
      }
      
      /**
Simple merge
Simple merge
Simple merge
@@@ -191,13 -190,25 +191,35 @@@ class Calendar_Setup_Update_Release8 ex
          $this->setTableVersion('cal_events', 7);
          $this->setApplicationVersion('Calendar', '8.4');
      }
 -    public function update_4()
 +    
 +    /**
 +     * - update import / export
 +     */
 +    public function update_4()
 +    {
 +        Setup_Controller::getInstance()->createImportExportDefinitions(Tinebase_Application::getInstance()->getApplicationByName('Calendar'));
++        $this->setTableVersion('cal_events', 7);
 +        $this->setApplicationVersion('Calendar', '8.5');
 +    }
+     /**
+      * adds external_seq col
+      * 
+      * @see 0009890: improve external event invitation support
+      */
 -        $this->setApplicationVersion('Calendar', '8.5');
++    public function update_6()
+     {
+         $seqCol = '<field>
+             <name>external_seq</name>
+             <type>integer</type>
+             <notnull>true</notnull>
+             <default>0</default>
+         </field>';
+         
+         $declaration = new Setup_Backend_Schema_Field_Xml($seqCol);
+         $this->_backend->addCol('cal_events', $declaration);
+         
+         $this->setTableVersion('cal_events', 8);
++        $this->setApplicationVersion('Calendar', '8.6');
+     }
  }
@@@ -2,7 -2,7 +2,7 @@@
  <application>
      <name>Calendar</name>
      <!-- gettext('Calendar') -->   
--    <version>8.5</version>
++    <version>8.6</version>
      <order>15</order>
      <status>enabled</status>
      <tables>
@@@ -482,12 -478,9 +482,12 @@@ class Tinebase_Container extends Tineba
       * @throws  Tinebase_Exception_NotFound
       * @throws  Tinebase_Exception_UnexpectedValue
       */
 -    public function getContainerByName($appName, $containerName, $type, $ownerId = NULL)
 +    public function getContainerByName($recordClass, $containerName, $type, $ownerId = NULL)
      {
-         if ($type !== Tinebase_Model_Container::TYPE_PERSONAL && $type !== Tinebase_Model_Container::TYPE_SHARED) {
 +        // legacy handling
 +        $meta = $this->_resolveRecordClassArgument($recordClass);
 +        
+         if (! in_array($type, array(Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Model_Container::TYPE_SHARED))) {
              throw new Tinebase_Exception_UnexpectedValue ("Invalid type $type supplied.");
          }