Commit 053949ae authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #409 in ZP/z-push from...

Merge pull request #409 in ZP/z-push from bugfix/ZP-1072-open-shared-folders-api-add-folders to develop

* commit '20274822':
  ZP-1072 Step into matched folders outside the main loop.
  ZP-1072 Keep folderid as additionalFolders key in ASDevice.
  ZP-1072 fixed typos and comments.
parents 9d3c7109 20274822
...@@ -880,7 +880,7 @@ class ASDevice extends StateObject { ...@@ -880,7 +880,7 @@ class ASDevice extends StateObject {
return false; return false;
} }
// check if a folder with that Name is already in the list and that it's parent exists // check if a folder with that Name is already in the list and that its parent exists
$parentFound = false; $parentFound = false;
foreach ($this->additionalfolders as $k => $folder) { foreach ($this->additionalfolders as $k => $folder) {
// TODO: this parentid check should go into fixstates! // TODO: this parentid check should go into fixstates!
...@@ -895,7 +895,7 @@ class ASDevice extends StateObject { ...@@ -895,7 +895,7 @@ class ASDevice extends StateObject {
} }
} }
if ($parentid != '0' && !$parentFound) { if ($parentid != '0' && !$parentFound) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because the parent folder '%s' can not be found: '%s'", $parentid, $folderid)); ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder '%s' ('%s') can not be added because the parent folder '%s' can not be found'", $name, $folderid, $parentid));
return false; return false;
} }
...@@ -1032,7 +1032,7 @@ class ASDevice extends StateObject { ...@@ -1032,7 +1032,7 @@ class ASDevice extends StateObject {
$noDupsCheck = array(); $noDupsCheck = array();
foreach($this->additionalfolders as $keepFolder) { foreach($this->additionalfolders as $keepFolder) {
if ($keepFolder['store'] !== $store) { if ($keepFolder['store'] !== $store) {
$newAF[] = $keepFolder; $newAF[$keepFolder['folderid']] = $keepFolder;
} }
else { else {
$noDupsCheck[$keepFolder['folderid']] = true; $noDupsCheck[$keepFolder['folderid']] = true;
...@@ -1068,7 +1068,7 @@ class ASDevice extends StateObject { ...@@ -1068,7 +1068,7 @@ class ASDevice extends StateObject {
if (!empty($toOrder)) { if (!empty($toOrder)) {
$s = ""; $s = "";
foreach($toOrder as $f) { foreach($toOrder as $f) {
$s .= sprintf("'%s'(%s) ", $f['name'], $f['folderid']); $s .= sprintf("'%s'('%s') ", $f['name'], $f['folderid']);
} }
ZLog::Write(LOGLEVEL_ERROR, "ASDevice->SetAdditionalFolderList(): cannot proceed as these folders have invalid parentids (not found): ". $s); ZLog::Write(LOGLEVEL_ERROR, "ASDevice->SetAdditionalFolderList(): cannot proceed as these folders have invalid parentids (not found): ". $s);
return false; return false;
...@@ -1093,19 +1093,23 @@ class ASDevice extends StateObject { ...@@ -1093,19 +1093,23 @@ class ASDevice extends StateObject {
* @param string $parentid the parentid to start with, if not set '0' (main folders) is used. * @param string $parentid the parentid to start with, if not set '0' (main folders) is used.
*/ */
private function orderAdditionalFoldersHierarchically(&$toOrderFolders, &$orderedFolders, $parentid = '0') { private function orderAdditionalFoldersHierarchically(&$toOrderFolders, &$orderedFolders, $parentid = '0') {
$stepInto = array();
// loop through the remaining folders that need to be ordered // loop through the remaining folders that need to be ordered
foreach($toOrderFolders as $folder) { foreach($toOrderFolders as $folder) {
// move folders with the matching parentid to the ordered array // move folders with the matching parentid to the ordered array
if ($folder['parentid'] == $parentid) { if ($folder['parentid'] == $parentid) {
echo "found.. \n";
$fid = $folder['folderid']; $fid = $folder['folderid'];
$orderedFolders[$fid] = $folder; $orderedFolders[$fid] = $folder;
unset($toOrderFolders[$fid]); unset($toOrderFolders[$fid]);
reset($toOrderFolders); $stepInto[] = $fid;
}
}
// call recursively to move/order the leaves as well // call recursively to move/order the leaves as well
foreach($stepInto as $fid) {
$this->orderAdditionalFoldersHierarchically($toOrderFolders, $orderedFolders, $fid); $this->orderAdditionalFoldersHierarchically($toOrderFolders, $orderedFolders, $fid);
} }
} }
}
/** /**
* Generates the AS folder hash from the backend folder id, type and name. * Generates the AS folder hash from the backend folder id, type and name.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment