--- role_delegation.module 2008-04-30 04:20:47.000000000 -0300 +++ /home/rfay/drupalwa/drupal-5.12/sites/all/modules/role_delegation/role_delegation.module 2008-12-01 10:31:35.609375000 -0300 @@ -120,10 +120,13 @@ function role_delegation_roles_form($acc */ function role_delegation_roles_form_submit($form_id, $form_values) { if (is_array($form_values['roles']) && isset($form_values['account']->uid)) { - db_query('DELETE FROM {users_roles} WHERE uid = %d', $form_values['account']->uid); + $account = user_load(array('uid' => (int)$form_values['account']->uid)); + $myroles = array(); + $rolenames = user_roles(TRUE); foreach (array_keys(array_filter($form_values['roles'])) as $rid) { - db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $form_values['account']->uid, $rid); + $myroles[$rid] = $rolenames[$rid]; // we don't need to have the role name } + user_save($account, array('roles' => $myroles)); // Delete the user's menu cache. cache_clear_all($form_values['account']->uid .':', 'cache_menu', TRUE);