Merge branch '2015.11-develop' into 2016.11
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 15 Sep 2016 08:14:39 +0000 (10:14 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 15 Sep 2016 08:14:39 +0000 (10:14 +0200)
15 files changed:
tests/tine20/Filemanager/Frontend/WebDAVTest.php
tests/tine20/Tinebase/ConfigTest.php
tests/tine20/Tinebase/WebDav/Plugin/OwnCloudTest.php
tests/tine20/Tinebase/WebDav/RootTest.php
tine20/Addressbook/Model/Contact.php
tine20/Filemanager/Frontend/Download.php
tine20/Filemanager/views/file.phtml
tine20/Filemanager/views/folder.phtml
tine20/Filemanager/views/notfound.phtml
tine20/Tinebase/Config.php
tine20/Tinebase/Timemachine/ModificationLog.php
tine20/Tinebase/User.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php
tine20/Tinebase/js/MainScreen.js
tine20/composer.lock

index 27fb478..e67e93c 100644 (file)
@@ -21,7 +21,16 @@ class Filemanager_Frontend_WebDAVTest extends TestCase
      * @var Sabre\DAV\ObjectTree
      */
     protected $_webdavTree;
-    
+
+    /**
+     * tear down tests
+     */
+    protected function tearDown()
+    {
+        parent::tearDown();
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, false);
+    }
+
     /**
      * testgetNodeForPath
      */
@@ -237,6 +246,24 @@ class Filemanager_Frontend_WebDAVTest extends TestCase
         $savedMTime = new Tinebase_DateTime($node->getLastModified());
         $this->assertEquals($mtime, $savedMTime, 'X_OC_MTIME not saved');
     }
+    
+    public function testgetNodeForPath_webdav_filemanager_currentuser2()
+    {
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, true);
+        $node = $this->_getWebDAVTree()->getNodeForPath('/webdav/Filemanager/' . Tinebase_Core::getUser()->accountLoginName);
+    
+        $this->assertInstanceOf('Filemanager_Frontend_WebDAV', $node, 'wrong node class');
+        $this->assertEquals(Tinebase_Core::getUser()->accountLoginName, $node->getName());
+    
+        $children = $node->getChildren();
+    
+        $this->assertGreaterThanOrEqual(1, count($children));
+        $this->assertInstanceOf('Filemanager_Frontend_WebDAV_Container', $children[0], 'wrong node class');
+    
+        $this->setExpectedException('Sabre\DAV\Exception\Forbidden');
+    
+        $this->_getWebDAVTree()->delete('/webdav/Filemanager/' . Tinebase_Core::getUser()->accountLoginName);
+    }
 
     /**
      * test chunked upload from OwnCloud clients
index 425f5d5..4d62347 100644 (file)
@@ -20,6 +20,7 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
 {
     /**
      * unit under test (UIT)
+     *
      * @var Tinebase_Config
      */
     protected $_instance;
@@ -30,7 +31,7 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     protected $objects = array();
 
     protected $_filenamesToDelete = array();
-    
+
     /**
      * Sets up the fixture.
      * This method is called before a test is executed.
@@ -56,16 +57,16 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
 
         Tinebase_Config::getInstance()->clearCache();
     }
-    
+
     /**
      * test instance retrival
-     * 
+     *
      */
     public function testConfigInstance()
     {
         $this->assertTrue($this->_instance === Tinebase_Core::getConfig(), 'Tinebase_Core::getConfig() is wrong instance');
     }
-    
+
     /**
      * test basic config getting/setting/deleting cycle
      */
@@ -73,14 +74,14 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     {
         $this->_instance->set(Tinebase_Config::PAGETITLEPOSTFIX, 'phpunit');
         $this->assertEquals('phpunit', $this->_instance->{Tinebase_Config::PAGETITLEPOSTFIX}, 'could not set config');
-        
+
         $this->_instance->delete(Tinebase_Config::PAGETITLEPOSTFIX, 'phpunit');
-        
+
         $this->assertEquals('###PHPUNIT-NOTSET###', $this->_instance->get(Tinebase_Config::PAGETITLEPOSTFIX, '###PHPUNIT-NOTSET###'), 'config got not deleted');
-        
+
         $this->assertFalse(isset($this->_instance->{Tinebase_Config::PAGETITLEPOSTFIX}), '__isset not working');
     }
