X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile_role.php;h=e7aa1f0f0675b45bb07145c1831fe6a18e2fd31b;hb=a7e33ac89df9f05b7497bfb34c6e69b3329a87e5;hp=74aca3730501777d5ef9d8afdc8e05b91a90caf4;hpb=4de09d6bd4eab3259d42fa846e4dd31f2516a038;p=quix0rs-gnu-social.git diff --git a/classes/Profile_role.php b/classes/Profile_role.php index 74aca37305..e7aa1f0f06 100644 --- a/classes/Profile_role.php +++ b/classes/Profile_role.php @@ -48,8 +48,27 @@ class Profile_role extends Memcached_DataObject return Memcached_DataObject::pkeyGet('Profile_role', $kv); } + const OWNER = 'owner'; const MODERATOR = 'moderator'; const ADMINISTRATOR = 'administrator'; const SANDBOXED = 'sandboxed'; const SILENCED = 'silenced'; + const DELETED = 'deleted'; // Pending final deletion of notices... + + public static function isValid($role) + { + // @fixme could probably pull this from class constants + $known = array(self::OWNER, + self::MODERATOR, + self::ADMINISTRATOR, + self::SANDBOXED, + self::SILENCED); + return in_array($role, $known); + } + + public static function isSettable($role) + { + $allowedRoles = array('administrator', 'moderator'); + return self::isValid($role) && in_array($role, $allowedRoles); + } }