You are here

function rules_condition_data_is in Rules 7.2

Condition: Compare data.

Related topics

1 string reference to 'rules_condition_data_is'
rules_data_condition_info in modules/data.rules.inc
Implements hook_rules_condition_info() on behalf of the pseudo data module.

File

modules/data.eval.inc, line 348
Contains rules integration for the data module needed during evaluation.

Code

function rules_condition_data_is($data, $op, $value) {
  switch ($op) {
    default:
    case '==':

      // In case both values evaluate to FALSE, further differentiate between
      // NULL values and values evaluating to FALSE.
      if (!$data && !$value) {
        return isset($data) && isset($value) || !isset($data) && !isset($value);
      }
      return $data == $value;
    case '<':
      return $data < $value;
    case '>':
      return $data > $value;

    // Note: This is deprecated by the text comparison condition and IN below.
    case 'contains':
      return is_string($data) && strpos($data, $value) !== FALSE || is_array($data) && in_array($value, $data);
    case 'IN':
      return is_array($value) && in_array($data, $value);
  }
}