]> 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 74aca3730501777d5ef9d8afdc8e05b91a90caf4..e7aa1f0f0675b45bb07145c1831fe6a18e2fd31b 100644 (file)
@@ -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);
+    }
 }