From 151c092dbb0eb5de73a19ef15b26a0622fe0fdb8 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sun, 8 Jan 2023 00:37:34 +0100 Subject: [PATCH] rename filters --- inc/Prepend.php | 4 ++-- inc/ReservedWhiteList.php | 16 ++++++++++++---- inc/UnmoderatedWhiteList.php | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/inc/Prepend.php b/inc/Prepend.php index 38683a6..9da5262 100644 --- a/inc/Prepend.php +++ b/inc/Prepend.php @@ -50,8 +50,8 @@ class Prepend ]); } - dcCore::app()->spamfilters[] = 'UnmoderatedWhiteList'; - dcCore::app()->spamfilters[] = 'ReservedWhiteList'; + dcCore::app()->spamfilters[] = __NAMESPACE__ . '\\' . 'UnmoderatedWhiteList'; + dcCore::app()->spamfilters[] = __NAMESPACE__ . '\\' . 'ReservedWhiteList'; dcCore::app()->addBehavior('publicAfterCommentCreate', function ($cur, $id) { if (dcCore::app()->blog === null diff --git a/inc/ReservedWhiteList.php b/inc/ReservedWhiteList.php index fd78c10..270a0f9 100644 --- a/inc/ReservedWhiteList.php +++ b/inc/ReservedWhiteList.php @@ -16,11 +16,13 @@ namespace Dotclear\Plugin\whiteListCom; /* dotclear ns */ use dcCore; +use dcPage; use dcSpamFilter; /* clearbricks ns */ use form; use html; +use http; /* php ns */ use Exception; @@ -31,7 +33,7 @@ use Exception; * @brief Filter for reserved names. * @since 2.6 */ -class whiteListComReservedFilter extends dcSpamFilter +class ReservedWhiteList extends dcSpamFilter { public $name = 'Reserved names'; public $has_gui = true; @@ -82,11 +84,14 @@ class whiteListComReservedFilter extends dcSpamFilter try { if (!empty($_POST['update_reserved'])) { $wlc->emptyReserved(); - foreach ($_POST['reserved'] as $email => $name) { - $wlc->addReserved($name, $email); + foreach ($_POST['reserved'] as $i => $name) { + $wlc->addReserved($name, $_POST['reserved_email'][$i]); } $wlc->commit(); + dcPage::addSuccessNotice(__('Reserved name have been successfully updated.')); + http::redirect($url); } + $comments = $wlc->getCommentsUsers(); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); @@ -99,17 +104,20 @@ class whiteListComReservedFilter extends dcSpamFilter '' . __('Author') . '' . __('Email') . '' . ''; + $i = 0; foreach ($comments as $user) { $res .= '' . '' . form::checkbox( - ['reserved[' . $user['email'] . ']'], + ['reserved[' . $i . ']'], $user['name'], (null === $wlc->isReserved($user['name'], $user['email'])) ) . + form::hidden(['reserved_email[' . $i . ']'], $user['email']) . ' ' . $user['name'] . '' . '' . $user['email'] . '' . ''; + $i++; } $res .= '' . diff --git a/inc/UnmoderatedWhiteList.php b/inc/UnmoderatedWhiteList.php index 500c894..7946c8f 100644 --- a/inc/UnmoderatedWhiteList.php +++ b/inc/UnmoderatedWhiteList.php @@ -140,7 +140,7 @@ class UnmoderatedWhiteList extends dcSpamFilter '' . '' . '' . - '

' . + '

' . dcCore::app()->formNonce() . '

' . '';