release 1.0 for dotclear 2.24

This commit is contained in:
Jean-Christian Paul Denis 2022-12-15 23:19:01 +01:00
parent 37e90b6e9d
commit dc2a78b398
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 233 additions and 167 deletions

View File

@ -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" * Suppression de l'attribut "required" sur le champ "c_mail"
* Correction pour une adresse mail valide "invalid@invalid" par "invalid@invalid.fr" * Correction pour une adresse mail valide "invalid@invalid" par "invalid@invalid.fr"
* Pré-requis dotclear V2.11 mini * Pré-requis dotclear V2.11 mini

23
LICENSE
View File

@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public 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 The precise terms and conditions for copying, distribution and
modification follow. modification follow.
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains 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 preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally. 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 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 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 PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES. 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 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 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 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. the "copyright" line and a pointer to where the full notice is found.
{description} <one line to give the program's name and a brief idea of what it does.>
Copyright (C) {year} {fullname} Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify 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 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 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker. `Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989 <signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into 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 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 library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. Public License instead of this License.

View File

@ -1,2 +1,45 @@
# emailOptionnel # README
Rendre la saisie de l'adresse e-mail optionnelle dans les commentaires
[![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.

View File

@ -1,14 +1,40 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of Email Optionnel, a plugin for Dotclear. * @brief emailOptionnel, a plugin for Dotclear 2
# *
# Copyright (c) 2007-2020 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx * @package Dotclear
# * @subpackage Plugin
# Licensed under the GPL version 2.0 license. *
# A copy is available in LICENSE file or at * @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html *
# -- END LICENSE BLOCK ------------------------------------ * @copyright Jean-Crhistian Denis
if (!defined('DC_CONTEXT_ADMIN')) { return; } * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
$core->addBehavior('adminBlogPreferencesForm', array('emailOptionnelBehaviors', 'adminBlogPreferencesForm')); dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function () {
$core->addBehavior('adminBeforeBlogSettingsUpdate', array('emailOptionnelBehaviors', 'adminBeforeBlogSettingsUpdate')); dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME);
echo
'<div class="fieldset"><h4 id="emailOptionnelParam">' . __('Optional e-mail address') . '</h4>' .
'<p>' . form::checkbox(
initEmailOptionnel::SETTING_NAME,
'1',
dcCore::app()->blog->settings->__get(initEmailOptionnel::SETTING_NAME)->enabled ? true : false
) .
'<label class="classic" for="' . initEmailOptionnel::SETTING_NAME . '">' . __('Make e-mail address optional in comments') . '</label></p>' .
'</div>';
});
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')
);
});

View File

@ -1,39 +1,35 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of Email Optionnel, a plugin for Dotclear. * @brief emailOptionnel, a plugin for Dotclear 2
# *
# Copyright (c) 2007-2020 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx * @package Dotclear
# * @subpackage Plugin
# Licensed under the GPL version 2.0 license. *
# A copy is available in LICENSE file or at * @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html *
# -- END LICENSE BLOCK ------------------------------------ * @copyright Jean-Crhistian Denis
if (!defined('DC_RC_PATH')) { return; } * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
# WARNING : if (!defined('DC_RC_PATH')) {
# Email Optionnel is distributed in the hope that it will be useful, return null;
# but WITHOUT ANY WARRANTY; without even the implied warranty of }
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
$this->registerModule( $this->registerModule(
/* Name */ 'emailOptionnel', 'emailOptionnel',
/* Description*/ 'Make e-mail address optional in comments', 'Make e-mail address optional in comments',
/* Author */ 'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx', 'Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors',
/* Version */ '0.5.0', '1.0',
/* Properties */ [
array( 'requires' => [['core', '2.24']],
'permissions' => 'admin', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcAuth::PERMISSION_ADMIN,
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332948#p332948', ]),
'details' => 'http://plugins.dotaddict.org/dc2/details/emailOptionnel', 'type' => 'plugin',
'requires' /* id(s) */ => array( 'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332948#p332948',
array('core', '2.11') 'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
), 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
/* depuis dc 2.11 */ 'settings' => [
'settings' => array( 'blog' => '#params.emailOptionnelParam',
'blog' => '#params.emailOptionnelParam' ],
) ]
)
); );

21
_init.php Normal file
View File

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

View File

@ -1,13 +0,0 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of Email Optionnel, a plugin for Dotclear.
#
# Copyright (c) 2007-2020 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx
#
# Licensed under the GPL version 2.0 license.
# A copy is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; }
$GLOBALS['__autoload']['emailOptionnelBehaviors'] = dirname(__FILE__).'/behaviors.php';

View File

@ -1,15 +1,65 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# This file is part of Email Optionnel, a plugin for Dotclear. * @brief emailOptionnel, a plugin for Dotclear 2
# *
# Copyright (c) 2007-2020 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx * @package Dotclear
# * @subpackage Plugin
# Licensed under the GPL version 2.0 license. *
# A copy is available in LICENSE file or at * @author Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html *
# -- END LICENSE BLOCK ------------------------------------ * @copyright Jean-Crhistian Denis
if (!defined('DC_RC_PATH')) { return; } * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$core->addBehavior('publicPrepend', array('emailOptionnelBehaviors','publicPrepend')); dcCore::app()->addBehavior('publicPrependV2', function () {
$core->addBehavior('publicBeforeCommentCreate', array('emailOptionnelBehaviors','publicBeforeCommentCreate')); dcCore::app()->blog->settings->addNamespace(initEmailOptionnel::SETTING_NAME);
$core->addBehavior('publicHeadContent', array('emailOptionnelBehaviors','publicHeadContent'));
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')
);
}
});

View File

@ -1,74 +0,0 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
# This file is part of Email Optionnel, a plugin for Dotclear.
#
# Copyright (c) 2007-2020 Oleksandr Syenchuk, Pierre Van Glabeke, Gvx
#
# Licensed under the GPL version 2.0 license.
# A copy is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {return;}
class emailOptionnelBehaviors {
const DEFAULT_EMAIL = 'invalid@invalid.fr';
const PLUGIN_NAME = 'emailoptionnel';
public static function adminBlogPreferencesForm($core) {
$core->blog->settings->addNamespace(self::PLUGIN_NAME);
$emailOptionnel = $core->blog->settings->emailoptionnel->enabled ? true : false;
echo '<div class="fieldset"><h4 id="emailOptionnelParam">'.__('Optional e-mail address').'</h4>'."\n".
'<p><label class="classic" for="emailOptionnel">'.form::checkbox(self::PLUGIN_NAME,'1',$emailOptionnel)."\n".
__('Make e-mail address optional in comments').'</label></p>'."\n".
'</div>'."\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);
}
}
}

13
dcstore.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<modules xmlns:da="http://dotaddict.org/da/">
<module id="emailOptionnel">
<name>emailOptionnel</name>
<version>1.0</version>
<author>Oleksandr Syenchuk, Pierre Van Glabeke, Gvx and Contributors</author>
<desc>Make e-mail address optional in comments</desc>
<file>https://github.com/JcDenis/emailOptionnel/releases/download/v1.0/plugin-emailOptionnel.zip</file>
<da:dcmin>2.24</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/emailOptionnel</da:details>
<da:support>http://forum.dotclear.org/viewtopic.php?pid=332948#p332948</da:support>
</module>
</modules>

View File

@ -1,17 +1,18 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: emailOptionnel 1.0\n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: \n" "PO-Revision-Date: 2022-12-15T22:15:54+00:00\n"
"Last-Translator: brol <contact@brol.info>\n" "Last-Translator: Jean-Crhistian Denis\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=iso-8859-1\n"
"Content-Transfer-Encoding: 8bit\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" msgid "Optional e-mail address"
msgstr "Adresse e-mail optionnelle" msgstr "Adresse e-mail optionnelle"
msgid "Make e-mail address optional in comments" msgid "Make e-mail address optional in comments"
msgstr "Rendre la saisie de l'adresse e-mail optionnelle dans les commentaires" msgstr "Rendre la saisie de l'adresse e-mail optionnelle dans les commentaires"