You are here

function flag_rules_condition_threshold in Flag 7.3

Same name and namespace in other branches
  1. 6.2 includes/flag.rules.inc \flag_rules_condition_threshold()
  2. 6 includes/flag.rules.inc \flag_rules_condition_threshold()
  3. 7.2 flag.rules.inc \flag_rules_condition_threshold()

Condition: Check flagging count.

The count that is returned during a flagging or an unflagging will take into acount the current flag/unflag process.

1 string reference to 'flag_rules_condition_threshold'
flag_rules_condition_info in ./flag.rules.inc
Implements hook_rules_condition_info().

File

./flag.rules.inc, line 594
Rules integration for the Flag module.

Code

function flag_rules_condition_threshold($flag, $entity, $number, $operator = '=') {
  $count = $flag
    ->get_count($flag
    ->get_entity_id($entity));
  switch ($operator) {
    case '>':
      return $count > $number;
    case '>=':
      return $count >= $number;
    case '=':
      return $count == $number;
    case '<':
      return $count < $number;
    case '<=':
      return $count <= $number;
  }
}