// Check if they can edit users. In that case, the Roles tab is not needed.
  if (user_access('administer users')) {
    return FALSE;
  }

I'm not sure that it makes sense to limit options for roles that already have administer users perm. This essentially restricts user 1 from using the tab to change roles.

I propose either taking out this line of code or adding || $user->uid == 1.

Comments

Andrew Schulman’s picture

Assigned: Unassigned » Andrew Schulman
Category: bug » feature
damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new532 bytes

The D7 code that handles showing the role selector is as follows:

  $form['account']['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => (!$register && isset($account->roles) ? array_keys($account->roles) : array()),
    '#options' => $roles,
    '#access' => $roles && user_access('administer permissions'),
    DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
  );

If a user only has the 'administer users' permission they cannot change the roles too. As a result the role_delegation_access code simply shouldn't check for 'administer users' and should rely upon the others.

danweasel’s picture

I ran across this earlier and found it very jarring from a usability perspective, that Admin users didn't see the page (and even hit an "access denied" page when trying to manually browse to the URL). I know that they don't "need" it per se, since just editing the user will work fine, but it was particularly odd when I added a contextual role-edit link (user/[current-user:uid]/roles) to the user menu and saw it not appear at all for an admin user.

As a quick and dirty personal change, I just edited FALSE to TRUE in the relevant section, but if the proposed patch removes this issue I am definitely in favor of the module not specifically blocking Admin users from access to the Roles tab.

pasqualle’s picture

Priority: Minor » Normal

please add a variable "hide role delegation tab if the user can edit users" or something and default to TRUE, so existing sites will not see this change, as using role delegation on the user edit page only is a valid use case also..

yes, administration page for that variable has to be created..

jeroent’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

It’s been a while since the last comments on this issue. If this is still a problem. Feel free to reopen and provide a patch.

nwom’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Assigned: Andrew Schulman » Unassigned
Status: Closed (outdated) » Needs work

#2 does not seem to be committed, so it would perhaps just need a reroll.

nwom’s picture

Status: Needs work » Needs review
jeroent’s picture

StatusFileSize
new6.22 KB
new5.09 KB

Added test coverage.

Status: Needs review » Needs work

The last submitted patch, 8: 1300590-8-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jeroent’s picture

Status: Needs work » Needs review

  • JeroenT committed 62572bd on 7.x-1.x authored by DamienMcKenna
    Issue #1300590 by JeroenT, DamienMcKenna: Admin cannot access role tab
    
jeroent’s picture

Status: Needs review » Fixed

Committed and pushed to 7.x-1.x. Thanks!

jeroent’s picture

please add a variable "hide role delegation tab if the user can edit users" or something and default to TRUE, so existing sites will not see this change, as using role delegation on the user edit page only is a valid use case also..

There is a separate issue for this: #2858437: user roles showing twice

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.