X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FProfile_role.php;h=e7aa1f0f0675b45bb07145c1831fe6a18e2fd31b;hb=061c8d959ba8351b145a27690d5a4caa477915ca;hp=afa7fb74e49e0e5902c725fd3af246d0c2077b57;hpb=6a1afda259c5223449f679a64f932e36df5ebe39;p=quix0rs-gnu-social.git diff --git a/classes/Profile_role.php b/classes/Profile_role.php index afa7fb74e4..e7aa1f0f06 100644 --- a/classes/Profile_role.php +++ b/classes/Profile_role.php @@ -43,13 +43,32 @@ class Profile_role extends Memcached_DataObject /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE - function &pkeyGet($kv) + function pkeyGet($kv) { 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); + } }