We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 0d487a1e authored by Evan Prodromou's avatar Evan Prodromou

Add spam-training, spam-reviewing rights

Replaced the check for a moderator role in certain spam-training and
-reviewing points. Make sure modhelpers can check, too.
parent 76e6bee6
...@@ -2472,7 +2472,7 @@ class Notice extends Managed_DataObject ...@@ -2472,7 +2472,7 @@ class Notice extends Managed_DataObject
$author = $this->getProfile(); $author = $this->getProfile();
if ($author->hasRole(Profile_role::SILENCED)) { if ($author->hasRole(Profile_role::SILENCED)) {
if (empty($profile) || !$profile->hasRole(Profile_role::MODERATOR)) { if (empty($profile) || !$profile->hasRight(Right::REVIEWSPAM)) {
return true; return true;
} }
} }
......
...@@ -1190,6 +1190,8 @@ class Profile extends Managed_DataObject ...@@ -1190,6 +1190,8 @@ class Profile extends Managed_DataObject
case Right::SILENCEUSER: case Right::SILENCEUSER:
case Right::DELETEUSER: case Right::DELETEUSER:
case Right::DELETEGROUP: case Right::DELETEGROUP:
case Right::TRAINSPAM:
case Right::REVIEWSPAM:
$result = $this->hasRole(Profile_role::MODERATOR); $result = $this->hasRole(Profile_role::MODERATOR);
break; break;
case Right::CONFIGURESITE: case Right::CONFIGURESITE:
......
...@@ -95,7 +95,7 @@ class ProfileNoticeStream extends ScopingNoticeStream ...@@ -95,7 +95,7 @@ class ProfileNoticeStream extends ScopingNoticeStream
if (common_config('notice', 'hidespam')) { if (common_config('notice', 'hidespam')) {
if ($this->streamProfile->hasRole(Profile_role::SILENCED) && 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; return true;
} }
} }
......
...@@ -68,5 +68,7 @@ class Right ...@@ -68,5 +68,7 @@ class Right
const CREATEGROUP = 'creategroup'; const CREATEGROUP = 'creategroup';
const WEBLOGIN = 'weblogin'; const WEBLOGIN = 'weblogin';
const API = 'api'; const API = 'api';
const REVIEWSPAM = 'reviewspam';
const TRAINSPAM = 'trainspam';
} }
...@@ -27,6 +27,8 @@ if (!defined('STATUSNET')) { ...@@ -27,6 +27,8 @@ if (!defined('STATUSNET')) {
*/ */
class ModHelperPlugin extends Plugin class ModHelperPlugin extends Plugin
{ {
static $rights = array(Right::SILENCEUSER, Right::TRAINSPAM, Right::REVIEWSPAM);
function onPluginVersion(&$versions) function onPluginVersion(&$versions)
{ {
$versions[] = array('name' => 'ModHelper', $versions[] = array('name' => 'ModHelper',
...@@ -42,7 +44,7 @@ class ModHelperPlugin extends Plugin ...@@ -42,7 +44,7 @@ class ModHelperPlugin extends Plugin
function onUserRightsCheck($profile, $right, &$result) 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. :) // Hrm.... really we should confirm that the *other* user isn't privleged. :)
if ($profile->hasRole('modhelper')) { if ($profile->hasRole('modhelper')) {
$result = true; $result = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment