When deleting the badge for removed role, the existing of the badge is incorrectly checked by looking at visible badges list, not all badges list for that user. The proposed patch solves this problem and also adds new all_badges array to user object. This array may be used when you need to know all badges for the user, not visible only (maybe on some administrative pages, etc.). The patch also adds rereading badges information after user role modification. It may be useful when user information modification in one module will be continued by hook_user implementations in other modules, and roles may be changed by these consequent modifications.
Comment | File | Size | Author |
---|---|---|---|
user_badges.patch | 2.43 KB | maximpodorov |
Comments
Comment #1
Richard Blackborder CreditAttribution: Richard Blackborder commentedThanks a lot for the patch!
I have used your technique, modifying slightly to cut down the number of database queries, but this was a smooth easy fix because of your patch and I appreciate that.
I have included your addition to the user object, which I think is a good idea. I renamed it to "badges_all", though.
The new dev version integrates these changes. Let me know if it gives you any problems.
Comment #2
maximpodorov CreditAttribution: maximpodorov commentedYou made a misprint in line 199 of user_badges.module:
$account->badges_all = user_badges_get_badges($account->uid);
$account->badges_all = user_badges_get_badges($account->uid, array('nolimit' => TRUE));
Comment #3
Richard Blackborder CreditAttribution: Richard Blackborder commentedUpdated the dev version, thank you.