Compare commits

..

1 Commits

Author SHA1 Message Date
c757540ca4
upgrade to Dotclear 2.28 2023-10-20 18:17:42 +02:00
7 changed files with 116 additions and 132 deletions

View File

@ -1,3 +1,9 @@
postslistOptions 2023.10.20
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
postslistOptions 2023.08.13
===========================================================
* Require Dotclear 2.27

View File

@ -1,26 +1,23 @@
# README
[![Release](https://img.shields.io/badge/release-2023.08.13-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases)
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases)
![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/postslistOptions)
[![License](https://img.shields.io/github/license/JcDenis/postslistOptions)](https://git.dotclear.watch/JcDenis/postslistOptions/blob/master/LICENSE)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/LICENSE)
## WHAT IS POSTsLISTOPTIONS ?
## ABOUT
"Posts list options" is a plugin for the open-source
web publishing software called Dotclear.
_postslistOptions_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
It add options on the posts list action box like
> Add options on the posts list action box like
open/close/delete comments/trackbacks on multiple posts.
## REQUIREMENTS
_postslistOptions_ requires:
* admin permissions
* Dotclear 2.27
* PHP 7.4
* Dotclear 2.28
* PHP 8.1
* Dotclear admin permissions
## USAGE
@ -31,12 +28,13 @@ Then this plugin adds options de the posts list actions box.
## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/postslistOptions) or [GitHub Page](https://github.com/JcDenis/postslistOptions)
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/postslistOptions/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postslistOptions)
* [License](https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/postslistOptions/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/postslistOptions))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/postslistOptions) (or on [GitHub](https://github.com/JcDenis/postslistOptions))
* [Issues & security](https://git.dotclear.watch/JcDenis/postslistOptions/issues) (or on [GitHub](https://github.com/JcDenis/postslistOptions/issues))
## CONTRIBUTORS
* Jean-Christian Denis
* Jean-Christian Denis (author)
You are welcome to contribute to this code.

View File

@ -1,32 +1,29 @@
<?php
/**
* @brief postslistOptions, a plugin for Dotclear 2
* @file
* @brief The plugin postslistOptions definition
* @ingroup postslistOptions
*
* @package Dotclear
* @subpackage Plugin
* @defgroup postslistOptions Plugin dcLog.
*
* @author Jean-Christian Denis and Contributors
* Add some options on admin posts list.
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
$this->registerModule(
'Posts list options',
'Add some options on admin posts list',
'Jean-Christian Denis and Contributors',
'2023.08.13',
'2023.10.20',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]),
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
'requires' => [['core', '2.28']],
'permissions' => 'My',
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
]
);

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postslistOptions">
<name>Posts list options</name>
<version>2023.08.13</version>
<version>2023.10.20</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Add some options on admin posts list</desc>
<file>https://git.dotclear.watch/JcDenis/postslistOptions/releases/download/v2023.08.13/plugin-postslistOptions.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/postslistOptions/releases/download/v2023.10.20/plugin-postslistOptions.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/postslistOptions/issues</da:support>
</module>

View File

@ -1,28 +1,20 @@
<?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 Dotclear\App;
use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Core\Process;
/**
* Improve admin class
* @brief postslistOptions backend class.
* @ingroup postslistOptions
*
* Add menu and dashboard icons, load Improve action modules.
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
@ -37,7 +29,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
App::behavior()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
$pa->addAction(
[
__('Comments') => [

View File

@ -1,22 +1,11 @@
<?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 dcBlog;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -32,6 +21,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html;
use Exception;
/**
* @brief postslistOptions backend behaviors class.
* @ingroup postslistOptions
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class BackendBehaviors
{
public static function commentsOpen(ActionsPosts $pa, ArrayObject $post): void
@ -54,8 +50,7 @@ class BackendBehaviors
public static function commentsDelete(ActionsPosts $pa, ArrayObject $post): void
{
//nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -64,9 +59,9 @@ class BackendBehaviors
if (empty($_POST['confirmdeletecomments'])) {
$pa->beginPage(
Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts comments') => '',
Html::escapeHTML(App::blog()->name()) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts comments') => '',
])
);
@ -78,16 +73,14 @@ class BackendBehaviors
(new Text('', $pa->getCheckboxes())),
(new Text('p', __('Are you sure you want to delete all comments?'))),
(new Para())
->__call('items', [array_merge(
[
(new Submit(['do']))
->__call('value', [__('yes')]),
dcCore::app()->formNonce(false),
(new Hidden(['action'], 'commentsdelete')),
(new Hidden(['confirmdeletecomments'], '1')),
],
$pa->hiddenFields(),
)]),
->__call('items', [
(new Submit(['do']))
->__call('value', [__('yes')]),
App::nonce()->formNonce(),
(new Hidden(['action'], 'commentsdelete')),
(new Hidden(['confirmdeletecomments'], '1')),
... $pa->hiddenFields(),
]),
]])
->render();
@ -122,8 +115,7 @@ class BackendBehaviors
public static function trackbacksDelete(ActionsPosts $pa, ArrayObject $post): void
{
//nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -132,9 +124,9 @@ class BackendBehaviors
if (empty($_POST['confirmdeletetrackbacks'])) {
$pa->beginPage(
Page::breadcrumb([
Html::escapeHTML(dcCore::app()->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts trackbacks') => '',
Html::escapeHTML(App::blog()->name()) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Delete posts trackbacks') => '',
])
);
@ -146,13 +138,13 @@ class BackendBehaviors
(new Text('', $pa->getCheckboxes())),
(new Text('p', __('Are you sure you want to delete all trackbacks?'))),
(new Para())
->__call('items', [array_merge([
->__call('items', [
(new Submit(['do']))
->__call('value', [__('yes')]),
dcCore::app()->formNonce(false),
App::nonce()->formNonce(),
(new Hidden(['action'], 'trackbacksdelete')),
(new Hidden(['confirmdeletetrackbacks'], '1')),
], $pa->hiddenFields())]),
... $pa->hiddenFields()]),
]])
->render();
@ -179,28 +171,26 @@ class BackendBehaviors
private static function updPostOption(int $id, string $option, int $value): void
{
//nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
$id = abs((int) $id);
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
$cur = App::blog()->openPostCursor();
$cur->setField($option, $value);
$cur->setField('post_upddt', date('Y-m-d H:i:s'));
$cur->update(
'WHERE post_id = ' . $id . ' ' .
"AND blog_id = '" . dcCore::app()->con->escapeStr((string) dcCore::app()->blog->id) . "' "
"AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
);
dcCore::app()->blog->triggerBlog();
App::blog()->triggerBlog();
}
private static function delPostComments(int $id, bool $tb = false): void
{
//nullsafe
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -209,11 +199,11 @@ class BackendBehaviors
'post_id' => abs((int) $id),
'comment_trackback' => $tb ? 1 : 0,
];
$comments = dcCore::app()->blog->getComments($params);
$comments = App::blog()->getComments($params);
while ($comments->fetch()) {
// slower but preserve behaviors
dcCore::app()->blog->delComment($comments->f('comment_id'));
App::blog()->delComment($comments->f('comment_id'));
}
}
}

View File

@ -18,4 +18,5 @@ use Dotclear\Module\MyPlugin;
class My extends MyPlugin
{
// Use defautl permissions
}