use correct filesystem path when accessing other users folders
authorLars Kneschke <l.kneschke@metaways.de>
Mon, 12 May 2014 17:31:08 +0000 (19:31 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:35 +0000 (11:26 +0200)
* use Tinebase_Model_Tree_Node_Path class to calcualte filesystem path
* relaxed tests
* ignore ACL when calculating owner

Change-Id: Ida947d815915ba48b731d55c67cee74f73b184da

Reviewed-on: http://gerrit.tine20.com/customers/628
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Filemanager/Frontend/WebDAVTest.php
tine20/Tinebase/Container.php
tine20/Tinebase/FileSystem.php
tine20/Tinebase/Frontend/WebDAV/Container.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php

index 4d8e966..6f64b8d 100644 (file)
@@ -63,7 +63,7 @@ class Filemanager_Frontend_WebDAVTest extends TestCase
         
         $children = $node->getChildren();
         
-        $this->assertEquals(2, count($children));
+        $this->assertGreaterThanOrEqual(2, count($children));
         $this->assertInstanceOf('Filemanager_Frontend_WebDAV', $children[0], 'wrong node class');
         
         $this->setExpectedException('Sabre\DAV\Exception\Forbidden');
index 2ed8a76..cca6a11 100644 (file)
@@ -1289,7 +1289,7 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
             return FALSE;
         }
         
-        $grants = (! $_container->account_grants) ? $this->getGrantsOfContainer($_container) : $_container->account_grants;
+        $grants = (! $_container->account_grants) ? $this->getGrantsOfContainer($_container, true) : $_container->account_grants;
         
         if (count($grants) === 0) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ 
@@ -1304,7 +1304,9 @@ class Tinebase_Container extends Tinebase_Backend_Sql_Abstract
             }
         }
         
-        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Container ' . $_container->name . ' has no owner.');
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(
+            __METHOD__ . '::' . __LINE__ . ' Container ' . $_container->name . ' has no owner.');
+        
         return FALSE;
     }
     
index a82b40c..1f7a274 100644 (file)
@@ -185,9 +185,12 @@ class Tinebase_FileSystem implements Tinebase_Controller_Interface
      */
     public function getContainerPath(Tinebase_Model_Container $container)
     {
-        $path = $this->getApplicationBasePath($container->application_id, $container->type) . '/' . $container->getId();
+        $treeNodePath = new Tinebase_Model_Tree_Node_Path(array(
+            'application' => Tinebase_Application::getInstance()->getApplicationById($container->application_id)
+        ));
+        $treeNodePath->setContainer($container);
         
-        return $path;
+        return $treeNodePath->statpath;
     }
     
     /**
index 6be5f4b..b62adc7 100644 (file)
@@ -51,12 +51,13 @@ class Tinebase_Frontend_WebDAV_Container extends Tinebase_WebDav_Container_Abstr
     {
         parent::__construct($_container, $_useIdAsName);
         
-        $this->_path = '/' . $this->_application->getId() . '/folders/' . $this->_container->type . '/';
+        $this->_path = Tinebase_FileSystem::getInstance()->getContainerPath($this->_container);
         
-        if ($this->_container->type == Tinebase_Model_Container::TYPE_SHARED) {
-            $this->_path .= $this->_container->getId();
-        } else {
-            $this->_path .= Tinebase_Core::getUser()->accountId . '/' . $this->_container->getId();
+        // make sure filesystem path exists
+        try {
+            Tinebase_FileSystem::getInstance()->stat($this->_path);
+        } catch (Tinebase_Exception_NotFound $tenf) {
+            Tinebase_FileSystem::getInstance()->mkdir($this->_path);
         }
     }
     
index d1cb6ad..14d394f 100644 (file)
@@ -228,15 +228,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                 
                 $objectClass = Tinebase_Application::getInstance()->getApplicationById($container->application_id)->name . '_Frontend_WebDAV_Container';
                 
-                $containerClass = new $objectClass($container, $this->_useIdAsName);
-                
-                try {
-                    $containerClass->getETag();
-                } catch (Tinebase_Exception_NotFound $tenf) {
-                    throw new \Sabre\DAV\Exception\NotFound("Filesystem path for $this->_path/$name not found");
-                }
-                
-                return $containerClass;
+                return new $objectClass($container, $this->_useIdAsName);
                 
                 break;