2023-04-15 15:38:25 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @brief Uninstaller, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Jean-Christian Denis and Contributors
|
|
|
|
*
|
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Dotclear\Plugin\Uninstaller;
|
|
|
|
|
|
|
|
use dcCore;
|
|
|
|
use dcNsProcess;
|
|
|
|
|
|
|
|
class Prepend extends dcNsProcess
|
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
|
|
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
|
|
|
&& My::phpCompliant()
|
2023-04-15 19:26:40 +00:00
|
|
|
&& dcCore::app()->auth?->isSuperAdmin();
|
2023-04-15 15:38:25 +00:00
|
|
|
|
|
|
|
return static::$init;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function process(): bool
|
|
|
|
{
|
|
|
|
if (!static::$init) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add cleaners to Uninstaller
|
2023-04-19 21:52:12 +00:00
|
|
|
dcCore::app()->addBehavior('UninstallerCleanersConstruct', function (Cleaners $cleaners): void {
|
|
|
|
$cleaners
|
2023-04-19 21:50:27 +00:00
|
|
|
->add(new Cleaner\Settings())
|
2023-04-23 15:58:35 +00:00
|
|
|
->add(new Cleaner\Preferences())
|
2023-04-19 21:50:27 +00:00
|
|
|
->add(new Cleaner\Tables())
|
|
|
|
->add(new Cleaner\Versions())
|
|
|
|
->add(new Cleaner\Logs())
|
|
|
|
->add(new Cleaner\Caches())
|
|
|
|
->add(new Cleaner\Vars())
|
|
|
|
->add(new Cleaner\Themes())
|
|
|
|
->add(new Cleaner\Plugins())
|
|
|
|
;
|
|
|
|
});
|
2023-04-15 15:38:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|