Merge branch '2013.10' into 2014.09
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 7 Nov 2014 17:23:02 +0000 (18:23 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 7 Nov 2014 17:23:02 +0000 (18:23 +0100)
Conflicts:
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Frontend/ActiveSyncTest.php
tests/tine20/Calendar/Import/ICalTest.php
tine20/Tinebase/Controller.php
tine20/Tinebase/Setup/setup.xml
tine20/composer.lock

Change-Id: If7c2d333cb69ea66646008060267289d04bad013

16 files changed:
1  2 
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Controller/MSEventFacadeTest.php
tests/tine20/Calendar/Controller/ResourceTest.php
tests/tine20/Calendar/Frontend/ActiveSyncTest.php
tests/tine20/Calendar/Frontend/WebDAV/EventTest.php
tests/tine20/Calendar/Import/ICalTest.php
tine20/Calendar/Backend/Sql.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Frontend/Cli.php
tine20/Felamimail/Controller/Message/Send.php
tine20/Tinebase/Container.php
tine20/Tinebase/Controller.php
tine20/Tinebase/Core.php
tine20/Tinebase/Setup/Update/Release8.php
tine20/Tinebase/Setup/setup.xml
tine20/composer.lock

@@@ -314,7 -319,7 +314,7 @@@ class Calendar_Controller_EventTests ex
          }
      
          $filter = new Calendar_Model_EventFilter(array(
--                array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId()),
++                array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId()),
                  array('field' => 'attender'    , 'operator' => 'notin',  'value' => array(
                          array(
                                  'user_type' => Calendar_Model_Attender::USERTYPE_USER,
          
          $this->_controller->delete($persistentEvent->getId());
          
 -        $contentSeq = Tinebase_Container::getInstance()->getContentSequence($this->_testCalendar);
 +        $contentSeq = Tinebase_Container::getInstance()->getContentSequence($this->_getTestCalendar());
-         $this->assertEquals(2, $contentSeq, 'container content seq should be increased 2 times!');
+         $this->assertEquals(3, $contentSeq, 'container content seq should be increased 3 times!');
          
          $this->setExpectedException('Tinebase_Exception_NotFound');
          $this->_controller->get($persistentEvent->getId());
@@@ -38,47 -27,13 +27,41 @@@ class Calendar_Import_ICalTest extends 
      }
      
      /**
 +     * test simple import from file into a not existing container
 +     * 
 +     *  - the calendar should be created
 +     */
 +    public function testSimpleImportIntoNewContainer()
 +    {
 +        $importer = new Calendar_Import_Ical(array(
 +            'container_id' => 'unittest_not_existing',
 +        ));
 +
 +        $result = $importer->importFile(dirname(__FILE__) . '/files/simple.ics');
 +
 +        $importedContainerId = Tinebase_Container::getInstance()->getContainerByName(
 +                    'Calendar',
 +                    'unittest_not_existing',
 +                    Tinebase_Model_Container::TYPE_PERSONAL,
 +                    Tinebase_Core::getUser()->getId()
 +                )->getId();
 +
 +        $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(
 +            array('field' => 'container_id', 'operator' => 'equals', 'value' => $importedContainerId)
 +        )), NULL);
 +        
 +        $this->assertEquals($importedContainerId, Tinebase_Container::getInstance()->getContainerById($importedContainerId)->getId());
 +        $this->assertEquals(6, $events->count(), 'events was not imported');
 +    }
 +    
++    /**
+      * testImportSimpleFromFile
+      */
      public function testImportSimpleFromFile()
      {
-         $importer = new Calendar_Import_Ical(array(
-             'container_id' => $this->_getTestCalendar()->getId(),
-         ));
-         
-         $importer->importFile(dirname(__FILE__) . '/files/simple.ics');
-         $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(
-             array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId())
-         )), NULL);
+         $importEvents = $this->_importHelper('simple.ics', 6);
          
