og_user_roles_og() mistakenly deletes existing roles on 'user update' if not admin
| Project: | OG User Roles |
| Version: | 6.x-4.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
hi,
typo in following code causes ALL preexisting roles to be lost for example when a user's status is changed from active=0 to active=1. this is because $rid hasn't been set. probably
og_user_roles_role_delete($nid, $uid, $rid);
should be changed to
og_user_roles_role_delete($nid, $uid, $default_admin_role);
case 'user update':
$default_admin_role = variable_get('og_user_roles_default_admin_role', 0);
$default_role = variable_get('og_user_roles_default_role', 0);
if ($default_admin_role > 0 && $default_admin_role != $default_role) {
// Grant role for new group admin.
if (isset($args['is_admin']) && $args['is_admin']) {
og_user_roles_role_add($nid, $uid, $default_admin_role);
}
// Delete role for obsolete group admin.
else {
og_user_roles_role_delete($nid, $uid, $rid);
}
}
break;

#1
as a follow up, i just tested this fix and it appears to work. the problem was that $rid was not defined anywhere in
function og_user_roles_og($op, $nid, $uid, $args = array()) {
so the line og_user_roles_role_delete($nid, $uid, $rid); ended up deleting ALL group roles for the user.
#2
Hmm... ugly.
Can you please provide a patch against cvs? It will get reviewed soon and can get fixed.
http://drupal.org/patch/create
#3
Please provide a proper patch. I'm unable to read changes you did from your post.
#4
It looks like this bug was already fix in this commit: http://drupal.org/cvs?commit=232194
#5
oopsie, looks like it's time for a new stable then ;)
Thanks, pwolanin! :-D
#6
Automatically closed -- issue fixed for 2 weeks with no activity.