rename filters

This commit is contained in:
Jean-Christian Denis 2023-01-08 00:37:34 +01:00
parent d6424f9442
commit 151c092dbb
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
3 changed files with 15 additions and 7 deletions

View file

@ -50,8 +50,8 @@ class Prepend
]); ]);
} }
dcCore::app()->spamfilters[] = 'UnmoderatedWhiteList'; dcCore::app()->spamfilters[] = __NAMESPACE__ . '\\' . 'UnmoderatedWhiteList';
dcCore::app()->spamfilters[] = 'ReservedWhiteList'; dcCore::app()->spamfilters[] = __NAMESPACE__ . '\\' . 'ReservedWhiteList';
dcCore::app()->addBehavior('publicAfterCommentCreate', function ($cur, $id) { dcCore::app()->addBehavior('publicAfterCommentCreate', function ($cur, $id) {
if (dcCore::app()->blog === null if (dcCore::app()->blog === null

View file

@ -16,11 +16,13 @@ namespace Dotclear\Plugin\whiteListCom;
/* dotclear ns */ /* dotclear ns */
use dcCore; use dcCore;
use dcPage;
use dcSpamFilter; use dcSpamFilter;
/* clearbricks ns */ /* clearbricks ns */
use form; use form;
use html; use html;
use http;
/* php ns */ /* php ns */
use Exception; use Exception;
@ -31,7 +33,7 @@ use Exception;
* @brief Filter for reserved names. * @brief Filter for reserved names.
* @since 2.6 * @since 2.6
*/ */
class whiteListComReservedFilter extends dcSpamFilter class ReservedWhiteList extends dcSpamFilter
{ {
public $name = 'Reserved names'; public $name = 'Reserved names';
public $has_gui = true; public $has_gui = true;
@ -82,11 +84,14 @@ class whiteListComReservedFilter extends dcSpamFilter
try { try {
if (!empty($_POST['update_reserved'])) { if (!empty($_POST['update_reserved'])) {
$wlc->emptyReserved(); $wlc->emptyReserved();
foreach ($_POST['reserved'] as $email => $name) { foreach ($_POST['reserved'] as $i => $name) {
$wlc->addReserved($name, $email); $wlc->addReserved($name, $_POST['reserved_email'][$i]);
} }
$wlc->commit(); $wlc->commit();
dcPage::addSuccessNotice(__('Reserved name have been successfully updated.'));
http::redirect($url);
} }
$comments = $wlc->getCommentsUsers(); $comments = $wlc->getCommentsUsers();
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
@ -99,17 +104,20 @@ class whiteListComReservedFilter extends dcSpamFilter
'<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' . '<thead><tr><th>' . __('Author') . '</th><th>' . __('Email') . '</th></tr></thead>' .
'<tbody>'; '<tbody>';
$i = 0;
foreach ($comments as $user) { foreach ($comments as $user) {
$res .= '<tr class="line">' . $res .= '<tr class="line">' .
'<td class="nowrap">' . '<td class="nowrap">' .
form::checkbox( form::checkbox(
['reserved[' . $user['email'] . ']'], ['reserved[' . $i . ']'],
$user['name'], $user['name'],
(null === $wlc->isReserved($user['name'], $user['email'])) (null === $wlc->isReserved($user['name'], $user['email']))
) . ) .
form::hidden(['reserved_email[' . $i . ']'], $user['email']) .
' ' . $user['name'] . '</td>' . ' ' . $user['name'] . '</td>' .
'<td class="nowrap">' . $user['email'] . '</td>' . '<td class="nowrap">' . $user['email'] . '</td>' .
'</tr>'; '</tr>';
$i++;
} }
$res .= '</tbody>' . $res .= '</tbody>' .

View file

@ -140,7 +140,7 @@ class UnmoderatedWhiteList extends dcSpamFilter
'</table>' . '</table>' .
'</div>' . '</div>' .
'</div>' . '</div>' .
'<p><input type="submit" name="update_unmoderated" value="' . __('Save') . '" />' . '<p><input type="submit" id="update_unmoderated" name="update_unmoderated" value="' . __('Save') . '" />' .
dcCore::app()->formNonce() . '</p>' . dcCore::app()->formNonce() . '</p>' .
'</form>'; '</form>';