check if plugin is configured

master
Jean-Christian Paul 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,6 +18,9 @@ dcCore::app()->blog->settings->addNamespace('zoneclearFeedServer');
require_once __DIR__ . '/_widgets.php'; require_once __DIR__ . '/_widgets.php';
if (dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_active
&& '' != dcCore::app()->blog->settings->zoneclearFeedServer->zoneclearFeedServer_user
) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Feeds server'), __('Feeds server'),
dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'), dcCore::app()->adminurl->get('admin.plugin.zoneclearFeedServer'),
@ -29,9 +32,6 @@ dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_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(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)) { if (dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->blog->id)) {
# Dashboard icon # Dashboard icon
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavoritesV2']); dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['zcfsAdminBehaviors', 'adminDashboardFavoritesV2']);
@ -47,6 +47,10 @@ if (dcCore::app()->auth->check(dcAuth::PERMISSION_CONTENT_ADMIN, dcCore::app()->
if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) { if (version_compare(dcCore::app()->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']); dcCore::app()->addbehavior('zcfsAfterPostCreate', ['zoneclearFeedServer', 'tweakurlsAfterPostCreate']);
} }
}
# Delete related info about feed post in meta table
dcCore::app()->addBehavior('adminBeforePostDelete', ['zcfsAdminBehaviors', 'adminBeforePostDelete']);
/** /**
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER * @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER

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';