]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add spam-training, spam-reviewing rights
authorEvan Prodromou <evan@status.net>
Sun, 25 Mar 2012 17:16:23 +0000 (13:16 -0400)
committerEvan Prodromou <evan@status.net>
Sun, 25 Mar 2012 17:18:16 +0000 (13:18 -0400)
Replaced the check for a moderator role in certain spam-training and
-reviewing points. Make sure modhelpers can check, too.

classes/Notice.php
classes/Profile.php
lib/profilenoticestream.php
lib/right.php
plugins/ModHelper/ModHelperPlugin.php

index a84dcf6ed3dde5a55ffde0344d8d20d6d2200cc4..a813db99b3b234a8ab8a057a4a6f1084c4da689a 100644 (file)
@@ -2472,7 +2472,7 @@ class Notice extends Managed_DataObject
             $author = $this->getProfile();
 
             if ($author->hasRole(Profile_role::SILENCED)) {
-                if (empty($profile) || !$profile->hasRole(Profile_role::MODERATOR)) {
+                if (empty($profile) || !$profile->hasRight(Right::REVIEWSPAM)) {
                     return true;
                 }
             }
index e07d37139b2bbcbe2de88f985a222e0c054c717a..cefcaf90b5b6a31823163bf27cfd50c8dd873ff6 100644 (file)
@@ -1190,6 +1190,8 @@ class Profile extends Managed_DataObject
             case Right::SILENCEUSER:
             case Right::DELETEUSER:
             case Right::DELETEGROUP:
+            case Right::TRAINSPAM:
+            case Right::REVIEWSPAM:
                 $result = $this->hasRole(Profile_role::MODERATOR);
                 break;
             case Right::CONFIGURESITE:
index 1fde1c6025e2408191284f5ae6b4be93387aa8e5..5b02bc7b3f28004f1eb071cef13703c6a3174d33 100644 (file)
@@ -95,7 +95,7 @@ class ProfileNoticeStream extends ScopingNoticeStream
 
         if (common_config('notice', 'hidespam')) {
             if ($this->streamProfile->hasRole(Profile_role::SILENCED) &&
-                (empty($this->userProfile) || !$this->userProfile->hasRole(Profile_role::MODERATOR))) {
+                (empty($this->userProfile) || !$this->userProfile->hasRight(Right::REVIEWSPAM))) {
                 return true;
             }
         }
index baa18d3c13606b011cc6ea96e6b924065bccb0e0..f00f59027877da07a63fdc75a117edeee6f453a4 100644 (file)
@@ -68,5 +68,7 @@ class Right
     const CREATEGROUP        = 'creategroup';
     const WEBLOGIN           = 'weblogin';
     const API                = 'api';
+    const REVIEWSPAM         = 'reviewspam';
+    const TRAINSPAM          = 'trainspam';
 }
 
index c2757bbeae5cb4c0a974866e140cca788e7bd773..bed0d8d49e3d8160e98535d3e2e5cf347aecb663 100644 (file)
@@ -27,6 +27,8 @@ if (!defined('STATUSNET')) {
  */
 class ModHelperPlugin extends Plugin
 {
+    static $rights = array(Right::SILENCEUSER, Right::TRAINSPAM, Right::REVIEWSPAM);
+
     function onPluginVersion(&$versions)
     {
         $versions[] = array('name' => 'ModHelper',
@@ -42,7 +44,7 @@ class ModHelperPlugin extends Plugin
 
     function onUserRightsCheck($profile, $right, &$result)
     {
-        if ($right == Right::SILENCEUSER) {
+        if (in_array($right, self::$rights)) {
             // Hrm.... really we should confirm that the *other* user isn't privleged. :)
             if ($profile->hasRole('modhelper')) {
                 $result = true;