summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-09-15 15:28:11 -0400
committerEvan Prodromou <evan@status.net>2009-09-27 21:11:45 -0400
commit6c069312e2911d3b2fe54d051354f579fde7bb63 (patch)
treecdc6ad4e49325fcb8808faa54544b90524b7e5dd /classes
parenta8d1b7e9c26b4449a4a1e0e250f9b6766b2d8e62 (diff)
user rights
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index 5e74c7fde..bea81af4d 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -711,4 +711,30 @@ class User extends Memcached_DataObject
return true;
}
+
+ /**
+ * Does this user have the right to do X?
+ *
+ * With our role-based authorization, this is merely a lookup for whether the user
+ * has a particular role. The implementation currently uses a switch statement
+ * to determine if the user has the pre-defined role to exercise the right. Future
+ * implementations may allow per-site roles, and different mappings of roles to rights.
+ *
+ * @param $right string Name of the right, usually a constant in class Right
+ * @return boolean whether the user has the right in question
+ */
+
+ function hasRight($right)
+ {
+ switch ($right)
+ {
+ case Right::deleteOthersNotice:
+ return $this->hasRole('moderator');
+ break;
+ default:
+ $result = false;
+ Event::handle('UserRightsCheck', array($this, &$result));
+ return $result;
+ }
+ }
}