From bc65324a7c6ecf1c2bf8c9ebc84c6c19a82df19c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 4 May 2009 16:37:10 +0000 Subject: [PATCH] new type F for egw_vfs::find to return only files or symlinks to files --> dont show symlinks to dirs as attachements / link-widget --- phpgwapi/inc/class.egw_link.inc.php | 2 +- phpgwapi/inc/class.egw_vfs.inc.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.egw_link.inc.php b/phpgwapi/inc/class.egw_link.inc.php index a230d38ece..30ad4a0d4a 100644 --- a/phpgwapi/inc/class.egw_link.inc.php +++ b/phpgwapi/inc/class.egw_link.inc.php @@ -904,7 +904,7 @@ class egw_link extends solink if (!($extra = self::get_registry($app,'find_extra'))) $extra = array(); $attached = array(); - if (($url2stats = egw_vfs::find($path,array('need_mime'=>true,'type'=>'f')+$extra,true))) + if (($url2stats = egw_vfs::find($path,array('need_mime'=>true,'type'=>'F')+$extra,true))) { $props = egw_vfs::propfind(array_keys($url2stats)); // get the comments foreach($url2stats as $url => &$fileinfo) diff --git a/phpgwapi/inc/class.egw_vfs.inc.php b/phpgwapi/inc/class.egw_vfs.inc.php index 9a16528ad2..d7dcc92d58 100644 --- a/phpgwapi/inc/class.egw_vfs.inc.php +++ b/phpgwapi/inc/class.egw_vfs.inc.php @@ -311,7 +311,7 @@ class egw_vfs extends vfs_stream_wrapper * * @param string/array $base base of the search * @param array $options=null the following keys are allowed: - * - type => {d|f} d=dirs, f=files, default both + * - type => {d|f|F} d=dirs, f=files (incl. symlinks), F=files (incl. symlinks to files), default all * - depth => {true|false(default)} put the contents of a dir before the dir itself * - dirsontop => {true(default)|false} allways return dirs before the files (two distinct blocks) * - mindepth,maxdepth minimal or maximal depth to be returned @@ -337,7 +337,7 @@ class egw_vfs extends vfs_stream_wrapper { //error_log(__METHOD__."(".print_r($base,true).",".print_r($options,true).",".print_r($exec,true).",".print_r($exec_params,true).")\n"); - $type = $options['type']; // 'd' or 'f' + $type = $options['type']; // 'd', 'f' or 'F' $dirs_last = $options['depth']; // put content of dirs before the dir itself // show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary) $dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0); @@ -514,7 +514,8 @@ class egw_vfs extends vfs_stream_wrapper { return; // not found, should not happen } - if ($type && ($type == 'd') == !($stat['mode'] & sqlfs_stream_wrapper::MODE_DIR)) // != is_dir() which can be true for symlinks + if ($type && (($type == 'd') == !($stat['mode'] & sqlfs_stream_wrapper::MODE_DIR) || // != is_dir() which can be true for symlinks + $type == 'F' && is_dir($path))) // symlink to a directory { return; // wrong type }