2023-03-21 21:13:14 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @brief postslistOptions, 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\postslistOptions;
|
|
|
|
|
|
|
|
use ArrayObject;
|
|
|
|
use dcCore;
|
|
|
|
use dcNsProcess;
|
|
|
|
use dcPostsActions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Improve admin class
|
|
|
|
*
|
|
|
|
* Add menu and dashboard icons, load Improve action modules.
|
|
|
|
*/
|
|
|
|
class Backend extends dcNsProcess
|
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
2023-04-23 18:46:38 +00:00
|
|
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
|
|
|
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
|
|
|
&& dcCore::app()->auth->check(
|
|
|
|
dcCore::app()->auth->makePermissions([
|
|
|
|
dcCore::app()->auth::PERMISSION_ADMIN,
|
|
|
|
]),
|
|
|
|
dcCore::app()->blog->id
|
|
|
|
);
|
2023-03-21 21:13:14 +00:00
|
|
|
|
|
|
|
return static::$init;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function process(): bool
|
|
|
|
{
|
|
|
|
if (!static::$init) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
dcCore::app()->addBehavior('adminPostsActions', function (dcPostsActions $pa) {
|
|
|
|
$pa->addAction(
|
|
|
|
[
|
|
|
|
__('Comments') => [
|
|
|
|
__('Mark as opened') => 'commentsopen',
|
|
|
|
__('Mark as closed') => 'commentsclose',
|
|
|
|
__('Delete all comments') => 'commentsdelete',
|
|
|
|
],
|
|
|
|
__('Trackbacks') => [
|
|
|
|
__('Mark as opened') => 'trackbacksopen',
|
|
|
|
__('Mark as closed') => 'trackbacksclose',
|
|
|
|
__('Delete all trackbacks') => 'trackbacksdelete',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
function (dcPostsActions $pa, ArrayObject $post) {
|
|
|
|
$actions = [
|
|
|
|
'commentsopen',
|
|
|
|
'commentsclose',
|
|
|
|
'commentsdelete',
|
|
|
|
'trackbacksopen',
|
|
|
|
'trackbacksclose',
|
|
|
|
'trackbacksdelete',
|
|
|
|
];
|
|
|
|
if (in_array($pa->getAction(), $actions)) {
|
|
|
|
BackendBehaviors::{$pa->getAction()}($pa, $post);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|