diff --git a/CHANGELOG.md b/CHANGELOG.md index 345e4c9..fc8c047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 2a2cc65..7a9c535 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/_define.php b/_define.php index 6e4d089..d43bd74 100644 --- a/_define.php +++ b/_define.php @@ -1,35 +1,31 @@ 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', - ], - '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', + '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', + 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', ] ); diff --git a/_init.php b/_init.php deleted file mode 100644 index 927753b..0000000 --- a/_init.php +++ /dev/null @@ -1,24 +0,0 @@ - emailOptionnel - 1.4 + 1.5 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors Make e-mail address optional in comments - https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.4/plugin-emailOptionnel.zip - 2.27 + https://git.dotclear.watch/JcDenis/emailOptionnel/releases/download/v1.5/plugin-emailOptionnel.zip + 2.28 https://git.dotclear.watch/JcDenis/emailOptionnel/src/branch/master/README.md https://git.dotclear.watch/JcDenis/emailOptionnel/issues diff --git a/src/Backend.php b/src/Backend.php index 504db8f..47bc860 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -1,28 +1,26 @@ addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings): void { - echo - '
' . - '

' . __('Optional e-mail address') . '

' . - (new Para())->__call('items', [[ - (new Checkbox(My::id() . '_enabled', (bool) $blog_settings->get(My::id())->get('enabled')))->__call('value', [1]), - (new Label(__('Make e-mail address optional in comments'), Label::OUTSIDE_LABEL_AFTER))->__call('for', [My::id() . '_enabled'])->__call('class', ['classic']), - ]])->render() . - '
'; - }); - - dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function (dcSettings $blog_settings): void { - $blog_settings->get(My::id())->put( - 'enabled', - !empty($_POST[My::id() . '_enabled']), - 'boolean', - __('Make e-mail address optional in comments') - ); - }); + App::behavior()->addBehaviors([ + 'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { + echo + '
' . + '

' . __('Optional e-mail address') . '

' . + (new Para())->__call('items', [[ + (new Checkbox(My::id() . '_enabled', (bool) $blog_settings->get(My::id())->get('enabled')))->__call('value', [1]), + (new Label(__('Make e-mail address optional in comments'), Label::OUTSIDE_LABEL_AFTER))->__call('for', [My::id() . '_enabled'])->__call('class', ['classic']), + ]])->render() . + '
'; + }, + '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; } diff --git a/src/Frontend.php b/src/Frontend.php index db77991..abff03b 100644 --- a/src/Frontend.php +++ b/src/Frontend.php @@ -1,24 +1,22 @@ 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')); } }, ]); diff --git a/src/My.php b/src/My.php index fbff05b..9426e07 100644 --- a/src/My.php +++ b/src/My.php @@ -1,15 +1,5 @@ plugins->moduleExists('Uninstaller')) { + if (!self::status()) { return false; }