Projet

Général

Profil

Révision 81b16cc2

Ajouté par Assos Assos il y a plus de 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/captcha/captcha.info
10 10
files[] = captcha.install
11 11
files[] = captcha.test
12 12

  
13
; Information added by Drupal.org packaging script on 2017-02-15
14
version = "7.x-1.4"
13
; Information added by Drupal.org packaging script on 2017-09-06
14
version = "7.x-1.5"
15 15
core = "7.x"
16 16
project = "captcha"
17
datestamp = "1487198287"
17
datestamp = "1504724060"
18 18

  
drupal7/sites/all/modules/captcha/captcha.install
69 69
      'sid' => array(
70 70
        'description' => "Session ID of the user.",
71 71
        'type' => 'varchar',
72
        'length' => 64,
72
        'length' => 128,
73 73
        'not null' => TRUE,
74 74
        'default' => '',
75 75
      ),
......
326 326
      ->execute();
327 327
  }
328 328
}
329

  
330
/**
331
 * Increase the Session Id field size.
332
 */
333
function captcha_update_7001() {
334
  $schema = captcha_schema();
335

  
336
  db_change_field('captcha_sessions', 'sid', 'sid', array(
337
    'description' => "Session ID of the user.",
338
    'type' => 'varchar',
339
    'length' => 128,
340
    'not null' => TRUE,
341
    'default' => '',
342
  ));
343
}
drupal7/sites/all/modules/captcha/image_captcha/image_captcha.info
11 11
files[] = image_captcha.user.inc
12 12
files[] = image_captcha.test
13 13

  
14
; Information added by Drupal.org packaging script on 2017-02-15
15
version = "7.x-1.4"
14
; Information added by Drupal.org packaging script on 2017-09-06
15
version = "7.x-1.5"
16 16
core = "7.x"
17 17
project = "captcha"
18
datestamp = "1487198287"
18
datestamp = "1504724060"
19 19

  
drupal7/sites/all/modules/media/js/media.popups.js
128 128
  var options = e.data;
129 129

  
130 130
  // Ensure that the iFrame is defined.
131
  if (this.contentWindow.Drupal.media == undefined) {
131
  if (typeof this.contentWindow.Drupal.media === 'undefined' || typeof
132
  this.contentWindow.Drupal.media.browser === 'undefined') {
132 133
    return;
133 134
  }
134 135

  
drupal7/sites/all/modules/media/media.info
3 3
package = Media
4 4
core = 7.x
5 5

  
6
dependencies[] = file_entity (>7.x-2.0)
6
dependencies[] = file_entity
7 7
dependencies[] = image
8 8
dependencies[] = views
9 9

  
......
24 24
; We have to add a fake version so Git checkouts do not fail Media dependencies
25 25
version = 7.x-2.x-dev
26 26

  
27
; Information added by Drupal.org packaging script on 2017-08-05
28
version = "7.x-2.10"
27
; Information added by Drupal.org packaging script on 2017-09-05
28
version = "7.x-2.11"
29 29
core = "7.x"
30 30
project = "media"
31
datestamp = "1501961348"
31
datestamp = "1504575549"
32 32

  
drupal7/sites/all/modules/media/media.install
112 112

  
113 113
  if ($phase == 'update') {
114 114
    $info = system_get_info('module', 'file_entity');
115
    if (strpos($info['version'], '7.x-2') === FALSE) {
115
    $file_entity_installed_date = $info['datestamp'];
116
    $file_entity_version = $info['version'];
117
    $file_entity_minimum_date = 1495439635;
118
    // Time of 2017-05-22 07:53:55 is most recent commit in 7.x-2.0.
119
    if ($file_entity_installed_date < $file_entity_minimum_date) {
120
      $description = $t('Media 2.10 or newer requires <a href="@url">File entity 2.0 or newer (2.4 or higher recommended)</a>. Please download the correct version and make sure you have deleted the file_entity folder inside the media module directory.', array('@url' => 'http://drupal.org/project/file_entity'));
121
      $requirements['file_entity']['description'] = $description;
122
      $requirements['file_entity']['severity'] = REQUIREMENT_ERROR;
123
      $requirements['file_entity']['value'] = $file_entity_version;
124
      $requirements['file_entity']['title'] = $t('Fieldable Files (file_entity) module 7.x-2.0 or newer is required by Media');
125
      drupal_set_message($description, 'error', TRUE);
126
    }
127
    if (strpos($info['version'], '7.x-2') === FALSE &&
128
      strpos($info['version'], '7.x-3') === FALSE) {
116 129
      $requirements['file_entity'] = array(
117
        'title' => $t('File entity 2.x'),
130
        'title' => $t('File entity 2.x or 3.x required.'),
118 131
        'value' => $t('Wrong version'),
119 132
        'severity' => REQUIREMENT_ERROR,
120
        'description' => $t('Media 2.x requires <a href="@url">File entity 2.x</a>. Please download the correct version and make sure you have deleted the file_entity folder inside the media module directory.', array('@url' => 'http://drupal.org/project/file_entity')),
133
        'description' => $t('Media requires <a href="@url">File entity 2.x or 3.x</a>. Please download the correct version and make sure you have deleted the file_entity folder inside the media module directory.', array('@url' => 'http://drupal.org/project/file_entity')),
121 134
      );
122 135
    }
123 136
  }
......
138 151
        $requirements['entity_translation']['severity'] = REQUIREMENT_ERROR;
139 152
        $requirements['entity_translation']['value'] = $et_installed_version;
140 153
        $requirements['entity_translation']['title'] = $t('Entity translation (when installed) with Media');
141
	drupal_set_message($description, 'error', TRUE);
154
        drupal_set_message($description, 'error', TRUE);
142 155
      }
143 156
    }
144 157
  }
drupal7/sites/all/modules/media/modules/media_bulk_upload/media_bulk_upload.info
15 15
files[] = includes/MediaBrowserBulkUpload.inc
16 16
files[] = tests/media_bulk_upload.test
17 17

  
18
; Information added by Drupal.org packaging script on 2017-08-05
19
version = "7.x-2.10"
18
; Information added by Drupal.org packaging script on 2017-09-05
19
version = "7.x-2.11"
20 20
core = "7.x"
21 21
project = "media"
22
datestamp = "1501961348"
22
datestamp = "1504575549"
23 23

  
drupal7/sites/all/modules/media/modules/media_internet/media_internet.info
12 12
files[] = includes/MediaInternetValidationException.inc
13 13
files[] = tests/media_internet.test
14 14

  
15
; Information added by Drupal.org packaging script on 2017-08-05
16
version = "7.x-2.10"
15
; Information added by Drupal.org packaging script on 2017-09-05
16
version = "7.x-2.11"
17 17
core = "7.x"
18 18
project = "media"
19
datestamp = "1501961348"
19
datestamp = "1504575549"
20 20

  
drupal7/sites/all/modules/media/modules/media_internet/tests/media_internet_test.info
7 7
files[] = includes/MediaInternetTestStreamWrapper.inc
8 8
files[] = includes/MediaInternetTestHandler.inc
9 9

  
10
; Information added by Drupal.org packaging script on 2017-08-05
11
version = "7.x-2.10"
10
; Information added by Drupal.org packaging script on 2017-09-05
11
version = "7.x-2.11"
12 12
core = "7.x"
13 13
project = "media"
14
datestamp = "1501961348"
14
datestamp = "1504575549"
15 15

  
drupal7/sites/all/modules/media/modules/media_migrate_file_types/media_migrate_file_types.info
8 8

  
9 9
configure = admin/structure/file-types/upgrade
10 10

  
11
; Information added by Drupal.org packaging script on 2017-08-05
12
version = "7.x-2.10"
11
; Information added by Drupal.org packaging script on 2017-09-05
12
version = "7.x-2.11"
13 13
core = "7.x"
14 14
project = "media"
15
datestamp = "1501961348"
15
datestamp = "1504575549"
16 16

  
drupal7/sites/all/modules/media/modules/media_wysiwyg/css/media_wysiwyg.base.css
11 11
  margin-left: 20px;
