From dc2a78b398c87d9d8cbd63860f57eabe7e71fdc4 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 15 Dec 2022 23:19:01 +0100 Subject: [PATCH] release 1.0 for dotclear 2.24 --- CHANGELOG.md | 6 +++- LICENSE | 23 +++++++------- README.md | 47 ++++++++++++++++++++++++++-- _admin.php | 50 ++++++++++++++++++++++-------- _define.php | 66 +++++++++++++++++++--------------------- _init.php | 21 +++++++++++++ _prepend.php | 13 -------- _public.php | 76 ++++++++++++++++++++++++++++++++++++++-------- behaviors.php | 74 -------------------------------------------- dcstore.xml | 13 ++++++++ locales/fr/main.po | 11 ++++--- 11 files changed, 233 insertions(+), 167 deletions(-) create mode 100644 _init.php delete mode 100644 _prepend.php delete mode 100644 behaviors.php create mode 100644 dcstore.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 36116db..40835d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ -Version 0.5.0 (2020-03-28) - Gvx +1.0 - 2022.12.15 +* update to dotclear 2.24 +* use anonymous function for behaviors + +0.5.0 - 2020.03.28 - Gvx * Suppression de l'attribut "required" sur le champ "c_mail" * Correction pour une adresse mail valide "invalid@invalid" par "invalid@invalid.fr" * Pré-requis dotclear V2.11 mini diff --git a/LICENSE b/LICENSE index 8cdb845..d511905 100644 --- a/LICENSE +++ b/LICENSE @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 - Copyright (C) 1989, 1991 Free Software Foundation, Inc., + Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - {description} - Copyright (C) {year} {fullname} + + Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -329,7 +329,7 @@ necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. - {signature of Ty Coon}, 1 April 1989 + , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into @@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. - diff --git a/README.md b/README.md index 51bb122..f2f069b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ -# emailOptionnel -Rendre la saisie de l'adresse e-mail optionnelle dans les commentaires +# README + +[![Release](https://img.shields.io/github/v/release/JcDenis/emailOptionnel)](https://github.com/JcDenis/emailOptionnel/releases) +[![Date](https://img.shields.io/github/release-date/JcDenis/emailOptionnel)](https://github.com/JcDenis/emailOptionnel/releases) +[![Issues](https://img.shields.io/github/issues/JcDenis/emailOptionnel)](https://github.com/JcDenis/emailOptionnel/issues) +[![Dotclear](https://img.shields.io/badge/dotclear-v2.24-blue.svg)](https://fr.dotclear.org/download) +[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/emailOptionnel) +[![License](https://img.shields.io/github/license/JcDenis/emailOptionnel)](https://github.com/JcDenis/emailOptionnel/blob/master/LICENSE) + +## WHAT IS EMAILOPTIONNEL ? + +_emailOptionnel_ is a plugin for the open-source +web publishing software called Dotclear. + +Allow visitors to publish comments without fill in their email. + +## REQUIREMENTS + + _emailOptionnel_ requires: + + * admin permissions to set up plugin + * Dotclear 2.24 + +## USAGE + +First install _emailOptionnel_, manualy from a zip package or from +Dotaddict repository. (See Dotclear's documentation to know how do this) + +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 : [GitHub Page](https://github.com/JcDenis/enhancePostContent) + * Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/enhancePostContent) + * Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332948#p332948) + +## CONTRIBUTORS + + * Oleksandr Syenchuk (author) + * Gvx + * Pierre Van Glabeke + * Jean-Christian Denis + + You are welcome to contribute to this code. \ No newline at end of file diff --git a/_admin.php b/_admin.php index 772680b..5a7a9b1 100644 --- a/_admin.php +++ b/_admin.php @@ -1,14 +1,40 @@ addBehavior('adminBlogPreferencesForm', array('emailOptionnelBehaviors', 'adminBlogPreferencesForm')); -$core->addBehavior('adminBeforeBlogSettingsUpdate', array('emailOptionnelBehaviors', 'adminBeforeBlogSettingsUpdate')); +dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function () { + dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME); + + echo + '

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

