function rb_cck_action_insert_value_multiple in Rules Bonus Pack 6
Action for 'rb_cck_action_insert_value_multiple'.
File
- ./
rb_cck.module, line 448 - Functions for extending CCK field management with Rules.
Code
function rb_cck_action_insert_value_multiple($node, $settings) {
// Get required metadata for the field.
$storage_key = rb_cck_field_storage_key($settings['field']);
// Check if the value is already present in the multiple-value field.
foreach ($node->{$settings['field']} as $existing_value) {
if ($settings['value'] == $existing_value[$storage_key]) {
// If we have a match, just bail out. No need to store anything new.
return;
}
}
// If we don't have a match, insert the new value.
$node->{$settings['field']}[] = array(
$storage_key => $settings['value'],
);
// Return the node, so Rules can save it later on.
return array(
'node' => $node,
);
}