]> git.mjollnir.org Git - moodle.git/commitdiff
Added new function
authormoodler <moodler>
Wed, 4 Oct 2006 07:07:57 +0000 (07:07 +0000)
committermoodler <moodler>
Wed, 4 Oct 2006 07:07:57 +0000 (07:07 +0000)
   function user_has_role_assignment($userid, $roleid, $contextid=0)

lib/accesslib.php

index 459e686d160a98814ca01084a1a9c6b3916ed1f6..262e407583fbbf0aa47fd6094453837fb44cd6c9 100755 (executable)
@@ -2994,4 +2994,16 @@ function get_users_from_role_on_context($role, $context) {
                                   AND roleid = $role->id");
 }
 
+/* 
+ * Simple function returning a boolean true if roles exist, otherwise false
+ */
+function user_has_role_assignment($userid, $roleid, $contextid=0) {
+
+    if ($contextid) {
+        return record_exists('role_assignments', 'userid', $userid, 'roleid', $roleid, 'contextid', $contextid);
+    } else {
+        return record_exists('role_assignments', 'userid', $userid, 'roleid', $roleid);
+    }
+}
+
 ?>