Entering a username on the "Enter the users this user is able to masquerade as:" field on a profile is not allowing a user to masquerade as set users. It seems that is not retaining the usernames entered.

As I understand it, this field should work without the need to allow "Masquerade as any user".

Any ideas?

Comments

offback’s picture

As I'm pretty new to drupal, I'm not sure if this is the right thing to do but I fixed this on my site by moving the code in the masquerade.module file the masquerade_user() function in the case update part of the code to the case submit part of the code. It seemed like there are times when masquerade_user() case update was called when the form data containing the users "masquerade as fields" has not been loaded in those cases the database field was cleared.

This may break other things but seems to be working for me.

case 'submit':
$old_session_id = session_id();
/* code move from case update to case submit */
if ($category == 'account') {
$users = drupal_explode_tags($edit['masquerade_users']);
db_query("DELETE FROM {masquerade_users} WHERE uid_from = %d", $edit_user->uid);
foreach ($users as $user) {
$u = user_load(array('name' => $user));
db_query("INSERT INTO {masquerade_users} VALUES (%d, %d)", $edit_user->uid, $u->uid);
}
$edit['masquerade_users'] = NULL;
}
/* end code moved */
break;

case 'update':

break;

boftx’s picture

I tried this, and it does keep existing assignments in place.

Howerver ...

It prevents new ones from being assigned.

apaderno’s picture

Version: 6.x-1.4 » 6.x-1.x-dev
Issue summary: View changes
Status: Active » Closed (outdated)

I am closing this bug report, as Drupal 6 is no longer supported. Please re-open it if the issue is still relevant for the Drupal 7 or 8 version of the module.