Compare commits
No commits in common. "master" and "v1.3" have entirely different histories.
24
CHANGELOG.md
24
CHANGELOG.md
@ -1,27 +1,3 @@
|
||||
dcAdvancedCleaner 1.6.1 - 2023.11.04
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Cosmetic fix
|
||||
|
||||
dcAdvancedCleaner 1.6 - 2023.10.18
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade plugin acitivtyReport
|
||||
|
||||
dcAdvancedCleaner 1.5 - 2023.10.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Code review
|
||||
|
||||
dcAdvancedCleaner 1.4 - 2023.10.07
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to Dotclear 2.28
|
||||
|
||||
dcAdvancedCleaner 1.3 - 2023.08.14
|
||||
===========================================================
|
||||
* Require Dotclear 2.27
|
||||
|
33
README.md
33
README.md
@ -1,23 +1,27 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-1.6.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Release](https://img.shields.io/badge/release-1.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases)
|
||||
[![Date](https://img.shields.io/badge/date-2023.08.14-c44d58.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/src/branch/master/LICENSE)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/dcAdvancedCleaner)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/blob/master/LICENSE)
|
||||
|
||||
## ABOUT
|
||||
## WHAT IS DCADVANCEDCLEANER ?
|
||||
|
||||
_dcAdvancedCleaner_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
|
||||
_dcAdvancedCleaner_ is a plugin for the open-source
|
||||
web publishing software called Dotclear.
|
||||
|
||||
> It help clean up Dotclear install, plugins, themes, settings, tables, cache, etc...
|
||||
It help clean up Dotclear install, plugins, themes,
|
||||
settings, tables, cache, etc...
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Plugin Uninstaller (from distribution)
|
||||
* Dotclaer superadmin permission
|
||||
_dcAdvancedCleaner_ requires:
|
||||
|
||||
* Permissions superadmin
|
||||
* Dotclear 2.27
|
||||
* PHP >= 8.1
|
||||
* Plugin Uninstaller (temporary at https://github.com/JcDenis/Uninstaller )
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -32,12 +36,7 @@ Once it's done you can manage cleaners from menu
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner) or [GitHub Page](https://github.com/JcDenis/dcAdvancedCleaner)
|
||||
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner)
|
||||
|
||||
* [License](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/src/branch/master/LICENSE)
|
||||
* [Packages & details](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner))
|
||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner) (or on [GitHub](https://github.com/JcDenis/dcAdvancedCleaner))
|
||||
* [Issues & security](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/issues) (or on [GitHub](https://github.com/JcDenis/dcAdvancedCleaner/issues))
|
||||
* [Discuss & help](https://forum.dotclear.org/viewtopic.php?id=40381)
|
||||
* Discuss and help : [Dotclear Forum](https://forum.dotclear.org/viewtopic.php?id=40381)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
|
25
_define.php
25
_define.php
@ -1,30 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin dcAdvancedCleaner definition
|
||||
* @ingroup dcAdvancedCleaner
|
||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||
*
|
||||
* @defgroup dcAdvancedCleaner Plugin dcAdvancedCleaner.
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* Make a huge cleaning of dotclear.
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->registerModule(
|
||||
'Advanced cleaner',
|
||||
'Make a huge cleaning of dotclear',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'1.6.1',
|
||||
'1.3',
|
||||
[
|
||||
'requires' => [
|
||||
['core', '2.28'],
|
||||
['Uninstaller', '1.0'],
|
||||
['php', '8.1'],
|
||||
['core', '2.27'],
|
||||
['Uninstaller', '0.8'],
|
||||
],
|
||||
'permissions' => 'My',
|
||||
'permissions' => null,
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||
|
@ -2,11 +2,11 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="dcAdvancedCleaner">
|
||||
<name>Advanced cleaner</name>
|
||||
<version>1.6.1</version>
|
||||
<version>1.3</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Make a huge cleaning of dotclear</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases/download/v1.6.1/plugin-dcAdvancedCleaner.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<file>https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases/download/v1.3/plugin-dcAdvancedCleaner.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/issues</da:support>
|
||||
</module>
|
||||
|
@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief dcAdvancedCleaner resources helper.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @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
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'dcAdvancedCleaner', __DIR__ . '/help/dcAdvancedCleaner.html');
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
dcCore::app()->resources['help']['dcAdvancedCleaner'] = __DIR__ . '/help/dcAdvancedCleaner.html';
|
||||
|
@ -1,11 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief dcAdvancedCleaner resources helper.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
* @brief dcAdvancedCleaner, a plugin for Dotclear 2
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @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
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'dcAdvancedCleaner', __DIR__ . '/help/dcAdvancedCleaner.html');
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
dcCore::app()->resources['help']['dcAdvancedCleaner'] = __DIR__ . '/help/dcAdvancedCleaner.html';
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\dcAdvancedCleaner;
|
||||
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\activityReport\{
|
||||
Action,
|
||||
ActivityReport,
|
||||
Group
|
||||
};
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner plugin activityReport class.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ActivityReportAction extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(true);
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$group = new Group(My::id(), My::name());
|
||||
|
||||
$group->add(new Action(
|
||||
'uninstall',
|
||||
__('Uninstalling module'),
|
||||
'%s',
|
||||
'UninstallerBeforeAction',
|
||||
function (string $id, string $action, string $ns): void {
|
||||
$success = Uninstaller::instance()->cleaners->get($id)?->get($action)?->success;
|
||||
if (!is_null($success)) {
|
||||
ActivityReport::instance()->addLog(My::id(), 'uninstall', [sprintf($success, $ns)]);
|
||||
}
|
||||
}
|
||||
));
|
||||
|
||||
ActivityReport::instance()->groups->add($group);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,20 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner backend class.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -24,19 +27,20 @@ class Backend extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !App::plugins()->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
My::addBackendMenuItem();
|
||||
|
||||
App::behavior()->addBehaviors([
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(My::id(), [
|
||||
'title' => My::name(),
|
||||
'url' => My::manageURL(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => dcCore::app()->auth?->isSuperAdmin(),
|
||||
]);
|
||||
},
|
||||
]);
|
||||
|
@ -1,10 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
@ -25,13 +35,6 @@ use Dotclear\Helper\Html\Form\{
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner manage class.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -41,7 +44,7 @@ class Manage extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status() || !App::plugins()->moduleExists('Uninstaller')) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -86,7 +89,7 @@ class Manage extends Process
|
||||
Notices::addSuccessNotice(__('Action successfuly excecuted'));
|
||||
My::redirect(['part' => $vars->cleaner->id]);
|
||||
} catch (Exception $e) {
|
||||
App::error()->add($e->getMessage());
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +112,7 @@ class Manage extends Process
|
||||
);
|
||||
|
||||
# --BEHAVIOR-- dcAdvancedCleanerAdminHeader
|
||||
App::behavior()->callBehavior('dcAdvancedCleanerAdminHeader');
|
||||
dcCore::app()->callBehavior('dcAdvancedCleanerAdminHeader');
|
||||
|
||||
$breadcrumb = [
|
||||
__('Plugins') => '',
|
||||
@ -141,7 +144,7 @@ class Manage extends Process
|
||||
|
||||
if (empty($vars->related)) {
|
||||
echo
|
||||
(new Form('parts_menu'))->method('get')->action(App::backend()->getPageURL())->fields([
|
||||
(new Form('parts_menu'))->method('get')->action(dcCore::app()->admin->getPageURL())->fields([
|
||||
(new Para())->class('anchor-nav')->items([
|
||||
(new Label(__('Goto:'), Label::OUTSIDE_LABEL_BEFORE))->for('part')->class('classic'),
|
||||
(new Select(['part', 'select_part']))->default($vars->cleaner->id)->items($vars->combo),
|
||||
@ -169,7 +172,7 @@ class Manage extends Process
|
||||
}
|
||||
|
||||
echo
|
||||
'<form method="post" action="' . App::backend()->getPageURL() . '" id="form-funcs">' .
|
||||
'<form method="post" action="' . dcCore::app()->admin->getPageURL() . '" id="form-funcs">' .
|
||||
'<div class="table-outer">' .
|
||||
'<table><caption>' . sprintf(__('There are %s entries'), count($rs)) . '</caption><thead><tr>' .
|
||||
'<th colspan="2">' . __('Name') . '</th><th colspan="2">' . __('Objects') . '</th>' .
|
||||
@ -218,7 +221,7 @@ class Manage extends Process
|
||||
}
|
||||
|
||||
echo
|
||||
(new Form('option'))->method('post')->action(App::backend()->getPageURL())->fields([
|
||||
(new Form('option'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
||||
(new Para())->items([
|
||||
(new Submit('option-action'))->value(My::settings()->getGlobal('dcproperty_hide') ? __('Show Dotclear default properties') : __('Hide Dotclear default properties')),
|
||||
(new Hidden('dcproperty_hide', My::settings()->getGlobal('dcproperty_hide') ? '0' : '1')),
|
||||
@ -237,7 +240,7 @@ class Manage extends Process
|
||||
echo (new Text('p', __('There is nothing to display')))->class('error')->render();
|
||||
} else {
|
||||
echo
|
||||
'<form method="post" action="' . App::backend()->getPageURL() . '" id="form-funcs">' .
|
||||
'<form method="post" action="' . dcCore::app()->admin->getPageURL() . '" id="form-funcs">' .
|
||||
'<div class="table-outer">' .
|
||||
'<table><caption>' . sprintf(__('There are %s related entries for the group "%s"'), count($rs), $vars->related) . '</caption><thead><tr>' .
|
||||
'<th colspan="2">' . __('Name') . '</th><th>' . __('Objects') . '</th>' .
|
||||
@ -260,11 +263,10 @@ class Manage extends Process
|
||||
'</tbody></table></div>' .
|
||||
(new Para())->items([
|
||||
(new Submit('do-action'))->class('delete')->value(__('I understand and I am want to delete this')),
|
||||
... My::hiddenFields([
|
||||
'related' => $vars->related,
|
||||
'part' => $vars->cleaner->id,
|
||||
'action' => 'delete_related',
|
||||
]),
|
||||
(new Hidden(['related'], $vars->related)),
|
||||
(new Hidden(['part'], $vars->cleaner->id)),
|
||||
(new Hidden(['action'], 'delete_related')),
|
||||
... My::hiddenFields(),
|
||||
])->render() .
|
||||
'<p class="warning">' .
|
||||
__('Beware: All actions done here are irreversible and are directly applied') .
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
@ -11,62 +21,27 @@ use Dotclear\Plugin\Uninstaller\{
|
||||
};
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner vars definition class.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class ManageVars
|
||||
{
|
||||
/**
|
||||
* self instance.
|
||||
*
|
||||
* @var ManageVars $container
|
||||
*/
|
||||
/** @var ManageVars self instance */
|
||||
private static $container;
|
||||
|
||||
/**
|
||||
* The cleaners stack.
|
||||
*
|
||||
* @var CleanersStack $cleaners
|
||||
*/
|
||||
/** @var CleanersStack The cleaners stack */
|
||||
public readonly CleanersStack $cleaners;
|
||||
|
||||
/**
|
||||
* The post form cleaner.
|
||||
*
|
||||
* @var null|CleanerParent $cleaner
|
||||
*/
|
||||
/** @var null|CleanerParent The post form cleaner */
|
||||
public readonly ?CleanerParent $cleaner;
|
||||
|
||||
/**
|
||||
* The post form related action id.
|
||||
*
|
||||
* @var string $related
|
||||
*/
|
||||
/** @var string $related The post form related action id */
|
||||
public readonly string $related;
|
||||
|
||||
/**
|
||||
* The post form selected ns.
|
||||
*
|
||||
* @var array<int,string> $entries
|
||||
*/
|
||||
/** @var array<int,string> The post form selected ns */
|
||||
public readonly array $entries;
|
||||
|
||||
/**
|
||||
* The post form action id.
|
||||
*
|
||||
* @var string $action
|
||||
*/
|
||||
/** @var string The post form action id */
|
||||
public readonly string $action;
|
||||
|
||||
/**
|
||||
* The form actions combo.
|
||||
*
|
||||
* @var array<string,string> $combo
|
||||
*/
|
||||
/** @var array<string,string> The form actions combo */
|
||||
public readonly array $combo;
|
||||
|
||||
protected function __construct()
|
||||
|
27
src/My.php
27
src/My.php
@ -1,27 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
|
||||
use Dotclear\App;
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner My helper.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
{
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return match ($context) {
|
||||
// Limit to super admin
|
||||
self::MODULE => App::auth()->isSuperAdmin(),
|
||||
default => null,
|
||||
};
|
||||
return $context === self::PREPEND ? dcCore::app()->auth->isSuperAdmin() : null;
|
||||
}
|
||||
}
|
||||
|
58
src/Prepend.php
Normal file
58
src/Prepend.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\activityReport\{
|
||||
Action,
|
||||
ActivityReport,
|
||||
Group
|
||||
};
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
class Prepend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
return self::status(My::checkContext(My::PREPEND));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// log plugin Uninstaller actions
|
||||
if (defined('ACTIVITY_REPORT') && ACTIVITY_REPORT == 3) {
|
||||
$group = new Group(My::id(), My::name());
|
||||
$group->add(new Action(
|
||||
'uninstaller',
|
||||
__('Uninstalling module'),
|
||||
'%s',
|
||||
'UninstallerBeforeAction',
|
||||
function (string $id, string $action, string $ns): void {
|
||||
$success = Uninstaller::instance()->cleaners->get($id)?->get($action)?->success;
|
||||
if (!is_null($success)) {
|
||||
ActivityReport::instance()->addLog(My::id(), 'uninstaller', [sprintf($success, $ns)]);
|
||||
}
|
||||
}
|
||||
));
|
||||
ActivityReport::instance()->groups->add($group);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,19 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner, 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\dcAdvancedCleaner;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
|
||||
/**
|
||||
* @brief dcAdvancedCleaner uninstall class.
|
||||
* @ingroup dcAdvancedCleaner
|
||||
*
|
||||
* @author Jean-Christian Denis (author)
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
@ -23,7 +27,7 @@ class Uninstall extends Process
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!self::status()) {
|
||||
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user