Does not work with Role Delegation

firstcontact - December 1, 2008 - 11:51
Project:Role Change Notify
Version:5.x-1.1-beta1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

If a role is assigned to a user with the role delegation module, no e-mail notification is sent out to that user. I have looked through the code myself but cannot figure out which part is analysing the change of roles in the Drupal system. Any help appreciated, thanks.

#1

rfay - December 1, 2008 - 12:31
Status:active» won't fix

Unfortunately, the role_delegation module does direct access to the database instead of using the drupal apis.

Here is the code from role_delegation:

<?php
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);
    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);
    }

   
// Delete the user's menu cache.
   
cache_clear_all($form_values['account']->uid .':', 'cache_menu', TRUE);

   
drupal_set_message(t('The roles have been updated.'));
  }
}
?>

My belief is that the correct way to accomplish this task (and the way used by other modules) is to use user_save(). That way modules like this one (role_change_notify) can listen on the hook (hook_user) and take actions.

Please file this bug against the role_delegation module. I think the information given here is enough to describe what change should be made. I'll be happy to help out.

-Randy

#2

rfay - December 1, 2008 - 14:17
Status:won't fix» active

I rolled patches for role_delegation for drupal5 (#341162: Module should use user_save instead of directly accessing drupal database (drupal5 patch)) and for drupal6 (#341165: Module should use user_save instead of directly accessing drupal database (drupal6 patch)) on this, so perhaps that will get into the module. In the meantime, you can patch role_delegation with these patches.

Please note that the mentioned patches are for Role Delegation, not for this module. They will not apply to role_change_notify.

#3

rfay - December 11, 2008 - 16:54
Status:active» won't fix

Won't (can't) fix, but hoping for the update in role delegation.

#4

rfay - March 7, 2009 - 21:31
Status:won't fix» fixed

This has apparently been fixed (the patches I submitted have been committed) in the latest releases. (6.x-1.1 and 5.x-1.2) of role_delegation

#5

System Message - March 21, 2009 - 21:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.