function user_badges_get_roles in User Badges 7.2
Same name and namespace in other branches
- 5 user_badges.module \user_badges_get_roles()
- 6.2 user_badges.module \user_badges_get_roles()
- 6 user_badges.module \user_badges_get_roles()
- 7.4 user_badges.module \user_badges_get_roles()
- 7 user_badges.module \user_badges_get_roles()
- 7.3 user_badges.module \user_badges_get_roles()
Returns an array where keys are role ids (rid) and values are the badge ids (bid) associated with that role These values are assigned on admin/people/user_badges/roles
Parameters
$rid - if set, return only values for this role:
$options - array of options: $options['returnbadges'] - if TRUE, return badge objects, not just bids
Return value
a list of roles pt the whole badge object.
2 calls to user_badges_get_roles()
- user_badges_for_uid in ./
user_badges.module - Returns HTML representation of user badges for given uid
- user_badges_roles_form in ./
user_badges.admin.inc - Form to associated badges with roles.
File
- ./
user_badges.module, line 949 - @brief User Badges module file
Code
function user_badges_get_roles($rid = NULL, $options = array()) {
$roles = array();
$options = array_merge(array(
'returnbadges' => FALSE,
), $options);
$query = db_select('user_badges_roles', 'ubr');
$query
->join('user_badges_badges', 'ubb', 'ubb.bid = ubr.bid');
$query
->fields('ubr', array(
'rid',
))
->fields('ubb');
if ($rid) {
$query
->condition('ubr.rid', $rid);
}
$records = $query
->execute();
foreach ($records as $row) {
if ($options['returnbadges']) {
$roles[$row->rid] = $row;
}
else {
$roles[$row->rid] = $row->bid;
}
}
return $roles;
}