Commit 20274822 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1072 Step into matched folders outside the main loop.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 9d44e7ce
...@@ -1093,18 +1093,22 @@ class ASDevice extends StateObject { ...@@ -1093,18 +1093,22 @@ 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
$this->orderAdditionalFoldersHierarchically($toOrderFolders, $orderedFolders, $fid);
} }
} }
// call recursively to move/order the leaves as well
foreach($stepInto as $fid) {
$this->orderAdditionalFoldersHierarchically($toOrderFolders, $orderedFolders, $fid);
}
} }
/** /**
......
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