You are here

function user_badges_rules_condition_badge_count in User Badges 7.3

Same name and namespace in other branches
  1. 7.4 user_badges.rules.inc \user_badges_rules_condition_badge_count()

Condition: User badge count.

1 string reference to 'user_badges_rules_condition_badge_count'
user_badges_rules_condition_info in ./user_badges.rules.inc
Implementation of hook_rules_condition_info().

File

./user_badges.rules.inc, line 191

Code

function user_badges_rules_condition_badge_count($user, $operator, $number) {
  $badges = user_badges_get_badges($user->uid);
  $badges_count = count($badges);
  switch ($operator) {
    case '>':
      return $badges_count > $number;
    case '>=':
      return $badges_count >= $number;
    case '=':
      return $badges_count == $number;
    case '<':
      return $badges_count < $number;
    case '<=':
      return $badges_count <= $number;
  }
}