You are here

function user_badges_get_roles in User Badges 5

Same name and namespace in other branches
  1. 6.2 user_badges.module \user_badges_get_roles()
  2. 6 user_badges.module \user_badges_get_roles()
  3. 7.4 user_badges.module \user_badges_get_roles()
  4. 7 user_badges.module \user_badges_get_roles()
  5. 7.2 user_badges.module \user_badges_get_roles()
  6. 7.3 user_badges.module \user_badges_get_roles()

Returns an array where keys are role ids (rid) and values are badge ids (bid) These values are assigned on admin/user/user_badges/roles

Parameters

$rid - if set, return only value for this role:

Return value

a list of roles

2 calls to user_badges_get_roles()
user_badges_roles_form in ./user_badges.module
user_badges_user in ./user_badges.module
Implementation of hook_user() This handles assignment of badges based on role. When role is assigned or removed, appropriate badges are added or removed.

File

./user_badges.module, line 731
@brief User Badges module file

Code

function user_badges_get_roles($rid = NULL) {
  $roles = array();
  if ($rid) {
    $sql = db_query('SELECT * FROM {user_badges_roles} WHERE rid = %d', $rid);
  }
  else {
    $sql = db_query('SELECT * FROM {user_badges_roles}');
  }
  while ($row = db_fetch_object($sql)) {
    $roles[$row->rid] = $row->bid;
  }
  return $roles;
}