check if plugin is configured

This commit is contained in:
Jean-Christian Denis 2022-11-26 21:19:55 +01:00
parent 3039ca75e5
commit d081835649
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
4 changed files with 50 additions and 30 deletions

View file

@ -18,36 +18,40 @@ dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
require_once __DIR__ . '/_widgets.php'; require_once __DIR__ . '/_widgets.php';
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
__('Feeds server'), && '' != dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_user
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'), ) {
dcPage::getPF('zoneclearFeedServer/icon.svg'), dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
preg_match( __('Feeds server'),
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/', dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
$_SERVER['REQUEST_URI'] dcPage::getPF('zoneclearFeedServer/icon.svg'),
), preg_match(
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id) '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer')) . '(&.*)?$/',
); $_SERVER['REQUEST_URI']
),
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_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', 'adminDashboardFavoritesV2']);
# User pref
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']);
}
# Take care about tweakurls (thanks Mathieu M.)
if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
}
}
# Delete related info about feed post in meta table # Delete related info about feed post in meta table
dcCore::app()->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']); dcCore::app()->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']);
if (dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)) {
# Dashboard icon
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavoritesV2']);
# User pref
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']);
}
# Take care about tweakurls (thanks Mathieu M.)
if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
}
/** /**
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER * @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER
* @brief Mix your blog with a feeds planet - admin methods. * @brief Mix your blog with a feeds planet - admin methods.

View file

@ -395,6 +395,13 @@ class zoneclearFeedServer
*/ */
public function checkFeedsUpdate($id = null, $throw = false) public function checkFeedsUpdate($id = null, $throw = false)
{ {
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
# Not configured
if (!$s->zoneclearFeedServer_active || !$s->zoneclearFeedServer_user) {
return false;
}
# Limit to one update at a time # Limit to one update at a time
try { try {
$this->lockUpdate(); $this->lockUpdate();
@ -408,7 +415,6 @@ class zoneclearFeedServer
dt::setTZ(dcCore::app()->blog->settings->system->blog_timezone); dt::setTZ(dcCore::app()->blog->settings->system->blog_timezone);
$time = time(); $time = time();
$s = dcCore::app()->blog->settings->zoneclearFeedServer;
# All feeds or only one (from admin) # All feeds or only one (from admin)
$f = !$id ? $f = !$id ?

View file

@ -23,13 +23,24 @@ dcPage::check(dcAuth::PERMISSION_CONTENT_ADMIN);
$zcfs = new zoneclearFeedServer(); $zcfs = new zoneclearFeedServer();
# Not configured
if (!dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
|| !dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_user
) {
echo
'<html><head><title>' . __('Feeds server') . '</title></head><body>' .
dcPage::breadcrumb([
__('Plugins') => '',
__('Feeds server') => '',
]) .
dcPage::notices();
############################################################ ############################################################
# #
# One feed # One feed
# #
############################################################ ############################################################
} elseif (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
$feed_id = ''; $feed_id = '';
$feed_name = ''; $feed_name = '';
$feed_desc = ''; $feed_desc = '';

View file

@ -10,5 +10,4 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
dcCore::app()->resources['help']['zoneclearFeedServer'] = __DIR__ . '/help/zoneclearFeedServer.html'; dcCore::app()->resources['help']['zoneclearFeedServer'] = __DIR__ . '/help/zoneclearFeedServer.html';