You are here

function flag_rules_condition_threshold in Flag 6.2

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

Condition: Check flagging count.

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

File

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

Code

function flag_rules_condition_threshold($flag, $object, $number, $settings) {
  $count = $flag
    ->get_count($flag
    ->get_content_id($object));
  switch ($settings['operator']) {
    case '>':
      return $count > $number;
    case '>=':
      return $count >= $number;
    case '=':
      return $count == $number;
    case '<':
      return $count < $number;
    case '<=':
      return $count <= $number;
  }
}