update license and adopt PSR2 coding style
parent
8ed255dac8
commit
3e2e840dd9
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,28 +1,26 @@
|
||||||
|
whiteListCom 0.7 - 2021-08-19
|
||||||
|
* fix PSR2 coding style
|
||||||
|
* update license
|
||||||
|
|
||||||
whiteListCom 0.6 - 2013-11-13
|
whiteListCom 0.6 - 2013-11-13
|
||||||
===========================================================
|
|
||||||
* Clean up code
|
* Clean up code
|
||||||
|
|
||||||
whiteListCom 0.5 - 2011-01-19
|
whiteListCom 0.5 - 2011-01-19
|
||||||
===========================================================
|
|
||||||
* Fixed calls to blog object
|
* Fixed calls to blog object
|
||||||
* Fixed (hope so) postgreSQL compatibility
|
* Fixed (hope so) postgreSQL compatibility
|
||||||
* Added messages on admin
|
* Added messages on admin
|
||||||
* New year copyright
|
* New year copyright
|
||||||
|
|
||||||
whiteListCom 0.4 - 2010-06-05
|
whiteListCom 0.4 - 2010-06-05
|
||||||
===========================================================
|
|
||||||
* Switched to DC 2.2
|
* Switched to DC 2.2
|
||||||
|
|
||||||
whiteListCom 0.3 - 2009-11-08
|
whiteListCom 0.3 - 2009-11-08
|
||||||
===========================================================
|
|
||||||
* Fixed whitout comment_trackback in admin comments list
|
* Fixed whitout comment_trackback in admin comments list
|
||||||
* Fixed typo
|
* Fixed typo
|
||||||
* Added LICENSE
|
* Added LICENSE
|
||||||
|
|
||||||
whiteListCom 0.2 - 2009-09-27
|
whiteListCom 0.2 - 2009-09-27
|
||||||
===========================================================
|
|
||||||
* Changed to antispam system
|
* Changed to antispam system
|
||||||
|
|
||||||
whiteListCom 0.1 - 2009-09-16
|
whiteListCom 0.1 - 2009-09-16
|
||||||
===========================================================
|
|
||||||
* First lab release
|
* First lab release
|
|
@ -23,3 +23,9 @@ Dotaddict repository. (See Dotclear's documentation to know how do this)
|
||||||
Enable and configure "Unmoderated authors" of "Reserved names"
|
Enable and configure "Unmoderated authors" of "Reserved names"
|
||||||
from antispam manager.
|
from antispam manager.
|
||||||
Note: User must write a comment before able to be added to the list.
|
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)
|
||||||
|
|
29
_define.php
29
_define.php
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -12,23 +11,21 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */
|
'Whitelist comments',
|
||||||
"Whitelist comments",
|
'Whitelists for comments moderation',
|
||||||
/* Description*/
|
'Jean-Christian Denis and Contributors',
|
||||||
"Whitelists for comments moderation",
|
'0.7',
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
|
||||||
/* Version */
|
|
||||||
'0.6',
|
|
||||||
array(
|
|
||||||
'permissions' => 'admin',
|
'permissions' => 'admin',
|
||||||
'priority' => 200,
|
'priority' => 200,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'dc_min' => '2.6',
|
'dc_min' => '2.18',
|
||||||
'support' => 'http://jcd.lv/q=whiteListCom',
|
'support' => 'https://github.com/JcDenis/whiteListCom',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/whiteListCom'
|
'details' => 'https://plugins.dotaddict.org/dc2/details/whiteListCom'
|
||||||
)
|
]
|
||||||
);
|
);
|
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +26,7 @@ $core->spamfilters[] = 'whiteListComModeratedFilter';
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'publicAfterCommentCreate',
|
'publicAfterCommentCreate',
|
||||||
array('whiteListComBehaviors', 'switchStatus')
|
['whiteListComBehaviors', 'switchStatus']
|
||||||
);
|
);
|
||||||
|
|
||||||
$core->spamfilters[] = 'whiteListComReservedFilter';
|
$core->spamfilters[] = 'whiteListComReservedFilter';
|
|
@ -3,8 +3,7 @@
|
||||||
#
|
#
|
||||||
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
# This file is part of whiteListCom, a plugin for Dotclear 2.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
|
||||||
# contact@jcdenis.fr http://jcd.lv
|
|
||||||
#
|
#
|
||||||
# Licensed under the GPL version 2.0 license.
|
# Licensed under the GPL version 2.0 license.
|
||||||
# A copy of this license is available in LICENSE file or at
|
# A copy of this license is available in LICENSE file or at
|
||||||
|
@ -13,7 +12,6 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +37,7 @@ class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
{
|
{
|
||||||
if ($type != 'comment'
|
if ($type != 'comment'
|
||||||
|| $this->core->blog === null
|
|| $this->core->blog === null
|
||||||
|| $this->core->blog->settings->system->comments_pub
|
|| $this->core->blog->settings->system->comments_pub) {
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,13 +48,13 @@ class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
|
|
||||||
# return true in order to change comment_status after
|
# return true in order to change comment_status after
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gui($url)
|
public function gui($url)
|
||||||
|
@ -74,8 +71,7 @@ class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
}
|
}
|
||||||
$posts = $wlc->getPostsUsers();
|
$posts = $wlc->getPostsUsers();
|
||||||
$comments = $wlc->getCommentsUsers();
|
$comments = $wlc->getCommentsUsers();
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$this->core->error->add($e->getMessage());
|
$this->core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,60 +79,66 @@ class whiteListComModeratedFilter extends dcSpamFilter
|
||||||
|
|
||||||
if ($this->core->blog->settings->system->comments_pub) {
|
if ($this->core->blog->settings->system->comments_pub) {
|
||||||
$res .=
|
$res .=
|
||||||
'<p class="message">'.
|
'<p class="message">' .
|
||||||
__('This filter is used only if comments are moderates').
|
__('This filter is used only if comments are moderates') .
|
||||||
'</p>';
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res .=
|
$res .=
|
||||||
'<form action="'.html::escapeURL($url).'" method="post">'.
|
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||||
'<p>'.__('Check the users who can make comments without being moderated.').'</p>'.
|
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
|
||||||
'<div class="two-cols">'.
|
'<div class="two-cols">' .
|
||||||
'<div class="col">'.
|
'<div class="col">' .
|
||||||
'<p>'.__('Posts authors list').'</p>'.
|
'<p>' . __('Posts authors list') . '</p>' .
|
||||||
'<table class="clear">'.
|
'<table class="clear">' .
|
||||||
'<thead><tr><th>'.__('Name').'</th><th>'.__('Email').'</th></tr></thead>'.
|
'<thead><tr><th>' . __('Name') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
'<tbody>';
|
'<tbody>';
|
||||||
|
|
||||||
foreach($posts as $user) {
|
foreach($posts as $user) {
|
||||||
$res .=
|
$res .=
|
||||||
'<tr class="line">'.
|
'<tr class="line">' .
|
||||||
'<td class="nowrap">'.
|
'<td class="nowrap">' .
|
||||||
form::checkbox(array('unmoderated[]'), $user['email'],
|
form::checkbox(
|
||||||
$wlc->isUnmoderated($user['email'])).' '.
|
array('unmoderated[]'),
|
||||||
$user['name'].'</td>'.
|
$user['email'],
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
$wlc->isUnmoderated($user['email'])
|
||||||
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res .=
|
$res .=
|
||||||
'</tbody>'.
|
'</tbody>' .
|
||||||
'</table>'.
|
'</table>' .
|
||||||
'</div>'.
|
'</div>' .
|
||||||
'<div class="col">'.
|
'<div class="col">' .
|
||||||
'<p>'.__('Comments authors list').'</p>'.
|
'<p>' . __('Comments authors list') . '</p>' .
|
||||||
'<table class="clear">'.
|
'<table class="clear">' .
|
||||||
'<thead><tr><th>'.__('Author').'</th><th>'.__('Email').'</th></tr></thead>'.
|
'<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
'<tbody>';
|
'<tbody>';
|
||||||
|
|
||||||
foreach($comments as $user) {
|
foreach($comments as $user) {
|
||||||
$res .=
|
$res .=
|
||||||
'<tr class="line">'.
|
'<tr class="line">' .
|
||||||
'<td class="nowrap">'.
|
'<td class="nowrap">' .
|
||||||
form::checkbox(array('unmoderated[]'), $user['email'],
|
form::checkbox(
|
||||||
$wlc->isUnmoderated($user['email'])).' '.
|
array('unmoderated[]'),
|
||||||
$user['name'].'</td>'.
|
$user['email'],
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
$wlc->isUnmoderated($user['email'])
|
||||||
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res .=
|
$res .=
|
||||||
'</tbody>'.
|
'</tbody>' .
|
||||||
'</table>'.
|
'</table>' .
|
||||||
'</div>'.
|
'</div>' .
|
||||||
'</div>'.
|
'</div>' .
|
||||||
'<p><input type="submit" name="update_unmoderated" value="'.__('Save').'" />'.
|
'<p><input type="submit" name="update_unmoderated" value="' . __('Save') . '" />' .
|
||||||
$this->core->formNonce().'</p>'.
|
$this->core->formNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -162,7 +164,6 @@ class whiteListComReservedFilter extends dcSpamFilter
|
||||||
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
|
||||||
{
|
{
|
||||||
if ($type != 'comment') {
|
if ($type != 'comment') {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,13 +175,12 @@ class whiteListComReservedFilter extends dcSpamFilter
|
||||||
$status = 'reserved name';
|
$status = 'reserved name';
|
||||||
//return true;
|
//return true;
|
||||||
$throw = true;
|
$throw = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {}
|
|
||||||
|
|
||||||
# This message is show to author even if comments are moderated, comment is not saved
|
# This message is show to author even if comments are moderated, comment is not saved
|
||||||
if($throw) {
|
if($throw) {
|
||||||
|
@ -188,7 +188,7 @@ class whiteListComReservedFilter extends dcSpamFilter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusMessage($status,$comment_id)
|
public function getStatusMessage($status, $comment_id)
|
||||||
{
|
{
|
||||||
return __('This name is reserved to an other user.');
|
return __('This name is reserved to an other user.');
|
||||||
}
|
}
|
||||||
|
@ -206,35 +206,37 @@ class whiteListComReservedFilter extends dcSpamFilter
|
||||||
$wlc->commit();
|
$wlc->commit();
|
||||||
}
|
}
|
||||||
$comments = $wlc->getCommentsUsers();
|
$comments = $wlc->getCommentsUsers();
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$this->core->error->add($e->getMessage());
|
$this->core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$res =
|
$res =
|
||||||
'<form action="'.html::escapeURL($url).'" method="post">'.
|
'<form action="' . html::escapeURL($url) . '" method="post">' .
|
||||||
'<p>'.__('Check the users who can make comments without being moderated.').'</p>'.
|
'<p>' . __('Check the users who can make comments without being moderated.') . '</p>' .
|
||||||
'<p>'.__('Comments authors list').'</p>'.
|
'<p>' . __('Comments authors list') . '</p>' .
|
||||||
'<table class="clear">'.
|
'<table class="clear">' .
|
||||||
'<thead><tr><th>'.__('Author').'</th><th>'.__('Email').'</th></tr></thead>'.
|
'<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' .
|
||||||
'<tbody>';
|
'<tbody>';
|
||||||
|
|
||||||
foreach($comments as $user) {
|
foreach($comments as $user) {
|
||||||
$res .=
|
$res .=
|
||||||
'<tr class="line">'.
|
'<tr class="line">' .
|
||||||
'<td class="nowrap">'.
|
'<td class="nowrap">' .
|
||||||
form::checkbox(array('reserved['.$user['email'].']'), $user['name'],
|
form::checkbox(
|
||||||
(null === $wlc->isReserved($user['name'], $user['email']))).' '.
|
array('reserved[' . $user['email'] . ']'),
|
||||||
$user['name'].'</td>'.
|
$user['name'],
|
||||||
'<td class="nowrap">'.$user['email'].'</td>'.
|
(null === $wlc->isReserved($user['name'], $user['email']))
|
||||||
|
) .
|
||||||
|
' ' . $user['name'] . '</td>' .
|
||||||
|
'<td class="nowrap">' . $user['email'] . '</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$res .=
|
$res .=
|
||||||
'</tbody>'.
|
'</tbody>' .
|
||||||
'</table>'.
|
'</table>' .
|
||||||
'<p><input type="submit" name="update_reserved" value="'.__('Save').'" />'.
|
'<p><input type="submit" name="update_reserved" value="' . __('Save') . '" />' .
|
||||||
$this->core->formNonce().'</p>'.
|
$this->core->formNonce() . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -299,13 +301,9 @@ class whiteListCom
|
||||||
{
|
{
|
||||||
if (!isset($this->reserved[$author])) {
|
if (!isset($this->reserved[$author])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
} elseif ($this->reserved[$author] != $email) {
|
||||||
elseif ($this->reserved[$author] != $email) {
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,10 +370,10 @@ class whiteListCom
|
||||||
{
|
{
|
||||||
$users = array();
|
$users = array();
|
||||||
$rs = $this->con->select(
|
$rs = $this->con->select(
|
||||||
'SELECT comment_author, comment_email '.
|
'SELECT comment_author, comment_email ' .
|
||||||
'FROM '.$this->core->prefix.'comment C '.
|
'FROM ' . $this->core->prefix . 'comment C ' .
|
||||||
'LEFT JOIN '.$this->core->prefix.'post P ON C.post_id=P.post_id '.
|
'LEFT JOIN ' . $this->core->prefix . 'post P ON C.post_id=P.post_id ' .
|
||||||
"WHERE blog_id='".$this->blog."' AND comment_trackback=0 ".
|
"WHERE blog_id='" . $this->blog . "' AND comment_trackback=0 " .
|
||||||
'GROUP BY comment_email, comment_author ' // Added author to fix postgreSql
|
'GROUP BY comment_email, comment_author ' // Added author to fix postgreSql
|
||||||
);
|
);
|
||||||
while($rs->fetch()) {
|
while($rs->fetch()) {
|
||||||
|
@ -411,25 +409,23 @@ class whiteListCom
|
||||||
class whiteListComBehaviors
|
class whiteListComBehaviors
|
||||||
{
|
{
|
||||||
# from behavior publicAfterCommentCreate
|
# from behavior publicAfterCommentCreate
|
||||||
public static function switchStatus($cur,$id)
|
public static function switchStatus($cur, $id)
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
if ($core->blog === null
|
if ($core->blog === null
|
||||||
|| $core->blog->settings->system->comments_pub
|
|| $core->blog->settings->system->comments_pub) {
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cur->comment_spam_filter == 'whiteListComModeratedFilter'
|
if ($cur->comment_spam_filter == 'whiteListComModeratedFilter'
|
||||||
&& $cur->comment_spam_status == 'unmoderated'
|
&& $cur->comment_spam_status == 'unmoderated') {
|
||||||
) {
|
|
||||||
$core->con->writeLock($core->prefix.'comment');
|
$core->con->writeLock($core->prefix.'comment');
|
||||||
|
|
||||||
$cur->comment_status = 1;
|
$cur->comment_status = 1;
|
||||||
$cur->comment_spam_status = 0;
|
$cur->comment_spam_status = 0;
|
||||||
$cur->comment_spam_filter = 0;
|
$cur->comment_spam_filter = 0;
|
||||||
$cur->update('WHERE comment_id = '.$id.' ');
|
$cur->update('WHERE comment_id = ' . $id . ' ');
|
||||||
|
|
||||||
$core->con->unlock();
|
$core->con->unlock();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue