Role delegation showing up on profile created tabs and wiping out assigned roles

djsmeg - July 15, 2009 - 17:12
Project:Role Delegation
Version:6.x-1.2
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:needs review
Description

I have some profile fields under their own tab in the user page. Role Delegation is now adding the "roles" section to the profile tab, and is not selecting any pre-existing assigned roles to the user. This means the user, from being very privileged goes to "authenticated user" if they save any profile changes from the profile tab. I can't see how I can easily fix this in the code, it looks like your code is mangling the user page whether or not it's the "base" user page, and for some reason (I can't see why) it's not picking up it's roles when it's not on the "base" user page.

To recreate, simply add a new profile field, with it's own category. try and edit that profile field on a user granted privileges, and you'll see that the assigned roles disappear.

Thanks

#1

djsmeg - July 15, 2009 - 19:57

OK. I spent some time, and figured out that using hook_form_alter is not going to respect profile tabs.

Attached is a diff for what I think is the way you're supposed to do it.

Hope this helps

Christian

AttachmentSize
rdfix.patch 4.04 KB

#2

LiveLoveWorkPlay - August 18, 2009 - 17:27

Any development on this? I have a production site where this issue is causing confusion. We'll apply the patch and test if it would help all.

#3

LiveLoveWorkPlay - August 20, 2009 - 12:01

Applied the changes in this patch - disabled/re-enabled the module. Did not find the problem addressed / corrected;

Roles show up on each profile category page, entirely empty, as title of this issue describes. This occurs for any user granted delegation permissions. Changes over-ride actual existing values, as described above if saved.

#4

shark - October 8, 2009 - 02:27

I see this as well. I will test the patch and report back soon.

#5

shark - October 8, 2009 - 05:40
Status:active» needs review

The patch from djsmeg fixed this issue for me (roles no longer show up in profile tabs other than account, and thus they don't get wiped out when the profile is saved), and I've simplified the patch a bit (the only change being that hook_form_alter() is completely removed).

I removed the hook_form_alter() implementation because it didn't appear to do anything (someone correct me if I'm wrong); the code after applying the original patch (and the code that I removed in the new version of the patch) is below:

/**
* Implementation of hook_form_alter().
*/
function role_delegation_form_alter(&$form, $form_state, $form_id) {
  // Only alter user form when user can't assign permissions without Role Delegation.
  if ($form_id != 'user_register' && $form_id != 'user_profile_form') {
    return;
  }
  if (user_access('administer permissions')) {
    return;
  }
}

AttachmentSize
rdfix2.patch 4.28 KB

#6

BenK - October 17, 2009 - 00:18

The patch in #5 solved this problem for me. Can we get this patch committed to the module?

Cheers,
Ben

#7

mineshaftgap - October 24, 2009 - 02:04

FYI for anyone having this problem and wanting a possibly upgrade friendly work around:

A new custom module dcpl_misc.module:

<?php

function dcpl_misc_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_profile_form':
// for this to work, wee need to run this SQL: update system set weight = 10 where name = 'dcpl_misc';
if (!array_key_exists('account', $form)) {
unset($form['roles_assign']);
}
break;
  }
}

issue the following SQL:

update system set weight = 10 where name = 'dcpl_misc';

#8

baronmunchowsen - November 6, 2009 - 21:09

Patch in #5 worked like a charm for me too.
Please roll it into the next relase if possible.

Cheers! And thanks for all your hard work on a great module!

 
 

Drupal is a registered trademark of Dries Buytaert.