diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-10 20:22:57 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-10 20:22:57 +0000 |
commit | b17cd3b613df6a2e4912c263af7cff49004ffc38 (patch) | |
tree | 3e87d6bf4a018990125085ba65ece70d86a8aba8 /modules/user/user.module | |
parent | 7ecd63ed9f977045a890f19a6e08d5e9f9dca7d4 (diff) | |
download | brdo-b17cd3b613df6a2e4912c263af7cff49004ffc38.tar.gz brdo-b17cd3b613df6a2e4912c263af7cff49004ffc38.tar.bz2 |
#18954 by kkaefer, Pancho: built-in role names were not translated and some user_roles() call cleanups
Diffstat (limited to 'modules/user/user.module')
-rw-r--r-- | modules/user/user.module | 25 |
1 files changed, 18 insertions, 7 deletions
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( |