You are here

function user_badges_has_badge in User Badges 6.2

Same name and namespace in other branches
  1. 6 user_badges.rules.inc \user_badges_has_badge()

Test the user_badges_has_badge condition

File

./user_badges.rules.inc, line 102
Provide better integration into the rules module

Code

function user_badges_has_badge($account, $settings) {
  $badges = user_badges_get_badges($account->uid);
  $result = $settings['operator'] == 'all' ? TRUE : FALSE;
  foreach ($settings['badges'] as $bid => $on) {
    if (!$on) {
      continue;
    }
    $has_badge = isset($badges[$bid]);
    if ($settings['operator'] == 'all') {
      $result = $result && $has_badge;
    }
    else {
      $result = $result || $has_badge;
    }
  }
  return $result;
}