Commit b17cd3b6 authored by Gábor Hojtsy's avatar Gábor Hojtsy

#18954 by kkaefer, Pancho: built-in role names were not translated and some...

#18954 by kkaefer, Pancho: built-in role names were not translated and some user_roles() call cleanups
parent 7ecd63ed
......@@ -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) {
......
......@@ -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',
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment