You are here

function webform_validation_node_clone in Webform Validation 6

Same name and namespace in other branches
  1. 7 webform_validation.module \webform_validation_node_clone()

Adds support for node_clone module

1 call to webform_validation_node_clone()
webform_validation_nodeapi in ./webform_validation.module
Implementation of hook_nodeapi().

File

./webform_validation.module, line 351

Code

function webform_validation_node_clone($node) {
  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) {
        $rule['action'] = 'add';
        $rule['nid'] = $node->nid;

        // attach existing rules to new node
        $rule['rule_components'] = $rule['components'];
        webform_validation_rule_save($rule);
      }
    }
  }
}