-         $this->assertEquals(6, $events->count(), 'events where not imported');
-         
-         $startbucks = $events->find('uid', '3632597');
+         $startbucks = $importEvents->find('uid', '3632597');
          $this->assertEquals('Calendar_Model_Event', get_class($startbucks));
          $this->assertEquals('2008-11-05 15:00:00', $startbucks->dtstart->format(Tinebase_Record_Abstract::ISO8601LONG));
      }
      protected function _checkImport($failMessage = '', $assertNumber = 1)
      {
          $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(
 -            array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId())
 +            array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId())
          )), NULL);
          
-         $this->assertEquals($assertNumber, $events->count(), 'events where not imported ' . $failMessage);
+         $this->assertEquals($assertNumber, $events->count(), 'Events were not imported ' . $failMessage);
      }
      
      /**
          }
      }
      
+     /**
+      * testImportOutlook12
+      */
      public function testImportOutlook12()
      {
+         $importEvents = $this->_importHelper('outlook12.ics');
+     }
+     
+     /**
+      * testImportExchange2007
+      */
+     public function testImportExchange2007()
+     {
+         $importEvents = $this->_importHelper('exchange2007_mail_anhang.ics');
+         $event = $importEvents->getFirstRecord();
+         $this->assertEquals('Blocker Wie bleibe ich gesund? Ernährung', $event->summary);
+     }
+     
+     /**
+      * import helper
+      * 
+      * @param string $filename
+      * @param integer $expectedNumber of imported events
+      * @param boolean $fromString
+      * @return Tinebase_Record_RecordSet
+      */
+     protected function _importHelper($filename, $expectedNumber = 1, $fromString = false)
+     {
          $importer = new Calendar_Import_Ical(array(
 -            'importContainerId' => $this->_testCalendar->getId(),
 +            'container_id' => $this->_getTestCalendar()->getId(),
          ));
          
-         $importer->importFile(dirname(__FILE__) . '/files/outlook12.ics');
+         if ($fromString) {
+             $icalData = file_get_contents(dirname(__FILE__) . '/files/' . $filename);
+             $importer->importData($icalData);
+         } else {
+             $importer->importFile(dirname(__FILE__) . '/files/' . $filename);
+         }
+         
          $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(
 -            array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_testCalendar->getId())
 +            array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getTestCalendar()->getId())
          )), NULL);
          
-         $this->assertEquals(1, $events->count(), 'events where not imported');
+         $this->assertEquals($expectedNumber, $events->count(), 'Events were not imported');
+         return $events;
      }
      
      /**
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -591,111 -616,4 +591,113 @@@ class Tinebase_Controller extends Tineb
                  break;
          }
      }
-         if (!$accessLog->getId()) {
 +    
 +    /**
 +     * set session for current request
 +     * 
 +     * @param Tinebase_Model_FullUser $user
 +     * @param Tinebase_Model_AccessLog $accessLog
 +     */
 +    protected function _setSessionId(Tinebase_Model_FullUser $user, Tinebase_Model_AccessLog &$accessLog)
 +    {
 +        if (in_array($accessLog->clienttype, array(Tinebase_Server_WebDAV::REQUEST_TYPE, ActiveSync_Server_Http::REQUEST_TYPE))) {
 +            try {
 +                $accessLog = Tinebase_AccessLog::getInstance()->getPreviousAccessLog($accessLog);
 +                // $accessLog->sessionid is set now
 +            } catch (Tinebase_Exception_NotFound $tenf) {
 +                // ignore
 +            }
 +        }
 +        
 +        if (!$accessLog->sessionid) {
 +            $accessLog->sessionid = Tinebase_Record_Abstract::generateUID();
 +        }
 +        
 +        Tinebase_Core::set(Tinebase_Core::SESSIONID, $accessLog->sessionid);
 +    }
 +    
 +    /**
 +     * update access log entry if needed
 +     * 
 +     * @param Tinebase_Model_FullUser $user
 +     * @param Tinebase_Model_AccessLog $accessLog
 +     */
 +    protected function _updateAccessLog(Tinebase_Model_FullUser $user, Tinebase_Model_AccessLog $accessLog)
 +    {
++        if (! $accessLog->getId()) {
 +            $user->setLoginTime($accessLog->ip);
 +            if ($this->_writeAccessLog) {
 +                $accessLog = Tinebase_AccessLog::getInstance()->create($accessLog);
 +            }
 +        }
++        
++        Tinebase_Core::set(Tinebase_Core::USERACCESSLOG, $accessLog);
 +    }
 +    
 +    /**
 +     * update credential cache
 +     * 
 +     * @param string $loginName
 +     * @param string $password
 +     */
 +    protected function _updateCredentialCache($loginName, $password)
 +    {
 +        $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($loginName, $password);
 +        Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
 +    }
 +    
 +    /**
 +     * validate is authentication was successful, user object is available and user is not expired
 +     * 
 +     * @param Zend_Auth_Result $authResult
 +     * @param Tinebase_Model_AccessLog $accessLog
 +     * @return boolean|Tinebase_Model_FullUser
 +     */
 +    protected function _validateAuthResult(Zend_Auth_Result $authResult, Tinebase_Model_AccessLog $accessLog)
 +    {
 +        // authentication failed
 +        if ($accessLog->result !== Tinebase_Auth::SUCCESS) {
 +            $this->_loginFailed($authResult, $accessLog);
 +            
 +            return false;
 +        }
 +        
 +        // try to retrieve user from accounts backend
 +        $user = $this->_getLoginUser($authResult->getIdentity(), $accessLog);
 +        
 +        if ($accessLog->result !== Tinebase_Auth::SUCCESS || !$user) {
 +            $this->_loginFailed($authResult, $accessLog);
 +            
 +            return false;
 +        }
 +        
 +        // check if user is expired or blocked
 +        $this->_checkUserStatus($user, $accessLog);
 +        
 +        if ($accessLog->result !== Tinebase_Auth::SUCCESS) {
 +            $this->_loginFailed($authResult, $accessLog);
 +            
 +            return false;
 +        }
 +        
 +        return $user;
 +    }
 +    
 +    /**
 +     * returns true if user account has been changed
 +     * 
 +     * @return boolean
 +     */
 +    public function userAccountChanged()
 +    {
 +        try {
 +            $session = Tinebase_Session::getSessionNamespace();
 +        } catch (Zend_Session_Exception $zse) {
 +            $session = null;
 +        }
 +        
 +        return ($session instanceof Zend_Session_Namespace && isset($session->userAccountChanged)) 
 +                ? $session->userAccountChanged
 +                : false;
 +    }
  }