-    
+
     /**
      * test if config from config.inc.php overwrites config in db
      *
@@ -88,20 +89,20 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     public function testConfigFromFileOverwrites()
     {
         $configData = include('config.inc.php');
-        
-        if (! (isset($configData['Overwrite Test']) || array_key_exists('Overwrite Test', $configData))) {
+
+        if (!(isset($configData['Overwrite Test']) || array_key_exists('Overwrite Test', $configData))) {
             $this->markTestSkipped('config.inc.php has no test key "Overwrite Test"');
             return;
         }
-        
+
         $overwrittenValue = Tinebase_Record_Abstract::generateUID();
         $this->_instance->{'Overwrite Test'} = $overwrittenValue;
-        
+
         $this->assertEquals($configData['Overwrite Test'], $this->_instance->{'Overwrite Test'});
-        
+
         $this->_instance->delete('Overwrite Test');
     }
-    
+
     /**
      * test get config from config.inc.php
      *
@@ -109,11 +110,11 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     public function testGetConfigFromFile()
     {
         $dbConfig = $this->_instance->database;
-        
+
         $this->assertGreaterThan(0, count($dbConfig), 'could not get db config');
         $this->assertTrue($dbConfig['dbname'] != '', 'could not get dbname');
     }
-    
+
     /**
      * test config value is a struct
      *
@@ -121,15 +122,15 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     public function testConfigTypeStruct()
     {
         $dbConfig = $this->_instance->database;
-        
+
         $this->assertTrue($dbConfig instanceof Tinebase_Config_Struct, 'db config is not a struct');
         $this->assertTrue($dbConfig['dbname'] != '', 'could not get dbname via arrayAccess');
         $this->assertTrue($dbConfig->dbname != '', 'could not get dbname via objectAccess');
     }
-    
+
     /**
      * test client config retrival
-     * 
+     *
      */
     public function testGetClientRegistryConfig()
     {
@@ -137,10 +138,10 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($clientConfig instanceof Tinebase_Config_Struct, 'clientconfig is not a struct');
         $this->assertTrue($clientConfig->Calendar instanceof Tinebase_Config_Struct, 'calendar clientconfig is not a struct');
         $this->assertEquals(Calendar_Config::getInstance()->fixedCalendars, $clientConfig->Calendar->fixedCalendars->value, 'fixed calendar config not correct');
-        
+
         $this->assertFalse((isset($clientConfig->Tinebase['SMTP']) || array_key_exists('SMTP', $clientConfig->Tinebase)), 'SMTP is not a client config');
     }
-    
+
     /**
      * test if config returns empty array if it's empty
      */
@@ -148,52 +149,52 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     {
         // Hold original value for further tests of sieve.
         $keepOriginalValue = $this->_instance->get("sieve");
-        
+
         // Ensure  sieve key is null
         $this->_instance->set("sieve", null);
-        
+
         // If key is null it throws an exception, so return empty array if it's null.
         $this->assertTrue($this->_instance->get("sieve") instanceof Tinebase_Config_Struct);
-        
+
         // Check common function of the getFunction
         $this->assertTrue(is_numeric($this->_instance->get("acceptedTermsVersion")));
-        
+
         // restore value
         $this->_instance->set("sieve", $keepOriginalValue);
     }
-    
+
     /**
      * testApplicationDefaultConfig
      */
     public function testApplicationDefaultConfig()
     {
         $defaultConfigFile = $this->_getSalesCustomDefaultConfig();
-        
+
         if (file_exists($defaultConfigFile)) {
             $this->markTestSkipped('ignore test because Sales default config exists');
         }
-        
+
         $ignoreBillablesConfig = Sales_Config::getInstance()->get(Sales_Config::IGNORE_BILLABLES_BEFORE);
         $this->assertEquals('2000-01-01 22:00:00', $ignoreBillablesConfig);
-        
+
         copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'configtest.inc.php', $defaultConfigFile);
         $this->_filenamesToDelete[] = $defaultConfigFile;
 
         Sales_Config::getInstance()->clearCache();
