name = __('Unmoderated authors'); $this->description = __('Whitelist of unmoderated authors'); } public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status) { if ($type != 'comment' || dcCore::app()->blog === null || dcCore::app()->blog->settings->system->comments_pub) { return null; } try { $wlc = new Core(); if ($wlc->isUnmoderated($email)) { $status = 'unmoderated'; # return true in order to change comment_status after return true; } return null; } catch (Exception $e) { } } public function gui(string $url): string { $wlc = new Core(); $posts = $comments = []; try { if (!empty($_POST['update_unmoderated'])) { $wlc->emptyUnmoderated(); foreach ($_POST['unmoderated'] as $email) { $wlc->addUnmoderated($email); } $wlc->commit(); dcPage::addSuccessNotice(__('Unmoderated names have been successfully updated.')); http::redirect($url); } $posts = $wlc->getPostsUsers(); $comments = $wlc->getCommentsUsers(); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } $res = ''; if (dcCore::app()->blog->settings->system->comments_pub) { $res .= '

' . __('This filter is used only if comments are moderates') . '

'; } $res .= '
' . '

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

' . '
' . '
' . '

' . __('Posts authors list') . '

' . '' . '' . ''; foreach ($posts as $user) { $res .= '' . '' . '' . ''; } $res .= '' . '
' . __('Name') . '' . __('Email') . '
' . form::checkbox( ['unmoderated[]'], $user['email'], $wlc->isUnmoderated($user['email']) ) . ' ' . $user['name'] . '' . $user['email'] . '
' . '
' . '
' . '

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

' . '' . '' . ''; foreach ($comments as $user) { $res .= '' . '' . '' . ''; } $res .= '' . '
' . __('Author') . '' . __('Email') . '
' . form::checkbox( ['unmoderated[]'], $user['email'], $wlc->isUnmoderated($user['email']) ) . ' ' . $user['name'] . '' . $user['email'] . '
' . '
' . '
' . '

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

' . '
'; return $res; } }