Compare commits

..

No commits in common. "master" and "v2023.08.13" have entirely different histories.

7 changed files with 132 additions and 116 deletions

View File

@ -1,9 +1,3 @@
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,23 +1,26 @@
# 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)
[![Date](https://img.shields.io/badge/date-2023.08.13-c44d58.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/releases)
[![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/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/postslistOptions/src/branch/master/LICENSE)
[![License](https://img.shields.io/github/license/JcDenis/postslistOptions)](https://git.dotclear.watch/JcDenis/postslistOptions/blob/master/LICENSE)
## ABOUT
## WHAT IS POSTsLISTOPTIONS ?
_postslistOptions_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
"Posts list options" is a plugin for the open-source
web publishing software called Dotclear.
> Add options on the posts list action box like
It add options on the posts list action box like
open/close/delete comments/trackbacks on multiple posts.
## REQUIREMENTS
* Dotclear 2.28
* PHP 8.1
* Dotclear admin permissions
_postslistOptions_ requires:
* admin permissions
* Dotclear 2.27
* PHP 7.4
## USAGE
@ -28,13 +31,12 @@ Then this plugin adds options de the posts list actions box.
## LINKS
* [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))
* 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)
## CONTRIBUTORS
* Jean-Christian Denis (author)
* Jean-Christian Denis
You are welcome to contribute to this code.

View File

@ -1,26 +1,29 @@
<?php
/**
* @file
* @brief The plugin postslistOptions definition
* @ingroup postslistOptions
* @brief postslistOptions, a plugin for Dotclear 2
*
* @defgroup postslistOptions Plugin dcLog.
* @package Dotclear
* @subpackage Plugin
*
* Add some options on admin posts list.
* @author Jean-Christian Denis and Contributors
*
* @author Jean-Christian Denis
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule(
'Posts list options',
'Add some options on admin posts list',
'Jean-Christian Denis and Contributors',
'2023.10.20',
'2023.08.13',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',
'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',

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postslistOptions">
<name>Posts list options</name>
<version>2023.10.20</version>
<version>2023.08.13</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.10.20/plugin-postslistOptions.zip</file>
<da:dcmin>2.28</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/postslistOptions/releases/download/v2023.08.13/plugin-postslistOptions.zip</file>
<da:dcmin>2.27</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,20 +1,28 @@
<?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 Dotclear\App;
use dcCore;
use Dotclear\Core\Backend\Action\ActionsPosts;
use Dotclear\Core\Process;
/**
* @brief postslistOptions backend class.
* @ingroup postslistOptions
* Improve admin class
*
* @author Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* Add menu and dashboard icons, load Improve action modules.
*/
class Backend extends Process
{
@ -29,7 +37,7 @@ class Backend extends Process
return false;
}
App::behavior()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
dcCore::app()->addBehavior('adminPostsActions', function (ActionsPosts $pa) {
$pa->addAction(
[
__('Comments') => [

View File

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

View File

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