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.

CommentFileSizeAuthor
user_badges.patch2.43 KBmaximpodorov
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Richard Blackborder’s picture

Version: 6.x-1.5 » 6.x-1.x-dev
Priority: Critical » Normal
Status: Active » Fixed

Thanks 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.

maximpodorov’s picture

You 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));

Richard Blackborder’s picture

Updated the dev version, thank you.

Status: Fixed » Closed (fixed)

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