From 3039ca75e5cf9ad64dd0d61786fabfaaa286fe97 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 26 Nov 2022 15:23:37 +0100 Subject: [PATCH] use constants for permissions names --- _admin.php | 30 ++++++++---------------------- inc/lib.zcfs.list.php | 2 +- index.php | 2 +- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/_admin.php b/_admin.php index 4a32e05..9c77a35 100644 --- a/_admin.php +++ b/_admin.php @@ -26,18 +26,18 @@ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/', $_SERVER['REQUEST_URI'] ), - dcCore::app()->auth->check('admin', dcCore::app()->blog->id) + dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id) ); # Delete related info about feed post in meta table dcCore::app()->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']); -if (dcCore::app()->auth->check('admin', dcCore::app()->blog->id)) { +if (dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)) { # Dashboard icon - dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavorites']); + dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavoritesV2']); # User pref - dcCore::app()->addBehavior('adminColumnsListsV2', ['zcfsAdminBehaviors', 'adminColumnsLists']); - dcCore::app()->addBehavior('adminFiltersListsV2', ['zcfsAdminBehaviors', 'adminFiltersLists']); + dcCore::app()->addBehavior('adminColumnsListsV2', ['zcfsAdminBehaviors', 'adminColumnsListsV2']); + dcCore::app()->addBehavior('adminFiltersListsV2', ['zcfsAdminBehaviors', 'adminFiltersListsV2']); # Add info about feed on post page sidebar dcCore::app()->addBehavior('adminPostHeaders', ['zcfsAdminBehaviors', 'adminPostHeaders']); dcCore::app()->addBehavior('adminPostFormItems', ['zcfsAdminBehaviors', 'adminPostFormItems']); @@ -82,7 +82,7 @@ class zcfsAdminBehaviors * * @param dcFavorites $favs Array of favorites */ - public static function adminDashboardFavorites(dcFavorites $favs) + public static function adminDashboardFavoritesV2(dcFavorites $favs) { $favs->register('zcfs', [ 'title' => __('Feeds server'), @@ -90,24 +90,10 @@ class zcfsAdminBehaviors 'small-icon' => dcPage::getPF('zoneclearFeedServer/icon.svg'), 'large-icon' => dcPage::getPF('zoneclearFeedServer/icon.svg'), 'permissions' => 'usage,contentadmin', - 'active_cb' => ['zcfsAdminBehaviors', 'adminDashboardFavoritesActive'], 'dashboard_cb' => ['zcfsAdminBehaviors', 'adminDashboardFavoritesCallback'], ]); } - /** - * Favorites selection. - * - * @param string $request Requested page - * @param array $params Requested parameters - */ - public static function adminDashboardFavoritesActive($request, $params) - { - return $request == 'plugin.php' - && isset($params['p']) - && $params['p'] == 'zoneclearFeedServer'; - } - /** * Favorites hack. * @@ -135,7 +121,7 @@ class zcfsAdminBehaviors * * @param arrayObject $cols Columns */ - public static function adminColumnsLists($cols) + public static function adminColumnsListsV2($cols) { $cols['zcfs_feeds'] = [ __('Feeds server: Feeds'), @@ -161,7 +147,7 @@ class zcfsAdminBehaviors * * @param arrayObject $sorts Sort options */ - public static function adminFiltersLists($sorts) + public static function adminFiltersListsV2($sorts) { $sorts['zcfs_feeds'] = [ __('Feeds server: Feeds'), diff --git a/inc/lib.zcfs.list.php b/inc/lib.zcfs.list.php index 0c5b107..d916805 100644 --- a/inc/lib.zcfs.list.php +++ b/inc/lib.zcfs.list.php @@ -211,7 +211,7 @@ class zcfsEntriesList extends adminGenericList private function postLine() { - $cat_link = dcCore::app()->auth->check('categories', dcCore::app()->blog->id) ? + $cat_link = dcCore::app()->auth->check(dcAuth::PERMISSION_CATEGORIES, dcCore::app()->blog->id) ? '%s' : '%2$s'; diff --git a/index.php b/index.php index 406d7a8..deb977e 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ if (dcCore::app()->getVersion('zoneclearFeedServer') != dcCore::app()->plugins-> return null; } -dcPage::check('admin'); +dcPage::check(dcAuth::PERMISSION_CONTENT_ADMIN); $zcfs = new zoneclearFeedServer();