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/modules/webform_validation_testing/webform_validation_testing.features.inc
1
<?php
2

  
3
/**
4
 * @file
5
 * webform_validation_testing.features.inc
6
 */
7

  
8
/**
9
 * Implements hook_node_info().
10
 */
11
function webform_validation_testing_node_info() {
12
  $items = array(
13
    'webform' => array(
14
      'name' => t('Webform'),
15
      'base' => 'node_content',
16
      'description' => t('Create a new form or questionnaire accessible to users. Submission results and statistics are recorded and accessible to privileged users.'),
17
      'has_title' => '1',
18
      'title_label' => t('Title'),
19
      'help' => '',
20
    ),
21
  );
22
  drupal_alter('node_info', $items);
23
  return $items;
24
}
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.features.uuid_node.inc
1
<?php
2

  
3
/**
4
 * @file
5
 * webform_validation_testing.features.uuid_node.inc
6
 */
7

  
8
/**
9
 * Implements hook_uuid_features_default_content().
10
 */
11
function webform_validation_testing_uuid_features_default_content() {
12
  $nodes = array();
13

  
14
  $nodes[] = array(
15
    'title' => 'webform_validation uuid_features test',
16
    'log' => '',
17
    'status' => 1,
18
    'comment' => 0,
19
    'promote' => 1,
20
    'sticky' => 0,
21
    'type' => 'webform',
22
    'language' => 'und',
23
    'created' => 1504429473,
24
    'tnid' => 0,
25
    'translate' => 0,
26
    'uuid' => '4ca52408-9bbd-49fa-baae-698c37dc5f42',
27
    'webform' => array(
28
      'nid' => 1,
29
      'next_serial' => 1,
30
      'confirmation' => '',
31
      'confirmation_format' => NULL,
32
      'redirect_url' => '<confirmation>',
33
      'status' => 1,
34
      'block' => 0,
35
      'allow_draft' => 0,
36
      'auto_save' => 0,
37
      'submit_notice' => 1,
38
      'confidential' => 0,
39
      'submit_text' => '',
40
      'submit_limit' => -1,
41
      'submit_interval' => -1,
42
      'total_submit_limit' => -1,
43
      'total_submit_interval' => -1,
44
      'progressbar_bar' => 1,
45
      'progressbar_page_number' => 0,
46
      'progressbar_percent' => 0,
47
      'progressbar_pagebreak_labels' => 1,
48
      'progressbar_include_confirmation' => 1,
49
      'progressbar_label_first' => 'Start',
50
      'progressbar_label_confirmation' => 'Complete',
51
      'preview' => 0,
52
      'preview_next_button_label' => '',
53
      'preview_prev_button_label' => '',
54
      'preview_title' => '',
55
      'preview_message' => '',
56
      'preview_message_format' => NULL,
57
      'preview_excluded_components' => array(),
58
      'record_exists' => TRUE,
59
      'roles' => array(
60
        0 => 1,
61
        1 => 2,
62
      ),
63
      'emails' => array(),
64
      'components' => array(
65
        1 => array(
66
          'nid' => 1,
67
          'cid' => 1,
68
          'pid' => 0,
69
          'form_key' => 'answer',
70
          'name' => 'What’s the answer to the ultimate question?',
71
          'type' => 'number',
72
          'value' => '',
73
          'extra' => array(
74
            'title_display' => 'before',
75
            'description_above' => 0,
76
            'private' => 0,
77
            'wrapper_classes' => '',
78
            'css_classes' => '',
79
            'integer' => 1,
80
            'type' => 'textfield',
81
            'field_prefix' => '',
82
            'field_suffix' => '',
83
            'disabled' => 0,
84
            'unique' => 0,
85
            'description' => '',
86
            'attributes' => array(),
87
            'analysis' => FALSE,
88
            'min' => '',
89
            'max' => '',
90
            'step' => '',
91
            'decimals' => '',
92
            'point' => '.',
93
            'separator' => ',',
94
            'excludezero' => 0,
95
          ),
96
          'required' => 1,
97
          'weight' => 0,
98
          'page_num' => 1,
99
        ),
100
      ),
101
      'conditionals' => array(),
102
      'validation' => array(
103
        'answer_42' => array(
104
          'rulename' => 'answer_42',
105
          'validator' => 'specific_value',
106
          'data' => 42,
107
          'error_message' => 'That’s the wrong answer.',
108
          'negate' => FALSE,
109
          'weight' => 0,
110
          'components' => array(
111
            1 => 1,
112
          ),
113
        ),
114
      ),
115
    ),
116
    'date' => '2017-09-03 09:04:33 +0000',
117
    'user_uuid' => '155c7ec5-8f9d-4934-888d-6951b7ac0728',
118
  );
119
  return $nodes;
120
}
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.info
7 7
dependencies[] = uuid_features
8 8
dependencies[] = webform_validation
9 9
hidden = TRUE
10
features[features_api][] = api:2
11
features[node][] = webform
12
features[uuid_node][] = 4ca52408-9bbd-49fa-baae-698c37dc5f42
10 13

  
11
; Information added by Drupal.org packaging script on 2018-10-01
12
version = "7.x-1.15"
14
; Information added by Drupal.org packaging script on 2019-08-26
15
version = "7.x-1.16"
13 16
core = "7.x"
14 17
project = "webform_validation"
15
datestamp = "1538404086"
18
datestamp = "1566849187"
drupal7/sites/all/modules/webform_validation/modules/webform_validation_testing/webform_validation_testing.module
5 5
 * Module file for webform_validation_testing.
6 6
 */
7 7

  
8
include_once 'webform_validation_testing.features.inc';
9

  
8 10
/**
9 11
 * Implements hook_webform_validation_validators().
10 12
 */
drupal7/sites/all/modules/webform_validation/tests/WebformValidationTestCase.test
46 46

  
47 47
    // Rule creation page.
48 48
    $this->clickLink('Minimum length');
49
    $this->assertTitle('Add validation | Drupal');
49
    $this->assertTitle('Add validation rule | Drupal');
50
    $this->assertText('Minimum length');
50 51
    $element = $this->xpath("//input[@id='edit-data'][@name='data'][@type='text']");
51 52
    $this->assertTrue($element, 'Page contains "edit-data" input.');
52 53

  
......
59 60
    $this->drupalPost(NULL, $values, t('Add rule'));
60 61
    $this->assertText(htmlspecialchars($values['rulename'], ENT_QUOTES), 'Rule name appears on page.');
61 62

  
63
    // Test rule creation validation.
64
    $this->clickLink('Compare two values');
65
    $this->assertTitle('Add validation rule | Drupal');
66
    $this->assertText('Compare two values');
67
    $values = array(
68
      'rulename' => $this->randomString(),
69
      'data' => 'invalid',
70
    );
71
    $this->drupalPost(NULL, $values, t('Add rule'));
72
    $this->assertText('Comparison operator is invalid.', 'Custom data validation fails.');
73
    $this->assertText('You need to select exactly 2 components.', 'Custom data validation fails.');
74
    $this->assertText('Custom error message field is required.', 'Custom data validation fails.');
75

  
76
    $values = array(
77
      'rule_components[20]' => TRUE,
78
      'rule_components[21]' => TRUE,
79
      'data' => '<',
80
      'error_message' => 'Error message.',
81
    );
82
    $this->drupalPost(NULL, $values, t('Add rule'));
83

  
62 84
    $this->clickLink('Webform Validation Testing 1');
63 85
    $element = $this->xpath("//textarea[@id='edit-data'][@name='data']");
64 86
    $this->assertTrue($element, 'Page contains "edit-data" textarea.');
drupal7/sites/all/modules/webform_validation/tests/WebformValidationUnitTestCase.test
1
<?php
2

  
3
/**
4
 * Unit test Webform Validation module.
5
 */
6
class WebformValidationUnitTestCase extends DrupalUnitTestCase {
7

  
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform Validation Unit Tests'),
14
      'description' => t('Unit tests for Webform Validation module.'),
15
      'group' => t('Webform'),
16
    );
17
  }
18

  
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function setUp() {
23
    parent::setUp();
24
  }
25

  
26
  /**
27
   * The tests.
28
   */
