name = __('Reserved names'); $this->description = __('Whitelist of reserved names of users'); } public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status) { if ($type != 'comment') { return null; } $throw = false; try { $wlc = new Core(); if (true === $wlc->isReserved($author, $email)) { $status = 'reserved name'; //return true; $throw = true; } else { return null; } } catch (Exception $e) { } # This message is show to author even if comments are moderated, comment is not saved if ($throw) { throw new Exception(__('This name is reserved to an other user.')); } } public function getStatusMessage($status, $comment_id) { return __('This name is reserved to an other user.'); } public function gui(string $url): string { $wlc = new Core(); $comments = []; try { if (!empty($_POST['update_reserved'])) { $wlc->emptyReserved(); 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()); } $res = '
' . '

' . __('Check the users who can make comments without being moderated.') . '

' . '

' . __('Comments authors list') . '

' . '' . '' . ''; $i = 0; foreach ($comments as $user) { $res .= '' . '' . '' . ''; $i++; } $res .= '' . '
' . __('Author') . '' . __('Email') . '
' . form::checkbox( ['reserved[' . $i . ']'], $user['name'], (null === $wlc->isReserved($user['name'], $user['email'])) ) . form::hidden(['reserved_email[' . $i . ']'], $user['email']) . ' ' . $user['name'] . '' . $user['email'] . '
' . '

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

' . '
'; return $res; } }