diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index 029804f..37dcbc7 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -846,12 +846,12 @@ function user_admin_roles($form, $form_state) { '#default_value' => $role->weight, '#attributes' => array('class' => array('role-weight')), ); - $form['roles'][$role->rid]['operations']['edit'] = array( + $form['roles'][$role->rid]['edit'] = array( '#type' => 'link', '#title' => t('edit role'), '#href' => 'admin/people/permissions/roles/edit/' . $role->rid, ); - $form['roles'][$role->rid]['operations']['permissions'] = array( + $form['roles'][$role->rid]['permissions'] = array( '#type' => 'link', '#title' => t('edit permissions'), '#href' => 'admin/people/permissions/' . $role->rid, @@ -906,19 +906,6 @@ function user_admin_roles_order_submit($form, &$form_state) { function theme_user_admin_roles($variables) { $form = $variables['form']; - $form['role']['name']['#title_display'] = 'invisible'; - unset($form['role']['name']['#description']); - unset($form['role']['rid']['#description']); - - // Distribute role add form into table columns. - $form['roles']['add']['name'] = array(); - $form['roles']['add']['weight'] = $form['role']['weight']; - $form['roles']['add']['operations'] = $form['role']['actions']; - unset($form['role']['weight']); - unset($form['role']['actions']); - $form['roles']['add']['name'] = $form['role']; - unset($form['role']); - $header = array(t('Name'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2)); foreach (element_children($form['roles']) as $rid) { $row = array(); @@ -926,10 +913,23 @@ function theme_user_admin_roles($variables) { $row[] = drupal_render($form['roles'][$rid][$column]); } $rows[] = array('data' => $row, 'class' => array('draggable')); - if (isset($form['roles'][$rid]['weight'])) { - } } + // Distribute the role add form into table columns. + $form['role']['name']['#title_display'] = 'invisible'; + unset($form['role']['name']['#description']); + unset($form['role']['rid']['#description']); + + $actions = $form['role']['actions']; + unset($form['role']['actions']); + unset($form['role']['weight']); + $row = array(); + $row[] = drupal_render($form['role']); + // Empty placeholder for the weight column. + $row[] = ''; + $row[] = array('data' => drupal_render($actions), 'colspan' => 2); + $rows[] = array('data' => $row); + drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight'); $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles'))); @@ -945,10 +945,6 @@ function theme_user_admin_roles($variables) { * @see user_admin_role_submit() */ function user_admin_role($form, $form_state, $role) { - if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) { - drupal_goto('admin/people/permissions/roles'); - } - $form['role'] = array( '#tree' => TRUE, '#parents' => array('role'), @@ -961,7 +957,7 @@ function user_admin_role($form, $form_state, $role) { '#size' => 30, '#required' => TRUE, '#maxlength' => 64, - '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'), + '#description' => t('The name for this role. Example: "Moderator", "Editorial board", "Site architect".'), ); $form['role']['rid'] = array( '#type' => 'machine_name', @@ -987,7 +983,7 @@ function user_admin_role($form, $form_state, $role) { $form['actions']['delete'] = array( '#type' => 'submit', '#value' => t('Delete role'), - '#access' => !empty($role->rid), + '#access' => !empty($role->rid) && !in_array($role->rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID)), '#submit' => array('user_admin_role_delete_submit'), ); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index cf859ae..7e1794a 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1566,14 +1566,13 @@ function user_menu() { $items['admin/people/permissions/roles/edit/%user_role'] = array( 'title' => 'Edit role', 'page arguments' => array('user_admin_role', 5), - 'access callback' => 'user_role_edit_access', - 'access arguments' => array(5), + 'access arguments' => array('administer permissions'), ); $items['admin/people/permissions/roles/delete/%user_role'] = array( 'title' => 'Delete role', 'page callback' => 'drupal_get_form', 'page arguments' => array('user_admin_role_delete_confirm', 5), - 'access callback' => 'user_role_edit_access', + 'access callback' => 'user_role_delete_access', 'access arguments' => array(5), 'file' => 'user.admin.inc', ); @@ -2758,10 +2757,10 @@ function user_role_delete($role) { } /** - * Menu access callback for user role editing. + * Menu access callback for user role deletion. */ -function user_role_edit_access($role) { - // Prevent the system-defined roles from being altered or removed. +function user_role_delete_access($role) { + // Prevent the system-defined roles from being removed. if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) { return FALSE; } diff --git a/core/modules/user/user.test b/core/modules/user/user.test index c1cbd14..4888ce2 100644 --- a/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -2055,12 +2055,14 @@ class UserRoleAdminTestCase extends WebTestBase { $this->assertNoLinkByHref("admin/people/permissions/roles/edit/{$role->rid}", t('Role edit link removed.')); $this->assertFalse(user_role_load($role_name), t('A deleted role can no longer be loaded.')); - // Make sure that the system-defined roles cannot be edited via the user + // Make sure that the system-defined roles can be edited via the user // interface. $this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_ANONYMOUS_RID); - $this->assertResponse(403, t('Access denied when trying to edit the built-in anonymous role.')); + $this->assertResponse(200, 'Access granted when trying to edit the built-in anonymous role.'); + $this->assertNoText(t('Delete role'), 'Delete button for the anonymous role is not present.'); $this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_AUTHENTICATED_RID); - $this->assertResponse(403, t('Access denied when trying to edit the built-in authenticated role.')); + $this->assertResponse(200, 'Access granted when trying to edit the built-in authenticated role.'); + $this->assertNoText(t('Delete role'), 'Delete button for the authenticated role is not present.'); } /**