29
  public function test() {
30

  
31
    $validator_name = 'comparison';
32
    $items = array(
33
      'one' => array(
34
        'hour' => 12,
35
        'minute' => 1,
36
        'ampm' => 'AM',
37
      ),
38
      'two' => array(
39
        'hour' => 12,
40
        'minute' => 4,
41
        'ampm' => 'AM',
42
      ),
43
    );
44
    $components = array(
45
      'one' => array(
46
        'type' => 'time',
47
      ),
48
      'two' => array(
49
        'type' => 'time',
50
      ),
51
    );
52
    $rule = array(
53
      'data' => '<',
54
      'components' => $components,
55
      'error_message' => 'Error message.',
56
    );
57
    $test_value = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
58
    $value = array();
59
    $this->assertIdentical($test_value, $value, 'No error for passing validation.');
60

  
61
    $rule['data'] = '>';
62
    $test_value = webform_validation_webform_validation_validate($validator_name, $items, $components, $rule);
63
    $value = array('two' => 'Error message.');
64
    $this->assertIdentical($test_value, $value, 'Error for failing validation.');
65
  }
66

  
67
}
drupal7/sites/all/modules/webform_validation/tests/WebformValidationUuidFeaturesTestCase.test
1
<?php
2

  
3
/**
4
 * Test the features integration of webform_validation.
5
 */
6
class WebformValidationUuidFeaturesTestCase extends DrupalWebTestCase {
7

  
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform Validation: UUID features integration'),
14
      'description' => t('Test the integration of webform_validation and uuid_features.'),
15
      'group' => t('Webform'),
16
      'dependencies' => array('webform_validation_testing'),
17
    );
18
  }
19

  
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp() {
24
    parent::setUp(array('webform_validation_testing'));
25
    module_load_include('entity.inc', 'uuid');
26
  }
27

  
28
  /**
29
   * Test whether the validations are loaded properly by enabling the feature.
30
   */
31
  public function testValidationsLoaded() {
32
    $uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42');
33
    $nids = entity_get_id_by_uuid('node', $uuids);
34
    $nid = reset($nids);
35
    $rules = webform_validation_get_node_rules($nid);
36
    $this->assertEqual(1, count($rules));
37
    $rule = reset($rules);
38
    unset($rule['ruleid']);
39
    unset($rule['nid']);
40
    $k = array_keys($rule['components']);
41
    $rule['components'] = array_combine($k, $k);
42
    $this->assertEqual(array(
43
      'rulename' => 'answer_42',
44
      'validator' => 'specific_value',
45
      'data' => '42',
46
      'error_message' => 'That’s the wrong answer.',
47
      'negate' => FALSE,
48
      'weight' => '0',
49
      'components' => array(
50
        1 => 1,
51
      ),
52
    ), $rule);
53
  }
54

  
55
  /**
56
   * Test whether re-exporting the feature yields the same result.
57
   */
58
  public function testValidationExport() {
59
    features_include_defaults();
60

  
61
    // Get data for a new export.
62
    $uuids = array('4ca52408-9bbd-49fa-baae-698c37dc5f42');
63
    $data = features_invoke('uuid_node', 'features_export_render', 'webform_validation_uuid_features_test', $uuids);
64
    $nodes = eval($data['uuid_features_default_content']);
65
    $this->assertEqual(1, count($nodes));
66
    $node = (object) reset($nodes);
67
    $this->assertEqual($uuids[0], $node->uuid);
68
    $this->assertTrue(!empty($node->webform['validation']));
69

  
70
    // Compare data with the defaults in the feature.
71
    $defaults = features_get_default('uuid_node', 'webform_validation_testing');
72
    $default_node = (object) reset($defaults);
73
    $this->assertEqual($default_node->webform['validation'], $node->webform['validation']);
74
  }
75

  
76
}
drupal7/sites/all/modules/webform_validation/webform_validation.admin.inc
173 173
  $form = array();
174 174
  $rule_validator = webform_validation_get_validator_info($validator);
175 175

  
176
  $form['rule'] = array(
177
    '#type' => 'fieldset',
178
    '#title' => ($action == 'edit') ? t('Edit rule') : t('Add rule'),
179
    '#collapsible' => FALSE,
180
    '#collapsed' => FALSE,
181
  );
176
  if ($action === 'edit') {
177
    $title = t('Edit validation rule %title', array('%title' => $rule['rulename']));
178
  }
179
  else {
180
    $title = t('Add validation rule');
181
  }
182
  drupal_set_title($title, PASS_THROUGH);
182 183

  
183 184
  $form['rule']['validator'] = array(
184 185
    '#type' => 'hidden',
......
208 209
    );
209 210
  }
210 211

  
212
  $form['rule']['type'] = array(
213
    '#type' => 'item',
214
    '#title' => t('Rule type'),
215
    '#markup' => $rule_validator['name'],
216
  );
217

  
211 218
  $form['rule']['rulename'] = array(
212 219
    '#type' => 'textfield',
213 220
    '#title' => t('Rule name'),
214
    '#default_value' => (isset($rule['rulename'])) ? $rule['rulename'] : '',
221
    '#default_value' => isset($rule['rulename']) ? $rule['rulename'] : NULL,
215 222
    '#required' => TRUE,
216 223
    '#size' => 60,
217 224
    '#maxlength' => 255,
......
224 231
    '#weight' => 3,
225 232
    '#description' => t('Select the components to be validated by this validation rule'),
226 233
    '#options' => webform_validation_get_webform_components($node, $validator),
227
    '#default_value' => (isset($rule['components'])) ? array_keys($rule['components']) : array(),
234
    '#default_value' => isset($rule['components']) ? array_keys($rule['components']) : array(),
228 235
  );
229 236

  
230 237
  if (!empty($rule_validator['custom_data']) && is_array($rule_validator['custom_data'])) {
......
272 279

  
273 280
  $form['rule']['submit'] = array(
274 281
    '#type' => 'submit',
275
    '#value' => (isset($rule['ruleid'])) ? t('Save rule') : t('Add rule'),
282
    '#value' => isset($rule['ruleid']) ? t('Save rule') : t('Add rule'),
276 283
    '#weight' => 25,
277 284
  );
278 285

  
......
297 304
  }
298 305

  
299 306
  $rule_validator = webform_validation_get_validator_info($values['validator']);
307

  
308
  // Validate custom data.
309
  if ($values['data'] && !empty($rule_validator['custom_data']['validate_regex']) && !preg_match($rule_validator['custom_data']['validate_regex'], $values['data'])) {
310
    form_set_error('data', $rule_validator['custom_data']['label'] . ' ' . t('is invalid.'));
311
  }
312

  
300 313
  $selected_components = count(array_filter($values['rule_components']));
301 314
  // Check validator min_components and min_components property when they are
302 315
  // equal.
303 316
  if (isset($rule_validator['min_components']) && isset($rule_validator['max_components']) && $rule_validator['min_components'] === $rule_validator['max_components'] && $selected_components !== $rule_validator['min_components']) {
304
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select exactly @count component', 'You need to select exactly @count components'));
317
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select exactly @count component.', 'You need to select exactly @count components.'));
305 318
  }
306 319
  // Check validator min_components property.
307 320
  elseif (isset($rule_validator['min_components']) && $selected_components < $rule_validator['min_components']) {
308
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select at least @count component', 'You need to select at least @count components'));
321
    form_set_error('rule_components', format_plural($rule_validator['min_components'], 'You need to select at least @count component.', 'You need to select at least @count components.'));
309 322
  }
310 323
  // Check validator max_components property.
311 324
  elseif (isset($rule_validator['max_components']) && $selected_components > $rule_validator['max_components']) {
312
    form_set_error('rule_components', format_plural($rule_validator['max_components'], 'You can select @count component at most', 'You can select @count components at most'));
325
    form_set_error('rule_components', format_plural($rule_validator['max_components'], 'You can select @count component at most.', 'You can select @count components at most.'));
313 326
  }
314 327
}
315 328

  
drupal7/sites/all/modules/webform_validation/webform_validation.info
5 5
dependencies[] = webform
6 6
test_dependencies[] = webform_validation_testing
7 7
files[] = tests/WebformValidationTestCase.test
8
files[] = tests/WebformValidationUnitTestCase.test
9
files[] = tests/WebformValidationUuidFeaturesTestCase.test
8 10
php = 5.3
9 11

  
10
; Information added by Drupal.org packaging script on 2018-10-01
11
version = "7.x-1.15"
12
; Information added by Drupal.org packaging script on 2019-08-26
13
version = "7.x-1.16"
12 14
core = "7.x"
13 15
project = "webform_validation"
14
datestamp = "1538404086"
16
datestamp = "1566849187"
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
}
drupal7/sites/all/modules/webform_validation/webform_validation.rules.inc
18 18

  
19 19
/**
20 20
 * Get an array of rules assigned to a webform node.
21
 *
22
 * @param int $nid
23
 *   The node ID.
24
 *
25
 * @return array
26
 *   The rules for a node keyed by their rule ID.
27
 *
28
 * @see webform_validation_get_node_rules_assoc()
21 29
 */
