360a361,434
> }
> 
> 
> /**
>  * Add webform validation value to the exported node
>  * 
>  * @param &$node
>  *   The node to alter.
>  * @param $original_node
>  *   The unaltered node.
>  * @param $method
>  *   'export' for exports, and 'prepopulate' or 'save-edit' for imports
>  *   depending on the method used.
>  * @return void
>  */
> function webform_validation_node_export_node_alter(&$node, $original_node, $method) {
> 	
> 	// Add validation array for the exported node
> 	if ($original_node->type == 'webform' && module_exists('webform_validation') && $method == 'export') {
> 		
> 		$node->webform['validation'] = array();
> 		
> 		// Get all validation rules
> 		$validation_rules = db_query("SELECT * FROM {webform_validation_rule} WHERE nid = %d", $node->nid);
> 		while ($rule = db_fetch_object($validation_rules)) {
> 			
> 			$rule->components = array();
> 			
> 			// Get all validation components
> 			$validation_components = db_query("SELECT * FROM {webform_validation_rule_components} WHERE ruleid = %d", $rule->ruleid);
> 			while ($component = db_fetch_object($validation_components)) {
> 				$rule->components[] = $component;
> 			}
> 			
> 			// Append the validation rule to the validation array
> 			$node->webform['validation'][] = $rule;
> 		}
> 	}
> 	
> 	// Insert validation rule and components during the node import
> 	if ($original_node->type == 'webform' && module_exists('webform_validation') && $method == 'save-edit') {
> 		
> 		if (!empty($node->webform['validation'])) {
> 			foreach ($node->webform['validation'] as $rule ) {
> 				
> 				// The $rule->nid will be updated after the node creation in the hook_nodeapi()
> 				drupal_write_record('webform_validation_rule', $rule);
> 				
> 				// Get the newly insterted ruleid
> 				$rule_id = db_result(db_query("SELECT ruleid FROM {webform_validation_rule}
> 					WHERE nid = %d AND validator = '%s'", $rule->nid, $rule->validator));
> 				
> 				foreach ($rule->components as $component) {
> 					db_query("INSERT INTO {webform_validation_rule_components} (ruleid, cid) VALUES (%d, %d)", $rule_id, $component->cid);
> 				}
> 			}
> 		}
> 	}
> }
> 
> /**
>  * Implementation of hook_nodeapi().
>  *
>  * @param &$node The node the action is being performed on.
>  * @param $op What kind of action is being performed. Possible values: alter, delete, delete revision, insert, load, prepare, prepare translation, print, rss item, search result, presave, update, update index, validate, view
>  * @param $a3
>  * @param $a4
>  */
> function webform_validation_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
> 	if ($op == 'insert' && $node->type == 'webform' && module_exists('webform_validation')) {
> 		foreach ($node->webform['validation'] as $rule ) {
> 			db_query('UPDATE {webform_validation_rule} SET nid = %d WHERE ruleid = %d', $node->nid, $rule->ruleid);
> 		}
> 	}
