function user_roles in Drupal 5
Same name and namespace in other branches
- 8 core/modules/user/user.module \user_roles()
- 4 modules/user.module \user_roles()
- 6 modules/user/user.module \user_roles()
- 7 modules/user/user.module \user_roles()
- 9 core/modules/user/user.module \user_roles()
Retrieve an array of roles matching specified conditions.
Parameters
$membersonly: Set this to TRUE to exclude the 'anonymous' role.
$permission: A string containing a permission. If set, only roles containing that permission are returned.
Return value
An associative array with the role id as the key and the role name as value.
12 calls to user_roles()
- blogapi_admin_settings in modules/
blogapi/ blogapi.module - blogapi_metaweblog_new_media_object in modules/
blogapi/ blogapi.module - Blogging API callback. Inserts a file into Drupal.
- filter_admin_format_form in modules/
filter/ filter.module - Generate a filter format form.
- filter_admin_format_form_submit in modules/
filter/ filter.module - Process filter format form submissions.
- filter_admin_overview in modules/
filter/ filter.module - Displays a list of all input formats and which one is the default
File
- modules/
user/ user.module, line 1797 - Enables the user registration and login system.
Code
function user_roles($membersonly = 0, $permission = 0) {
$roles = array();
if ($permission) {
$result = db_query("SELECT r.* FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid WHERE p.perm LIKE '%%%s%%' ORDER BY r.name", $permission);
}
else {
$result = db_query('SELECT * FROM {role} ORDER BY name');
}
while ($role = db_fetch_object($result)) {
if (!$membersonly || $membersonly && $role->rid != DRUPAL_ANONYMOUS_RID) {
$roles[$role->rid] = $role->name;
}
}
return $roles;
}