22 30
function webform_validation_get_node_rules($nid) {
23 31
  $rules = array();
......
30 38
  return $rules;
31 39
}
32 40

  
41
/**
42
 * Get an array of rules assigned to a webform node keyed by their rulename.
43
 *
44
 * @param int $nid
45
 *   The node ID.
46
 *
47
 * @return array
48
 *   The rules for a node keyed by their rulename.
49
 *
50
 * @see webform_validation_get_node_rules()
51
 */
52
function webform_validation_get_node_rules_assoc($nid) {
53
  $assoc_rules = array();
54
  if ($rules = webform_validation_get_node_rules($nid)) {
55
    foreach ($rules as $rule) {
56
      $components = array();
57
      foreach ($rule['components'] as $cid => $component) {
58
        $components[$cid] = $cid;
59
      }
60
      ksort($components);
61
      $rule['components'] = $components;
62
      $assoc_rules[$rule['rulename']] = $rule;
63
    }
64
    ksort($assoc_rules);
65
  }
66
  return $assoc_rules;
67
}
68

  
33 69
/**
34 70
 * Get an array of components linked to a rule.
35 71
 */
drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc
36 36
        'textfield',
37 37
      ),
38 38
      'custom_data' => array(
39
        'label' => t('Specify numeric validation range'),
40
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against. Usage:') . theme('item_list', array('items' => array(t('empty: no value validation'), t('"100": greater than or equal to 100'), t('"|100": less than or equal to 100 (including negative numbers)'), t('"0|100": greater than or equal to 0 &amp; less than or equal to 100'), t('"10|100": greater than or equal to 10 &amp; less than or equal to 100'), t('"-100|-10": greater than or equal to -100 &amp; less than or equal to -10')))),
39
        'label' => t('Numeric validation range'),
40
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against. Usage:') . theme('table', array(
41
          'header' => array(t('Value'), t('Meaning')),
42
          'rows' => array(
43
            array(t('(empty)'), t('No value validation')),
44
            array('100', t('Greater than or equal to 100')),
45
            array('|100', t('Less than or equal to 100 (including negative numbers)')),
46
            array('0|100', t('Greater than or equal to 0 &amp; less than or equal to 100')),
47
            array('10|100', t('Greater than or equal to 10 &amp; less than or equal to 100')),
48
            array('-100|-10', t('Greater than or equal to -100 &amp; less than or equal to -10')),
49
          ),
50
        )),
51
        'validate_regex' => '/^((-?[\d.]+)?\|)?(-?[\d.]+)$/',
41 52
        'required' => FALSE,
42 53
      ),
43 54
      'description' => t('Verifies that user-entered values are numeric, with the option to specify min and / or max values.'),
......
54 65
      'custom_data' => array(
55 66
        'label' => t('Minimum number of characters'),
56 67
        'description' => t('Specify the minimum number of characters that have to be entered to pass validation.'),
68
        'validate_regex' => '/^\d+$/',
57 69
      ),
58 70
      'description' => t('Verifies that a user-entered value contains at least the specified number of characters.'),
59 71
    ),
......
69 81
      'custom_data' => array(
70 82
        'label' => t('Maximum number of characters'),
71 83
        'description' => t('Specify the maximum number of characters that can be entered to pass validation.'),
84
        'validate_regex' => '/^\d+$/',
72 85
      ),
73 86
      'description' => t('Verifies that a user-entered value contains at most the specified number of characters.'),
74 87
    ),
......
83 96
      'custom_data' => array(
84 97
        'label' => t('Minimum number of words'),
85 98
        'description' => t('Specify the minimum number of words that have to be entered to pass validation. Words are defined as strings of letters separated by spaces.'),
99
        'validate_regex' => '/^\d+$/',
86 100
      ),
87 101
      'description' => t('Verifies that a user-entered value contains at least the specified number of words.'),
88 102
    ),
