release 1.5
This commit is contained in:
parent
5b53934df4
commit
fd582fa42c
9 changed files with 67 additions and 99 deletions
|
@ -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
|
||||
- require dotclear 2.26
|
||||
- require PHP 8.1+
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[![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)
|
||||
[![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)
|
||||
[![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:
|
||||
|
||||
* PHP 8.1+
|
||||
* Dotclear 2.26
|
||||
* Dotclear 2.27
|
||||
* super admin permission
|
||||
|
||||
## USAGE
|
||||
|
|
|
@ -18,11 +18,11 @@ $this->registerModule(
|
|||
"Dotclear's logs",
|
||||
'Displays Dotclear logs',
|
||||
'Tomtom and Contributors',
|
||||
'1.4',
|
||||
'1.5',
|
||||
[
|
||||
'requires' => [
|
||||
['php', '8.1'],
|
||||
['core', '2.26'],
|
||||
['core', '2.27'],
|
||||
],
|
||||
'permissions' => null,
|
||||
'type' => 'plugin',
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="dcLog">
|
||||
<name>Dotclear's logs</name>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
<author>Tomtom and Contributors</author>
|
||||
<desc>Displays Dotclear logs</desc>
|
||||
<file>https://github.com/JcDenis/dcLog/releases/download/v1.4/plugin-dcLog.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<file>https://github.com/JcDenis/dcLog/releases/download/v1.5/plugin-dcLog.zip</file>
|
||||
<da:dcmin>2.27</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/dcLog</da:details>
|
||||
<da:support>https://github.com/JcDenis/dcLog</da:support>
|
||||
</module>
|
||||
|
|
|
@ -15,43 +15,26 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcLog;
|
||||
|
||||
use ArrayObject;
|
||||
use dcAdmin;
|
||||
use dcCore;
|
||||
use dcFavorites;
|
||||
use dcMenu;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\Backend\Menus;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
class Backend extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth)
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::BACKEND));
|
||||
;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// backend sidebar menu icon
|
||||
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()
|
||||
);
|
||||
}
|
||||
My::addBackendMenuItem(Menus::MENU_SYSTEM);
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
// backend user preference for logs list columns
|
||||
|
@ -86,12 +69,12 @@ class Backend extends dcNsProcess
|
|||
];
|
||||
},
|
||||
// backend user preference for dashboard icon
|
||||
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
|
||||
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
|
||||
$favs->register(My::BACKEND_LIST_ID, [
|
||||
'title' => My::name(),
|
||||
'url' => dcCore::app()->adminurl?->get('admin.plugin.' . My::id()),
|
||||
'small-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'large-icon' => dcPage::getPF(My::id() . '/icon.svg'),
|
||||
'url' => My::manageUrl(),
|
||||
'small-icon' => My::icons(),
|
||||
'large-icon' => My::icons(),
|
||||
//'permissions' => null,
|
||||
]);
|
||||
},
|
||||
|
|
|
@ -15,8 +15,10 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcLog;
|
||||
|
||||
use ArrayObject;
|
||||
use adminGenericListV2;
|
||||
use dcPager;
|
||||
use Dotclear\Core\Backend\Listing\{
|
||||
Listing,
|
||||
Pager
|
||||
};
|
||||
use Dotclear\Helper\Date;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
|
@ -30,7 +32,7 @@ use Dotclear\Helper\Html\Form\{
|
|||
/**
|
||||
* Backend logs list helper.
|
||||
*/
|
||||
class BackendList extends adminGenericListV2
|
||||
class BackendList extends Listing
|
||||
{
|
||||
/**
|
||||
* Display logs record.
|
||||
|
@ -51,7 +53,7 @@ class BackendList extends adminGenericListV2
|
|||
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([
|
||||
'date' => (new Text('th', __('Date')))
|
||||
|
|
|
@ -15,8 +15,11 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcLog;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Core\Backend\{
|
||||
Notices,
|
||||
Page
|
||||
};
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Div,
|
||||
Form,
|
||||
|
@ -30,20 +33,16 @@ use Exception;
|
|||
/**
|
||||
* Manage logs list
|
||||
*/
|
||||
class Manage extends dcNsProcess
|
||||
class Manage extends Process
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth)
|
||||
&& dcCore::app()->auth->isSuperAdmin();
|
||||
|
||||
return static::$init;
|
||||
return self::status(My::checkContext(My::MANAGE));
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -53,12 +52,12 @@ class Manage extends dcNsProcess
|
|||
if ($current->selected_logs && !empty($current->entries) || $current->all_logs) {
|
||||
try {
|
||||
dcCore::app()->log->delLogs($current->entries, $current->all_logs);
|
||||
dcPage::addSuccessNotice(
|
||||
Notices::addSuccessNotice(
|
||||
$current->all_logs ?
|
||||
__('All logs have been successfully deleted') :
|
||||
__('Selected logs have been successfully deleted')
|
||||
);
|
||||
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id());
|
||||
My::redirect();
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
}
|
||||
|
@ -69,30 +68,30 @@ class Manage extends dcNsProcess
|
|||
|
||||
public static function render(): void
|
||||
{
|
||||
if (!static::$init) {
|
||||
if (!self::status()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current = ManageVars::init();
|
||||
|
||||
dcPage::openModule(
|
||||
Page::openModule(
|
||||
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_all_log' => __('Are you sure you want to delete all logs?'),
|
||||
]) .
|
||||
$current->filter->js((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) .
|
||||
dcPage::jsLoad(dcPage::getPF(My::id() . '/js/backend.js'))
|
||||
$current->filter->js((string) My::manageUrl()) .
|
||||
My::jsLoad('backend')
|
||||
);
|
||||
|
||||
echo
|
||||
dcPage::breadcrumb(
|
||||
Page::breadcrumb(
|
||||
[
|
||||
__('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->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('nb')) ? (int) $current->filter->__get('nb') : 10,
|
||||
(new Form('dcLog_form'))
|
||||
->action(dcCore::app()->adminurl?->get('admin.plugin.' . My::id()))
|
||||
->action(My::manageUrl())
|
||||
->method('post')
|
||||
->fields([
|
||||
(new Text('', '%s')),
|
||||
|
@ -131,7 +130,7 @@ class Manage extends dcNsProcess
|
|||
]),
|
||||
(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()
|
||||
)),
|
||||
]),
|
||||
|
@ -141,6 +140,6 @@ class Manage extends dcNsProcess
|
|||
}
|
||||
}
|
||||
|
||||
dcPage::closeModule();
|
||||
Page::closeModule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Dotclear\Plugin\dcLog;
|
||||
|
||||
use adminGenericFilterV2;
|
||||
use dcAdminFilters;
|
||||
use dcCore;
|
||||
use Dotclear\Core\Backend\Filter\{
|
||||
Filters,
|
||||
FiltersLibrary
|
||||
};
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Exception;
|
||||
|
||||
|
@ -28,8 +30,8 @@ class ManageVars
|
|||
/** @var ManageVars $container self instance */
|
||||
private static $container;
|
||||
|
||||
/** @var adminGenericFilterV2 $filter The filter instance */
|
||||
public readonly adminGenericFilterV2 $filter;
|
||||
/** @var Filters $filter The filter instance */
|
||||
public readonly Filters $filter;
|
||||
|
||||
/** @var null|MetaRecord $logs The current records */
|
||||
public readonly ?MetaRecord $logs;
|
||||
|
@ -55,12 +57,12 @@ class ManageVars
|
|||
$this->all_logs = isset($_POST['all_logs']);
|
||||
$this->selected_logs = isset($_POST['selected_logs']);
|
||||
|
||||
$this->filter = new adminGenericFilterV2('dcloglist');
|
||||
$this->filter->add(dcAdminFilters::getPageFilter());
|
||||
$this->filter->add(dcAdminFilters::getInputFilter('blog_id', __('Blog:')));
|
||||
$this->filter->add(dcAdminFilters::getInputFilter('user_id', __('User:')));
|
||||
$this->filter->add(dcAdminFilters::getInputFilter('log_table', __('Component:')));
|
||||
$this->filter->add(dcAdminFilters::getInputFilter('log_ip', __('IP:')));
|
||||
$this->filter = new Filters('dcloglist');
|
||||
$this->filter->add(FiltersLibrary::getPageFilter());
|
||||
$this->filter->add(FiltersLibrary::getInputFilter('blog_id', __('Blog:')));
|
||||
$this->filter->add(FiltersLibrary::getInputFilter('user_id', __('User:')));
|
||||
$this->filter->add(FiltersLibrary::getInputFilter('log_table', __('Component:')));
|
||||
$this->filter->add(FiltersLibrary::getInputFilter('log_ip', __('IP:')));
|
||||
$params = $this->filter->params();
|
||||
|
||||
try {
|
||||
|
|
31
src/My.php
31
src/My.php
|
@ -15,38 +15,15 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\dcLog;
|
||||
|
||||
use dcCore;
|
||||
use Dotclear\Module\MyPlugin;
|
||||
|
||||
/**
|
||||
* This module definition.
|
||||
*/
|
||||
class My
|
||||
class My extends MyPlugin
|
||||
{
|
||||
/** @var string Admin list ID */
|
||||
public const BACKEND_LIST_ID = 'dcloglist';
|
||||
|
||||
/**
|
||||
* This module id.
|
||||
*/
|
||||
public static function id(): string
|
||||
public static function checkCustomContext(int $context): ?bool
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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__);
|
||||
return dcCore::app()->auth->isSuperAdmin();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue