Project

General

Profile

Revision 65389548

Added by Assos Assos over 4 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/webform_validation/webform_validation.module
234 234
/**
235 235
 * Helper function to get all field keys (including fields in fieldsets).
236 236
 *
237
 * @deprecated No longer used and will be removed in 7.x-2.x.
237
 * @deprecated in webform_validation:7.x-1.14 and is removed from
238
 * webform_validation:7.x-2.0. No longer used.
239
 * @see https://www.drupal.org/project/webform_validation/issues/2841817
238 240
 */
239 241
function webform_validation_get_field_keys($submitted, $node) {
240 242
  static $fields = array();
......
274 276
/**
275 277
 * Get array of formkeys for all components that have been assigned to a rule.
276 278
 *
277
 * @deprecated No longer used and will be removed in 7.x-2.x.
279
 * @deprecated in webform_validation:7.x-1.14 and is removed from
280
 * webform_validation:7.x-2.0. No longer used.
281
 * @see https://www.drupal.org/project/webform_validation/issues/2841817
278 282
 */
279 283
function webform_validation_rule_get_formkeys($rule) {
280 284
  $formkeys = array();
......
531 535
    }
532 536
  }
533 537
}
538

  
539
/**
540
 * Implements hook_uuid_node_features_export_alter().
541
 */
542
function webform_validation_uuid_node_features_export_alter(&$data, $node, $module) {
543
  $nid = reset(entity_get_id_by_uuid('node', array($node->uuid)));
544
  if (webform_validation_get_node_rules($nid)) {
545
    $data['dependencies']['webform_validation'] = 'webform_validation';
546
  }
547
}
548

  
549
/**
550
 * Implements hook_uuid_node_features_export_render_alter().
551
 */
552
function webform_validation_uuid_node_features_export_render_alter(&$export, $node, $module) {
553
  if (!empty($node->webform)) {
554
    $rules = webform_validation_get_node_rules_assoc($node->nid);
555
    foreach ($rules as &$rule) {
556
      unset($rule['nid']);
557
      unset($rule['ruleid']);
558
    }
559
    $export->webform['validation'] = $rules;
560
  }
561
}
562

  
563
/**
564
 * Implements hook_uuid_entity_uuid_save().
565
 */
566
function webform_validation_entity_uuid_save($node, $entity_type) {
567
  if ($entity_type == 'node') {
568
    if (isset($node->webform['validation'])) {
569
      $rules = $node->webform['validation'];
570
      $orig_rules = webform_validation_get_node_rules_assoc($node->nid);
571
      // Delete obsolete rules.
572
      $delete = array_diff_key($orig_rules, $rules);
573
      foreach ($delete as $rule) {
574
        webform_dynamic_delete_rule($rule['ruleid']);
575
      }
576
      // Add new rules.
577
      $new = array_diff_key($rules, $orig_rules);
578
      foreach ($new as $rule) {
579
        $rule['action'] = 'add';
580
        $rule['nid'] = $node->nid;
581
        $rule['rule_components'] = $rule['components'];
582
        webform_validation_rule_save($rule);
583
      }
584
      // Update existing rules.
585
      $existing = array_diff_key($rules, $new + $delete);
586
      foreach ($existing as $name => $rule) {
587
        $orig_rule = $orig_rules[$name];
588
        $rule['nid'] = $orig_rule['nid'];
589
        $rule['ruleid'] = $orig_rule['ruleid'];
590
        if ($rule != $orig_rule) {
591
          $rule['action'] = 'edit';
592
          $rule['rule_components'] = $rule['components'];
593
          webform_validation_rule_save($rule);
594
        }
595
      }
596
    }
597
  }
598

  
599
}

Also available in: Unified diff