......
97 111
      'custom_data' => array(
98 112
        'label' => t('Maximum number of words'),
99 113
        'description' => t('Specify the maximum number of words that have to be entered to pass validation. Words are defined as strings of letters separated by spaces.'),
114
        'validate_regex' => '/^\d+$/',
100 115
      ),
101 116
      'description' => t('Verifies that a user-entered value contains at most the specified number of words.'),
102 117
    ),
......
117 132
            t('Enter "<=20" if the components must add up to less than or equal to 20.'),
118 133
          ),
119 134
        )),
135
        'validate_regex' => '/^(=|>|>=|<|<=)(-?[\d.]+)$/',
120 136
      ),
121 137
      'description' => t('Require the values of the selected fields to add up to exactly, greater than or equal to, or less than or equal to a specified number.'),
122 138
    ),
......
152 168
      'custom_data' => array(
153 169
        'label' => t('Comparison operator'),
154 170
        'description' => t('Specify the comparison operator you want to use. Must be one of: >, >=, <, <=. The validator will compare the first component with the second using this operator. If the components are of type email, they will get case-insensitive comparison.'),
171
        'validate_regex' => '/^(>|>=|<|<=)$/',
155 172
      ),
156 173
      'min_components' => 2,
157 174
      'max_components' => 2,
......
229 246
            t('Enter "<=2" if the user must complete <b>at most</b> 2 of the selected components.'),
230 247
          ),
231 248
        )),
249
        'validate_regex' => '/^[><]?=\d+$/',
232 250
      ),
233 251
      'min_components' => 2,
234 252
      'description' => t('Requires the user to complete some number of components out of a group of components. For example, complete at least 2 out of 3, complete at most 4 out of 6, or complete exactly 3 our of 4.'),
......
241 259
      'custom_data' => array(
242 260
        'label' => t('Minimum number of selections'),
243 261
        'description' => t('Specify the minimum number of options a user should select.'),
262
        'validate_regex' => '/^\d+$/',
244 263
      ),
245 264
      'description' => t('Forces the user to select at least a defined number of options from the specified webform components.'),
246 265
    ),
......
252 271
      'custom_data' => array(
253 272
        'label' => t('Maximum number of selections'),
254 273
        'description' => t('Specify the maximum number of options a user can select.'),
274
        'validate_regex' => '/^\d+$/',
255 275
      ),
256 276
      'description' => t('Forces the user to select at most a defined number of options from the specified webform components.'),
257 277
    ),
......
264 284
      'custom_data' => array(
265 285
        'label' => t('Number of selections'),
266 286
        'description' => t('Specify how many options a user can select.'),
287
        'validate_regex' => '/^\d+$/',
267 288
      ),
268 289
      'description' => t('Forces the user to select exactly the defined number of options from the specified webform components.'),
269 290
    ),
......
431 452
    return NULL;
432 453
  }
433 454

  
455
  // Allow translation for all components item names if available.
456
  if (module_exists('webform_localization')) {
457
    foreach ($components as &$component) {
458
      $dummy_element = array(
459
        '#title' => '',
460
      );
461
      _webform_localization_translate_component($dummy_element, $component);
462
      if (isset($dummy_element['#title']) && (string) $dummy_element['#title']) {
463
        $component['name'] = $dummy_element['#title'];
464
      }
465
    }
466
  }
467

  
434 468
  // For certain validators, if all components to be compared are email
435 469
  // components, make the values lower-case to avoid case-sensitive comparison.
436 470
  if (in_array($validator_name, array('equal', 'comparison', 'unique'))) {
......
624 658
          }
625 659
        }
626 660
        elseif ($components[$entry[$count]['key']]['type'] === 'time') {
627
          $time = $value['hour'] . ':' . $value['minute'];
628
          if (!empty($value['ampm'])) {
629
            $time .= ' ' . $value['ampm'];
661
          if (isset($value['hour']) && isset($value['minute'])) {
662
            $time = $value['hour'] . ':' . str_pad($value['minute'], 2, '0', STR_PAD_LEFT);
663
            if (!empty($value['ampm'])) {
664
              $time .= ' ' . $value['ampm'];
665
            }
666
            $time = strtotime($time);
667
          }
668
          else {
669
            $time = NULL;
630 670
          }
631
          $time = strtotime($time);
632 671
          if ($time) {
633 672
            $entry[$count]['value'] = date('H:i', $time);
634 673
          }

Also available in: Unified diff