Commit 83f679fb authored by mmn's avatar mmn

Profile->isPrivileged() to check if users have more rights than to post etc.

parent 3cef75bc
......@@ -1179,9 +1179,9 @@ class Profile extends Managed_DataObject
if (!$actor->hasRight(Right::SILENCEUSER)) {
throw new AuthorizationException(_('You cannot silence users on this site.'));
}
// Only administrators can silence other priviliged users (those who have the right to silence as well).
if ($this->hasRight(Right::SILENCEUSER) && !$actor->hasRole(Profile_role::ADMINISTRATOR)) {
throw new AuthorizationException(_('You cannot silence other priviliged users.'));
// Only administrators can silence other privileged users (such as others who have the right to silence).
if ($this->isPrivileged() && !$actor->hasRole(Profile_role::ADMINISTRATOR)) {
throw new AuthorizationException(_('You cannot silence other privileged users.'));
}
if ($this->isSilenced()) {
// TRANS: Client error displayed trying to silence an already silenced user.
......@@ -1221,6 +1221,22 @@ class Profile extends Managed_DataObject
}
}
public function isPrivileged()
{
// TODO: An Event::handle so plugins can report if users are privileged.
// The ModHelper is the only one I care about when coding this, and that
// can be tested with Right::SILENCEUSER which I do below:
switch (true) {
case $this->hasRight(Right::SILENCEUSER):
case $this->hasRole(Profile_role::MODERATOR):
case $this->hasRole(Profile_role::ADMINISTRATOR):
case $this->hasRole(Profile_role::OWNER):
return true;
}
return false;
}
/**
* Does this user have the right to do X?
*
......
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