Admin Role module assigns perms to wrong or no role
| Project: | Admin Role |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (to be ported) |
Jump to:
Hi there,
Forgive me if this issue as already been addressed, I am a newbie and I tried to find any information about this in the forums and was unsuccessful. I'm running Drupal 6.5 and here is the problem I am having with adminrole 6.x-1.0-beta2:
1. I installed Admin Role
2. I enabled the module
3. I created a new Role called "Administrator"
4. I assigned Admin Role to "Administrator"
5. I checked Permissions and my "Blogger" role had received all the permissions from Admin Role, instead of "Administrator".
6. I tried this with "Blogger" role and it worked fine, and with "Forum Moderator" role and it worked fine as well.
7. I renamed the "Administrator" role to various other names, but still had the same problem.
8. I deleted the "Administrator" role, disabled AdminRole, created "Administrator", enabled AdminRole and tried again and still it assigned all permissions to "Blogger".
9. I uninstalled and reinstalled the module and still the same thing happened.
10. I deleted the "Blogger" role and tried again, and then when I assigned the AdminRole to "Administrator" no permissions were assigned to any role. The same thing happened when I deleted and recreated "Forum Moderator", now no permissions are assigned to any role.
11. I tried applying the patch http://drupal.org/node/309393, but to no avail. Of course, I am a newbie and while I read the patch documentation, I'm not sure I applied the patch correctly through cPanel. I did change the actual code in the module per the instructions in the above thread, but no luck there either.
12. The two roles that worked for Admin Role ("Blogger" and "Forum Moderator") are roles I had created before I upgraded to 6.5. I'm not sure if that makes any difference.
Any help would be appreciated.
Thanks!

#1
I was experiencing this same issue because there was a role that had been deleted. The values for the select box on the settings page would being set in numerical order, so setting the role to anything after the break in sequence (1,2,3,5,6,7) and would make the options (1,2,3,4,5,6).
I was going to upload a patch but noticed that it was already fixed when checking out DRUPAL-6--2 drupal via CVS.
@vfranklyn - can you create a new release with that fix in it please?
This is the function that had the problem, replace it in your adminrole.module file and then go and back and set the admin role, but be sure the form gets refreshed.
<?php
function adminrole_admin_settings() {
$form = array();
$u_roles = user_roles();
// Removing Authenticated and anonymous roles
unset($u_roles[1]);
unset($u_roles[2]);
$u_roles[0] = t('-- Please Select One --');
ksort($u_roles);
$form['adminrole_adminrole'] = array(
'#type' => 'select',
'#title' => t('Admin Roles'),
'#default_value' => variable_get('adminrole_adminrole', 0),
'#description' => t("Which role should get all permissions?"),
'#options' => $u_roles,
);
return system_settings_form($form);
}
?>
#2
Subscribing.
#3
Hi lee20,
I tried your fixed and it worked!! Thanks so very much for the help!
From what I've read, I can't create a new release of a module unless I have CVS access to the project. Besides, I'm guessing the owner of this module might want to create the release instead of me. As a newbie, my chances of screwing it up seem high...
Thanks again!
#4
@vfranklyn - Oops I meant to direct that towards the module owner.
@JacobSingh - Can you create a new release with this fix in it? If not, grant me CVS commit access and I can. -Thanks
#5
Hi there,
i´ve fixed it without unsetting the two roles.
function adminrole_admin_settings() {
$form = array();
$u_roles = user_roles();
reset($u_roles);
$u_roles[0] = t('-- Please Select One --');
natsort($u_roles);
$form['adminrole_adminrole'] = array(
'#type' => 'select',
'#title' => t('Admin Roles'),
'#default_value' => variable_get('adminrole_adminrole', 0),
'#description' => t("Which Role is Admin?"),
'#options' => $u_roles,
);
return system_settings_form($form);
}
Thanks for this tiny helper module. :-)
#6
Please test whether this issue can be reproduced with latest d6 dev (DRUPAL-6--1). If so, please roll a standard patch fo it and update the issue's version and status. Thanks! ;)
#7
#8
They just released RC2 which includes this fix.
#9
Please mark fixed issues as fixed and let drupal.org mark as closed. Thanks!
#10
Automatically closed -- issue fixed for 2 weeks with no activity.
#11
Is this issue only relevant for v6.x, or also for v5.x?
(current 5.x stable version is from last summer)
#12
This was only ever a bug in the 6 version (AFAIK) and was fixed there.
#13
This is an issue for 5.x 1.5 as well. Fix works.
#14