Posted by firstcontact on December 1, 2008 at 11:51am
Jump to:
| Project: | Role Change Notify |
| Version: | 5.x-1.1-beta1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Comments
#1
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
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
Won't (can't) fix, but hoping for the update in role delegation.
#4
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
Automatically closed -- issue fixed for 2 weeks with no activity.