From 50f4eb46b654ef04135bd83ab28a48021aa284c8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Fri, 16 Dec 2022 00:32:15 +0100 Subject: [PATCH] use abstract plugin name --- _admin.php | 22 +++++++++++----------- _config.php | 12 ++++++------ _define.php | 6 +++--- _init.php | 1 + _install.php | 2 +- _prepend.php | 2 +- _uninstall.php | 12 ++++++------ inc/class.activity.report.behaviors.php | 6 +++--- inc/class.activity.report.php | 8 ++++---- inc/lib.parselogs.config.php | 2 +- index.php | 4 ++-- 11 files changed, 39 insertions(+), 38 deletions(-) diff --git a/_admin.php b/_admin.php index d340ace..d395464 100644 --- a/_admin.php +++ b/_admin.php @@ -19,10 +19,10 @@ if (!defined('ACTIVITY_REPORT_V2')) { dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( __('Activity report'), - dcCore::app()->adminurl->get('admin.plugin.activityReport'), - dcPage::getPF('activityReport/icon.png'), + dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)), + dcPage::getPF(basename(__DIR__) . '/icon.png'), preg_match( - '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.activityReport')) . '(&.*)?$/', + '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ @@ -40,8 +40,8 @@ class activityReportAdmin { public static function adminDashboardContents($items) { - dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); - $limit = abs((int) dcCore::app()->auth->user_prefs->activityReport->dashboard_item); + dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__)); + $limit = abs((int) dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->dashboard_item); if (!$limit) { return null; } @@ -83,10 +83,10 @@ class activityReportAdmin '

' . __('Activity report') . '

' . '
' . implode('', $lines) . '
' . '

' . + dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">' . __('View all logs') . ' - ' . @@ -97,7 +97,7 @@ class activityReportAdmin public static function adminDashboardOptionsForm() { - dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); + dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__)); echo '

' . @@ -107,7 +107,7 @@ class activityReportAdmin form::combo( 'activityReport_dashboard_item', self::comboList(), - self::comboList(dcCore::app()->auth->user_prefs->activityReport->dashboard_item) + self::comboList(dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->dashboard_item) ) . '

' . '
'; } @@ -118,8 +118,8 @@ class activityReportAdmin return; } - dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); - dcCore::app()->auth->user_prefs->activityReport->put( + dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__)); + dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->put( 'dashboard_item', self::comboList(@$_POST['activityReport_dashboard_item']), 'integer' diff --git a/_config.php b/_config.php index ab19762..88b136e 100644 --- a/_config.php +++ b/_config.php @@ -79,7 +79,7 @@ if (!empty($_POST['save'])) { dcAdminNotices::addSuccessNotice( __('Configuration successfully updated.') ); - dcCore::app()->adminurl->redirect('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => $super]); + dcCore::app()->adminurl->redirect('admin.plugins', ['module' => basename(__DIR__), 'conf' => 1, 'super' => $super]); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } @@ -108,7 +108,7 @@ echo '

' . ($super ? __('All blogs') : __('Current blog')) . '

'; if (dcCore::app()->auth->isSuperAdmin()) { echo sprintf( '

%s

', - dcCore::app()->adminurl->get('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => !$super]), + dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__DIR__), 'conf' => 1, 'super' => !$super]), sprintf(__('Configure activity report for %s'), $super ? __('current blog') : __('all blogs')) ); } @@ -141,13 +141,13 @@ form::hidden(['super'], $super); if (!$super) { echo - '

' . __('RSS feed') . '' . + '

' . __('RSS feed') . '' . '' . + dcCore::app()->blog->url . dcCore::app()->url->getBase(basename(__DIR__)) . '/rss2/' . dcCore::app()->activityReport->getUserCode() . '">' . __('Rss2 feed for activity on this blog') . '
' . - '' . __('Atom feed') . '' . + '' . __('Atom feed') . '' . '' . + dcCore::app()->blog->url . dcCore::app()->url->getBase(basename(__DIR__)) . '/atom/' . dcCore::app()->activityReport->getUserCode() . '">' . __('Atom feed for activity on this blog') . '

'; } echo ' diff --git a/_define.php b/_define.php index 17ad93b..1673e7e 100644 --- a/_define.php +++ b/_define.php @@ -28,8 +28,8 @@ $this->registerModule( ]), 'priority' => -1000000, 'type' => 'plugin', - 'support' => 'https://github.com/JcDenis/activityReport', - 'details' => 'http://plugins.dotaddict.org/dc2/details/activityReport', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/activityReport/master/dcstore.xml', + 'support' => 'https://github.com/JcDenis/' . basename(__DIR__), + 'details' => 'http://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), + 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', ] ); diff --git a/_init.php b/_init.php index 74460ba..89a16e9 100644 --- a/_init.php +++ b/_init.php @@ -18,4 +18,5 @@ class initActivityReport { public const ACTIVITY_TABLE_NAME = 'activity'; public const SETTING_TABLE_NAME = 'activity_setting'; + public const CACHE_DIR_NAME = 'activityreport'; } diff --git a/_install.php b/_install.php index ec62eed..1b52252 100644 --- a/_install.php +++ b/_install.php @@ -25,7 +25,7 @@ try { $s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $s->{initActivityReport::ACTIVITY_TABLE_NAME} ->activity_id('bigint', 0, false) - ->activity_type('varchar', 32, false, "'activityReport'") + ->activity_type('varchar', 32, false, "'" . basename(__DIR__) . "'") ->blog_id('varchar', 32, true) ->activity_group('varchar', 32, false) ->activity_action('varchar', 32, false) diff --git a/_prepend.php b/_prepend.php index c11b6a7..f38fd80 100644 --- a/_prepend.php +++ b/_prepend.php @@ -24,7 +24,7 @@ try { dcCore::app()->__set('activityReport', new activityReport()); dcCore::app()->url->register( - 'activityReport', + basename(__DIR__), 'reports', '^reports/((atom|rss2)/(.+))$', ['activityReportPublicUrl', 'feed'] diff --git a/_uninstall.php b/_uninstall.php index 72bf0ee..def1c60 100644 --- a/_uninstall.php +++ b/_uninstall.php @@ -42,7 +42,7 @@ $this->addUserAction( /* action */ 'delete', /* ns */ - 'activityReport', + basename(__DIR__), /* description */ __('delete plugin files') ); @@ -53,7 +53,7 @@ $this->addUserAction( /* action */ 'delete', /* ns */ - 'activityReport', + basename(__DIR__), /* description */ __('delete the version number') ); @@ -64,9 +64,9 @@ $this->addDirectAction( /* action */ 'delete', /* ns */ - 'activityReport', + basename(__DIR__), /* description */ - sprintf(__('delete %s version number'), 'activityReport') + sprintf(__('delete %s version number'), basename(__DIR__)) ); $this->addDirectAction( @@ -75,7 +75,7 @@ $this->addDirectAction( /* action */ 'delete', /* ns */ - 'activityReport', + basename(__DIR__), /* description */ - sprintf(__('delete %s plugin files'), 'activityReport') + sprintf(__('delete %s plugin files'), basename(__DIR__)) ); diff --git a/inc/class.activity.report.behaviors.php b/inc/class.activity.report.behaviors.php index 9da3091..85d8df7 100644 --- a/inc/class.activity.report.behaviors.php +++ b/inc/class.activity.report.behaviors.php @@ -23,10 +23,10 @@ class activityReportBehaviors public static function registerBehaviors() { // ActivityReport plugin - dcCore::app()->activityReport->addGroup('activityReport', __('ActivityReport messages')); + dcCore::app()->activityReport->addGroup(basename(dirname(__DIR__)), __('ActivityReport messages')); dcCore::app()->activityReport->addAction( - 'activityReport', + basename(dirname(__DIR__)), 'message', __('Special messages'), __('%s'), @@ -220,7 +220,7 @@ class activityReportBehaviors public static function messageActivityReport($message) { $logs = [$message]; - dcCore::app()->activityReport->addLog('activityReport', 'message', $logs); + dcCore::app()->activityReport->addLog(basename(dirname(__DIR__)), 'message', $logs); } public static function blogUpdate($cur, $blog_id) diff --git a/inc/class.activity.report.php b/inc/class.activity.report.php index 1ea8752..005cf55 100644 --- a/inc/class.activity.report.php +++ b/inc/class.activity.report.php @@ -18,7 +18,7 @@ class activityReport { public $con; - private $ns = 'activityReport'; + private $ns = null; private $_global = 0; private $blog = null; private $groups = []; @@ -26,11 +26,11 @@ class activityReport private $lock_blog = null; private $lock_global = null; - public function __construct($ns = 'activityReport') + public function __construct($ns = null) { $this->con = dcCore::app()->con; $this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id); - $this->ns = dcCore::app()->con->escape($ns); + $this->ns = dcCore::app()->con->escape($ns ?? basename(dirname(__DIR__))); $this->getSettings(); @@ -535,7 +535,7 @@ class activityReport $cached_file = sprintf( '%s/%s/%s/%s/%s.txt', DC_TPL_CACHE, - 'activityreport', + initActivityReport::CACHE_DIR_NAME, substr($f_md5, 0, 2), substr($f_md5, 2, 2), $f_md5 diff --git a/inc/lib.parselogs.config.php b/inc/lib.parselogs.config.php index 824f556..4294f0c 100644 --- a/inc/lib.parselogs.config.php +++ b/inc/lib.parselogs.config.php @@ -40,7 +40,7 @@ $format = [ '' . '' . '
%PERIOD%
%TEXT%
' . - '

Powered by activityReport

' . + '

Powered by activityReport

' . '', ], 'plain' => [ diff --git a/index.php b/index.php index e857027..1db35ec 100644 --- a/index.php +++ b/index.php @@ -32,13 +32,13 @@ $logs = dcCore::app()->activityReport->getLogs([]); if ($super) { $breadcrumb = [ - __('Current blog') => dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 0]), + __('Current blog') => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['super' => 0]), '' . __('All blogs') . '' => '', ]; } else { $breadcrumb = ['' . __('Current blog') . '' => '']; if (dcCore::app()->auth->isSuperAdmin()) { - $breadcrumb[__('All blogs')] = dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 1]); + $breadcrumb[__('All blogs')] = dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['super' => 1]); } }