update license and adopt PSR2 coding style

master
Jean-Christian Paul Denis 2021-08-21 00:39:20 +02:00
parent 8ed255dac8
commit 3e2e840dd9
5 changed files with 370 additions and 375 deletions

View File

@ -1,28 +1,26 @@
whiteListCom 0.7 - 2021-08-19
* fix PSR2 coding style
* update license
whiteListCom 0.6 - 2013-11-13
===========================================================
* Clean up code
whiteListCom 0.5 - 2011-01-19
===========================================================
* Fixed calls to blog object
* Fixed (hope so) postgreSQL compatibility
* Added messages on admin
* New year copyright
whiteListCom 0.4 - 2010-06-05
===========================================================
* Switched to DC 2.2
whiteListCom 0.3 - 2009-11-08
===========================================================
* Fixed whitout comment_trackback in admin comments list
* Fixed typo
* Added LICENSE
whiteListCom 0.2 - 2009-09-27
===========================================================
* Changed to antispam system
whiteListCom 0.1 - 2009-09-16
===========================================================
* First lab release

View File

@ -23,3 +23,9 @@ Dotaddict repository. (See Dotclear's documentation to know how do this)
Enable and configure "Unmoderated authors" of "Reserved names"
from antispam manager.
Note: User must write a comment before able to be added to the list.
## MORE
* License : GNU GPL v2
* Source & contribution : [GitHub Page](https://github.com/JcDenis/whiteListCom)
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/whiteListCom)

View File

@ -3,8 +3,7 @@
#
# This file is part of whiteListCom, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -12,23 +11,21 @@
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')){return;}
if (!defined('DC_RC_PATH')) {
return null;
}
$this->registerModule(
/* Name */
"Whitelist comments",
/* Description*/
"Whitelists for comments moderation",
/* Author */
"Jean-Christian Denis",
/* Version */
'0.6',
array(
'Whitelist comments',
'Whitelists for comments moderation',
'Jean-Christian Denis and Contributors',
'0.7',
[
'permissions' => 'admin',
'priority' => 200,
'type' => 'plugin',
'dc_min' => '2.6',
'support' => 'http://jcd.lv/q=whiteListCom',
'details' => 'http://plugins.dotaddict.org/dc2/details/whiteListCom'
)
'dc_min' => '2.18',
'support' => 'https://github.com/JcDenis/whiteListCom',
'details' => 'https://plugins.dotaddict.org/dc2/details/whiteListCom'
]
);

View File

@ -3,8 +3,7 @@
#
# This file is part of whiteListCom, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
@ -28,7 +26,7 @@ $core->spamfilters[] = 'whiteListComModeratedFilter';
$core->addBehavior(
'publicAfterCommentCreate',
array('whiteListComBehaviors', 'switchStatus')
['whiteListComBehaviors', 'switchStatus']
);
$core->spamfilters[] = 'whiteListComReservedFilter';

View File

@ -3,8 +3,7 @@
#
# This file is part of whiteListCom, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
@ -39,8 +37,7 @@ class whiteListComModeratedFilter extends dcSpamFilter
{
if ($type != 'comment'
|| $this->core->blog === null
|| $this->core->blog->settings->system->comments_pub
) {
|| $this->core->blog->settings->system->comments_pub) {
return null;
}
@ -51,13 +48,13 @@ class whiteListComModeratedFilter extends dcSpamFilter
# return true in order to change comment_status after
return true;
}
else {
} else {
return null;
}
} catch (Exception $e) {
}
catch (Exception $e) {}
}
public function gui($url)
@ -74,8 +71,7 @@ class whiteListComModeratedFilter extends dcSpamFilter
}
$posts = $wlc->getPostsUsers();
$comments = $wlc->getCommentsUsers();
}
catch (Exception $e) {
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
}
@ -102,9 +98,12 @@ class whiteListComModeratedFilter extends dcSpamFilter
$res .=
'<tr class="line">' .
'<td class="nowrap">' .
form::checkbox(array('unmoderated[]'), $user['email'],
$wlc->isUnmoderated($user['email'])).' '.
$user['name'].'</td>'.
form::checkbox(
array('unmoderated[]'),
$user['email'],
$wlc->isUnmoderated($user['email'])
) .
' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>';
}
@ -123,9 +122,12 @@ class whiteListComModeratedFilter extends dcSpamFilter
$res .=
'<tr class="line">' .
'<td class="nowrap">' .
form::checkbox(array('unmoderated[]'), $user['email'],
$wlc->isUnmoderated($user['email'])).' '.
$user['name'].'</td>'.
form::checkbox(
array('unmoderated[]'),
$user['email'],
$wlc->isUnmoderated($user['email'])
) .
' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>';
}
@ -162,7 +164,6 @@ class whiteListComReservedFilter extends dcSpamFilter
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
{
if ($type != 'comment') {
return null;
}
@ -174,13 +175,12 @@ class whiteListComReservedFilter extends dcSpamFilter
$status = 'reserved name';
//return true;
$throw = true;
}
else {
} else {
return null;
}
} catch (Exception $e) {
}
catch (Exception $e) {}
# This message is show to author even if comments are moderated, comment is not saved
if($throw) {
@ -206,8 +206,7 @@ class whiteListComReservedFilter extends dcSpamFilter
$wlc->commit();
}
$comments = $wlc->getCommentsUsers();
}
catch (Exception $e) {
} catch (Exception $e) {
$this->core->error->add($e->getMessage());
}
@ -223,9 +222,12 @@ class whiteListComReservedFilter extends dcSpamFilter
$res .=
'<tr class="line">' .
'<td class="nowrap">' .
form::checkbox(array('reserved['.$user['email'].']'), $user['name'],
(null === $wlc->isReserved($user['name'], $user['email']))).' '.
$user['name'].'</td>'.
form::checkbox(
array('reserved[' . $user['email'] . ']'),
$user['name'],
(null === $wlc->isReserved($user['name'], $user['email']))
) .
' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>';
}
@ -299,13 +301,9 @@ class whiteListCom
{
if (!isset($this->reserved[$author])) {
return false;
}
elseif ($this->reserved[$author] != $email) {
} elseif ($this->reserved[$author] != $email) {
return true;
}
else {
} else {
return null;
}
}
@ -416,14 +414,12 @@ class whiteListComBehaviors
global $core;
if ($core->blog === null
|| $core->blog->settings->system->comments_pub
) {
|| $core->blog->settings->system->comments_pub) {
return null;
}
if ($cur->comment_spam_filter == 'whiteListComModeratedFilter'
&& $cur->comment_spam_status == 'unmoderated'
) {
&& $cur->comment_spam_status == 'unmoderated') {
$core->con->writeLock($core->prefix.'comment');
$cur->comment_status = 1;