fix not working permission check

This commit is contained in:
Ralf Becker 2016-01-21 12:02:00 +00:00
parent 29c73a8694
commit 77ab3e6531

View File

@ -166,35 +166,38 @@ class filemanager_admin extends filemanager_ui
{ {
$msg = lang('Permission denied')."\n\n".lang('You are NOT allowed to finally delete older versions and deleted files!'); $msg = lang('Permission denied')."\n\n".lang('You are NOT allowed to finally delete older versions and deleted files!');
} }
// we need to be root to delete files independent of permissions and ownership
Vfs::$is_root = true;
if (!Vfs::file_exists($content['versionedpath']) || !Vfs::is_dir($content['versionedpath']))
{
$msg = lang('Directory "%1" NOT found!', $content['versionedpath']);
}
else else
{ {
$deleted = $errors = 0; // we need to be root to delete files independent of permissions and ownership
Vfs::find($content['versionedpath'], array( Vfs::$is_root = true;
'show-deleted' => true, if (!Vfs::file_exists($content['versionedpath']) || !Vfs::is_dir($content['versionedpath']))
'hidden' => true,
'path_preg' => '#/\.versions/#',
)+(!(int)$content['ctime'] ? array() : array(
'ctime' => ($content['ctime']<0?'-':'+').(int)$content['ctime'],
)), function($path) use (&$deleted, &$errors)
{ {
if (Vfs::unlink($path)) $msg = lang('Directory "%1" NOT found!', $content['versionedpath']);
}
else
{
$deleted = $errors = 0;
Vfs::find($content['versionedpath'], array(
'show-deleted' => true,
'hidden' => true,
'path_preg' => '#/\.versions/#',
)+(!(int)$content['ctime'] ? array() : array(
'ctime' => ($content['ctime']<0?'-':'+').(int)$content['ctime'],
)), function($path) use (&$deleted, &$errors)
{ {
++$deleted; if (Vfs::unlink($path))
} {
else ++$deleted;
{ }
++$errors; else
} {
}); ++$errors;
$msg = $errors ? lang('%1 files deleted with %2 errors!', $deleted, $errors) : lang('%1 files deleted.', $deleted); }
});
$msg = $errors ? lang('%1 files deleted with %2 errors!', $deleted, $errors) : lang('%1 files deleted.', $deleted);
}
Vfs::$is_root = false;
} }
Vfs::$is_root = false;
} }
} }
if (true) $content = array( if (true) $content = array(