function webform_validation_node_clone in Webform Validation 7
Same name and namespace in other branches
- 6 webform_validation.module \webform_validation_node_clone()
Adds support for node_clone module.
1 call to webform_validation_node_clone()
- webform_validation_node_insert in ./
webform_validation.module - Implements hook_node_insert().
File
- ./
webform_validation.module, line 448
Code
function webform_validation_node_clone($node) {
if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
return;
}
if (isset($node->clone_from_original_nid)) {
$original_nid = $node->clone_from_original_nid;
// Get existing rules for original node.
$rules = webform_validation_get_node_rules($original_nid);
if ($rules) {
foreach ($rules as $orig_ruleid => $rule) {
unset($rule['ruleid']);
$rule['action'] = 'add';
// Attach existing rules to new node.
$rule['nid'] = $node->nid;
$rule['rule_components'] = $rule['components'];
webform_validation_rule_save($rule);
}
}
}
}