diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/upload/upload.admin.inc | 2 | ||||
-rw-r--r-- | modules/user/user.admin.inc | 10 | ||||
-rw-r--r-- | modules/user/user.module | 25 |
3 files changed, 24 insertions, 13 deletions
diff --git a/modules/upload/upload.admin.inc b/modules/upload/upload.admin.inc index 7963d7320..d9371909a 100644 --- a/modules/upload/upload.admin.inc +++ b/modules/upload/upload.admin.inc @@ -109,7 +109,7 @@ function upload_admin_settings() { $form['settings_general']['upload_max_size'] = array('#value' => '<p>'. t('Your PHP settings limit the maximum file size per upload to %size.', array('%size' => format_size(file_upload_max_size()))) .'</p>'); - $roles = user_roles(0, 'upload files'); + $roles = user_roles(FALSE, 'upload files'); $form['roles'] = array('#type' => 'value', '#value' => $roles); foreach ($roles as $rid => $role) { diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index 5ef118fe2..b86872c90 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -172,7 +172,7 @@ function user_admin_account() { $destination = drupal_get_destination(); $status = array(t('blocked'), t('active')); - $roles = user_roles(1); + $roles = user_roles(TRUE); $accounts = array(); while ($account = db_fetch_object($result)) { $accounts[$account->uid] = ''; @@ -617,9 +617,9 @@ function theme_user_admin_perm($form) { * @see theme_user_admin_new_role() */ function user_admin_role() { - $id = arg(4); - if ($id) { - if (DRUPAL_ANONYMOUS_RID == $id || DRUPAL_AUTHENTICATED_RID == $id) { + $rid = arg(4); + if ($rid) { + if ($rid == DRUPAL_ANONYMOUS_RID || $rid == DRUPAL_AUTHENTICATED_RID) { drupal_goto('admin/user/roles'); } // Display the edit role form. @@ -635,7 +635,7 @@ function user_admin_role() { ); $form['rid'] = array( '#type' => 'value', - '#value' => $id, + '#value' => $rid, ); $form['submit'] = array( '#type' => 'submit', diff --git a/modules/user/user.module b/modules/user/user.module index 82d2c5a6b..3082fa86e 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1436,7 +1436,7 @@ function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) { $form['account']['status'] = array('#type' => 'radios', '#title' => t('Status'), '#default_value' => isset($edit['status']) ? $edit['status'] : 1, '#options' => array(t('Blocked'), t('Active'))); } if (user_access('administer permissions')) { - $roles = user_roles(1); + $roles = user_roles(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); if ($roles) { $default = empty($edit['roles']) ? array() : array_keys($edit['roles']); @@ -1628,22 +1628,33 @@ 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 = FALSE, $permission = FALSE) { +function user_roles($membersonly = FALSE, $permission = NULL) { // System roles take the first two positions. $roles = array( DRUPAL_ANONYMOUS_RID => NULL, DRUPAL_AUTHENTICATED_RID => NULL, ); - if ($permission) { + if (!empty($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; + switch ($role->rid) { + // We only translate the built in role names + case DRUPAL_ANONYMOUS_RID: + if (!$membersonly) { + $roles[$role->rid] = t($role->name); + } + break; + case DRUPAL_AUTHENTICATED_RID: + $roles[$role->rid] = t($role->name); + break; + default: + $roles[$role->rid] = $role->name; } } @@ -1670,7 +1681,7 @@ function user_user_operations($form_state = array()) { ); if (user_access('administer permissions')) { - $roles = user_roles(1); + $roles = user_roles(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); // Can't edit authenticated role. $add_roles = array(); @@ -1867,7 +1878,7 @@ function _user_sort($a, $b) { function user_filters() { // Regular filters $filters = array(); - $roles = user_roles(1); + $roles = user_roles(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role. if (count($roles)) { $filters['role'] = array( |