Allow to empty trash from users page
This commit is contained in:
parent
ef96655277
commit
7f0a87be44
|
@ -3,6 +3,7 @@
|
|||
* Add support for `PROPPATCH`-ing last modification time
|
||||
* Fix creation of ghost directory in user directory (fix #46)
|
||||
* Fix bug with NextCloud client where files were not showing up anymore
|
||||
* Allow to empty trash from user home
|
||||
* Update dependencies
|
||||
|
||||
## 0.4.2
|
||||
|
|
|
@ -547,7 +547,7 @@ class Storage extends AbstractStorage implements TrashInterface
|
|||
|
||||
while ($f = readdir($dir)) {
|
||||
// Skip dots
|
||||
if ($f == '.' || $f = '..') {
|
||||
if ($f === '.' || $f === '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -564,7 +564,7 @@ class Storage extends AbstractStorage implements TrashInterface
|
|||
|
||||
closedir($dir);
|
||||
|
||||
@rmdir($path);
|
||||
rmdir($path);
|
||||
}
|
||||
|
||||
static public function getDirectoryMTime(string $path): int
|
||||
|
|
|
@ -345,4 +345,10 @@ class Users
|
|||
Storage::deleteDirectory($user->path);
|
||||
DB::getInstance()->run('DELETE FROM users WHERE id = ?;', $user->id);
|
||||
}
|
||||
|
||||
public function emptyTrash(?stdClass $user)
|
||||
{
|
||||
$path = rtrim($user->path, '/') . '/.trash';
|
||||
Storage::deleteDirectory($path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,12 @@ if (!$user) {
|
|||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET['empty_trash'])) {
|
||||
$users->emptyTrash($user);
|
||||
header('Location: ./');
|
||||
exit;
|
||||
}
|
||||
|
||||
$quota = $users->quota($user, true);
|
||||
$free = format_bytes($quota->free);
|
||||
$used = format_bytes($quota->used);
|
||||
|
@ -30,6 +36,11 @@ $trash = format_bytes($quota->trash ?? 0);
|
|||
$percent = $quota->total ? floor(($quota->used / $quota->total)*100) . '%' : '100%';
|
||||
$www_url = WWW_URL;
|
||||
$username = htmlspecialchars($user->login);
|
||||
$trash_button = '';
|
||||
|
||||
if ($quota->trash) {
|
||||
$trash_button = '<br /><a href="?empty_trash" class="btn sm">Empty trash now</a>';
|
||||
}
|
||||
|
||||
html_head('My files');
|
||||
|
||||
|
@ -40,7 +51,7 @@ echo <<<EOF
|
|||
<dd><h3>{$percent} used, {$free} free</h3></dd>
|
||||
<dd><progress max="{$quota->total}" value="{$quota->used}"></progress>
|
||||
<dd>Used {$used} out of a total of {$total}.</dd>
|
||||
<dd>Trash: {$trash}.</dd>
|
||||
<dd>Trash: {$trash}. {$trash_button}</dd>
|
||||
<dt>WebDAV URL</dt>
|
||||
<dd><h3><a href="{$user->dav_url}"><tt>{$user->dav_url}</tt></a></h3>
|
||||
<dt>NextCloud URL</dt>
|
||||
|
|
Loading…
Reference in a new issue