-        
+
         $ignoreBillablesConfigAppDefault = Sales_Config::getInstance()->get(Sales_Config::IGNORE_BILLABLES_BEFORE);
         $this->assertEquals('1999-10-01 22:00:00', $ignoreBillablesConfigAppDefault);
     }
-    
+
     protected function _getSalesCustomDefaultConfig()
     {
         return dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'tine20'
-            . DIRECTORY_SEPARATOR . 'Sales' . DIRECTORY_SEPARATOR . 'config.inc.php';
+        . DIRECTORY_SEPARATOR . 'Sales' . DIRECTORY_SEPARATOR . 'config.inc.php';
     }
-    
+
     /**
      * testFeatureEnabled
-     * 
+     *
      * @see 0010756: add feature switches for easy enabling/disabling of features
      */
     public function testFeatureEnabled()
@@ -202,9 +203,9 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
         if (file_exists($customConfigFilename)) {
             $this->markTestSkipped('do not test with existing custom config');
         }
-        
+
         $invoicesFeatureEnabled = Sales_Config::getInstance()->featureEnabled(Sales_Config::FEATURE_INVOICES_MODULE);
-        
+
         $this->assertTrue($invoicesFeatureEnabled);
     }
 
@@ -216,7 +217,7 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
     public function testComposeConfigDir()
     {
         $confdfolder = Tinebase_Config::getInstance()->get(Tinebase_Config::CONFD_FOLDER);
-        if (empty($confdfolder) || ! is_readable($confdfolder)) {
+        if (empty($confdfolder) || !is_readable($confdfolder)) {
             $this->markTestSkipped('no confdfolder configured/readable');
         }
 
@@ -239,4 +240,14 @@ class Tinebase_ConfigTest extends PHPUnit_Framework_TestCase
         $defaultPolicy = ActiveSync_Config::getInstance()->get(ActiveSync_Config::DEFAULT_POLICY, null);
         $this->assertTrue(is_null($defaultPolicy), 'config should be null: ' . var_export($defaultPolicy, true));
     }
+
+    /**
+     * set + get bool config
+     */
+    public function testBoolConfig()
+    {
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, true);
+
+        $this->assertEquals(true, Tinebase_Config::getInstance()->get(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME));
+    }
 }
index c992c9f..6448d72 100644 (file)
@@ -43,6 +43,15 @@ class Tinebase_WebDav_Plugin_OwnCloudTest extends Tinebase_WebDav_Plugin_Abstrac
     }
 
     /**
+     * tear down tests
+     */
+    protected function tearDown()
+    {
+        parent::tearDown();
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, false);
+    }
+
+    /**
      * test getPluginName method
      */
     public function testGetPluginName()
@@ -90,4 +99,45 @@ class Tinebase_WebDav_Plugin_OwnCloudTest extends Tinebase_WebDav_Plugin_Abstrac
         $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
         $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
     }
+    
+    /**
+     * test testGetProperties method with alternate loginname config
+     */
+    public function testGetProperties2()
+    {
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, true);
+        
+        $body = '<?xml version="1.0" encoding="utf-8"?>
+                 <propfind xmlns="DAV:">
+                    <prop>
+                        <getlastmodified xmlns="DAV:"/>
+                        <getcontentlength xmlns="DAV:"/>
+                        <resourcetype xmlns="DAV:"/>
+                        <getetag xmlns="DAV:"/>
+                        <id xmlns="http://owncloud.org/ns"/>
+                    </prop>
+                 </propfind>';
+    
+        $request = new Sabre\HTTP\Request(array(
+                'REQUEST_METHOD' => 'PROPFIND',
+                'REQUEST_URI'    => '/remote.php/webdav/' . Tinebase_Core::getUser()->accountLoginName,
+                'HTTP_DEPTH'     => '0',
+        ));
+        $request->setBody($body);
+    
+        $this->server->httpRequest = $request;
+        $this->server->exec();
+        //var_dump($this->response->body);
+        $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status);
+    
+        $responseDoc = new DOMDocument();
+        $responseDoc->loadXML($this->response->body);
+        //$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
+        $xpath = new DomXPath($responseDoc);
+        $xpath->registerNamespace('owncloud', 'http://owncloud.org/ns');
+    
+        $nodes = $xpath->query('//d:multistatus/d:response/d:propstat/d:prop/owncloud:id');
+        $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
+        $this->assertNotEmpty($nodes->item(0)->nodeValue, $responseDoc->saveXML());
+    }
 }