12 12
}
13 13
.media-wysiwyg-align-center {
14
  text-align: -moz-center;
15
  text-align: -webkit-center;
14 16
  text-align: center;
15 17
}
drupal7/sites/all/modules/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
238 238
            $settings[$dimension] = $settings['attributes'][$dimension];
239 239
          }
240 240
        }
241
        // If the element is floated via WYSIWYG editor functionality, delegate
242
        // that information to the outer element.
243
        if (!empty($css_properties['float'])) {
244
          $settings['float'] = $css_properties['float'];
245
        }
241 246
      }
242 247
      foreach (array('title', 'alt') as $field_type) {
243 248
        if (isset($settings['attributes'][$field_type])) {
......
331 336
      field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode'], $langcode);
332 337
      entity_prepare_view('file', array($file->fid => $file), $langcode);
333 338
      $element['content'] += field_attach_view('file', $file, $tag_info['view_mode'], $langcode);
339

  
340
      // Add any float information via an extra class
341
      if (!empty($settings['float'])) {
342
        $element['content']['file']['#attributes']['class'][] = drupal_html_class('media-float-' . $settings['float']);
343
      }
334 344
    }
335 345
    if (count(element_children($element['content'])) > 1) {
336 346
      // Add surrounding divs to group them together.
......
342 352
        'media-element-container',
343 353
        'media-' . $element['content']['file']['#view_mode'],
344 354
      );
355
      // Add the float information to the outer element.
356
      if (!empty($settings['float'])) {
357
        $element['content']['#attributes']['class'][] = drupal_html_class('media-float-' . $settings['float']);
358
      }
345 359
      if (variable_get('media_wysiwyg_remove_media_class', FALSE)) {
346 360
        $classes = $element['content']['#attributes']['class'];
347 361
        $element['content']['#attributes']['class'] = array_diff($classes, array('media'));
drupal7/sites/all/modules/media/modules/media_wysiwyg/js/wysiwyg-media.js
13 13
 */
14 14
Drupal.wysiwyg.plugins.media = {
15 15

  
16
  /**
17
   * The selected text string.
18
   */
19
  selectedText: null,
20

  
16 21
  /**
17 22
   * Determine whether a DOM element belongs to this plugin.
18 23
   *
......
51 56
        insert.onSelect([media_file]);
52 57
      }
53 58
      else {
59
        // Store currently selected text.
60
        this.selectedText = data.content;
61

  
54 62
        // Insert new media.
55 63
        insert.prompt(settings.global);
56 64
      }
......
118 126
          fid: this.mediaFile.fid,
119 127
          view_mode: formatted_media.type,
120 128
          attributes: this.mediaFile.attributes,
121
          fields: formatted_media.options
129
          fields: formatted_media.options,
130
          link_text: Drupal.wysiwyg.plugins.media.selectedText
122 131
        });
123 132
    // Get the markup and register it for the macro / placeholder handling.
124 133
    var markup = Drupal.media.filter.getWysiwygHTML(element);
drupal7/sites/all/modules/media/modules/media_wysiwyg/media_wysiwyg.info
16 16

  
17 17
configure = admin/config/media/browser
18 18

  
19
; Information added by Drupal.org packaging script on 2017-08-05
20
version = "7.x-2.10"
19
; Information added by Drupal.org packaging script on 2017-09-05
20
version = "7.x-2.11"
21 21
core = "7.x"
22 22
project = "media"
23
datestamp = "1501961348"
23
datestamp = "1504575549"
24 24

  
drupal7/sites/all/modules/media/modules/media_wysiwyg/tests/media_wysiwyg.macro.test
92 92
    // Ensure that the alt/title from attributes display rather the field ones.
93 93
    $this->assertRaw(drupal_attributes($attributes), t('Image displays with alt/title set as attributes overriding field values.'));
94 94
  }
95

  
96
  /**
97
   * Test image media overrides on images with fields attached.
98
   */
99
  public function testAttributeOverridesWithFields() {
100
    // First make images display the title field on the preview mode we use.
101
    $instance = field_read_instance('file', 'field_file_image_title_text', 'image');
102
    $instance['display']['preview']['type'] = 'text_default';
103
    $instance['display']['preview']['module'] = 'text';
104
    field_update_instance($instance);
105

  
106
    $files = $this->drupalGetTestFiles('image');
107
    $file = file_save($files[0]);
108

  
109
    $attributes = array(
110
      'style' => 'float: left;',
111
    );
112
    $fields = array(
113
      'field_file_image_title_text[und][0][value]' => $this->randomName(),
114
    );
115
    $nid = $this->createNode($file->fid, $attributes, $fields);
116
    $this->drupalGet('node/' . $nid);
117
    $this->assertRaw('float: left;', 'Image displays with overriden attributes when displays with fields.');
118
    $this->assertRaw('media-float-left', 'Media float class added.');
119
  }
95 120
}
drupal7/sites/all/modules/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.info
3 3
package = Media
4 4
core = 7.x
5 5

  
6
; Information added by Drupal.org packaging script on 2017-08-05
7
version = "7.x-2.10"
6
; Information added by Drupal.org packaging script on 2017-09-05
7
version = "7.x-2.11"
8 8
core = "7.x"
9 9
project = "media"
10
datestamp = "1501961348"
10
datestamp = "1504575549"
11 11

  
drupal7/sites/all/modules/media/modules/mediafield/mediafield.info
4 4
core = 7.x
5 5
dependencies[] = media
6 6

  
7
; Information added by Drupal.org packaging script on 2017-08-05
8
version = "7.x-2.10"
7
; Information added by Drupal.org packaging script on 2017-09-05
8
version = "7.x-2.11"
9 9
core = "7.x"
10 10
project = "media"
11
datestamp = "1501961348"
11
datestamp = "1504575549"
12 12

  
drupal7/sites/all/modules/media/tests/media_module_test.info
6 6

  
7 7
files[] = includes/MediaModuleTest.inc
8 8

  
9
; Information added by Drupal.org packaging script on 2017-08-05
10
version = "7.x-2.10"
9
; Information added by Drupal.org packaging script on 2017-09-05
10
version = "7.x-2.11"
11 11
core = "7.x"
12 12
project = "media"
13
datestamp = "1501961348"
13
datestamp = "1504575549"
14 14

  
drupal7/sites/all/modules/webform_validation/tests/WebformValidationTestCase.test
1
<?php
2

  
3
/**
4
 * @file
5
 * Test Webform Validation module.
6
 */
7
class WebformValidationTestCase extends WebformTestCase {
8
  /**
9
   * {@inheritdoc}
10
   */
11
  public static function getInfo() {
12
    return array(
13
      'name' => t('Webform Validation'),
14
      'description' => t('Test Webform Validation module.'),
15
      'group' => t('Webform'),
16
    );
17
  }
18

  
19
  /**
20
   * {@inheritdoc}
21
   */
22
  public function setUp($added_modules = array()) {
23
    $modules = array('webform_validation');
24
    parent::setUp(array_merge($modules, $added_modules));
25
  }
26

  
27
  /**
28
   * The tests.
29
   */
30
  public function test() {
31
    // Create test Webform.
32
    $node = $this->webformForm();
33

  
34
    // Test access to "Form validation" tab.
35
    $this->drupalLogin($this->webform_users['userAccess']);
36
    $this->drupalGet('node/' . $node->nid . '/webform/validation');
37
    $this->assertResponse(403, 'Authenticated user does not have access to "Form validation" tab');
38

  
39
    $this->drupalLogin($this->webform_users['admin']);
40
    $this->drupalGet('node/' . $node->nid . '/webform/validation');
41
    $this->assertResponse(200, 'Webform admin user has access to "Form validation" tab');
42
    $this->assertTitle('Test Webform | Drupal');
43
    $this->assertText('Add a validation rule');
44
    $this->assertText('No validation rules available.');
45

  
46
    // Test rule creation.
47
    $this->clickLink('Minimum length');
48
    $this->assertTitle('Add validation | Drupal');
49
    $values = array(
50
      'rulename' => $this->randomString(),
51
      'rule_components[21]' => TRUE,
52
      'data' => 2,
53
    );
54
    $this->drupalPost(NULL, $values, t('Add rule'));
55
    $this->assertText(htmlspecialchars($values['rulename'], ENT_QUOTES), 'Rule name appears on page.');
56
  }
57

  
58
}
drupal7/sites/all/modules/webform_validation/webform_validation.admin.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Manages validation rules administration UI
5
 * Manages validation rules administration UI.
6 6
 */
7 7

  
8 8
/**
9
 * Menu callback function to show an overview of the existing validation rules, and the option to add a rule
9
 * Menu callback function to show an overview of the existing validation rules, and the option to add a rule.
10 10
 */
11 11
function webform_validation_manage($node) {
12 12
  $rules = webform_validation_get_webform_rules($node);
......
20 20
}
21 21

  
22 22
/**
23
 * Get the list of rules associated with the webform
23
 * Get the list of rules associated with the webform.
24 24
 */
25 25
function webform_validation_get_webform_rules($node) {
26 26
  if (in_array($node->type, webform_variable_get('webform_node_types'))) {
......
30 30
  return $rules;
31 31
}
32 32

  
33

  
34 33
/**
35
 * Themable function to list and re-order the rules assigned to a webform
34
 * Themable function to list and re-order the rules assigned to a webform.
36 35
 */
37 36
function theme_webform_validation_manage_overview_form($variables) {
38 37
  $form = $variables['form'];
39
  $header = array(t('Rule name'), t('Validator'), t('Components'), t('Weight'), array(
40
    'data' => t('Operations'),
41
    'colspan' => 2,
42
  ));
38
  $header = array(
39
    t('Rule name'),
40
    t('Validator'),
41
    t('Components'),
42
    t('Weight'), array(
43
      'data' => t('Operations'),
44
      'colspan' => 2,
45
    ),
46
  );
43 47

  
44 48
  $rows = array();
45 49
  foreach (element_children($form) as $rule) {
46 50
    $row = array();
47 51
    foreach (element_children($form[$rule]) as $item) {
48
      //unset the titles of the form elements, since we are displaying them in a table with a header.
52
      // Unset the titles of the form elements, since we are displaying them in
53
      // a table with a header.
49 54
      unset($form[$rule][$item]['#title']);
50
      //add a class to the weight field
55
      // Add a class to the weight field.
51 56
      $form[$rule]['weight']['#attributes']['class'] = array('ruleid-weight');
52 57
      $row[] = array(
53 58
        'data' => drupal_render($form[$rule][$item]),
......
72 77
      'colspan' => 5,
73 78
    );
74 79
  }
75
  $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'webform-validation-overview-form')));
80
  $output = theme('table', array(
81
    'header' => $header,
82
    'rows' => $rows,
83
    'attributes' => array(
84
      'id' => 'webform-validation-overview-form',
85
    ),
86
  ));
76 87
  $output .= drupal_render_children($form);
77 88
  if ($drag) {
78 89
    drupal_add_tabledrag('webform-validation-overview-form', 'order', 'sibling', 'ruleid-weight');
......
81 92
}
82 93

  
83 94
/**
84
 * Form to list and reorder the rules assigned to a webform
95
 * Form to list and reorder the rules assigned to a webform.
85 96
 */
86 97
function webform_validation_manage_overview_form($form, &$form_state, $rules, $node) {
87 98
  $form = array();
......
138 149
 * Submit function for rule overview form.
139 150
 */
140 151
function webform_validation_manage_overview_form_submit($form, $form_state) {
141
  //Save the rule weights.
152
  // Save the rule weights.
142 153
  foreach ($form_state['values'] as $ruleid => $value) {
143 154
    if (is_numeric($ruleid)) {
144 155
      $update = db_update('webform_validation_rule')
145
        ->fields(array(
146
          'weight' => $value['weight'],
147
        ))
148
        ->condition('ruleid', $ruleid)
149
        ->execute();
156
          ->fields(array(
157
            'weight' => $value['weight'],
158
          ))
159
          ->condition('ruleid', $ruleid)
160
          ->execute();
150 161
    }
151 162
  }
152 163
  drupal_set_message(t('The order of the validation rules has been saved.'));
153 164
}
154 165

  
155 166
/**
156
 * Callback function to add or edit a validation rule
167
 * Callback function to add or edit a validation rule.
157 168
 */
158
function webform_validation_manage_rule($form, $form_state, $node, $action = 'add', $validator, $rule = NULL) {
169
function webform_validation_manage_rule($form, $form_state, $node, $action, $validator, $rule = NULL) {
159 170
  $form = array();
160 171
  $rule_validator = webform_validation_get_validator_info($validator);
161 172

  
......
266 277
}
267 278

  
268 279
/**
269
 * Validation handler to add / edit a rule
280
 * Validation handler to add / edit a rule.
270 281
 */
271 282
function webform_validation_manage_rule_validate($form, &$form_state) {
272 283
  $values = $form_state['values'];
......
280 291
  $selected_components = count(array_filter($values['rule_components']));
281 292
  // Check validator min_components and min_components property when they are equal.
282 293
  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']) {
283
      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'));
294
    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'));
284 295
  }
285
  // check validator min_components property
296
  // Check validator min_components property.
286 297
  elseif (isset($rule_validator['min_components']) && $selected_components < $rule_validator['min_components']) {
287
      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'));
298
    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'));
288 299
  }
289
  // check validator max_components property
300
  // Check validator max_components property.
290 301
  elseif (isset($rule_validator['max_components']) && $selected_components > $rule_validator['max_components']) {
291
      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'));
302
    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'));
292 303
  }
293 304
}
294 305

  
295

  
296 306
/**
297
 * Submit handler to add / edit a rule
307
 * Submit handler to add / edit a rule.
298 308
 */
299 309
function webform_validation_manage_rule_submit($form, &$form_state) {
300 310
  $values = $form_state['values'];
......
302 312
}
303 313

  
304 314
/**
305
 * Get a list of components for a specific webform, filtered by the validator settings
315
 * Get a list of components for a specific webform, filtered by the validator settings.
306 316
 */
307 317
function webform_validation_get_webform_components($node, $validator) {
318
  form_load_include($form_state, 'inc', 'webform', 'includes/webform.components');
319

  
308 320
  $ret = array();
309 321
  $components = $node->webform['components'];
310 322
  if ($components) {
......
320 332
}
321 333

  
322 334
/**
323
 * Confirmation form to delete a rule
335
 * Confirmation form to delete a rule.
324 336
 */
325 337
function webform_validation_delete_rule($form, &$form_state, $rule) {
326 338
  if (isset($rule['ruleid'])) {
......
330 342
    );
331 343
  }
332 344

  
333
  return confirm_form($form,
334
    t('Are you sure you want to delete the rule %name?', array('%name' => $rule['rulename'])),
335
    isset($_GET['destination']) ? $_GET['destination'] : $_GET['q'],
336
    t('This action cannot be undone.'),
337
    t('Delete'),
338
    t('Cancel')
345
  return confirm_form($form, t('Are you sure you want to delete the rule %name?', array('%name' => $rule['rulename'])), isset($_GET['destination']) ? $_GET['destination'] : $_GET['q'], t('This action cannot be undone.'), t('Delete'), t('Cancel')
339 346
  );
340 347
}
341 348

  
342 349
/**
343
 * Submit handler to delete a rule
350
 * Submit handler to delete a rule.
344 351
 */
345 352
function webform_validation_delete_rule_submit($form, &$form_state) {
346 353
  $ruleid = $form_state['values']['ruleid'];
drupal7/sites/all/modules/webform_validation/webform_validation.info
3 3
core = 7.x
4 4
package = Webform
5 5
dependencies[] = webform
6
files[] = tests/WebformValidationTestCase.test
6 7
php = 5.3
7 8

  
8
; Information added by Drupal.org packaging script on 2017-01-04
9
version = "7.x-1.13"
9
; Information added by Drupal.org packaging script on 2017-09-05
10
version = "7.x-1.14"
10 11
core = "7.x"
11 12
project = "webform_validation"
12
datestamp = "1483565351"
13
datestamp = "1504625946"
13 14

  
drupal7/sites/all/modules/webform_validation/webform_validation.install
2 2

  
3 3
/**
4 4
 * @file
5
 * webform_validation installation file
5
 * Webform_validation installation file.
6 6
 */
7 7

  
8 8
/**
......
123 123
}
124 124

  
125 125
/**
126
 * Helper function: update numeric validator range to new syntax
126
 * Helper function: update numeric validator range to new syntax.
127 127
 */
128 128
function _webform_validation_update_range_syntax($range) {
129
  // no longer use "0" as indicator for no validation. This should be an empty string
129
  // No longer use "0" as indicator for no validation. This should be an empty string.
130 130
  if ($range === "0") {
131 131
    return "";
132 132
  }
133 133

  
134
  // replace "0-VAL" with "|VAL" as indicator for less than or equal to
134
  // Replace "0-VAL" with "|VAL" as indicator for less than or equal to.
135 135
  if (preg_match('/^0 ?-/', $range)) {
136 136
    $range_arr = explode('-', $range);
137 137
    $range_end = $range_arr[1];
138 138
    return "|" . trim($range_end);
139 139
  }
140 140

  
141
  // replace "-" as separator between range values in favor of "|"
141
  // Replace "-" as separator between range values in favor of "|".
142 142
  $range = str_replace("-", "|", $range);
143 143
  return $range;
144 144
}
drupal7/sites/all/modules/webform_validation/webform_validation.module
2 2

  
3 3
/**
4 4
 * @file
5
 * Add validation rules to webforms
5
 * Add validation rules to webforms.
6 6
 */
7 7

  
8
include_once('webform_validation.validators.inc');
9
include_once('webform_validation.rules.inc');
8
include_once 'webform_validation.validators.inc';
9
include_once 'webform_validation.rules.inc';
10 10

  
11 11
/**
12 12
 * Implements hook_menu().
......
59 59
}
60 60

  
61 61
/**
62
 * Loads validation rule from menu parameter
62
 * Loads validation rule from menu parameter.
63 63
 */
64 64
function webform_validation_rule_load($ruleid) {
65 65
  return webform_validation_get_rule($ruleid);
66 66
}
67 67

  
68

  
69 68
/**
70 69
 * Implements hook_theme().
71 70
 */
......
99 98
  $groups['webform_validation'] = array(
100 99
    'title' => t('Webform Validation'),
101 100
    'description' => t('Translatable strings for webform validation translation'),
102
    'format' => FALSE, // This group doesn't have strings with format
103
    'list' => FALSE, // This group cannot list all strings
101
    // This group doesn't have strings with format.
102
    'format' => FALSE,
103
    // This group cannot list all strings.
104
    'list' => FALSE,
104 105
    'refresh callback' => 'webform_validation_i18n_string_refresh',
105 106
  );
106 107
  return $groups;
107 108
}
108 109

  
109 110
/**
110
 * Webform validation handler to validate against the given rules
111
 * Webform validation handler to validate against the given rules.
111 112
 */
112 113
function webform_validation_validate($form, &$form_state) {
113 114
  $static_error_messages = &drupal_static(__FUNCTION__, array());
......
119 120
  $rules = webform_validation_get_node_rules($nid);
120 121
  $sid = empty($form_state['values']['details']['sid']) ? 0 : $form_state['values']['details']['sid'];
121 122

  
122
  // Get number of pages for this webform
123
  // Get number of pages for this webform.
123 124
  if (isset($form_state['webform']['page_count'])) {
124 125
    $page_count = $form_state['webform']['page_count'];
125 126
  }
......
127 128
    $page_count = $form_state['storage']['page_count'];
128 129
  }
129 130

  
130
  // Filter out rules that don't apply to this step in the multistep form
131
  // Filter out rules that don't apply to this step in the multistep form.
131 132
  if ($values && $page_count && $page_count > 1) {
132
    $current_page_components = webform_validation_get_field_keys($form_state['values']['submitted'], $node);
133
    if ($rules) {
134
       // filter out rules that don't belong in the current step
135
      foreach ($rules as $ruleid => $rule) {
136
        // get all the component formkeys for this specific validation rule
137
        $rule_formkeys = webform_validation_rule_get_formkeys($rule);
138
        $rule_applies_to_current_page = FALSE;
139
        if (!empty($rule_formkeys)) {
140
          foreach ($rule_formkeys as $formkey) {
141
            if (in_array($formkey, $current_page_components)) {
142
              // this rule applies to the current page,
143
              // because one of the rule components is on the page
144
              $rule_applies_to_current_page = TRUE;
145
            }
133
    $validators = webform_validation_get_validators();
134
    foreach ($rules as $ruleid => $rule) {
135
      // Skip the rule if it does not have any components on the current page.
136
      if (!array_intersect_key($flat_values, $rule['components'])) {
137
        unset($rules[$ruleid]);
138
      }
139
      // For validators that require at least 2 components, skip the rule if any
140
      // of the components are on a page past the current page.
141
      elseif (isset($validators[$rule['validator']]['min_components']) && $validators[$rule['validator']]['min_components'] > 1) {
142
        foreach (array_keys($rule['components']) as $cid) {
143
          if ($node->webform['components'][$cid]['page_num'] > $form_state['webform']['page_num']) {
144
            unset($rules[$ruleid]);
145
            break;
146 146
          }
147 147
        }
148

  
149
        if (!$rule_applies_to_current_page) {
150
          unset($rules[$ruleid]);
151
        }
152 148
      }
153 149
    }
154 150
  }
......
173 169
    }
174 170
    else {
175 171
      // Old conditionals system removed in Webform 7.x-4.8.
176
      // Webform 7.x-3.x does not define WEBFORM_CONDITIONAL_INCLUDE. Define if needed.
172
      // Webform 7.x-3.x does not define WEBFORM_CONDITIONAL_INCLUDE.
173
      // Define if needed.
177 174
      if (!defined('WEBFORM_CONDITIONAL_INCLUDE')) {
178 175
        define('WEBFORM_CONDITIONAL_INCLUDE', 1);
179 176
      }
180 177
      foreach ($component_definitions as $key => $component) {
181
        // In Webform 7.x-3.x, _webform_client_form_rule_check() returns boolean.
178
        // In Webform 7.x-3.x, _webform_client_form_rule_check() returns
179
        // boolean.
182 180
        // Cast to int so that the function behaves as it does in 7.x-4.x.
183 181
        if (isset($flat_values[$key]) && (int) _webform_client_form_rule_check($node, $component, 0, $form_state['values']['submitted']) !== WEBFORM_CONDITIONAL_INCLUDE) {
184 182
          unset($flat_values[$key]);
......
187 185
    }
188 186

  
189 187
    foreach ($rules as $rule) {
190
      // create a list of components that need validation against this rule (component id => user submitted value)
188
      // Create a list of components that need validation against this rule
189
      // (component id => user submitted value).
191 190
      $items = array();
192 191
      foreach ($rule['components'] as $cid => $component) {
193 192
        if (array_key_exists($cid, $flat_values)) {
194 193
          $items[$cid] = $flat_values[$cid];
195 194
        }
196 195
      }
197
      // prefix array keys to avoid reindexing by the module_invoke_all function call
196
      // Prefix array keys to avoid reindexing by the module_invoke_all function
197
      // call.
198 198
      $items = webform_validation_prefix_keys($items);
199 199
      $rule['sid'] = $sid;
200
      // have the submitted values validated
200
      // Have the submitted values validated.
201 201
      $errors = module_invoke_all("webform_validation_validate", $rule['validator'], $items, $component_definitions, $rule);
202 202
      if ($errors) {
203 203
        $errors = webform_validation_unprefix_keys($errors);
204 204
        $components = webform_validation_unprefix_keys($component_definitions);
205 205
        foreach ($errors as $item_key => $error) {
206
          // Do not set error message if an identical message has already been set.
206
          // Do not set error message if an identical message has already been
207
          // set.
207 208
          if (in_array($error, $static_error_messages, TRUE)) {
208 209
            continue;
209 210
          }
210 211
          $static_error_messages[] = $error;
211 212

  
212
          // build the proper form element error key, taking into account hierarchy
213
          // Build the proper form element error key, taking into account
214
          // hierarchy.
213 215
          $error_key = 'submitted][' . webform_validation_parent_tree($item_key, $components) . $components[$item_key]['form_key'];
214 216
          if (is_array($error)) {
215 217
            foreach ($error as $sub_item_key => $sub_error) {
......
217 219
            }
218 220
          }
219 221
          else {
220
            // @ignore security_form_set_error. filter_xss() is run in _webform_validation_i18n_error_message().
222
            // filter_xss() is run in _webform_validation_i18n_error_message().
223
            // @ignore security_form_set_error.
221 224
            form_set_error($error_key, $error);
222 225
          }
223 226
        }
......
227 230
}
228 231

  
229 232
/**
230
 * Recursive helper function to get all field keys (including fields in fieldsets)
233
 * Helper function to get all field keys (including fields in fieldsets).
234
 *
235
 * @deprecated No longer used and will be removed in 7.x-2.x.
231 236
 */
232 237
function webform_validation_get_field_keys($submitted, $node) {
233 238
  static $fields = array();
234 239
  foreach (element_children($submitted) as $child) {
235 240
    if (is_array($submitted[$child]) && element_children($submitted[$child])) {
236
      // only keep searching recursively if it's a fieldset
241
      // Only keep searching recursively if it's a fieldset.
237 242
      $group_components = _webform_validation_get_group_types();
238 243
      if (in_array(_webform_validation_get_component_type($node, $child), $group_components)) {
239 244
        webform_validation_get_field_keys($submitted[$child], $node);
......
251 256
}
252 257

  
253 258
/**
254
 * Recursively add the parents for the element, to be used as first argument to form_set_error
259
 * Recursively add the parents for the element, to be used as first argument to form_set_error.
255 260
 */
256 261
function webform_validation_parent_tree($cid, $components) {
257 262
  $output = '';
......
263 268
}
264 269

  
265 270
/**
266
 * Get an array of formkeys for all components that have been assigned to a rule
271
 * Get array of formkeys for all components that have been assigned to a rule.
272
 *
273
 * @deprecated No longer used and will be removed in 7.x-2.x.
267 274
 */
268 275
function webform_validation_rule_get_formkeys($rule) {
269 276
  $formkeys = array();
......
276 283
}
277 284

  
278 285
/**
279
 * Prefix numeric array keys to avoid them being reindexed by module_invoke_all
286
 * Prefix numeric array keys to avoid them being reindexed by module_invoke_all.
280 287
 */
281 288
function webform_validation_prefix_keys($arr) {
282 289
  $ret = array();
......
287 294
}
288 295

  
289 296
/**
290
 * Undo prefixing numeric array keys to avoid them being reindexed by module_invoke_all
297
 * Undo prefixing numeric array keys to avoid them being reindexed by module_invoke_all.
291 298
 */
292 299
function webform_validation_unprefix_keys($arr) {
293 300
  $ret = array();
......
297 304
  }
298 305
  return $ret;
299 306
}
307

  
300 308
/**
301
 * Theme the 'add rule' list
309
 * Theme the 'add rule' list.
302 310
 */
303 311
function theme_webform_validation_manage_add_rule($variables) {
304 312
  $nid = $variables['nid'];
......
368 376
}
369 377

  
370 378
/**
371
 * Adds support for node_clone module
379
 * Adds support for node_clone module.
372 380
 */
373 381
function webform_validation_node_clone($node) {
374 382
  if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
......
376 384
  }
377 385
  if (isset($node->clone_from_original_nid)) {
378 386
    $original_nid = $node->clone_from_original_nid;
379
    // Get existing rules for original node
387
    // Get existing rules for original node.
380 388
    $rules = webform_validation_get_node_rules($original_nid);
381 389
    if ($rules) {
382 390
      foreach ($rules as $orig_ruleid => $rule) {
383 391
        unset($rule['ruleid']);
384 392
        $rule['action'] = 'add';
385
        $rule['nid'] = $node->nid; // attach existing rules to new node
393
        // Attach existing rules to new node.
394
        $rule['nid'] = $node->nid;
386 395
        $rule['rule_components'] = $rule['components'];
387 396
        webform_validation_rule_save($rule);
388 397
      }
......
391 400
}
392 401

  
393 402
/**
394
 * Save a validation rule. Data comes from the admin form or nodeapi function in
395
 * case of node clone.
403
 * Save a validation rule.
404
 *
405
 * Data comes from the admin form or nodeapi function in case of node clone.
396 406
 *
397 407
 * @param array $values
398 408
 *   An associative array containing:
......
407 417
 * @return int
408 418
 *   The $ruleid of the rule added or edited.
409 419
 */
410
function webform_validation_rule_save($values) {
420
function webform_validation_rule_save(array $values) {
411 421
  if ($values['action'] === 'add') {
412 422
    $primary_keys = array();
413 423
  }
......
442 452
 * @param int $ruleid
443 453
 *   The ruleid of the rule being saved.
444 454
 * @param array $components
445
 *   An array in which the keys are the cid's of the components attached to the rule.
455
 *   An array in which the keys are the cid's of the components attached to the
456
 *   rule.
457
 *
446 458
 * @return array
447 459
 *   An array of the return statuses for each query keyed by cid.
448 460
 */
449
function webform_validation_save_rule_components($ruleid, $components) {
461
function webform_validation_save_rule_components($ruleid, array $components) {
450 462
  $return_status = array();
451 463
  foreach ($components as $cid => $component) {
452 464
    $return_status[$cid] = db_merge('webform_validation_rule_components')
......
464 476
}
465 477

  
466 478
/**
467
 * Given a webform node, get the component type based on a given component key
479
 * Given a webform node, get the component type based on a given component key.
468 480
 */
469 481
function _webform_validation_get_component_type($node, $component_key) {
470 482
  if ($node->webform['components']) {
......
478 490
}
479 491

  
480 492
/**
481
 * Get all webform components that are defined as a group
493
 * Get all webform components that are defined as a group.
482 494
 */
483 495
function _webform_validation_get_group_types() {
484 496
  $types = array();
......
494 506
 * Implements hook_webform_validator_alter().
495 507
 */
496 508
function webform_validation_webform_validator_alter(&$validators) {
497
  // Add support for the Select (or Other) module
509
  // Add support for the Select (or Other) module.
498 510
  if (module_exists('select_or_other')) {
499
    // if this module exists, all select components can now except user input.
500
    // Thus we provide those components the same rules as a textfield
511
    // If this module exists, all select components can now except user input.
512
    // Thus we provide those components the same rules as a textfield.
501 513
    if ($validators) {
502 514
      foreach ($validators as $validator_name => $validator_info) {
503 515
        if (in_array('textfield', $validator_info['component_types'])) {
drupal7/sites/all/modules/webform_validation/webform_validation.rules.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * provides API and management functions for the webform validation rules
5
 * Provides API and management functions for the webform validation rules.
6 6
 */
7 7

  
8 8
/**
9
 * Get a rule entry
9
 * Get a rule entry.
10 10
 */
11 11
function webform_validation_get_rule($ruleid) {
12 12
  $result = db_query("SELECT ruleid, rulename, nid, validator, data, error_message, negate, weight FROM {webform_validation_rule} WHERE ruleid = :ruleid", array(':ruleid' => $ruleid), array('fetch' => PDO::FETCH_ASSOC));
......
17 17
}
18 18

  
19 19
/**
20
 * Get an array of rules assigned to a webform node
20
 * Get an array of rules assigned to a webform node.
21 21
 */
22 22
function webform_validation_get_node_rules($nid) {
23 23
  $rules = array();
......
31 31
}
32 32

  
33 33
/**
34
 * Get an array of components linked to a rule
34
 * Get an array of components linked to a rule.
35 35
 */
36 36
function webform_validation_get_rule_components($ruleid, $nid) {
37 37
  $cids = array();
......
54 54
}
55 55

  
56 56
/**
57
 * Get info on all components that are available on a webform
57
 * Get info on all components that are available on a webform.
58 58
 */
59 59
function webform_validation_get_all_components($nid) {
60 60
  $components = array();
drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Provides validation functionality and hooks
5
 * Provides validation functionality and hooks.
6 6
 */
7 7

  
8 8
/**
......
17 17
 * - custom_data (optional): define whether custom data can be added to the validation rule
18 18
 * - min_components (optional): define the minimum number of components to be selected for creating a validation rule
19 19
 * - max_components (optional): define the maximum number of components to be selected for creating a validation rule
20
 * - description (optional): provide a descriptive explanation about the validator
20
 * - description (optional): provide a descriptive explanation about the validator.
21 21
 */
22 22
function webform_validation_webform_validation_validators() {
23 23
  $validators = array(
......
30 30
      ),
31 31
      'custom_data' => array(
32 32
        'label' => t('Specify numeric validation range'),
33
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against.') . ' ' . t('Usage') . ':'
34
          . 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')))),
33
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against.') . ' ' . t('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')))),
35 34
        'required' => FALSE,
36 35
      ),
37 36
      'description' => t('Verifies that user-entered values are numeric, with the option to specify min and / or max values.'),
......
102 101
      ),
103 102
      'custom_data' => array(
104 103
        'label' => t('Number the fields add up to'),
105
        'description' => t('Specify the number and the type of comparison. For example:') . theme('item_list', array('items' => array(
106
          t('Enter "=3" if the components must add up to exactly 3.'),
107
          t('Enter ">10" if the components must add up to greater than 10.'),
108
          t('Enter ">=10" if the components must add up to greater than or equal to 10.'),
109
          t('Enter "<20" if the components must add up to less than 20.'),
110
          t('Enter "<=20" if the components must add up to less than or equal to 20.'),
111
        ))),
104
        'description' => t('Specify the number and the type of comparison. For example:') . theme('item_list', array(
105
          'items' => array(
106
            t('Enter "=3" if the components must add up to exactly 3.'),
107
            t('Enter ">10" if the components must add up to greater than 10.'),
108
            t('Enter ">=10" if the components must add up to greater than or equal to 10.'),
109
            t('Enter "<20" if the components must add up to less than 20.'),
110
            t('Enter "<=20" if the components must add up to less than or equal to 20.'),
111
          ),
112
        )),
112 113
      ),
113 114
      '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.'),
114 115
    ),
......
182 183
        'label' => t('(Key) value'),
183 184
        'description' => t('Specify the specific value(s) you want the component to contain. Separate multiple options by a comma. For components that have keys, use the key value instead.'),
184 185
      ),
185
      'max_components' => 1,
186 186
      'description' => t('Verifies that the value of the specified component is from a list of allowed values.'),
187 187
    ),
188 188
    'default_value' => array(
......
215 215
      ),
216 216
      'custom_data' => array(
217 217
        'label' => t('Number to be completed'),
218
        'description' => t('Specify the number that must be completed and the type of comparison. For example:') . theme('item_list', array('items' => array(
219
          t('Enter ">=1" if the user must complete <b>at least</b> 1 of the selected components.'),
220
          t('Enter "=3" if the user must complete <b>exactly</b> 3 of the selected components.'),
221
          t('Enter "<=2" if the user must complete <b>at most</b> 2 of the selected components.'),
222
        ))),
218
        'description' => t('Specify the number that must be completed and the type of comparison. For example:') . theme('item_list', array(
219
          'items' => array(
220
            t('Enter ">=1" if the user must complete <b>at least</b> 1 of the selected components.'),
221
            t('Enter "=3" if the user must complete <b>exactly</b> 3 of the selected components.'),
222
            t('Enter "<=2" if the user must complete <b>at most</b> 2 of the selected components.'),
223
          ),
224
        )),
223 225
      ),
224 226
      'min_components' => 2,
225 227
      '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.'),
......
267 269
        'textarea',
268 270
        'textfield',
269 271
      ),
270
      'description' => t('Verifies that user-entered data doesn\'t contain HTML tags.'),
272
      'description' => t("Verifies that user-entered data doesn't contain HTML tags."),
271 273
    ),
272 274
    'starts_with' => array(
273 275
      'name' => t('Starts with'),
......
311 313
      'custom_error' => TRUE,
312 314
      'custom_data' => array(
313 315
        'label' => t('Pattern'),
314
        'description' => t('Specify a pattern where:')
315
          . theme('item_list', array('items' => array(t('@ = any letter A-Z'), t('# = any numeral 0-9'), t('| = separates two or more acceptable patterns'), t('Any other character must appear in its exact position'))))
316
          . t('Examples')
317
          . theme('item_list', array('items' => array(t('North American phone number: (###) ###-####'), t('D-2500 series model numbers: D-25##'), t('UK Postal Code: @# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA')))),
316
        'description' => t('Specify a pattern where:') . theme('item_list', array('items' => array(t('@ = any letter A-Z'), t('# = any numeral 0-9'), t('| = separates two or more acceptable patterns'), t('Any other character must appear in its exact position')))) . t('Examples') . theme('item_list', array('items' => array(t('North American phone number: (###) ###-####'), t('D-2500 series model numbers: D-25##'), t('UK Postal Code: @# #@@|@## #@@|@@# #@@|@@## #@@|@#@ #@@|@@#@ #@@|GIR0AA')))),
318 317
      ),
319 318
      'description' => t('Verifies that a user-entered value follows to a specified pattern.'),
320 319
    ),
......
376 375
        'label' => t('Blacklisted words'),
377 376
        'description' => t('Specify illegal words, seperated by commas.'),
378 377
      ),
379
      'description' => t('Validates that user-entered data doesn\'t contain any of the specified illegal words.'),
378
      'description' => t("Validates that user-entered data doesn't contain any of the specified illegal words."),
380 379
    ),
381 380
    'username' => array(
382 381
      'name' => t('Must match a username'),
......
460 459
      $num_range = _webform_numeric_check_data($rule['data']);
461 460
      foreach ($items as $key => $val) {
462 461
        foreach ($val as $subval) {
463
          // first check if the value is numeric
462
          // First check if the value is numeric.
464 463
          if (is_numeric($subval)) {
465 464
            $subval = (float) $subval;
466 465
          }
......
469 468
            continue;
470 469
          }
471 470

  
472
          // now validate the entered numeric value against the validator range settings, if appropriate
473
          // a. validate min & max
471
          // Now validate the entered numeric value against the validator range settings, if appropriate
472
          // a. validate min & max.
474 473
          if (isset($num_range['min']) && isset($num_range['max'])) {
475
            // validate the min - max range
474
            // Validate the min - max range.
476 475
            if ($subval < $num_range['min'] || $subval > $num_range['max']) {
477
              $errors[$key] = t('%item is not within the allowed range %range.', array('%item' => $components[$key]['name'], '%range' => str_replace('|' , ' - ', $rule['data'])));
476
              $errors[$key] = t('%item is not within the allowed range %range.', array('%item' => $components[$key]['name'], '%range' => str_replace('|', ' - ', $rule['data'])));
478 477
            }
479 478
          }
480 479
          else {
481
            // b. validate min
480
            // b. validate min.
482 481
            if (isset($num_range['min'])) {
483 482
              if ($subval < $num_range['min']) {
484 483
                $errors[$key] = t('%item should be greater than or equal to %val.', array('%item' => $components[$key]['name'], '%val' => $num_range['min']));
485 484
              }
486 485
            }
487
            // c. validate max
486
            // c. validate max.
488 487
            if (isset($num_range['max'])) {
489 488
              if ($subval > $num_range['max']) {
490 489
                $errors[$key] = t('%item should be less than or equal to %val.', array('%item' => $components[$key]['name'], '%val' => $num_range['max']));
......
494 493
        }
495 494
      }
496 495
      return $errors;
496

  
497 497
    case 'min_length':
498 498
      $min_length = $rule['data'];
499 499
      foreach ($items as $key => $val) {
......
504 504
        }
505 505
      }
506 506
      return $errors;
507

  
507 508
    case 'max_length':
508 509
      $max_length = $rule['data'];
509 510
      foreach ($items as $key => $val) {
......
514 515
        }
515 516
      }
516 517
      return $errors;
518

  
517 519
    case 'min_words':
518 520
      $min_words = $rule['data'];
519 521
      foreach ($items as $key => $val) {
......
525 527
        }
526 528
      }
527 529
      return $errors;
530

  
528 531
    case 'max_words':
529 532
      $max_words = $rule['data'];
530 533
      foreach ($items as $key => $val) {
......
536 539
        }
537 540
      }
538 541
      return $errors;
542

  
539 543
    case 'sum':
540 544
      // Get the numbers to sum.
541 545
      $sum = array();
......
587 591
        $errors[$keys[0]] = t('These items must add up to %verb %compare_number:', array('%verb' => $error, '%compare_number' => $compare_number)) . theme('item_list', array('items' => _webform_validation_get_names_of_rule_components($rule)));
588 592
      }
589 593
      return $errors;
594

  
590 595
    case 'equal':
591 596
      $first_entry_key = key($items);
592 597
      $first_entry = array_shift($items);
......
596 601
        }
597 602
      }
598 603
      return $errors;
604

  
599 605
    case 'comparison':
600 606
      foreach (array(1, 2) as $count) {
601 607
        $entry[$count]['key'] = key($items);
......
638 644
            $error = TRUE;
639 645
          }
640 646
          break;
647

  
641 648
        case '>=':
642 649
          if (!($entry[1]['value'] >= $entry[2]['value'])) {
643 650
            $error = TRUE;
644 651
          }
645 652
          break;
653

  
646 654
        case '<':
647 655
          if (!($entry[1]['value'] < $entry[2]['value'])) {
648 656
            $error = TRUE;
649 657
          }
650 658
          break;
659

  
651 660
        case '<=':
652 661
          if (!($entry[1]['value'] <= $entry[2]['value'])) {
653 662
            $error = TRUE;
......
659 668
        $errors[$entry[2]['key']] = _webform_validation_i18n_error_message($rule);
660 669
      }
661 670
      return $errors;
671

  
662 672
    case 'unique':
663 673
      foreach ($items as $key => $val) {
664 674
        $items[$key] = _webform_validation_flatten_array($val);
665 675
      }
666
      // now we count how many times each value appears, and find out which values appear more than once
676
      // Now we count how many times each value appears, and find out which values appear more than once.
667 677
      $items_count = array_count_values(array_map('drupal_strtolower', array_map('trim', $items)));
668 678
      $doubles = array_filter($items_count, create_function('$x', 'return $x > 1;'));
669 679
      foreach ($items as $key => $val) {
......
672 682
        }
673 683
      }
674 684
      return $errors;
685

  
675 686
    case 'specific_value':
676 687
      $specific_values = explode(',', $rule['data']);
677 688
      $specific_values = array_map('trim', $specific_values);
......
682 693
        _webform_validation_test($errors, $key, $rule, $test);
683 694
      }
684 695
      return $errors;
696

  
685 697
    case 'default_value':
686 698
      foreach ($items as $key => $val) {
687 699
        $val = _webform_validation_flatten_array($val);
......
689 701
        _webform_validation_test($errors, $key, $rule, $test);
690 702
      }
691 703
      return $errors;
704

  
692 705
    case 'someofseveral':
693 706
      // Determine the number of components completed.
694 707
      foreach ($items as $key => $val) {
......
730 743
        $errors[$keys[0]] = t('You must complete %verb %compare_number of these items:', array('%verb' => $error, '%compare_number' => $compare_number)) . theme('item_list', array('items' => _webform_validation_get_names_of_rule_components($rule)));
731 744
      }
732 745
      return $errors;
746

  
733 747
    case 'select_min':
734 748
      $min_selections = $rule['data'];
735 749
      foreach ($items as $key => $val) {
......
738 752
        }
739 753
      }
740 754
      return $errors;
755

  
741 756
    case 'select_max':
742 757
      $max_selections = $rule['data'];
743 758
      foreach ($items as $key => $val) {
......
746 761
        }
747 762
      }
748 763
      return $errors;
764

  
749 765
    case 'select_exact':
750 766
      $allowed_selections = $rule['data'];
751 767
      foreach ($items as $key => $val) {
......
758 774
        _webform_validation_test($errors, $key, $rule, $test, $error_strings, $error_vars);
759 775
      }
760 776
      return $errors;
777

  
761 778
    case 'plain_text':
762 779
      foreach ($items as $key => $val) {
763 780
        $error_strings = array(
......
771 788
        }
772 789
      }
773 790
      return $errors;
791

  
774 792
    case 'starts_with':
775 793
    case 'ends_with':
776 794
      $pattern = preg_quote($rule['data'], '/');
......
796 814
        }
797 815
      }
798 816
      return $errors;
817

  
799 818
    case 'pattern':
800 819
      $pattern = preg_quote($rule['data'], '/');
801 820
      $pattern = str_replace('@', '[a-zA-Z]', $pattern);
......
810 829
        }
811 830
      }
812 831
      return $errors;
832

  
813 833
    case 'regex':
814 834
    case 'regexi':
815 835
      mb_regex_encoding('UTF-8');
......
827 847
        }
828 848
      }
829 849
      return $errors;
850

  
830 851
    case 'must_be_empty':
831 852
      foreach ($items as $key => $val) {
832 853
        if (count($val) !== 0) {
......
834 855
        }
835 856
      }
836 857
      return $errors;
858

  
837 859
    case 'blacklist':
838 860
      $blacklist = preg_quote($rule['data'], '/');
839 861
      $blacklist = explode(',', $blacklist);
......
846 868
        }
847 869
      }
848 870
      return $errors;
871

  
849 872
    case 'username':
850 873
      foreach ($items as $key => $val) {
851 874
        $error_strings = array(
......
859 882
        }
860 883
      }
861 884
      return $errors;
885

  
862 886
    case 'valid_url':
863 887
      foreach ($items as $key => $val) {
864 888
        $error_strings = array(
......
872 896
        }
873 897
      }
874 898
      return $errors;
899

  
875 900
    case 'email_verify':
876 901
      if (module_exists('email_verify')) {
877 902
        foreach ($items as $key => $val) {
......
890 915
/**
891 916
 * Return an array of the names of the components in a validation rule.
892 917
 *
893
 * @param $rule array
918
 * @param array $rule
894 919
 *   Array of information about a validation rule.
895 920
 *
896 921
 * @return array
......
947 972
}
948 973

  
949 974
/**
950
 * Helper function to deal with submitted values that are arrays (for example, multiple select component).
951
 * We flatten the array as a comma-separated list to do the comparison.
975
 * Helper function to deal with submitted values that are arrays.
976
 *
977
 * For example, multiple select component. We flatten the array as a
978
 * comma-separated list to do the comparison.
952 979
 */
953 980
function _webform_validation_flatten_array($val) {
954 981
  if (is_array($val)) {
......
959 986
}
960 987

  
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff