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"
* Correction pour une adresse mail valide "invalid@invalid" par "invalid@invalid.fr"
* Pré-requis dotclear V2.11 mini

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
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
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -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}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
<signature of Ty Coon>, 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.

View File

@ -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.

View File

@ -1,14 +1,40 @@
<?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_CONTEXT_ADMIN')) { return; }
/**
* @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_CONTEXT_ADMIN')) {
return null;
}
$core->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
'<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
# -- 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; }
# WARNING :
# Email Optionnel is distributed in the hope that it will be useful,
# 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.
/**
* @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;
}
$this->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',
'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' => 'http://plugins.dotaddict.org/dc2/details/emailOptionnel',
'requires' /* id(s) */ => array(
array('core', '2.11')
),
/* depuis dc 2.11 */
'settings' => array(
'blog' => '#params.emailOptionnelParam'
)
)
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
'settings' => [
'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
# -- 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; }
/**
* @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;
}
$core->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')
);
}
});

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 ""
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 <contact@brol.info>\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"