summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2008-01-10 16:00:44 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2008-01-10 16:00:44 +0000
commita816feaddf335c67833785f13c52a546392ac8d7 (patch)
tree80a70891a1e8ac89471b897685cf6af77829171b
parenta541e5fbfb30a9b4e1e9c73028e10660e5495a5f (diff)
downloadbrdo-a816feaddf335c67833785f13c52a546392ac8d7.tar.gz
brdo-a816feaddf335c67833785f13c52a546392ac8d7.tar.bz2
#206078 by Pancho, traxer: order roles with system roles first (usability)
-rw-r--r--modules/user/user.admin.inc14
-rw-r--r--modules/user/user.module15
2 files changed, 12 insertions, 17 deletions
diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc
index cda6fbb97..5ef118fe2 100644
--- a/modules/user/user.admin.inc
+++ b/modules/user/user.admin.inc
@@ -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}');
diff --git a/modules/user/user.module b/modules/user/user.module
index b31dce5cd..82d2c5a6b 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -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;
}
-