index af1b5e2..02a0380 100644 (file)
@@ -28,17 +28,14 @@ class Tinebase_WebDav_RootTest extends TestCase
      * @var array test objects
      */
     protected $objects = array();
-    
+
     /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
+     * tear down tests
      */
-    public static function main()
+    protected function tearDown()
     {
-        $suite  = new PHPUnit_Framework_TestSuite('Tinebase_WebDav_RootTest');
-        PHPUnit_TextUI_TestRunner::run($suite);
+        parent::tearDown();
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, false);
     }
 
     /**
@@ -91,6 +88,54 @@ class Tinebase_WebDav_RootTest extends TestCase
     }
     
     /**
+     * test getLastModified method
+     */
+    public function testGetLastModified2()
+    {
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, true);
+        
+        $remoteWebDav = $this->_getWebDAVTree()->getNodeForPath('/remote.php/webdav');
+        
+        $this->assertNotEmpty($remoteWebDav->getLastModified());
+        
+        $personal = $remoteWebDav->getChild(Tinebase_Core::getUser()->accountLoginName);
+        
+        $this->assertNotEmpty($personal->getLastModified());
+        
+        $shared = $remoteWebDav->getChild('shared');
+        
+        $this->assertNotEmpty($shared->getLastModified());
+        
+        $this->assertContains($remoteWebDav->getLastModified(), array($personal->getLastModified(), $shared->getLastModified()));
+        
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, false);
+        
+    }
+    
+    /**
+     * test getETag
+     */
+    public function testGetETag2()
+    {
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, true);
+        
+        $remoteWebDav = $this->_getWebDAVTree()->getNodeForPath('/remote.php/webdav');
+        $properties = $remoteWebDav->getProperties(array('{DAV:}getetag'));
+        $this->assertArrayHasKey('{DAV:}getetag', $properties);
+    
+        $currentUser = $remoteWebDav->getChild(Tinebase_Core::getUser()->accountLoginName);
+        $properties = $currentUser->getProperties(array('{DAV:}getetag'));
+        $this->assertArrayHasKey('{DAV:}getetag', $properties);
+    
+        foreach ($currentUser->getChildren() as $child) {
+            $properties = $child->getProperties(array('{DAV:}getetag'));
+            $this->assertArrayHasKey('{DAV:}getetag', $properties);
+        }
+        
+        Tinebase_Config::getInstance()->set(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME, false);
+    }
+    
+    /**
      * 
      * @return \Sabre\DAV\ObjectTree
      */
index dfd3c7b..edfe0a1 100644 (file)
@@ -331,7 +331,8 @@ class Addressbook_Model_Contact extends Tinebase_Record_Abstract
      * @param array $_data
      * @return array $_data
      */
