release 1.5

This commit is contained in:
Jean-Christian Denis 2023-07-28 23:39:25 +02:00
parent 5b53934df4
commit fd582fa42c
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
9 changed files with 67 additions and 99 deletions

View file

@ -1,3 +1,8 @@
1.5 - 2023.07.28
- require dotclear 2.27
- require PHP 8.1+
- update to dotclear 2.27-dev
1.4 - 2023.05.13 1.4 - 2023.05.13
- require dotclear 2.26 - require dotclear 2.26
- require PHP 8.1+ - require PHP 8.1+

View file

@ -3,7 +3,7 @@
[![Release](https://img.shields.io/github/v/release/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/releases)
[![Date](https://img.shields.io/github/release-date/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/releases) [![Date](https://img.shields.io/github/release-date/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/releases)
[![Issues](https://img.shields.io/github/issues/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/issues) [![Issues](https://img.shields.io/github/issues/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/issues)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/dcLog) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/dcLog)
[![License](https://img.shields.io/github/license/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/blob/master/LICENSE) [![License](https://img.shields.io/github/license/JcDenis/dcLog)](https://github.com/JcDenis/dcLog/blob/master/LICENSE)
@ -19,7 +19,7 @@ Display dotclear's logs.
_dcLog_ requires: _dcLog_ requires:
* PHP 8.1+ * PHP 8.1+
* Dotclear 2.26 * Dotclear 2.27
* super admin permission * super admin permission
## USAGE ## USAGE

View file

@ -18,11 +18,11 @@ $this->registerModule(
"Dotclear's logs", "Dotclear's logs",
'Displays Dotclear logs', 'Displays Dotclear logs',
'Tomtom and Contributors', 'Tomtom and Contributors',
'1.4', '1.5',
[ [
'requires' => [ 'requires' => [
['php', '8.1'], ['php', '8.1'],
['core', '2.26'], ['core', '2.27'],
], ],
'permissions' => null, 'permissions' => null,
'type' => 'plugin', 'type' => 'plugin',

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="dcLog"> <module id="dcLog">
<name>Dotclear's logs</name> <name>Dotclear's logs</name>
<version>1.4</version> <version>1.5</version>
<author>Tomtom and Contributors</author> <author>Tomtom and Contributors</author>
<desc>Displays Dotclear logs</desc> <desc>Displays Dotclear logs</desc>
<file>https://github.com/JcDenis/dcLog/releases/download/v1.4/plugin-dcLog.zip</file> <file>https://github.com/JcDenis/dcLog/releases/download/v1.5/plugin-dcLog.zip</file>
<da:dcmin>2.26</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/dcLog</da:details> <da:details>https://plugins.dotaddict.org/dc2/details/dcLog</da:details>
<da:support>https://github.com/JcDenis/dcLog</da:support> <da:support>https://github.com/JcDenis/dcLog</da:support>
</module> </module>

View file

@ -15,43 +15,26 @@ declare(strict_types=1);
namespace Dotclear\Plugin\dcLog; namespace Dotclear\Plugin\dcLog;
use ArrayObject; use ArrayObject;
use dcAdmin;
use dcCore; use dcCore;
use dcFavorites; use Dotclear\Core\Process;
use dcMenu; use Dotclear\Core\Backend\Favorites;
use dcNsProcess; use Dotclear\Core\Backend\Menus;
use dcPage;
class Backend extends dcNsProcess class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::BACKEND));
&& !is_null(dcCore::app()->auth) ;
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
// backend sidebar menu icon My::addBackendMenuItem(Menus::MENU_SYSTEM);
if (!is_null(dcCore::app()->auth)
&& !is_null(dcCore::app()->adminurl)
&& (dcCore::app()->menu[dcAdmin::MENU_SYSTEM] instanceof dcMenu)
) {
dcCore::app()->menu[dcAdmin::MENU_SYSTEM]->addItem(
My::name(),
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
dcPage::getPF(My::id() . '/icon.svg'),
preg_match('/' . preg_quote((string) dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->isSuperAdmin()
);
}
dcCore::app()->addBehaviors([ dcCore::app()->addBehaviors([
// backend user preference for logs list columns // backend user preference for logs list columns
@ -86,12 +69,12 @@ class Backend extends dcNsProcess
]; ];
}, },
// backend user preference for dashboard icon // backend user preference for dashboard icon
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void { 'adminDashboardFavoritesV2' => function (Favorites $favs): void {
$favs->register(My::BACKEND_LIST_ID, [ $favs->register(My::BACKEND_LIST_ID, [
'title' => My::name(), 'title' => My::name(),
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), 'url' => My::manageUrl(),
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'), 'small-icon' => My::icons(),
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'), 'large-icon' => My::icons(),
//'permissions' => null, //'permissions' => null,
]); ]);
}, },

View file

@ -15,8 +15,10 @@ declare(strict_types=1);
namespace Dotclear\Plugin\dcLog; namespace Dotclear\Plugin\dcLog;
use ArrayObject; use ArrayObject;
use adminGenericListV2; use Dotclear\Core\Backend\Listing\{
use dcPager; Listing,
Pager
};
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
@ -30,7 +32,7 @@ use Dotclear\Helper\Html\Form\{
/** /**
* Backend logs list helper. * Backend logs list helper.
*/ */
class BackendList extends adminGenericListV2 class BackendList extends Listing
{ {
/** /**
* Display logs record. * Display logs record.
@ -51,7 +53,7 @@ class BackendList extends adminGenericListV2
return; return;
} }
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10); $pager = new Pager($page, $this->rs_count, $nb_per_page, 10);
$cols = new ArrayObject([ $cols = new ArrayObject([
'date' => (new Text('th', __('Date'))) 'date' => (new Text('th', __('Date')))

View file

@ -15,8 +15,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\dcLog; namespace Dotclear\Plugin\dcLog;
use dcCore; use dcCore;
use dcNsProcess; use Dotclear\Core\Process;
use dcPage; use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Div, Div,
Form, Form,
@ -30,20 +33,16 @@ use Exception;
/** /**
* Manage logs list * Manage logs list
*/ */
class Manage extends dcNsProcess class Manage extends Process
{ {
public static function init(): bool public static function init(): bool
{ {
static::$init = defined('DC_CONTEXT_ADMIN') return self::status(My::checkContext(My::MANAGE));
&& !is_null(dcCore::app()->auth)
&& dcCore::app()->auth->isSuperAdmin();
return static::$init;
} }
public static function process(): bool public static function process(): bool
{ {
if (!static::$init) { if (!self::status()) {
return false; return false;
} }
@ -53,12 +52,12 @@ class Manage extends dcNsProcess
if ($current->selected_logs && !empty($current->entries) || $current->all_logs) { if ($current->selected_logs && !empty($current->entries) || $current->all_logs) {
try { try {
dcCore::app()->log->delLogs($current->entries, $current->all_logs); dcCore::app()->log->delLogs($current->entries, $current->all_logs);
dcPage::addSuccessNotice( Notices::addSuccessNotice(
$current->all_logs ? $current->all_logs ?
__('All logs have been successfully deleted') : __('All logs have been successfully deleted') :
__('Selected logs have been successfully deleted') __('Selected logs have been successfully deleted')
); );
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id()); My::redirect();
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
@ -69,30 +68,30 @@ class Manage extends dcNsProcess
public static function render(): void public static function render(): void
{ {
if (!static::$init) { if (!self::status()) {
return; return;
} }
$current = ManageVars::init(); $current = ManageVars::init();
dcPage::openModule( Page::openModule(
My::name(), My::name(),
dcPage::jsJson('dcLog_msg', [ Page::jsJson('dcLog_msg', [
'confirm_delete_selected_log' => __('Are you sure you want to delete selected logs?'), 'confirm_delete_selected_log' => __('Are you sure you want to delete selected logs?'),
'confirm_delete_all_log' => __('Are you sure you want to delete all logs?'), 'confirm_delete_all_log' => __('Are you sure you want to delete all logs?'),
]) . ]) .
$current->filter->js((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) . $current->filter->js((string) My::manageUrl()) .
dcPage::jsLoad(dcPage::getPF(My::id() . '/js/backend.js')) My::jsLoad('backend')
); );
echo echo
dcPage::breadcrumb( Page::breadcrumb(
[ [
__('System') => '', __('System') => '',
My::name() => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()), My::name() => My::manageUrl(),
] ]
) . ) .
dcPage::notices(); Notices::getNotices();
if ($current->logs !== null && $current->list != null) { if ($current->logs !== null && $current->list != null) {
if ($current->logs->isEmpty() && !$current->filter->show()) { if ($current->logs->isEmpty() && !$current->filter->show()) {
@ -109,7 +108,7 @@ class Manage extends dcNsProcess
is_numeric($current->filter->__get('page')) ? (int) $current->filter->__get('page') : 1, is_numeric($current->filter->__get('page')) ? (int) $current->filter->__get('page') : 1,
is_numeric($current->filter->__get('nb')) ? (int) $current->filter->__get('nb') : 10, is_numeric($current->filter->__get('nb')) ? (int) $current->filter->__get('nb') : 10,
(new Form('dcLog_form')) (new Form('dcLog_form'))
->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) ->action(My::manageUrl())
->method('post') ->method('post')
->fields([ ->fields([
(new Text('', '%s')), (new Text('', '%s')),
@ -131,7 +130,7 @@ class Manage extends dcNsProcess
]), ]),
(new Text( (new Text(
'', '',
dcCore::app()->adminurl?->getHiddenFormFields('admin.plugin.' . My::id(), $current->filter->values()) . dcCore::app()->admin->url->getHiddenFormFields('admin.plugin.' . My::id(), $current->filter->values()) .
dcCore::app()->formNonce() dcCore::app()->formNonce()
)), )),
]), ]),
@ -141,6 +140,6 @@ class Manage extends dcNsProcess
} }
} }
dcPage::closeModule(); Page::closeModule();
} }
} }

View file

@ -14,9 +14,11 @@ declare(strict_types=1);
namespace Dotclear\Plugin\dcLog; namespace Dotclear\Plugin\dcLog;
use adminGenericFilterV2;
use dcAdminFilters;
use dcCore; use dcCore;
use Dotclear\Core\Backend\Filter\{
Filters,
FiltersLibrary
};
use Dotclear\Database\MetaRecord; use Dotclear\Database\MetaRecord;
use Exception; use Exception;
@ -28,8 +30,8 @@ class ManageVars
/** @var ManageVars $container self instance */ /** @var ManageVars $container self instance */
private static $container; private static $container;
/** @var adminGenericFilterV2 $filter The filter instance */ /** @var Filters $filter The filter instance */
public readonly adminGenericFilterV2 $filter; public readonly Filters $filter;
/** @var null|MetaRecord $logs The current records */ /** @var null|MetaRecord $logs The current records */
public readonly ?MetaRecord $logs; public readonly ?MetaRecord $logs;
@ -55,12 +57,12 @@ class ManageVars
$this->all_logs = isset($_POST['all_logs']); $this->all_logs = isset($_POST['all_logs']);
$this->selected_logs = isset($_POST['selected_logs']); $this->selected_logs = isset($_POST['selected_logs']);
$this->filter = new adminGenericFilterV2('dcloglist'); $this->filter = new Filters('dcloglist');
$this->filter->add(dcAdminFilters::getPageFilter()); $this->filter->add(FiltersLibrary::getPageFilter());
$this->filter->add(dcAdminFilters::getInputFilter('blog_id', __('Blog:'))); $this->filter->add(FiltersLibrary::getInputFilter('blog_id', __('Blog:')));
$this->filter->add(dcAdminFilters::getInputFilter('user_id', __('User:'))); $this->filter->add(FiltersLibrary::getInputFilter('user_id', __('User:')));
$this->filter->add(dcAdminFilters::getInputFilter('log_table', __('Component:'))); $this->filter->add(FiltersLibrary::getInputFilter('log_table', __('Component:')));
$this->filter->add(dcAdminFilters::getInputFilter('log_ip', __('IP:'))); $this->filter->add(FiltersLibrary::getInputFilter('log_ip', __('IP:')));
$params = $this->filter->params(); $params = $this->filter->params();
try { try {

View file

@ -15,38 +15,15 @@ declare(strict_types=1);
namespace Dotclear\Plugin\dcLog; namespace Dotclear\Plugin\dcLog;
use dcCore; use dcCore;
use Dotclear\Module\MyPlugin;
/** class My extends MyPlugin
* This module definition.
*/
class My
{ {
/** @var string Admin list ID */ /** @var string Admin list ID */
public const BACKEND_LIST_ID = 'dcloglist'; public const BACKEND_LIST_ID = 'dcloglist';
/** public static function checkCustomContext(int $context): ?bool
* This module id.
*/
public static function id(): string
{ {
return basename(dirname(__DIR__)); return dcCore::app()->auth->isSuperAdmin();
}
/**
* This module name.
*/
public static function name(): string
{
$name = dcCore::app()->plugins->moduleInfo(self::id(), 'name');
return __(is_string($name) ? $name : self::id());
}
/**
* This module path.
*/
public static function path(): string
{
return dirname(__DIR__);
} }
} }