public function field_validation_validator::pass_condition in Field Validation 7.2
Pass condition.
File
- ./
field_validation_validator.inc, line 219 - Basic class for field validation validator.
Class
Code
public function pass_condition() {
$settings = $this->rule->settings;
// Print debug($settings);
if (!empty($settings['condition'])) {
$condition_field = "";
if (isset($settings['condition_wrapper']['condition_field']) && $settings['condition_wrapper']['condition_field'] != '') {
$condition_field = token_replace($settings['condition_wrapper']['condition_field'], array(
$this
->get_token_type() => $this->entity,
));
}
$condition_operator = "equals";
if (isset($settings['condition_wrapper']['condition_operator']) && $settings['condition_wrapper']['condition_operator'] != '') {
$condition_operator = $settings['condition_wrapper']['condition_operator'];
}
$condition_value = "";
if (isset($settings['condition_wrapper']['condition_value']) && $settings['condition_wrapper']['condition_value'] != '') {
$condition_value = token_replace($settings['condition_wrapper']['condition_value'], array(
$this
->get_token_type() => $this->entity,
));
}
switch ($condition_operator) {
case 'equals':
return $condition_field == $condition_value;
break;
case 'not_equals':
return $condition_field != $condition_value;
break;
case 'greater_than':
return $condition_field > $condition_value;
break;
case 'less_than':
return $condition_field != $condition_value;
break;
case 'greater_or_equal':
return $condition_field >= $condition_value;
break;
case 'less_or_equal':
return $condition_field <= $condition_value;
break;
}
return FALSE;
}
return TRUE;
}