From 3f19508c04df7437f1566f2884ecf08b777a3805 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 7 Feb 2006 15:17:19 +0000 Subject: [PATCH] Disable spamblock for registered authors --- docs/NEWS | 3 + .../UTF-8/lang_de.inc.php | 2 + .../lang_de.inc.php | 2 + .../lang_en.inc.php | 2 + .../serendipity_event_spamblock.php | 59 ++++++++++++++++++- 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index de44bc4..332a7d7 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.0-beta2 () ------------------------------------------------------------------------ + * Enable Spamblock plugin to allow registered authors to not enter + captchas and other spamchecks (garvinhicking) + * Fixed spartacus DB error on postgreSQL installations, thanks to volkris! (garvinhicking) diff --git a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php index d4444aa..6867d8b 100644 --- a/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php @@ -83,3 +83,5 @@ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Kommentare abweisen, die als Text nur den Artikeltitel enthalten'); @define('PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_SCRAMBLE', 'Stärkere Captchas'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE', 'Spamblock für Autoren deaktivieren'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE_DESC', 'Autoren der aktivierten Benutzergruppen können Kommentare ohne Spamprüfung schreiben.'); diff --git a/plugins/serendipity_event_spamblock/lang_de.inc.php b/plugins/serendipity_event_spamblock/lang_de.inc.php index 1d96dce..0b2ffce 100644 --- a/plugins/serendipity_event_spamblock/lang_de.inc.php +++ b/plugins/serendipity_event_spamblock/lang_de.inc.php @@ -83,3 +83,5 @@ @define('PLUGIN_EVENT_SPAMBLOCK_FILTER_TITLE', 'Kommentare abweisen, die als Text nur den Artikeltitel enthalten'); @define('PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_SCRAMBLE', 'Stärkere Captchas'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE', 'Spamblock für Autoren deaktivieren'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE_DESC', 'Autoren der aktivierten Benutzergruppen können Kommentare ohne Spamprüfung schreiben.'); diff --git a/plugins/serendipity_event_spamblock/lang_en.inc.php b/plugins/serendipity_event_spamblock/lang_en.inc.php index ba5d0f1..bc98a2d 100644 --- a/plugins/serendipity_event_spamblock/lang_en.inc.php +++ b/plugins/serendipity_event_spamblock/lang_en.inc.php @@ -98,3 +98,5 @@ @define('PLUGIN_EVENT_SPAMBLOCK_CAPTCHAS_SCRAMBLE', 'Scrambled Captchas'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE', 'Disable spamblock for Authors'); +@define('PLUGIN_EVENT_SPAMBLOCK_HIDE_DESC', 'You can allow authors in the following usergroups to post comments without them being checked by the spamblock plugin.'); diff --git a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php index 2a14839..7558604 100644 --- a/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php +++ b/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php @@ -34,7 +34,7 @@ var $filter_defaults; 'smarty' => '2.6.7', 'php' => '4.1.0' )); - $propbag->add('version', '1.32'); + $propbag->add('version', '1.33'); $propbag->add('event_hooks', array( 'frontend_saveComment' => true, 'external_plugin' => true, @@ -43,7 +43,7 @@ var $filter_defaults; 'backend_comments_top' => true, 'backend_view_comment' => true )); - $propbag->add('configuration', array('killswitch', 'bodyclone', 'entrytitle', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'trackback_check_url', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'bloggdeblacklist', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile')); + $propbag->add('configuration', array('killswitch', 'hide_for_authors', 'bodyclone', 'entrytitle', 'ipflood', 'captchas', 'captchas_ttl', 'captcha_color', 'forcemoderation', 'disable_api_comments', 'trackback_check_url', 'links_moderate', 'links_reject', 'contentfilter_activate', 'contentfilter_urls', 'bloggdeblacklist', 'contentfilter_authors', 'hide_email', 'checkmail', 'required_fields', 'logtype', 'logfile')); $propbag->add('groups', array('ANTISPAM')); $this->filter_defaults = array( @@ -124,6 +124,25 @@ var $filter_defaults; )); break; + case 'hide_for_authors': + $_groups =& serendipity_getAllGroups(); + $groups = array( + 'all' => ALL_AUTHORS, + 'none' => NONE + ); + + foreach($_groups AS $group) { + $groups[$group['confkey']] = $group['confvalue']; + } + + $propbag->add('type', 'multiselect'); + $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_HIDE); + $propbag->add('description', PLUGIN_EVENT_SPAMBLOCK_HIDE_DESC); + $propbag->add('select_values', $groups); + $propbag->add('select_size', 5); + $propbag->add('default', 'all'); + break; + case 'killswitch': $propbag->add('type', 'boolean'); $propbag->add('name', PLUGIN_EVENT_SPAMBLOCK_KILLSWITCH); @@ -326,6 +345,32 @@ var $filter_defaults; $title = $this->title; } + // Checks whether the current author is contained in one of the gorups that need no spam checking + function inGroup() { + global $serendipity; + + $checkgroups = explode('^', $this->get_config('hide_for_authors')); + + if (!isset($serendipity['authorid']) || !is_array($checkgroups)) { + return false; + } + + $mygroups =& serendipity_getGroups($serendipity['authorid'], true); + if (!is_array($mygroups)) { + return false; + } + + foreach($checkgroups AS $key => $groupid) { + if ($groupid == 'all') { + return true; + } elseif (in_array($groupid, $mygroups)) { + return true; + } + } + + return false; + } + function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; @@ -387,6 +432,11 @@ var $filter_defaults; } } } + + // Check whether to allow comments from registered authors + if (serendipity_userLoggedIn() && $this->inGroup()) { + return true; + } // Check if entry title is the same as comment body if (serendipity_db_bool($this->get_config('entrytitle')) && trim($eventData['title']) == trim($addData['comment'])) { @@ -637,6 +687,11 @@ var $filter_defaults; echo '
' . PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL_NOTICE . '
'; } + // Check whether to allow comments from registered authors + if (serendipity_userLoggedIn() && $this->inGroup()) { + return true; + } + if ($show_captcha) { echo '
'; if (!isset($serendipity['POST']['preview']) || strtolower($serendipity['POST']['captcha'] != strtolower($_SESSION['spamblock']['captcha']))) { -- 2.39.5