61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* @brief noodles, a plugin for Dotclear 2
|
|
*
|
|
* @package Dotclear
|
|
* @subpackage Plugin
|
|
*
|
|
* @author Jean-Christian Denis and contributors
|
|
*
|
|
* @copyright Jean-Christian Denis
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Dotclear\Plugin\noodles;
|
|
|
|
use dcAdmin;
|
|
use dcCore;
|
|
use dcMenu;
|
|
use dcNsProcess;
|
|
use dcPage;
|
|
|
|
class Backend extends dcNsProcess
|
|
{
|
|
public static function init(): bool
|
|
{
|
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
|
&& My::phpCompliant()
|
|
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
|
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
|
]), dcCore::app()->blog->id);
|
|
|
|
return static::$init;
|
|
}
|
|
|
|
public static function process(): bool
|
|
{
|
|
if (!static::$init) {
|
|
return false;
|
|
}
|
|
|
|
if (is_null(dcCore::app()->auth)
|
|
|| is_null(dcCore::app()->blog)
|
|
|| is_null(dcCore::app()->adminurl)
|
|
|| !(dcCore::app()->menu[dcAdmin::MENU_PLUGINS] instanceof dcMenu)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
|
My::name(),
|
|
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
|
dcPage::getPF(My::id() . '/icon.png'),
|
|
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . My::id())) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
|
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
|
);
|
|
|
|
return true;
|
|
}
|
|
}
|