Skip to content
Snippets Groups Projects
Commit a816fead authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#206078 by Pancho, traxer: order roles with system roles first (usability)

parent a541e5fb
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -6,7 +6,6 @@
* Admin page callback file for the user module.
*/
function user_admin($callback_arg = '') {
$op = isset($_POST['op']) ? $_POST['op'] : $callback_arg;
......@@ -514,16 +513,10 @@ function user_admin_perm($form_state, $rid = NULL) {
$role_permissions[$role->rid] = $role->perm .',';
}
// Retrieve role names for columns.
$role_names = user_roles();
if (is_numeric($rid)) {
$result = db_query('SELECT rid, name FROM {role} r WHERE r.rid = %d ORDER BY name', $rid);
}
else {
$result = db_query('SELECT rid, name FROM {role} ORDER BY name');
}
$role_names = array();
while ($role = db_fetch_object($result)) {
$role_names[$role->rid] = $role->name;
$role_names = array($rid => $role_names[$rid]);
}
// Render role/permission overview:
......@@ -557,7 +550,6 @@ function user_admin_perm($form_state, $rid = NULL) {
return $form;
}
function user_admin_perm_submit($form, &$form_state) {
// Save permissions:
$result = db_query('SELECT * FROM {role}');
......
......@@ -1628,8 +1628,12 @@ function _user_mail_text($key, $language = NULL, $variables = array()) {
* @return
* An associative array with the role id as the key and the role name as value.
*/
function user_roles($membersonly = 0, $permission = 0) {
$roles = array();
function user_roles($membersonly = FALSE, $permission = FALSE) {
// System roles take the first two positions.
$roles = array(
DRUPAL_ANONYMOUS_RID => NULL,
DRUPAL_AUTHENTICATED_RID => NULL,
);
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);
......@@ -1642,7 +1646,9 @@ function user_roles($membersonly = 0, $permission = 0) {
$roles[$role->rid] = $role->name;
}
}
return $roles;
// Filter to remove unmatched system roles.
return array_filter($roles);
}
/**
......@@ -2102,8 +2108,6 @@ function _user_password_dynamic_validation() {
}
}
/**
* Implementation of hook_hook_info().
*/
......@@ -2381,4 +2385,3 @@ function _user_forms(&$edit, $account, $category, $hook = 'form') {
return empty($groups) ? FALSE : $groups;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment