function _content_rules_field_has_value in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 6.2 includes/content.rules.inc \_content_rules_field_has_value()
Checks whether both field values match in a robust way.
It returns TRUE, only if the number of multiple values matches and each property of the cck field's value is the same in the node.
Parameters
$node_value The value present in the node.:
$value The value to check for.:
2 calls to _content_rules_field_has_value()
- content_rules_field_changed in includes/
content.rules.inc - Condition: Check if the field has changed.
- content_rules_field_has_value in includes/
content.rules.inc - Condition: Check the value of a field.
File
- includes/
content.rules.inc, line 330 - Provides basic rules module support.
Code
function _content_rules_field_has_value($node_value, $value) {
if (count($value) != count($node_value)) {
return FALSE;
}
// Loop over multiple fields
foreach ($value as $delta => $sub_value) {
// Check if all properties of the value are there in the node value too
if (is_array($sub_value) && is_array($node_value[$delta])) {
if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
return FALSE;
}
}
elseif ($sub_value !== $node_value[$delta]) {
return FALSE;
}
}
return TRUE;
}