upgrade plugin activityReport

This commit is contained in:
Jean-Christian Paul Denis 2023-10-18 23:44:35 +02:00
parent 0d7b97346a
commit 24a4f68663
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
5 changed files with 63 additions and 58 deletions

View File

@ -1,3 +1,9 @@
dcAdvancedCleaner 1.6 - 2023.10.18
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade plugin acitivtyReport
dcAdvancedCleaner 1.5 - 2023.10.13 dcAdvancedCleaner 1.5 - 2023.10.13
=========================================================== ===========================================================
* Require Dotclear 2.28 * Require Dotclear 2.28

View File

@ -1,7 +1,7 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases) [![Release](https://img.shields.io/badge/release-1.6-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/releases)
![Date](https://img.shields.io/badge/date-2023.10.13-c44d58.svg) ![Date](https://img.shields.io/badge/date-2023.10.18-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/dcAdvancedCleaner) [![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/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/dcAdvancedCleaner/src/branch/master/LICENSE)

View File

@ -18,7 +18,7 @@ $this->registerModule(
'Advanced cleaner', 'Advanced cleaner',
'Make a huge cleaning of dotclear', 'Make a huge cleaning of dotclear',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'1.5', '1.6',
[ [
'requires' => [ 'requires' => [
['core', '2.28'], ['core', '2.28'],

View File

@ -0,0 +1,54 @@
<?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;
}
}

View File

@ -1,55 +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 prepend class.
* @ingroup dcAdvancedCleaner
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
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;
}
}