upgrade to Dotclear 2.27

This commit is contained in:
Jean-Christian Paul Denis 2023-08-17 16:25:19 +02:00
parent d6cc7fca09
commit 0ef7f22f9b
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
13 changed files with 118 additions and 171 deletions

View File

@ -274,7 +274,7 @@ class ActivityBehaviors
public static function blogUpdate(Cursor $cur, string $blog_id): void
{
$logs = [self::str(dcCore::app()->auth?->getInfo('user_cn'))];
$logs = [self::str(dcCore::app()->auth->getInfo('user_cn'))];
ActivityReport::instance()->addLog('blog', 'update', $logs);
}
@ -292,18 +292,19 @@ class ActivityBehaviors
$post_url = dcCore::app()->blog?->getPostURL('', self::str($cur->getField('post_dt')), self::str($cur->getField('post_title')), $post_id);
$logs = [
self::str($cur->getField('post_title')),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
self::str(dcCore::app()->blog?->url) . dcCore::app()->url->getBase(self::str($cur->getField('post_type'))) . '/' . $post_url,
];
ActivityReport::instance()->addLog('post', 'create', $logs);
}
public static function postUpdate(Cursor $cur, int $post_id): void
public static function postUpdate(Cursor $cur, int|string $post_id): void
{
$post_id = is_numeric($post_id) ? (int) $post_id : 0;
$post_url = dcCore::app()->blog?->getPostURL('', self::str($cur->getField('post_dt')), self::str($cur->getField('post_title')), $post_id);
$logs = [
self::str($cur->getField('post_title')),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
self::str(dcCore::app()->blog?->url) . dcCore::app()->url->getBase(self::str($cur->getField('post_type'))) . '/' . $post_url,
];
ActivityReport::instance()->addLog('post', 'update', $logs);
@ -317,7 +318,7 @@ class ActivityBehaviors
}
$logs = [
self::str($posts->f('post_title')),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
];
ActivityReport::instance()->addLog('post', 'delete', $logs);
}
@ -365,7 +366,7 @@ class ActivityBehaviors
}
$logs = [
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
self::str($posts->f('post_title')),
self::str(dcCore::app()->blog?->url) . dcCore::app()->url->getBase(self::str($posts->f('post_type'))) .
'/' . self::str($posts->f('post_url')) . '#c' . self::str($old->f('comment_id')),
@ -400,7 +401,7 @@ class ActivityBehaviors
{
$logs = [
self::str($cur->getField('cat_title')),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
self::str(dcCore::app()->blog?->url) . dcCore::app()->url->getBase('category') . '/' . self::str($cur->getField('cat_url')),
];
ActivityReport::instance()->addLog('category', 'create', $logs);
@ -410,7 +411,7 @@ class ActivityBehaviors
{
$logs = [
self::str($cur->getField('cat_title')),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
self::str(dcCore::app()->blog?->url) . dcCore::app()->url->getBase('category') . '/' . self::str($cur->getField('cat_url')),
];
ActivityReport::instance()->addLog('category', 'update', $logs);
@ -426,7 +427,7 @@ class ActivityBehaviors
);
$logs = [
self::str($user_cn),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
];
ActivityReport::instance()->addLog('user', 'create', $logs);
}
@ -441,7 +442,7 @@ class ActivityBehaviors
);
$logs = [
self::str($user_cn),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
];
ActivityReport::instance()->addLog('user', 'update', $logs);
}
@ -480,7 +481,7 @@ class ActivityBehaviors
);
$logs = [
self::str($user_cn),
self::str(dcCore::app()->auth?->getInfo('user_cn')),
self::str(dcCore::app()->auth->getInfo('user_cn')),
];
ActivityReport::instance()->addLog('user', 'delete', $logs);
}

View File

