]> git.mjollnir.org Git - s9y.git/commitdiff
Disable spamblock for registered authors
authorgarvinhicking <garvinhicking>
Tue, 7 Feb 2006 15:17:19 +0000 (15:17 +0000)
committergarvinhicking <garvinhicking>
Tue, 7 Feb 2006 15:17:19 +0000 (15:17 +0000)
docs/NEWS
plugins/serendipity_event_spamblock/UTF-8/lang_de.inc.php
plugins/serendipity_event_spamblock/lang_de.inc.php
plugins/serendipity_event_spamblock/lang_en.inc.php
plugins/serendipity_event_spamblock/serendipity_event_spamblock.php

index de44bc40301c835906e17a21a517c1d6b2966168..332a7d73bbd16d2dbdad19c2de2d493bd1730916 100644 (file)
--- 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)
 
index d4444aa797b2771334366c398a6d87ab939f5d01..6867d8b5b241cc11de7edd08876e4290704b64ac 100644 (file)
@@ -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.');
index 1d96dce55cb2c27bddf51355a0b7937304501d97..0b2ffce68e7508cb2e1fa732358e2d1706a04f88 100644 (file)
@@ -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.');
index ba5d0f12eb06f12a43f027819b7890f6a6ba2344..bc98a2d93752567873876896a88c909e1c5b5846 100644 (file)
@@ -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.');
index 2a14839b4b76a89013bff3152cd5a928673daae3..75586049e0466f4f4782bbddc82d0217737a2eb1 100644 (file)
@@ -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 '<div class="serendipity_commentDirection serendipity_comment_spamblock">' . PLUGIN_EVENT_SPAMBLOCK_HIDE_EMAIL_NOTICE . '</div>';
                     }
 
+                    // Check whether to allow comments from registered authors
+                    if (serendipity_userLoggedIn() && $this->inGroup()) {
+                        return true;
+                    }
+
                     if ($show_captcha) {
                         echo '<div class="serendipity_commentDirection serendipity_comment_captcha">';
                         if (!isset($serendipity['POST']['preview']) || strtolower($serendipity['POST']['captcha'] != strtolower($_SESSION['spamblock']['captcha']))) {