You are here

function user_badges_rules_condition_badge_count in User Badges 7.4

Same name and namespace in other branches
  1. 7.3 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
Implements hook_rules_condition_info().

File

./user_badges.rules.inc, line 199
user_badges.rules.inc

Code

function user_badges_rules_condition_badge_count($user, $operator, $number) {
  $badges = user_badges_get_badges($user->uid);
  $badges_count = count($badges);
  if (is_numeric(trim($number))) {
    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;
    }
  }
  else {
    return FALSE;
  }
}