From 72d80f4afe29a7029d27defce8b6f3df4401a562 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Philipp=20Sch=C3=BCle?=
Date: Thu, 28 Apr 2016 13:06:50 +0200
Subject: [PATCH] 0010132: Create Folder inside a folder with the same name
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
* 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
Reviewed-by: Philipp Schüle
---
tests/tine20/Filemanager/Frontend/JsonTests.php | 16 +++++++++-------
tine20/Tinebase/FileSystem.php | 4 ++--
tine20/Tinebase/js/widgets/tree/ContextMenu.js | 16 +++++++++++++---
3 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/tests/tine20/Filemanager/Frontend/JsonTests.php b/tests/tine20/Filemanager/Frontend/JsonTests.php
index 19cfeb2..be8ef68 100644
--- a/tests/tine20/Filemanager/Frontend/JsonTests.php
+++ b/tests/tine20/Filemanager/Frontend/JsonTests.php
@@ -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');
diff --git a/tine20/Tinebase/FileSystem.php b/tine20/Tinebase/FileSystem.php
index 96c140d..c5acb46 100644
--- a/tine20/Tinebase/FileSystem.php
+++ b/tine20/Tinebase/FileSystem.php
@@ -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
diff --git a/tine20/Tinebase/js/widgets/tree/ContextMenu.js b/tine20/Tinebase/js/widgets/tree/ContextMenu.js
index 2a89c32..76507b4 100644
--- a/tine20/Tinebase/js/widgets/tree/ContextMenu.js
+++ b/tine20/Tinebase/js/widgets/tree/ContextMenu.js
@@ -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
});
--
2.7.4