upgrade to Dotclear 2.28

This commit is contained in:
Jean-Christian Paul 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
===========================================================
* Require Dotclear 2.27

View File

@ -1,25 +1,22 @@
# README
[![Release](https://img.shields.io/badge/release-1.4-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)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![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.10.16-c44d58.svg)
[![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)
[![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
web publishing software called Dotclear.
_emailOptionnel_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org).
Allow visitors to publish comments without fill in their email.
> Allow visitors to publish comments without fill in their email.
## REQUIREMENTS
_emailOptionnel_ requires:
* admin permissions to set up plugin
* Dotclear 2.27
* PHP 7.4+
* Dotclear 2.28
* PHP 8.1+
* Dotclear admin permissions to set up plugin
## USAGE
@ -30,16 +27,17 @@ Go to ''blog preference'' => fieldset ''plugin preference'', fill in form.
## 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/emailOptionnel) or [GitHub Page](https://github.com/JcDenis/enhancePostContent)
* Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/enhancePostContent)
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332948#p332948)
* [License](https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/LICENSE)
* [Packages & details](https://git.dotclear.watch/JcDenis/emailOptionnel/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/emailOptionnel))
* [Sources & contributions](https://git.dotclear.watch/JcDenis/emailOptionnel) (or on [GitHub](https://github.com/JcDenis/emailOptionnel))
* [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
* Oleksandr Syenchuk (author)
* Gvx
* Pierre Van Glabeke
* Jean-Christian Denis
* Jean-Christian Denis (latest)
You are welcome to contribute to this code.

View File

@ -1,32 +1,28 @@
<?php
/**
* @brief emailOptionnel, a plugin for Dotclear 2
* @file
* @brief The plugin emailOptionnel definition
* @ingroup emailOptionnel
*
* @package Dotclear
* @subpackage Plugin
* @defgroup emailOptionnel Plugin emailOptionnel.
*
* @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
* Make e-mail address optional in comments.
*
* @copyright Jean-Christian Denis
* @author Oleksandr Syenchuk (author)
* @author Jean-Christian Denis (latest)
* @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(
'emailOptionnel',
'Make e-mail address optional in comments',
'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors',
'1.4',
'1.5',
[
'requires' => [['core', '2.27']],
'permissions' => dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_ADMIN,
]),
'settings' => [
'blog' => '#params.' . basename(__DIR__) . 'Param',
],
'requires' => [['core', '2.28']],
'permissions' => 'My',
'settings' => ['blog' => '#params.' . basename(__DIR__) . 'Param'],
'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

@ -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/">
<module id="emailOptionnel">
<name>emailOptionnel</name>
<version>1.4</version>
<version>1.5</version>
<author>Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors</author>
<desc>Make e-mail address optional in comments</desc>
<file>https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.4/plugin-emailOptionnel.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.5/plugin-emailOptionnel.zip</file>
<da:dcmin>2.28</da:dcmin>
<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>
</module>

View File

@ -1,28 +1,26 @@
<?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);
namespace Dotclear\Plugin\emailOptionnel;
use dcCore;
use dcSettings;
use Dotclear\App;
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{
Checkbox,
Label,
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
{
public static function init(): bool
@ -36,7 +34,8 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings): void {
App::behavior()->addBehaviors([
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
echo
'<div class="fieldset">' .
'<h4 id="emailOptionnelParam">' . __('Optional e-mail address') . '</h4>' .
@ -45,16 +44,16 @@ class Backend extends Process
(new Label(__('Make e-mail address optional in comments'), Label::OUTSIDE_LABEL_AFTER))->__call('for', [My::id() . '_enabled'])->__call('class', ['classic']),
]])->render() .
'</div>';
});
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function (dcSettings $blog_settings): void {
},
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
$blog_settings->get(My::id())->put(
'enabled',
!empty($_POST[My::id() . '_enabled']),
'boolean',
__('Make e-mail address optional in comments')
);
});
},
]);
return true;
}

View File

@ -1,24 +1,22 @@
<?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);
namespace Dotclear\Plugin\emailOptionnel;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
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
{
public static function init(): bool
@ -32,10 +30,9 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'publicPrependV2' => function (): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
@ -49,8 +46,7 @@ class Frontend extends Process
$_POST['c_mail'] = My::DEFAULT_EMAIL;
},
'publicBeforeCommentCreate' => function (Cursor $cur): void {
// nullsafe PHP < 8.0
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
if (!App::blog()->isDefined()) {
return;
}
@ -58,12 +54,12 @@ class Frontend extends Process
&& $cur->getField('comment_email') == My::DEFAULT_EMAIL
) {
# 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')) {
$cp = new ArrayObject([]);
}
$cp['mail'] = '';
dcCore::app()->ctx->__set('comment_preview', $cp);
App::frontend()->context()->__set('comment_preview', $cp);
# n'enregistre pas de mail dans la BDD
$cur->setField('comment_email', '');
# n'enregistre pas le mail dans le cookie
@ -83,7 +79,7 @@ class Frontend extends Process
},
'publicHeadContent' => function (): void {
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
/**
* @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);
namespace Dotclear\Plugin\emailOptionnel;
@ -17,10 +7,21 @@ namespace Dotclear\Plugin\emailOptionnel;
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
{
/** @var string Default email */
/**
* Default email.
*
* @var string DEFAULT_EMAIL
*/
public const DEFAULT_EMAIL = 'invalid@invalid.fr';
// Use default permissions
}

View File

@ -1,23 +1,20 @@
<?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);
namespace Dotclear\Plugin\emailOptionnel;
use dcCore;
use Dotclear\Core\Process;
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
{
public static function init(): bool
@ -27,7 +24,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status()) {
return false;
}