]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile_role.php
Merge branch 'extprofile' into 0.9.x
[quix0rs-gnu-social.git] / classes / Profile_role.php
index afa7fb74e49e0e5902c725fd3af246d0c2077b57..e7aa1f0f0675b45bb07145c1831fe6a18e2fd31b 100644 (file)
@@ -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);
+    }
 }