Simple merge
@@@ -424,45 -254,25 +424,68 @@@ class Tinebase_Setup_Update_Release8 ex
      }
      
      /**
 -     * update 5 -> adds index for id column of table container_content
 +     * - add filter acl (check if table already exists)
 +     * 
 +     * @see 0009610: shared favorites acl
       */
 -    public function update_5()
 +    public function update_7()
 +    {
 +        $this->validateTableVersion('access_log', 4);
 +        
 +        $declaration = new Setup_Backend_Schema_Field_Xml('<field>
 +            <name>id</name>
 +            <type>text</type>
 +            <length>40</length>
 +            <notnull>true</notnull>
 +        </field>');
 +        
 +        $this->_backend->alterCol('access_log', $declaration);
 +        
 +        $declaration = new Setup_Backend_Schema_Field_Xml('<field>
 +            <name>user_agent</name>
 +            <type>text</type>
 +            <length>255</length>
 +        </field>');
 +        
 +        $this->_backend->addCol('access_log', $declaration);
 +        
 +        $declaration = new Setup_Backend_Schema_Index_Xml('<index>
 +            <name>account_id-ip</name>
 +            <field>
 +                <name>account_id</name>
 +            </field>
 +            <field>
 +                <name>ip</name>
 +            </field>
 +        </index>');
 +        
 +        $this->_backend->addIndex('access_log', $declaration);
 +        
 +        $this->setTableVersion('access_log', 5);
 +        
 +        $this->setApplicationVersion('Tinebase', '8.8');
 +    }
++    
++    /**
++     * update 8 -> adds index for id column of table container_content
++     */
++    public function update_8()
+     {
+         $declaration = new Setup_Backend_Schema_Index_Xml('
+             <index>
+                 <name>id</name>
+                 <field>
+                     <name>id</name>
+                 </field>
+             </index>
+         ');
+         try {
+             $this->_backend->addIndex('container_content', $declaration);
+         } catch (Zend_Db_Statement_Exception $zdse) {
+             Tinebase_Exception::log($zdse);
+         }
+         
+         $this->setTableVersion('container_content', '2');
 -        $this->setApplicationVersion('Tinebase', '8.6');
++        $this->setApplicationVersion('Tinebase', '8.9');
+     }
  }
@@@ -1,7 -1,7 +1,7 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <application>
      <name>Tinebase</name>
-     <version>8.8</version>
 -    <version>8.6</version>
++    <version>8.9</version>
      <tables>
          <table>
              <name>applications</name>
              ],
              "description": "Library to sync mobile phones",
              "homepage": "http://www.syncroton.org",
-             "time": "2013-10-23 14:05:40"
+             "time": "2014-11-07 12:52:57"
          },
          {
 +            "name": "zendframework/zend-escaper",
 +            "version": "2.2.4",
 +            "target-dir": "Zend/Escaper",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/zendframework/Component_ZendEscaper.git",
 +                "reference": "5db67b32359d86326077209f1fefbbf1183911e8"
 +            },
 +            "dist": {
 +                "type": "zip",
 +                "url": "https://api.github.com/repos/zendframework/Component_ZendEscaper/zipball/5db67b32359d86326077209f1fefbbf1183911e8",
 +                "reference": "5db67b32359d86326077209f1fefbbf1183911e8",
 +                "shasum": ""
 +            },
 +            "require": {
 +                "php": ">=5.3.3"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Escaper\\": ""
 +                }
 +            },
 +            "notification-url": "https://packagist.org/downloads/",
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "keywords": [
 +                "escaper",
 +                "zf2"
 +            ],
 +            "time": "2013-05-01 21:53:03"
 +        },
 +        {
 +            "name": "zendframework/zend-http",
 +            "version": "2.2.8-p2",
 +            "target-dir": "Zend/Http",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/lkneschke/Component_ZendHttp",
 +                "reference": "2d65788807272b60e0c0f0b20d92b8b2e4a1516f"
 +            },
 +            "require": {
 +                "php": ">=5.3.3",
 +                "zendframework/zend-loader": "2.2.*",
 +                "zendframework/zend-stdlib": "2.2.*",
 +                "zendframework/zend-uri": "2.2.*",
 +                "zendframework/zend-validator": "2.2.*"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Http\\": ""
 +                }
 +            },
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "description": "provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests",
 +            "keywords": [
 +                "http",
 +                "zf2"
 +            ],
 +            "time": "2014-10-29 08:18:58"
 +        },
 +        {
 +            "name": "zendframework/zend-loader",
 +            "version": "2.2.6",
 +            "target-dir": "Zend/Loader",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/zendframework/Component_ZendLoader.git",
 +                "reference": "27a9f770630839e36cd5705f3661b5ef9abf8793"
 +            },
 +            "dist": {
 +                "type": "zip",
 +                "url": "https://api.github.com/repos/zendframework/Component_ZendLoader/zipball/27a9f770630839e36cd5705f3661b5ef9abf8793",
 +                "reference": "27a9f770630839e36cd5705f3661b5ef9abf8793",
 +                "shasum": ""
 +            },
 +            "require": {
 +                "php": ">=5.3.3"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Loader\\": ""
 +                }
 +            },
 +            "notification-url": "https://packagist.org/downloads/",
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "keywords": [
 +                "loader",
 +                "zf2"
 +            ],
 +            "time": "2014-03-06 18:00:07"
 +        },
 +        {
 +            "name": "zendframework/zend-stdlib",
 +            "version": "2.2.4",
 +            "target-dir": "Zend/Stdlib",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/zendframework/Component_ZendStdlib.git",
 +                "reference": "7c87ce4e840957596bf3401fa4ae4fb0355682e2"
 +            },
 +            "dist": {
 +                "type": "zip",
 +                "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/7c87ce4e840957596bf3401fa4ae4fb0355682e2",
 +                "reference": "7c87ce4e840957596bf3401fa4ae4fb0355682e2",
 +                "shasum": ""
 +            },
 +            "require": {
 +                "php": ">=5.3.3"
 +            },
 +            "suggest": {
 +                "zendframework/zend-eventmanager": "To support aggregate hydrator usage",
 +                "zendframework/zend-servicemanager": "To support hydrator plugin manager usage"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Stdlib\\": ""
 +                }
 +            },
 +            "notification-url": "https://packagist.org/downloads/",
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "keywords": [
 +                "stdlib",
 +                "zf2"
 +            ],
 +            "time": "2013-08-21 17:08:07"
 +        },
 +        {
 +            "name": "zendframework/zend-uri",
 +            "version": "2.2.4",
 +            "target-dir": "Zend/Uri",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/zendframework/Component_ZendUri.git",
 +                "reference": "e2a4b038a0939d46e53bfa40cfc9f1791533ae84"
 +            },
 +            "dist": {
 +                "type": "zip",
 +                "url": "https://api.github.com/repos/zendframework/Component_ZendUri/zipball/e2a4b038a0939d46e53bfa40cfc9f1791533ae84",
 +                "reference": "e2a4b038a0939d46e53bfa40cfc9f1791533ae84",
 +                "shasum": ""
 +            },
 +            "require": {
 +                "php": ">=5.3.3",
 +                "zendframework/zend-escaper": "self.version",
 +                "zendframework/zend-validator": "self.version"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Uri\\": ""
 +                }
 +            },
 +            "notification-url": "https://packagist.org/downloads/",
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "description": "a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)",
 +            "keywords": [
 +                "uri",
 +                "zf2"
 +            ],
 +            "time": "2013-06-12 19:46:02"
 +        },
 +        {
 +            "name": "zendframework/zend-validator",
 +            "version": "2.2.4",
 +            "target-dir": "Zend/Validator",
 +            "source": {
 +                "type": "git",
 +                "url": "https://github.com/zendframework/Component_ZendValidator.git",
 +                "reference": "3aa2c87ee3d36763b30087b1188f42a6c95f414f"
 +            },
 +            "dist": {
 +                "type": "zip",
 +                "url": "https://api.github.com/repos/zendframework/Component_ZendValidator/zipball/3aa2c87ee3d36763b30087b1188f42a6c95f414f",
 +                "reference": "3aa2c87ee3d36763b30087b1188f42a6c95f414f",
 +                "shasum": ""
 +            },
 +            "require": {
 +                "php": ">=5.3.3",
 +                "zendframework/zend-stdlib": "self.version"
 +            },
 +            "require-dev": {
 +                "zendframework/zend-filter": "self.version",
 +                "zendframework/zend-i18n": "self.version",
 +                "zendframework/zend-math": "self.version",
 +                "zendframework/zend-servicemanager": "self.version"
 +            },
 +            "suggest": {
 +                "zendframework/zend-db": "Zend\\Db component",
 +                "zendframework/zend-filter": "Zend\\Filter component, required by the Digits validator",
 +                "zendframework/zend-i18n": "Zend\\I18n component to allow translation of validation error messages as well as to use the various Date validators",
 +                "zendframework/zend-math": "Zend\\Math component",
 +                "zendframework/zend-resources": "Translations of validator messages",
 +                "zendframework/zend-servicemanager": "Zend\\ServiceManager component to allow using the ValidatorPluginManager and validator chains"
 +            },
 +            "type": "library",
 +            "extra": {
 +                "branch-alias": {
 +                    "dev-master": "2.2-dev",
 +                    "dev-develop": "2.3-dev"
 +                }
 +            },
 +            "autoload": {
 +                "psr-0": {
 +                    "Zend\\Validator\\": ""
 +                }
 +            },
 +            "notification-url": "https://packagist.org/downloads/",
 +            "license": [
 +                "BSD-3-Clause"
 +            ],
 +            "description": "provides a set of commonly needed validators",
 +            "keywords": [
 +                "validator",
 +                "zf2"
 +            ],
 +            "time": "2013-08-21 17:07:51"
 +        },
 +        {
              "name": "zendframework/zendframework1",
              "version": "1.12.3",
              "source": {