feat(files_trashbin): Allow preventing trash to be deleted permanently
Signed-off-by: provokateurin <kate@provokateurin.de>pull/50077/head
parent
26fa4da8c2
commit
31c21c7797
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Trashbin\Listeners;
|
||||
|
||||
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
|
||||
use OCA\Files_Trashbin\Service\ConfigService;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
|
||||
/** @template-implements IEventListener<BeforeTemplateRenderedEvent> */
|
||||
class BeforeTemplateRendered implements IEventListener {
|
||||
public function __construct(
|
||||
private IInitialState $initialState,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof BeforeTemplateRenderedEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigService::injectInitialState($this->initialState);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\Files_Trashbin\Service;
|
||||
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\IConfig;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
class ConfigService {
|
||||
public static function getDeleteFromTrashEnabled(): bool {
|
||||
return Server::get(IConfig::class)->getSystemValueBool('files.trash.delete', true);
|
||||
}
|
||||
|
||||
public static function injectInitialState(IInitialState $initialState): void {
|
||||
$initialState->provideLazyInitialState('config', function () {
|
||||
return [
|
||||
'allow_delete' => ConfigService::getDeleteFromTrashEnabled(),
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue