From 47df86be97ba6542cc516a4c7d6cb58ad9a5dba0 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 23 Sep 2014 17:46:06 +0000 Subject: [PATCH] - Add some more filter options - Fix maxdepth option to work --- filemanager/inc/class.filemanager_ui.inc.php | 9 +++++++-- phpgwapi/inc/class.egw_vfs.inc.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 20a9fa97ec..b9bbeb077e 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -457,6 +457,8 @@ class filemanager_ui '' => 'Current directory', '2' => 'Directories sorted in', '3' => 'Show hidden files', + '4' => 'All subdirectories', + '5' => 'Files from next subdirectory', '0' => 'Files from subdirectories', ); @@ -767,11 +769,14 @@ class filemanager_ui // Re-map so 'No filters' favorite ('') is depth 1 $filter = $query['filter'] === '' ? 1 : $query['filter']; + + $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; + if($filter == 5) $maxdepth = 2; foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],array( 'mindepth' => 1, - 'maxdepth' => $filter ? (int)(boolean)$filter : null, + 'maxdepth' => $maxdepth, 'dirsontop' => $filter <= 1, - 'type' => $filter ? null : 'f', + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : 'f', 'order' => $query['order'], 'sort' => $query['sort'], 'limit' => (int)$query['num_rows'].','.(int)$query['start'], 'need_mime' => true, diff --git a/phpgwapi/inc/class.egw_vfs.inc.php b/phpgwapi/inc/class.egw_vfs.inc.php index e981d88dc7..d52b05a1e7 100644 --- a/phpgwapi/inc/class.egw_vfs.inc.php +++ b/phpgwapi/inc/class.egw_vfs.inc.php @@ -495,7 +495,7 @@ class egw_vfs extends vfs_stream_wrapper { self::_check_add($options,$path,$result); } - if ($is_dir && (!isset($options['maxdepth']) || $options['maxdepth'] > 0) && ($dir = @opendir($path))) + if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 && $options['depth'] < $options['maxdepth'])) && ($dir = @opendir($path))) { while(($file = readdir($dir)) !== false) { @@ -514,7 +514,7 @@ class egw_vfs extends vfs_stream_wrapper { $opts = $options; if ($opts['mindepth']) $opts['mindepth']--; - if ($opts['maxdepth']) $opts['maxdepth']++; + if ($opts['maxdepth']) $opts['depth']++;; unset($opts['order']); unset($opts['limit']); foreach(self::find($options['url']?$file:parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)