' . + '

' . form::checkbox( + initEmailOptionnel::SETTING_NAME, + '1', + dcCore::app()->blog->settings->__get(initEmailOptionnel::SETTING_NAME)->enabled ? true : false + ) . + '

' . + '
'; +}); + +dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function ($blog_settings) { + dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME); + + $blog_settings->__get(initEmailOptionnel::SETTING_NAME)->put( + 'enabled', + empty($_POST[initEmailOptionnel::SETTING_NAME]) ? false : true, + 'boolean', + __('Make e-mail address optional in comments') + ); +}); diff --git a/_define.php b/_define.php index d51268a..920b6a5 100644 --- a/_define.php +++ b/_define.php @@ -1,39 +1,35 @@ registerModule( - /* Name */ 'emailOptionnel', - /* Description*/ 'Make e-mail address optional in comments', - /* Author */ 'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx', - /* Version */ '0.5.0', - /* Properties */ - array( - 'permissions' => 'admin', - 'type' => 'plugin', - 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332948#p332948', - 'details' => 'http://plugins.dotaddict.org/dc2/details/emailOptionnel', - 'requires' /* id(s) */ => array( - array('core', '2.11') - ), - /* depuis dc 2.11 */ - 'settings' => array( - 'blog' => '#params.emailOptionnelParam' - ) - ) - + 'emailOptionnel', + 'Make e-mail address optional in comments', + 'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors', + '1.0', + [ + 'requires' => [['core', '2.24']], + 'permissions' => dcCore::app()->auth->makePermissions([ + dcAuth::PERMISSION_ADMIN, + ]), + 'type' => 'plugin', + 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332948#p332948', + 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__), + 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml', + 'settings' => [ + 'blog' => '#params.emailOptionnelParam', + ], + ] ); diff --git a/_init.php b/_init.php new file mode 100644 index 0000000..3e71440 --- /dev/null +++ b/_init.php @@ -0,0 +1,21 @@ +addBehavior('publicPrepend', array('emailOptionnelBehaviors','publicPrepend')); -$core->addBehavior('publicBeforeCommentCreate', array('emailOptionnelBehaviors','publicBeforeCommentCreate')); -$core->addBehavior('publicHeadContent', array('emailOptionnelBehaviors','publicHeadContent')); +dcCore::app()->addBehavior('publicPrependV2', function () { + dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME); + + if (!isset($_POST['c_content']) + || !empty($_POST['preview']) + || !empty($_POST['c_mail']) + || !dcCore::app()->blog->settings->get(initEmailOptionnel::SETTING_NAME)->enabled + ) { + return; + } + $_POST['c_mail'] = initEmailOptionnel::DEFAULT_EMAIL; +}); + +dcCore::app()->addBehavior('publicBeforeCommentCreate', function ($cur) { + dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME); + + if (dcCore::app()->blog->settings->get(initEmailOptionnel::SETTING_NAME)->enabled + && $cur->comment_email == initEmailOptionnel::DEFAULT_EMAIL + ) { + # désactive l'affichage du mail dans le template + dcCore::app()->ctx->comment_preview['mail'] = ''; + # n'enregistre pas de mail dans la BDD + $cur->comment_email = ''; + # n'enregistre pas le mail dans le cookie + if (empty($_POST['c_remember'])) { + return; + } + if (!empty($_COOKIE['comment_info'])) { + $cookie_info = explode("\n", $_COOKIE['comment_info']); + if (count($cookie_info) == 3) { + return; + } + } + $c_cookie = ['name' => $cur->comment_author, 'mail' => $cur->comment_email, 'site' => $cur->comment_site]; + $c_cookie = serialize($c_cookie); + setcookie('comment_info', $c_cookie, strtotime('+3 month'), '/'); + } +}); + +dcCore::app()->addBehavior('publicHeadContent', function () { + dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME); + + if (dcCore::app()->blog->settings->get(initEmailOptionnel::SETTING_NAME)->enabled) { + echo dcUtils::jsLoad( + dcCore::app()->blog->getPF(basename(__DIR__) . '/public.js'), + dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version') + ); + } +}); diff --git a/behaviors.php b/behaviors.php deleted file mode 100644 index 2eb471d..0000000 --- a/behaviors.php +++ /dev/null @@ -1,74 +0,0 @@ -blog->settings->addNamespace(self::PLUGIN_NAME); - $emailOptionnel = $core->blog->settings->emailoptionnel->enabled ? true : false; - echo '

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

'."\n". - '

'."\n". - '
'."\n"; - } - - public static function adminBeforeBlogSettingsUpdate($blog_settings) { - $emailOptionnel = empty($_POST[self::PLUGIN_NAME]) ? false : true; - $blog_settings->addNamespace(self::PLUGIN_NAME); - $blog_settings->emailoptionnel->put('enabled', $emailOptionnel, 'boolean', __('Make e-mail address optional in comments')); - } - - public static function publicPrepend($core) { - $core->blog->settings->addNamespace(self::PLUGIN_NAME); - if (!isset($_POST['c_content']) || !empty($_POST['preview']) || !empty($_POST['c_mail']) || !$core->blog->settings->emailoptionnel->enabled) { - return; - } - $_POST['c_mail'] = self::DEFAULT_EMAIL; - } - - public static function publicBeforeCommentCreate($cur) { - global $core; - $core->blog->settings->addNamespace(self::PLUGIN_NAME); - $emailOptionnel = $core->blog->settings->emailoptionnel->enabled ? true : false; - if ($emailOptionnel && $cur->comment_email == self::DEFAULT_EMAIL) { - $_ctx = &$GLOBALS['_ctx']; - # désactive l'affichage du mail dans le template - $_ctx->comment_preview['mail'] = ''; - # n'enregistre pas de mail dans la BDD - $cur->comment_email = ''; - # n'enregistre pas le mail dans le cookie - if (empty($_POST['c_remember'])) { return; } - if (!empty($_COOKIE['comment_info'])) { - $cookie_info = explode("\n",$_COOKIE['comment_info']); - if (count($cookie_info) == 3) { return; } - } - $c_cookie = array('name' => $cur->comment_author, 'mail' => $cur->comment_email, 'site' => $cur->comment_site); - $c_cookie = serialize($c_cookie); - setcookie('comment_info',$c_cookie,strtotime('+3 month'),'/'); - } - } - - public static function publicHeadContent($core, $_ctx) { - $core->blog->settings->addNamespace(self::PLUGIN_NAME); - $emailOptionnel = $core->blog->settings->emailoptionnel->enabled ? true : false; - if ($emailOptionnel) { - $plugin_id = basename(dirname(__FILE__)); - $file = $plugin_id.'/public.js'; - $version = $core->plugins->moduleInfo($plugin_id, 'version'); - echo dcUtils::jsLoad($core->blog->getPF($file), $version); - } - } - -} diff --git a/dcstore.xml b/dcstore.xml new file mode 100644 index 0000000..2b4f259 --- /dev/null +++ b/dcstore.xml @@ -0,0 +1,13 @@ + + + + emailOptionnel + 1.0 + Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors + Make e-mail address optional in comments + https://github.com/JcDenis/emailOptionnel/releases/download/v1.0/plugin-emailOptionnel.zip + 2.24 + https://plugins.dotaddict.org/dc2/details/emailOptionnel + http://forum.dotclear.org/viewtopic.php?pid=332948#p332948 + + diff --git a/locales/fr/main.po b/locales/fr/main.po index 7ff32a3..28734c0 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -1,17 +1,18 @@ msgid "" msgstr "" -"Project-Id-Version: \n" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: emailOptionnel 1.0\n" "POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: brol \n" +"PO-Revision-Date: 2022-12-15T22:15:54+00:00\n" +"Last-Translator: Jean-Crhistian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.5.7\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" msgid "Optional e-mail address" msgstr "Adresse e-mail optionnelle" msgid "Make e-mail address optional in comments" msgstr "Rendre la saisie de l'adresse e-mail optionnelle dans les commentaires" +