* Filemanager: When user tries to access a directory with no permission, redirect to previous directory instead of home

This commit is contained in:
nathangray 2020-06-08 10:18:15 -06:00
parent 18852b91bc
commit 8778be01ff
2 changed files with 20 additions and 14 deletions

View File

@ -905,6 +905,8 @@ class filemanager_ui
*/ */
function get_rows(&$query, &$rows) function get_rows(&$query, &$rows)
{ {
$old_session = Api\Cache::getSession('filemanager','index');
// do NOT store query, if hierarchical data / children are requested // do NOT store query, if hierarchical data / children are requested
if (!$query['csv_export']) if (!$query['csv_export'])
{ {
@ -933,15 +935,19 @@ class filemanager_ui
if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE))
{ {
// only redirect, if it would be to some other location, gives redirect-loop otherwise // only redirect, if it would be to some other location, gives redirect-loop otherwise
if ($query['path'] != ($path = static::get_home_dir())) foreach([$old_session['path'], static::get_home_dir()] as $new_path)
{ {
// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give if ($new_path && Vfs::stat($new_path) && $query['path'] != $new_path)
// an appropriate message {
Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
'path' => $path, // an appropriate message
'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), Egw::redirect_link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index',
'ajax' => 'true' 'path' => $new_path,
)); 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])),
'ajax' => 'true'
));
break;
}
} }
$rows = array(); $rows = array();
return 0; return 0;
@ -971,6 +977,10 @@ class filemanager_ui
{ {
$row['class'] .= 'noEdit '; $row['class'] .= 'noEdit ';
} }
if(!Vfs::is_executable($path))
{
$row['class'] .= 'noExecute';
}
} }
elseif (!$dir_is_writable[Vfs::dirname($path)]) elseif (!$dir_is_writable[Vfs::dirname($path)])
{ {

View File

@ -103,15 +103,11 @@
<rows> <rows>
<row> <row>
<description value="User"/> <description value="User"/>
<menulist> <select-account label="@ro_uid_root" id="uid" empty_label="root" account_type="accounts"/>
<menupopup type="select-account" label="@ro_uid_root" id="uid" options="root,accounts"/>
</menulist>
</row> </row>
<row> <row>
<description value="Group"/> <description value="Group"/>
<menulist> <select-account label="@ro_gid_root" id="gid" empty_label="root" account_type="groups"/>
<menupopup type="select-account" label="@ro_gid_root" id="gid" options="root,groups"/>
</menulist>
</row> </row>
</rows> </rows>
</grid> </grid>