upgrade to Dotclear 2.28

This commit is contained in:
Jean-Christian Denis 2023-10-16 22:25:52 +02:00
parent d05b62d910
commit 76730fb6d7
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
9 changed files with 113 additions and 144 deletions

View file

@ -1,3 +1,9 @@
emailOptionnel 1.5 - 2023.10.16
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
emailOptionnel 1.4 - 2023.08.12 emailOptionnel 1.4 - 2023.08.12
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View file

@ -1,25 +1,22 @@
# README # README
[![Release](https://img.shields.io/badge/release-1.4-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) [![Release](https://img.shields.io/badge/release-1.5-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/emailOptionnel/releases)
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) ![Date](https://img.shields.io/badge/date-2023.10.16-c44d58.svg)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/emailOptionnel) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/emailOptionnel)
[![License](https://img.shields.io/github/license/JcDenis/emailOptionnel)](https://git.dotclear.watch/JcDenis/emailOptionnel/blob/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/LICENSE)
## WHAT IS EMAILOPTIONNEL ? ## ABOUT
_emailOptionnel_ is a plugin for the open-source _emailOptionnel_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
web publishing software called Dotclear.
Allow visitors to publish comments without fill in their email. > Allow visitors to publish comments without fill in their email.
## REQUIREMENTS ## REQUIREMENTS
_emailOptionnel_ requires: * Dotclear 2.28
* PHP 8.1+
* admin permissions to set up plugin * Dotclear admin permissions to set up plugin
* Dotclear 2.27
* PHP 7.4+
## USAGE ## USAGE
@ -30,16 +27,17 @@ Go to ''blog preference'' => fieldset ''plugin preference'', fill in form.
## LINKS ## LINKS
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html) * [License](https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/LICENSE)
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/emailOptionnel) or [GitHub Page](https://github.com/JcDenis/enhancePostContent) * [Packages & details](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/emailOptionnel))
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/enhancePostContent) * [Sources & contributions](https://git.dotclear.watch/JcDenis/emailOptionnel) (or on [GitHub](https://github.com/JcDenis/emailOptionnel))
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332948#p332948) * [Issues & security](https://git.dotclear.watch/JcDenis/emailOptionnel/issues) (or on [GitHub](https://github.com/JcDenis/emailOptionnel/issues))
* [Discuss & help](http://forum.dotclear.org/viewtopic.php?pid=332948#p332948)
## CONTRIBUTORS ## CONTRIBUTORS
* Oleksandr Syenchuk (author) * Oleksandr Syenchuk (author)
* Gvx * Gvx
* Pierre Van Glabeke * Pierre Van Glabeke
* Jean-Christian Denis * Jean-Christian Denis (latest)
You are welcome to contribute to this code. You are welcome to contribute to this code.

View file

@ -1,35 +1,31 @@
<?php <?php
/** /**
* @brief emailOptionnel, a plugin for Dotclear 2 * @file
* @brief The plugin emailOptionnel definition
* @ingroup emailOptionnel
* *
* @package Dotclear * @defgroup emailOptionnel Plugin emailOptionnel.
* @subpackage Plugin
* *
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors * Make e-mail address optional in comments.
* *
* @copyright Jean-Christian Denis * @author Oleksandr Syenchuk (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
if (!defined('DC_RC_PATH')) { declare(strict_types=1);
return null;
}
$this->registerModule( $this->registerModule(
'emailOptionnel', 'emailOptionnel',
'Make e-mail address optional in comments', 'Make e-mail address optional in comments',
'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors', 'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors',
'1.4', '1.5',
[ [
'requires' => [['core', '2.27']], 'requires' => [['core', '2.28']],
'permissions' => dcCore::app()->auth->makePermissions([ 'permissions' => 'My',
dcCore::app()->auth::PERMISSION_ADMIN, 'settings' => ['blog' => '#params.' . basename(__DIR__) . 'Param'],
]), 'type' => 'plugin',
'settings' => [ 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'blog' => '#params.' . basename(__DIR__) . 'Param', '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',
'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

@ -1,24 +0,0 @@
<?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class initEmailOptionnel
{
/** @var string Default email */
public const DEFAULT_EMAIL = 'invalid@invalid.fr';
/** @var string NO MORE USED */
public const SETTING_NAME = 'emailoptionnel';
}

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="emailOptionnel"> <module id="emailOptionnel">
<name>emailOptionnel</name> <name>emailOptionnel</name>
<version>1.4</version> <version>1.5</version>
<author>Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors</author> <author>Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors</author>
<desc>Make e-mail address optional in comments</desc> <desc>Make e-mail address optional in comments</desc>
<file>https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.4/plugin-emailOptionnel.zip</file> <file>https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.5/plugin-emailOptionnel.zip</file>
<da:dcmin>2.27</da:dcmin> <da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/emailOptionnel/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/emailOptionnel/issues</da:support>
</module> </module>

View file

@ -1,28 +1,26 @@
<?php <?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\emailOptionnel; namespace Dotclear\Plugin\emailOptionnel;
use dcCore; use Dotclear\App;
use dcSettings;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
Checkbox, Checkbox,
Label, Label,
Para Para
}; };
use Dotclear\Interface\Core\BlogSettingsInterface;
/**
* @brief emailOptionnel backend class.
* @ingroup emailOptionnel
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -36,25 +34,26 @@ class Backend extends Process
return false; return false;
} }
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings): void { App::behavior()->addBehaviors([
echo 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
'<div class="fieldset">' . echo
'<h4 id="emailOptionnelParam">' . __('Optional e-mail address') . '</h4>' . '<div class="fieldset">' .
(new Para())->__call('items', [[ '<h4 id="emailOptionnelParam">' . __('Optional e-mail address') . '</h4>' .
(new Checkbox(My::id() . '_enabled', (bool) $blog_settings->get(My::id())->get('enabled')))->__call('value', [1]), (new Para())->__call('items', [[
(new Label(__('Make e-mail address optional in comments'), Label::OUTSIDE_LABEL_AFTER))->__call('for', [My::id() . '_enabled'])->__call('class', ['classic']), (new Checkbox(My::id() . '_enabled', (bool) $blog_settings->get(My::id())->get('enabled')))->__call('value', [1]),
]])->render() . (new Label(__('Make e-mail address optional in comments'), Label::OUTSIDE_LABEL_AFTER))->__call('for', [My::id() . '_enabled'])->__call('class', ['classic']),
'</div>'; ]])->render() .
}); '</div>';
},
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function (dcSettings $blog_settings): void { 'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
$blog_settings->get(My::id())->put( $blog_settings->get(My::id())->put(
'enabled', 'enabled',
!empty($_POST[My::id() . '_enabled']), !empty($_POST[My::id() . '_enabled']),
'boolean', 'boolean',
__('Make e-mail address optional in comments') __('Make e-mail address optional in comments')
); );
}); },
]);
return true; return true;
} }

View file

@ -1,24 +1,22 @@
<?php <?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\emailOptionnel; namespace Dotclear\Plugin\emailOptionnel;
use ArrayObject; use ArrayObject;
use dcCore; use Dotclear\App;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Database\Cursor; use Dotclear\Database\Cursor;
/**
* @brief emailOptionnel frontend class.
* @ingroup emailOptionnel
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -32,10 +30,9 @@ class Frontend extends Process
return false; return false;
} }
dcCore::app()->addBehaviors([ App::behavior()->addBehaviors([
'publicPrependV2' => function (): void { 'publicPrependV2' => function (): void {
// nullsafe PHP < 8.0 if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog)) {
return; return;
} }
@ -49,8 +46,7 @@ class Frontend extends Process
$_POST['c_mail'] = My::DEFAULT_EMAIL; $_POST['c_mail'] = My::DEFAULT_EMAIL;
}, },
'publicBeforeCommentCreate' => function (Cursor $cur): void { 'publicBeforeCommentCreate' => function (Cursor $cur): void {
// nullsafe PHP < 8.0 if (!App::blog()->isDefined()) {
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
return; return;
} }
@ -58,12 +54,12 @@ class Frontend extends Process
&& $cur->getField('comment_email') == My::DEFAULT_EMAIL && $cur->getField('comment_email') == My::DEFAULT_EMAIL
) { ) {
# désactive l'affichage du mail dans le template # désactive l'affichage du mail dans le template
$cp = dcCore::app()->ctx->__get('comment_preview'); $cp = App::frontend()->context()->__get('comment_preview');
if (is_a($cp, 'ArrayObject')) { if (is_a($cp, 'ArrayObject')) {
$cp = new ArrayObject([]); $cp = new ArrayObject([]);
} }
$cp['mail'] = ''; $cp['mail'] = '';
dcCore::app()->ctx->__set('comment_preview', $cp); App::frontend()->context()->__set('comment_preview', $cp);
# n'enregistre pas de mail dans la BDD # n'enregistre pas de mail dans la BDD
$cur->setField('comment_email', ''); $cur->setField('comment_email', '');
# n'enregistre pas le mail dans le cookie # n'enregistre pas le mail dans le cookie
@ -83,7 +79,7 @@ class Frontend extends Process
}, },
'publicHeadContent' => function (): void { 'publicHeadContent' => function (): void {
if (My::settings()->get('enabled')) { if (My::settings()->get('enabled')) {
echo My::jsLoad('frontend', dcCore::app()->plugins->moduleInfo(My::id(), 'version')); echo My::jsLoad('frontend', App::plugins()->moduleInfo(My::id(), 'version'));
} }
}, },
]); ]);

View file

@ -1,15 +1,5 @@
<?php <?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\emailOptionnel; namespace Dotclear\Plugin\emailOptionnel;
@ -17,10 +7,21 @@ namespace Dotclear\Plugin\emailOptionnel;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
* This module definitions. * @brief emailOptionnel My helper.
* @ingroup emailOptionnel
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class My extends MyPlugin class My extends MyPlugin
{ {
/** @var string Default email */ /**
* Default email.
*
* @var string DEFAULT_EMAIL
*/
public const DEFAULT_EMAIL = 'invalid@invalid.fr'; public const DEFAULT_EMAIL = 'invalid@invalid.fr';
// Use default permissions
} }

View file

@ -1,23 +1,20 @@
<?php <?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\emailOptionnel; namespace Dotclear\Plugin\emailOptionnel;
use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller; use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief emailOptionnel uninstall class.
* @ingroup emailOptionnel
*
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Uninstall extends Process class Uninstall extends Process
{ {
public static function init(): bool public static function init(): bool
@ -27,7 +24,7 @@ class Uninstall extends Process
public static function process(): bool public static function process(): bool
{ {
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) { if (!self::status()) {
return false; return false;
} }