From dd0da70b06ae0baca91211815a94e8a6f32b46ff Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 6 Jan 2021 19:26:40 +0000 Subject: filter out self and child folders from the folder list (cherry picked from commit a0c8e1959af2a98400fd9fbbdc61471bbf461614) --- Zotlabs/Storage/Browser.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php index f8377eb70..e447a41e8 100644 --- a/Zotlabs/Storage/Browser.php +++ b/Zotlabs/Storage/Browser.php @@ -100,7 +100,7 @@ class Browser extends DAV\Browser\Plugin { $folder_parent = ((isset($arr[1])) ? prev($arr) : ''); $folder_list = attach_folder_select_list($channel_id); - +hz_syslog(print_r($folder_list,true)); $siteroot_disabled = get_config('system', 'cloud_disable_siteroot'); $is_root_folder = (($path === 'cloud/' . $nick) ? true : false); @@ -294,9 +294,16 @@ class Browser extends DAV\Browser\Plugin { // create a copy of the list which we can alter for the current resource $folders = $folder_list; + if($data['is_dir']) { - // can not copy a folder into itself - unset($folders[$folder_hash]); + + $rm_path = $folders[$folder_hash]; + // can not copy a folder into itself or own child folders + foreach($folders as $k => $v) { + if(strpos($v, $rm_path) === 0) + unset($folders[$k]); + } + } $ft['newfolder'] = ['newfolder_' . $id, t('Select a target location'), $data['folder'], '', $folders]; -- cgit v1.2.3