-    protected function _resolveAutoValues(array $_data) {
+    protected function _resolveAutoValues(array $_data)
+    {
         if (! (isset($_data['org_name']) || array_key_exists('org_name', $_data))) {
             $_data['org_name'] = '';
         }
index 98afaf5..50abd93 100644 (file)
@@ -55,9 +55,7 @@ class Filemanager_Frontend_Download extends Tinebase_Frontend_Http_Abstract
             
             header('HTTP/1.0 404 Not found');
             
-            $view = new Zend_View();
-            $view->setScriptPath('Filemanager/views');
-            
+            $view = $this->_getView();
             header('Content-Type: text/html; charset=utf-8');
             die($view->render('notfound.phtml'));
         }
@@ -129,11 +127,7 @@ class Filemanager_Frontend_Download extends Tinebase_Frontend_Http_Abstract
      */
     protected function _listDirectory(Filemanager_Model_DownloadLink $download, Tinebase_Model_Tree_Node $node, $path)
     {
-        $view = new Zend_View();
-        $view->setScriptPath('Filemanager/views');
-        
-        $view->path = '/' . implode('/', $path);
-        
+        $this->_getView($path, $node);
         $view->files = Filemanager_Controller_DownloadLink::getInstance()->getFileList($download, $path, $node);
         
         header('Content-Type: text/html; charset=utf-8');
@@ -149,17 +143,26 @@ class Filemanager_Frontend_Download extends Tinebase_Frontend_Http_Abstract
      */
     protected function _displayFile(Filemanager_Model_DownloadLink $download, Tinebase_Model_Tree_Node $node, $path)
     {
-        $view = new Zend_View();
-        $view->setScriptPath('Filemanager/views');
-        
-        $view->path = '/' . implode('/', $path);
-        
+        $view = $this->_getView($path, $node);
+
         $view->file = $node;
         $view->file->path = $download->getDownloadUrl('get') . '/' . implode('/', $path);
         
         header('Content-Type: text/html; charset=utf-8');
         die($view->render('file.phtml'));
     }
+
+    protected function _getView($path = null, $node = null)
+    {
+        $view = new Zend_View();
+        $view->setScriptPath('Filemanager/views');
+
+        $view->logoPath = Tinebase_Core::getUrl() . '/images/tine_logo.png';
+
+        if ($path !== null) {
+            $view->path = (empty($path)) ? '/' . $node->name : '/' . implode('/', $path);
+        }
+    }
     
     /**
      * sets download link owner (creator) as current user to ensure ACL handling
index a676dfb..5993987 100644 (file)
@@ -6,7 +6,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=8; IE=7" />
 </head>
  <body>
-    <img alt="Tine 2.0" src="/images/tine_logo.png"><h1><?php echo $this->path ?></h1>
+    <img alt="Tine 2.0" src="<?php echo $this->logoPath ?>"><h1><?php echo $this->path ?></h1>
     <hr>
     <table>
         <tr><td>Name:</td><td><?php echo $this->file->name ?></td></tr>
index 4283b2a..b82f84f 100644 (file)
@@ -6,7 +6,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=8; IE=7" />
 </head>
  <body>
-    <img alt="Tine 2.0" src="/images/tine_logo.png"><h1><?php echo $this->path ?></h1>
+    <img alt="Tine 2.0" src="<?php echo $this->logoPath ?>"><h1><?php echo $this->path ?></h1>
     <hr>
     <table>
         <tr><th>Name</th><th>letzte Änderung</th><th>Größe</th><th>Beschreibung</th></tr>
index 17068e0..dd53f1c 100644 (file)
@@ -6,7 +6,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=8; IE=7" />
 </head>
  <body>
-    <img alt="Tine 2.0" src="/images/tine_logo.png"><h1></h1>
+    <img alt="Tine 2.0" src="<?php echo $this->logoPath ?>"><h1></h1>
     File not found!
 </body>
 </html>
index 96d4ad0..4aae225 100644 (file)
@@ -373,12 +373,12 @@ class Tinebase_Config extends Tinebase_Config_Abstract
     /**
      * maintenance mode
      *
-     * @var bool
+     * @var string
      */
     const MAINTENANCE_MODE = 'maintenanceMode';
 
     /**
-     * @var array of strings
+     * @var string
      */
     const FAT_CLIENT_CUSTOM_JS = 'fatClientCustomJS';
     
@@ -389,6 +389,16 @@ class Tinebase_Config extends Tinebase_Config_Abstract
     const BRANDING_DESCRIPTION = 'branding_description';
 
     /**
+     * @var string
+     */
+    const USE_LOGINNAME_AS_FOLDERNAME = 'useLoginnameAsFoldername';
+
+    /**
+     * @var string
+     */
+    const VERSION_CHECK = 'versionCheck';
+
+    /**
      * (non-PHPdoc)
      * @see tine20/Tinebase/Config/Definition::$_properties
      */
@@ -883,6 +893,16 @@ class Tinebase_Config extends Tinebase_Config_Abstract
             'setByAdminModule'      => TRUE,
             'setBySetupModule'      => TRUE,
         ),
+        self::VERSION_CHECK => array(
+            //_('Version check enabled')
+            'label'                 => 'Version check enabled',
+            'description'           => 'Version check enabled',
+            'type'                  => 'bool',
+            'default'               => true,
+            'clientRegistryInclude' => true,
+            'setByAdminModule'      => false,
+            'setBySetupModule'      => false,
+        ),
         self::FAT_CLIENT_CUSTOM_JS => array(
             // NOTE: it's possible to deliver customjs vom vfs by using the tine20:// streamwrapper
             //       tine20://<applicationid>/folders/shared/<containerid>/custom.js
@@ -951,6 +971,17 @@ class Tinebase_Config extends Tinebase_Config_Abstract
                 'setByAdminModule'      => FALSE,
                 'setBySetupModule'      => FALSE,
         ),
+        self::USE_LOGINNAME_AS_FOLDERNAME => array(
+        //_('Use login name instead of full name')
+            'label'                 => 'Use login name instead of full name',
+        //_('Use login name instead of full name for webdav.')
+            'description'           => 'Use login name instead of full name for webdav.',
+            'type'                  => 'bool',
+            'clientRegistryInclude' => FALSE,
+            'setByAdminModule'      => FALSE,
+            'setBySetupModule'      => FALSE,
+            'default'               => FALSE,
+        ),
     );
     
     /**
index c279572..654bedf 100644 (file)
@@ -703,7 +703,7 @@ class Tinebase_Timemachine_ModificationLog
      */
     protected function _getCommonModlog($_model, $_backend, $_updateMetaData = array(), $_recordId = NULL)
     {
-        if (empty($_updateMetaData)) {
+        if (empty($_updateMetaData) || ! isset($_updateMetaData['last_modified_by']) ||  ! isset($_updateMetaData['last_modified_time'])) {
             list($currentAccountId, $currentTime) = Tinebase_Timemachine_ModificationLog::getCurrentAccountIdAndTime();
         } else {
             $currentAccountId = $_updateMetaData['last_modified_by'];
index dfeb698..5f4a05b 100644 (file)
@@ -570,9 +570,22 @@ class Tinebase_User
                 . ' new contact: ' . print_r($contact->toArray(), true)
                 . ' orig contact:' . print_r($originalContact->toArray(), true));
 
-            $syncPhoto = isset($options['syncContactPhoto']) && $options['syncContactPhoto'];
-            $diff = $contact->diff($originalContact, $syncPhoto ? array() : array('jpegphoto'));
-            if (! $diff->isEmpty() || ($originalContact->jpegphoto == 0 && ! empty($contact->jpegphoto))) {
+            if (isset($options['syncContactPhoto']) && $options['syncContactPhoto']) {
+                $syncPhoto = true;
+                if ($originalContact->jpegphoto == 1) {
+                    // TODO use generic function with ignoreAcl ...
+                    //$originalContact->jpegphoto = Tinebase_Controller::getInstance()->getImage('Addressbook', $originalContact->getId())->getBlob();
+                    $adb = new Addressbook_Backend_Sql();
+                    $originalContact->jpegphoto = $adb->getImage($originalContact->getId());
+                }
+                if ($contact->jpegphoto == 1) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__
+                        . ' Removing/unset current jpegphoto');
+                    $contact->jpegphoto = false;
+                }
+            }
+            $diff = $contact->diff($originalContact, $syncPhoto ? array('n_fn') : array('jpegphoto', 'n_fn'));
+            if (! $diff->isEmpty() || ($originalContact->jpegphoto === 0 && ! empty($contact->jpegphoto)) ) {
                 // add modlog info
                 Tinebase_Timemachine_ModificationLog::setRecordMetaData($contact, 'update');
                 if ($contact->container_id !== null) {
@@ -721,6 +734,11 @@ class Tinebase_User
                     $contact->{$contactKey} = $user->{$userKey};
             }
         }
+
+        if ($contact->n_fn !== $user->accountFullName) {
+            // use accountFullName overwrites contact n_fn
+            $contact->n_fn = $user->accountFullName;
+        }
         
         return $contact;
     }
index f2496a1..058d812 100644 (file)
@@ -64,7 +64,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
     protected $_useIdAsName;
     
     protected static $_classCache = array (
-        '_getContact' => array()
+        '_getUser' => array()
     );
     
     /**
@@ -78,6 +78,16 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
         $this->_path        = $path;
         $this->_useIdAsName = $useIdAsName;
     }
+
+    /**
+     * use login as folder name
+     *
+     * @return boolean
+     */
+    protected function _useLoginAsFolderName()
+    {
+        return Tinebase_Config::getInstance()->get(Tinebase_Config::USE_LOGINNAME_AS_FOLDERNAME);
+    }
     
     /**
      * (non-PHPdoc)
@@ -94,7 +104,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
      * (non-PHPdoc)
      * @see \Sabre\DAV\IExtendedCollection::createExtendedCollection()
      */
-    function createExtendedCollection($name, array $resourceType, array $properties)
+    public function createExtendedCollection($name, array $resourceType, array $properties)
     {
         return $this->_createContainer(array(
             'name'  => isset($properties['{DAV:}displayname']) ? $properties['{DAV:}displayname'] : $name,
@@ -126,13 +136,17 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                         
                     } else {
                         try {
-                            $contact = $this->_getContact($name);
+                            // check if it exists only
+                            $this->_getUser($name);
                             
                         } catch (Tinebase_Exception_NotFound $tenf) {
-                            throw new \Sabre\DAV\Exception\NotFound("Directory $this->_path/$name not found");
+                            $message = "Directory $this->_path/$name not found";
+                            if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) Tinebase_Core::getLogger()->info(
+                                __METHOD__ . '::' . __LINE__ . ' ' . $message);
+                            throw new \Sabre\DAV\Exception\NotFound($message);
                         }
                         
-                        $path = $this->_path . '/' . ($this->_useIdAsName ? $contact->getId() : $contact->n_fileas);
+                        $path = $this->_path . '/' . $name;
                     }
                     
                 } else {
@@ -185,7 +199,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                         
                     } else {
                         try {
-                            $accountId = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()))->account_id;
+                            $accountId = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()))->accountId;
                             
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             throw new \Sabre\DAV\Exception\NotFound("Directory $this->_path/$name not found");
@@ -266,8 +280,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                 
                 if ($this->_hasPersonalFolders) {
                     $children[] = $this->getChild(
-                        $this->_useIdAsName ? Tinebase_Core::getUser()->contact_id :
-                        Addressbook_Controller_Contact::getInstance()->get(Tinebase_Core::getUser()->contact_id)->n_fileas
+                        $this->_useIdAsName ? Tinebase_Core::getUser()->contact_id : $this->_useLoginAsFolderName() ? Tinebase_Core::getUser()->accountLoginName : Tinebase_Core::getUser()->accountDisplayName
                     );
                     
                     $otherUsers = Tinebase_Container::getInstance()->getOtherUsers(Tinebase_Core::getUser(), $this->_getApplicationName(), array(
@@ -278,8 +291,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                     foreach ($otherUsers as $user) {
                         if ($user->contact_id && $user->visibility === Tinebase_Model_User::VISIBILITY_DISPLAYED) {
                             try {
-                                $folderId = $this->_useIdAsName ? $user->contact_id :
-                                    Addressbook_Controller_Contact::getInstance()->get($user->contact_id)->n_fileas;
+                                $folderId = $this->_useIdAsName ? $user->contact_id : $this->_useLoginAsFolderName() ? $user->accountLoginName : $user->accountDisplayName;
 
                                 $children[] = $this->getChild($folderId);
                             } catch (\Sabre\DAV\Exception\NotFound $sdavenf) {
@@ -310,7 +322,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                         
                     } else {
                         try {
-                            $accountId = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()))->account_id;
+                            $accountId = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()))->accountId;
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             throw new \Sabre\DAV\Exception\NotFound("Path $this->_path not found");
                         }
@@ -466,9 +478,9 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
             !$this->_useIdAsName
         ) {
             try {
-                $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
+                $user = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()));
                 
-                $name = $contact->n_fileas;
+                $name = $this->_useLoginAsFolderName() ? $user->accountLoginName : $user->accountDisplayName;
                 
             } catch (Tinebase_Exception_NotFound $tenf) {
                 list(,$name) = Sabre\DAV\URLUtil::splitPath($this->_path);
@@ -492,12 +504,12 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
     {
         if (count($this->_getPathParts()) === 2 && $this->getName() !== Tinebase_Model_Container::TYPE_SHARED) {
             try {
-                $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
+                $user = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()));
             } catch (Tinebase_Exception_NotFound $tenf) {
                 return null;
             }
             
-            return 'principals/users/' . $contact->getId();
+            return 'principals/users/' . $user->contact_id;
         }
         
         return null;
@@ -521,7 +533,8 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                 case '{DAV:}displayname':
                     if (count($this->_getPathParts()) === 2 && $this->getName() !== Tinebase_Model_Container::TYPE_SHARED) {
                         try {
-                            $contact = $this->_getContact(Tinebase_Helper::array_value(1, $this->_getPathParts()));
+                            $user = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()));
+                            $contact = Addressbook_Controller_Contact::getInstance()->get($user->contact_id);
                         } catch (Tinebase_Exception_NotFound $tenf) {
                             continue;
                         }
@@ -726,41 +739,28 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
         
         return $pathParts;
     }
-    
-    /**
-     * resolve contact_id to Addressbook_Model_Contact
-     * 
-     * @return Addressbook_Model_Contact
-     */
-    protected function _getContact($contactId)
+
+    protected function _getUser($_id)
     {
-        $classCacheId = ($this->_useIdAsName ? 'id' : 'n_fileas') . $contactId;
-        
+        $classCacheId = ($this->_useIdAsName ? 'contact_id' : $this->_useLoginAsFolderName() ? 'accountLoginName' : 'accountDisplayName') . $_id;
+
         if (isset(self::$_classCache[__FUNCTION__][$classCacheId])) {
             return self::$_classCache[__FUNCTION__][$classCacheId];
         }
-        
-        $filter = new Addressbook_Model_ContactFilter(array(
-            array(
-                'field'     => 'type',
-                'operator'  => 'equals',
-                'value'     => Addressbook_Model_Contact::CONTACTTYPE_USER
-            ),
-            array(
-                'field'     => $this->_useIdAsName ? 'id' : 'n_fileas',
-                'operator'  => 'equals',
-                'value'     => $contactId
-            ),
-        ));
-        
-        $contact = Addressbook_Controller_Contact::getInstance()->search($filter)->getFirstRecord();
-        
-        if (!$contact) {
-            throw new Tinebase_Exception_NotFound('contact not found');
+
+        if ($this->_useIdAsName) {
+            $contact = Addressbook_Controller_Contact::getInstance()->get($_id);
+            $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $contact->account_id, 'Tinebase_Model_FullUser');
+        } else {
+            if ($this->_useLoginAsFolderName()) {
+                $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountLoginName', $_id, 'Tinebase_Model_FullUser');
+            } else {
+                $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountDisplayName', $_id, 'Tinebase_Model_FullUser');
+            }
         }
-        
-        self::$_classCache[__FUNCTION__][$classCacheId] = $contact;
-        
-        return $contact;
+
+        self::$_classCache[__FUNCTION__][$classCacheId] = $user;
+
+        return $user;
     }
 }
index 50b6297..0053cae 100644 (file)
@@ -129,8 +129,13 @@ Tine.Tinebase.MainScreenPanel = Ext.extend(Ext.Panel, {
         
         this.activateDefaultApp();
         
-        // check for new version 
-        if (Tine.Tinebase.common.hasRight('check_version', 'Tinebase')) {
+        // check for new version
+        // TODO add helper function for fetching config ... this condition sucks.
+        if ((      ! Tine.Tinebase.registry.get("config")
+                || ! Tine.Tinebase.registry.get("config").versionCheck
+                ||   Tine.Tinebase.registry.get("config").versionCheck.value
+            ) && Tine.Tinebase.common.hasRight('check_version', 'Tinebase')
+        ) {
             Tine.widgets.VersionCheck();
         }
         
index e5f8054..ca64ae3 100644 (file)
         },
         {
             "name": "syncroton/syncroton",
-            "version": "1.2.1",
+            "version": "1.2.2",
             "source": {
                 "type": "git",
                 "url": "http://git.syncroton.org/Syncroton",
-                "reference": "31d151de7cba6fa95ffd34efffd85444ccab0b2d"
+                "reference": "05ff4ef7b67d7ad92ca21a8b086c5e92e090a365"
             },
             "require": {
                 "php": ">=5.3.0",