@ -667,7 +667,7 @@ class ActivityReport
$headers[] = 'From: ' . (defined('DC_ADMIN_MAILFROM') && str_contains(DC_ADMIN_MAILFROM, '@') ? DC_ADMIN_MAILFROM : 'dotclear@local');
$headers[] = 'Content-Type: text/' . $mailformat . '; charset=UTF-8;';
//$headers[] = 'MIME-Version: 1.0';
//$headers[] = 'X-Originating-IP: ' . mb_encode_mimeheader(http::realIP(), 'UTF-8', 'B');
//$headers[] = 'X-Originating-IP: ' . mb_encode_mimeheader(Http::realIP(), 'UTF-8', 'B');
//$headers[] = 'X-Mailer: Dotclear';
//$headers[] = 'X-Blog-Id: ' . mb_encode_mimeheader(dcCore::app()->blog->id), 'UTF-8', 'B');
//$headers[] = 'X-Blog-Name: ' . mb_encode_mimeheader(dcCore::app()->blog->name), 'UTF-8', 'B');
@ -693,8 +693,8 @@ class ActivityReport
*/
public function getUserCode(): string
{
$id = is_string(dcCore::app()->auth?->userID()) ? dcCore::app()->auth->userID() : '';
$pw = is_string(dcCore::app()->auth?->getInfo('user_pwd')) ? dcCore::app()->auth->getInfo('user_pwd') : '';
$id = is_string(dcCore::app()->auth->userID()) ? dcCore::app()->auth->userID() : '';
$pw = is_string(dcCore::app()->auth->getInfo('user_pwd')) ? dcCore::app()->auth->getInfo('user_pwd') : '';
$code = pack('a32', $id) . pack('H*', Crypt::hmac(DC_MASTER_KEY, $pw));
return bin2hex($code);

View File

@ -15,13 +15,10 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use ArrayObject;
use dcAdmin;
use dcAuth;
use dcCore;
use dcFavorites;
use dcMenu;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Process;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Form\{
Div,
@ -34,54 +31,37 @@ use Dotclear\Helper\Html\Form\{
/**
* Backend process
*/
class Backend extends dcNsProcess
class Backend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& defined('ACTIVITY_REPORT')
&& My::isInstalled();
return static::$init;
return self::status(My::checkContext(My::BACKEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
if ((dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu)) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
My::name(),
(string) 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']
),
(bool) dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]), dcCore::app()->blog?->id)
);
}
My::addBackendMenuItem();
dcCore::app()->addBehaviors([
// dashboard favorites icon
'adminDashboardFavoritesV2' => function (dcFavorites $favs): void {
'adminDashboardFavoritesV2' => function (Favorites $favs): void {
$favs->register(My::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'),
'permissions' => dcCore::app()->auth?->makePermissions([
'url' => My::manageUrl(),
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]),
]);
},
// dashboard content display
'adminDashboardContentsV2' => function (ArrayObject $items): void {
$db = dcCore::app()->auth?->user_prefs?->get(My::id())->get('dashboard_item');
$db = dcCore::app()->auth->user_prefs?->get(My::id())->get('dashboard_item');
$limit = abs(is_numeric($db) ? (int) $db : 0);
if (!$limit) {
return ;
@ -109,7 +89,7 @@ class Backend extends dcNsProcess
'<br />' . Date::str(
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
(int) strtotime($row->dt),
is_string(dcCore::app()->auth?->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC'
is_string(dcCore::app()->auth->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC'
) . '<dt>' .
'<dd><p>' .
'<em>' . ActivityReport::parseMessage(__($group->get($row->action)->message), $row->logs) . '</em></p></dd>';
@ -123,12 +103,12 @@ class Backend extends dcNsProcess
'<h3>' . My::name() . '</h3>' .
'<dl id="reports">' . implode('', $lines) . '</dl>' .
'<p class="modules"><a class="module-details" href="' .
dcCore::app()->adminurl?->get('admin.plugin.' . My::id()) . '">' .
My::manageUrl() . '">' .
__('View all logs') . '</a> - <a class="module-config" href="' .
dcCore::app()->adminurl?->get('admin.plugins', [
dcCore::app()->admin->url->get('admin.plugins', [
'module' => My::id(),
'conf' => 1,
'redir' => dcCore::app()->adminurl->get('admin.home'),
'redir' => dcCore::app()->admin->url->get('admin.home'),
]) . '">' .
__('Configure plugin') . '</a></p>' .
'</div>',
@ -136,7 +116,7 @@ class Backend extends dcNsProcess
},
// dashboard content user preference form
'adminDashboardOptionsFormV2' => function (): void {
$db = dcCore::app()->auth?->user_prefs?->get(My::id())->get('dashboard_item');
$db = dcCore::app()->auth->user_prefs?->get(My::id())->get('dashboard_item');
echo
(new Div())->class('fieldset')->items([
(new Text('h4', My::name())),
@ -157,7 +137,7 @@ class Backend extends dcNsProcess
// save dashboard content user preference
'adminAfterDashboardOptionsUpdate' => function (?string $user_id = null): void {
if (!is_null($user_id)) {
dcCore::app()->auth?->user_prefs?->get(My::id())->put(
dcCore::app()->auth->user_prefs?->get(My::id())->put(
'dashboard_item',
(int) $_POST[My::id() . '_dashboard_item'],
'integer'

View File

@ -56,7 +56,7 @@ class Combo
*
* @return array<string,int> The obsolete period combo
*/
public static function obselete(): array
public static function obsolete(): array
{
return [
__('every hour') => 3600,

View File

@ -14,10 +14,9 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcAuth;
use dcCore;
use dcPage;
use dcNsProcess;
use Dotclear\Core\Backend\Notices;
use Dotclear\Core\Process;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Form\{
Checkbox,
@ -35,22 +34,16 @@ use Exception;
/**
* Config process.
*/
class Config extends dcNsProcess
class Config extends Process
{
public static function init(): bool
{
static::$init == defined('DC_CONTEXT_ADMIN')
&& defined('ACTIVITY_REPORT')
&& dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]), dcCore::app()->blog?->id);
return static::$init;
return self::status(My::checkContext(My::CONFIG));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
@ -65,7 +58,7 @@ class Config extends dcNsProcess
if (in_array($_POST['interval'], Combo::interval())) {
$s->set('interval', (int) $_POST['interval']);
}
if (in_array($_POST['obsolete'], Combo::obselete())) {
if (in_array($_POST['obsolete'], Combo::obsolete())) {
$s->set('obsolete', (int) $_POST['obsolete']);
}
$s->set('mailinglist', explode(';', $_POST['mailinglist']));
@ -73,26 +66,26 @@ class Config extends dcNsProcess
$s->set('dateformat', $_POST['dateformat']);
$s->set('requests', $_POST['requests'] ?? []);
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Configuration successfully updated.')
);
if (!empty($_POST['send_report_now'])) {
ActivityReport::instance()->needReport(true);
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Report successfully sent.')
);
}
if (!empty($_POST['delete_report_now'])) {
ActivityReport::instance()->deleteLogs();
dcPage::addSuccessNotice(
Notices::addSuccessNotice(
__('Logs successfully deleted.')
);
}
dcCore::app()->adminurl?->redirect('admin.plugins', [
dcCore::app()->admin->url->redirect('admin.plugins', [
'module' => My::id(),
'conf' => 1,
]);
@ -105,12 +98,12 @@ class Config extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}
$s = ActivityReport::instance()->settings;
$tz = is_string(dcCore::app()->auth?->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC';
$tz = is_string(dcCore::app()->auth->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC';
if (!$s->lastreport) {
$last_report = __('never');
@ -171,11 +164,11 @@ class Config extends dcNsProcess
]),
(new Text(
'ul',
'<li><img alt="' . __('RSS feed') . '" src="' . dcPage::getPF(My::id() . '/img/feed.png') . '" /> ' .
'<li><img alt="' . __('RSS feed') . '" src="' . My::fileURL('img/feed.png') . '" /> ' .
'<a title="' . __('RSS feed') . '" href="' .
dcCore::app()->blog?->url . dcCore::app()->url->getBase(My::id()) . '/rss2/' . ActivityReport::instance()->getUserCode() . '">' .
__('Rss2 activities feed') . '</a></li>' .
'<li><img alt="' . __('Atom feed') . '" src="' . dcPage::getPF(My::id() . '/img/feed.png') . '" /> ' .
'<li><img alt="' . __('Atom feed') . '" src="' . My::fileURL('img/feed.png') . '" /> ' .
'<a title="' . __('Atom feed') . '" href="' .
dcCore::app()->blog?->url . dcCore::app()->url->getBase(My::id()) . '/atom/' . ActivityReport::instance()->getUserCode() . '">' .
__('Atom activities feed') . '</a></li>'
@ -211,8 +204,8 @@ class Config extends dcNsProcess
(new Div('settings'))->class('fieldset')->items([
(new Text('h4', __('Maintenance'))),
(new Para())->items([
(new Label(__('Automatic cleaning of old logs:'), Label::OUTSIDE_LABEL_BEFORE))->for('obselete'),
(new Select('obselete'))->default((string) $s->obsolete)->items(Combo::obselete()),
(new Label(__('Automatic cleaning of old logs:'), Label::OUTSIDE_LABEL_BEFORE))->for('obsolete'),
(new Select('obsolete'))->default((string) $s->obsolete)->items(Combo::obsolete()),
]),
(new Para())->items([
(new Checkbox('send_report_now'))->value(1),

View File

@ -15,24 +15,21 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
/**
* Front end process.
*/
class Frontend extends dcNsProcess
class Frontend extends Process
{
public static function init(): bool
{
static::$init = defined('ACTIVITY_REPORT')
&& My::isInstalled();
return static::$init;
return self::status(My::checkContext(My::FRONTEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Database\Structure;
use Dotclear\Database\Statement\{
DropStatement,
@ -26,20 +26,16 @@ use Exception;
/**
* Install process.
*/
class Install extends dcNsProcess
class Install extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& is_string(dcCore::app()->plugins->moduleInfo(My::id(), 'version'))
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
return static::$init;
return self::status(My::checkContext(My::INSTALL));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -15,11 +15,13 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use ArrayObject;
use adminGenericFilter;
use dcAuth;
use dcCore;
use dcNsProcess;
use dcPage;
use Dotclear\Core\Backend\Filter\Filters;
use Dotclear\Core\Backend\{
Notices,
Page
};
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{
Form,
Hidden,
@ -32,30 +34,24 @@ use Exception;
/**
* Manage process (admin logs list).
*/
class Manage extends dcNsProcess
class Manage extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN')
&& defined('ACTIVITY_REPORT')
&& dcCore::app()->auth?->check(dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_ADMIN,
]), dcCore::app()->blog?->id);
return static::$init;
return self::status(My::checkContext(My::MANAGE));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}
if (!empty($_POST['delete_all_logs']) || !empty($_POST['delete_reported_logs'])) {
try {
ActivityReport::instance()->deleteLogs(!empty($_POST['delete_reported_logs']));
dcPage::addSuccessNotice(__('Logs successfully deleted'));
dcCore::app()->adminurl?->redirect('admin.plugin.' . My::id());
Notices::addSuccessNotice(__('Logs successfully deleted'));
My::redirect();
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
@ -66,40 +62,40 @@ class Manage extends dcNsProcess
public static function render(): void
{
if (!static::$init) {
if (!self::status()) {
return;
}
$logs = $counter = $list = null;
$filter = new adminGenericFilter(dcCore::app(), My::id());
$filter = new Filters(My::id());
$params = new ArrayObject($filter->params());
try {
$logs = ActivityReport::instance()->getLogs($params);
$counter = ActivityReport::instance()->getLogs($params, true);
if (!is_null($logs) && !is_null($counter)) {
$list = new ManageList(dcCore::app(), $logs, $counter->f(0));
$list = new ManageList($logs, $counter->f(0));
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
}
dcPage::openModule(
Page::openModule(
My::name(),
$filter->js((string) dcCore::app()->adminurl?->get('admin.plugin.' . My::id())) .
dcPage::jsJson(My::id(), ['confirm_delete' => __('Are you sure you want to delete logs?')]) .
dcPage::jsModuleLoad(My::id() . '/js/backend.js') .
$filter->js((string) My::manageUrl()) .
Page::jsJson(My::id(), ['confirm_delete' => __('Are you sure you want to delete logs?')]) .
My::jsLoad('backend') .
# --BEHAVIOR-- activityReportListHeader --
dcCore::app()->callBehavior('activityReportListHeader')
);
echo
dcPage::breadcrumb([
Page::breadcrumb([
__('Plugins') => '',
My::name() => '',
]) .
dcPage::notices();
Notices::getNotices();
if (!is_null($list)) {
$filter->display('admin.plugin.' . My::id(), (new Hidden('p', My::id()))->render());
@ -112,11 +108,11 @@ class Manage extends dcNsProcess
(new Para())->class('right')->separator(' ')->items([
(new Submit('delete_all_logs'))->class('delete')->value(__('Delete all aticivity logs')),
(new Submit('delete_reported_logs'))->class('delete')->value(__('Delete all allready reported logs')),
dcCore::app()->formNonce(false),
... My::hiddenFields(),
]),
])->render();
}
dcPage::closeModule();
Page::closeModule();
}
}

View File

@ -15,18 +15,20 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use ArrayObject;
use adminGenericFilter;
use adminGenericList;
use dcCore;
use dcPager;
use Dotclear\Core\Backend\Filter\Filters;
use Dotclear\Core\Backend\Listing\{
Listing,
Pager
};
use Dotclear\Helper\Date;
/**
* Logs admin list helper.
*/
class ManageList extends adminGenericList
class ManageList extends Listing
{
public function logsDisplay(adminGenericFilter $filter, string $enclose_block = ''): void
public function logsDisplay(Filters $filter, string $enclose_block = ''): void
{
if (!$this->rs || $this->rs->isEmpty()) {
if ($filter->show()) {
@ -37,7 +39,7 @@ class ManageList extends adminGenericList
} else {
$page = $filter->value('page');
$nbpp = $filter->value('nb');
$pager = new dcPager(is_numeric($page) ? (int) $page : 1, (int) $this->rs_count, is_numeric($nbpp) ? (int) $nbpp : 20, 10);
$pager = new Pager(is_numeric($page) ? (int) $page : 1, (int) $this->rs_count, is_numeric($nbpp) ? (int) $nbpp : 20, 10);
$pager->var_page = 'page';
$html_block = '<div class="table-outer"><table><caption>' . (
@ -83,7 +85,7 @@ class ManageList extends adminGenericList
$date = Date::str(
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
(int) strtotime($row->dt),
is_string(dcCore::app()->auth?->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC'
is_string(dcCore::app()->auth->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC'
);
$status = $row->status == ActivityReport::STATUS_PENDING ? __('pending') : __('reported');

View File

@ -15,11 +15,12 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
*/
class My
class My extends MyPlugin
{
/** @var string Activity database table name */
public const ACTIVITY_TABLE_NAME = 'activity';
@ -27,30 +28,23 @@ class My
/** @var int Incremental version by breaking changes */
public const COMPATIBILITY_VERSION = 3;
/**
* 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__);
switch($context) {
case My::FRONTEND:
return defined('ACTIVITY_REPORT') && My::isInstalled();
case My::BACKEND:
return defined('DC_CONTEXT_ADMIN') && defined('ACTIVITY_REPORT') && My::isInstalled();
case My::CONFIG:
case My::MANAGE:
return defined('DC_CONTEXT_ADMIN')
&& defined('ACTIVITY_REPORT')
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]), dcCore::app()->blog?->id);
default:
return null;
}
}
/**
@ -60,6 +54,6 @@ class My
*/
public static function isInstalled(): bool
{
return dcCore::app()->getVersion(self::id()) == dcCore::app()->plugins->moduleInfo(self::id(), 'version');
return dcCore::app()->getVersion(self::id()) == (string) dcCore::app()->plugins->getDefine(self::id())->get('version');
}
}

View File

@ -15,25 +15,22 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
use Exception;
/**
* Prepend process.
*/
class Prepend extends dcNsProcess
class Prepend extends Process
{
public static function init(): bool
{
static::$init = defined('DC_RC_PATH')
&& My::isInstalled();
return static::$init;
return self::status(My::checkContext(My::PREPEND));
}
public static function process(): bool
{
if (!static::$init) {
if (!self::status()) {
return false;
}

View File

@ -14,9 +14,6 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use Exception;
/**
* Module settings helper.
*/
@ -51,10 +48,6 @@ class Settings
*/
public function __construct()
{
if (is_null(dcCore::app()->blog)) {
throw new Exception('Blog is not set');
}
$this->feed_active = (bool) ($this->get('feed_active') ?? false);
$this->obsolete = is_numeric($this->get('obsolete')) ? (int) $this->get('obsolete') : 2419200;
$this->interval = is_numeric($this->get('interval')) ? (int) $this->get('interval') : 86400;
@ -86,7 +79,7 @@ class Settings
public function set(string $key, mixed $value): void
{
if (property_exists($this, $key) && gettype($value) == gettype($this->{$key})) {
dcCore::app()->blog?->settings->get(My::id())->put(
My::settings()->put(
$key,
$value,
gettype($value),
@ -106,6 +99,6 @@ class Settings
*/
private function get(string $key): mixed
{
return dcCore::app()->blog?->settings->get(My::id())->get($key);
return My::settings()->get($key);
}
}

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Dotclear\Plugin\activityReport;
use dcCore;
use dcNsProcess;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
@ -23,18 +23,16 @@ use Dotclear\Plugin\Uninstaller\Uninstaller;
*
* Using plugin Uninstaller
*/
class Uninstall extends dcNsProcess
class Uninstall extends Process
{
public static function init(): bool
{
static::$init = defined('DC_CONTEXT_ADMIN');
return static::$init;
return self::status(My::checkContext(My::UNINSTALL));
}
public static function process(): bool
{
if (!static::$init || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
return false;
}