0010132: Create Folder inside a folder with the same name
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 28 Apr 2016 11:06:50 +0000 (13:06 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 29 Apr 2016 14:49:17 +0000 (16:49 +0200)
* use array_diff_assoc instead of array_diff ...
* improve robustness of js tree node creation
* fixes test

 https://forge.tine20.org/view.php?id=10132

Change-Id: Ic2e926f8fb1ebfc3ff97a15730eaaa04221f7514
Reviewed-on: http://gerrit.tine20.com/customers/3112
Tested-by: Jenkins CI (http://ci.tine20.com/)
Tested-by: sstamer <s.stamer@metaways.de>
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Filemanager/Frontend/JsonTests.php
tine20/Tinebase/FileSystem.php
tine20/Tinebase/js/widgets/tree/ContextMenu.js

index 19cfeb2..be8ef68 100644 (file)
@@ -1237,13 +1237,15 @@ class Filemanager_Frontend_JsonTests extends TestCase
     public function testCreateFolderInFolderWithSameName()
     {
         $path = '/personal/' .Tinebase_Core::getUser()->accountLoginName . '/' . $this->_getPersonalFilemanagerContainer()->name;
-        
-        $this->_json->createNode($path . '/Test1', 'folder', NULL, FALSE);
-        $this->_json->createNode($path . '/Test1/Test1', 'folder', NULL, FALSE);
+
+        $result = $this->_json->createNode($path . '/Test1', 'folder', NULL, FALSE);
+        $this->assertTrue(isset($result['id']));
+        $result = $this->_json->createNode($path . '/Test1/Test1', 'folder', NULL, FALSE);
+        $this->assertTrue(isset($result['id']), 'node has not been created');
         $e = new Tinebase_Exception('nothing');
         try {
             $this->_json->createNode($path . '/Test1/Test1/Test2', 'folder', NULL, FALSE);
-        } catch(Exception $e) {
+        } catch (Exception $e) {
             $this->fail('The folder couldn\'t be found, so it hasn\'t ben created');
         }
         
@@ -1432,15 +1434,15 @@ class Filemanager_Frontend_JsonTests extends TestCase
         
         $this->assertEquals(1, $result['totalcount']);
     }
-    
+
     /**
      * testDeleteDownloadLinks
      */
     public function testDeleteDownloadLinks()
     {
         $downloadLink = $this->testSaveDownloadLinkFile();
-        
-        $result = $this->_json->deleteDownloadLinks(array($downloadLink['id']));
+
+        $this->_json->deleteDownloadLinks(array($downloadLink['id']));
         try {
             Filemanager_Controller_DownloadLink::getInstance()->get($downloadLink['id']);
             $this->fail('link should have been deleted');
index 96c140d..c5acb46 100644 (file)
@@ -735,12 +735,12 @@ class Tinebase_FileSystem implements Tinebase_Controller_Interface
             }
         }
         
-        $missingPathParts = array_diff($this->_splitPath($path), $pathParts);
+        $missingPathParts = array_diff_assoc($this->_splitPath($path), $pathParts);
         
         foreach ($missingPathParts as $pathPart) {
             $node = $this->_treeNodeBackend->getChild($parentNode, $pathPart);
             
-            // keep track of current path posistion
+            // keep track of current path position
             array_push($pathParts, $pathPart);
             
             // add found path to statCache
index 2a89c32..76507b4 100644 (file)
@@ -233,6 +233,12 @@ Tine.widgets.tree.ContextMenu = {
                     success: function(result, request){
                         var nodeData = Ext.util.JSON.decode(result.responseText);
 
+                        if (nodeData.length == 0) {
+                            Tine.log.err('Server returned empty node data!');
+                            Ext.MessageBox.hide();
+                            return;
+                        }
+
                         // TODO add + icon if it wasn't expandable before
                         if(nodeData.type == 'folder') {
                             var nodeData = Ext.util.JSON.decode(result.responseText);
@@ -481,16 +487,20 @@ Tine.widgets.tree.ContextMenu = {
     manageProperties: function() {
         if (this.scope.ctxNode) {
             var node = this.scope.ctxNode,
-                grantsContainer;
-            if(node.attributes.nodeRecord && node.attributes.nodeRecord.data.name) {
+                grantsContainer,
+                ctxNodeName;
+            if (node.attributes.nodeRecord && node.attributes.nodeRecord.data.name) {
                 grantsContainer = node.attributes.nodeRecord.data.name;
             } else if(node.attributes.container) {
                 grantsContainer = node.attributes.container;
             }
+
+            ctxNodeName = grantsContainer.name ? grantsContainer.name : grantsContainer;
             
             var window = Tine.widgets.container.PropertiesDialog.openWindow({
-                title: String.format(_('Properties for {0} "{1}"'), this.nodeName, Ext.util.Format.htmlEncode(grantsContainer.name)),
+                title: String.format(_('Properties for {0} "{1}"'), this.nodeName, Ext.util.Format.htmlEncode(ctxNodeName)),
                 containerName: this.nodeName,
+                // TODO fix this in Filemanager! sub-nodes do not have a container...
                 grantContainer: grantsContainer,
                 app: this.scope.app.appName
             });