Révision bb746689
Ajouté par Assos Assos il y a plus de 9 ans
drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc | ||
---|---|---|
94 | 94 |
), |
95 | 95 |
'description' => t('Verifies that a user-entered value contains at most the specified number of words.'), |
96 | 96 |
), |
97 |
// Only available in Webform 4; removed below if not. |
|
97 | 98 |
'sum' => array( |
98 | 99 |
'name' => t('Adds up to'), |
99 | 100 |
'component_types' => array( |
... | ... | |
392 | 393 |
), |
393 | 394 |
); |
394 | 395 |
|
396 |
// Only available in Webform 4. |
|
397 |
module_load_include('inc', 'webform', 'components/number'); |
|
398 |
if (!function_exists('webform_compare_floats')) { |
|
399 |
unset($validators['sum']); |
|
400 |
} |
|
401 |
|
|
395 | 402 |
if (module_exists('email_verify')) { |
396 | 403 |
$validators['email_verify'] = array( |
397 | 404 |
'name' => t('Email Verify'), |
... | ... | |
540 | 547 |
$compare_number = (float) preg_replace('/^[^0-9]+/', '', $rule['data']); |
541 | 548 |
|
542 | 549 |
// Parse the comparision operator and do comparison. |
543 |
module_load_include('inc', 'webform', 'includes/webform.conditionals');
|
|
550 |
module_load_include('inc', 'webform', 'components/number');
|
|
544 | 551 |
$error = FALSE; |
545 | 552 |
if (substr($rule['data'], 0, 2) === '<=') { |
546 |
if (!(webform_conditional_compare_floats($sum, $compare_number) <= 0)) {
|
|
553 |
if (!(webform_compare_floats($sum, $compare_number) <= 0)) { |
|
547 | 554 |
$error = t('less than or equal to'); |
548 | 555 |
} |
549 | 556 |
} |
550 | 557 |
elseif (substr($rule['data'], 0, 1) === '<') { |
551 |
if (!(webform_conditional_compare_floats($sum, $compare_number) < 0)) {
|
|
558 |
if (!(webform_compare_floats($sum, $compare_number) < 0)) { |
|
552 | 559 |
$error = t('less than'); |
553 | 560 |
} |
554 | 561 |
} |
555 | 562 |
elseif (substr($rule['data'], 0, 2) === '>=') { |
556 |
if (!(webform_conditional_compare_floats($sum, $compare_number) >= 0)) {
|
|
563 |
if (!(webform_compare_floats($sum, $compare_number) >= 0)) { |
|
557 | 564 |
$error = t('greater than or equal to'); |
558 | 565 |
} |
559 | 566 |
} |
560 | 567 |
elseif (substr($rule['data'], 0, 1) === '>') { |
561 |
if (!(webform_conditional_compare_floats($sum, $compare_number) > 0)) {
|
|
568 |
if (!(webform_compare_floats($sum, $compare_number) > 0)) { |
|
562 | 569 |
$error = t('greater than'); |
563 | 570 |
} |
564 | 571 |
} |
565 | 572 |
else { |
566 |
if (!(webform_conditional_compare_floats($sum, $compare_number) === 0)) {
|
|
573 |
if (!(webform_compare_floats($sum, $compare_number) === 0)) { |
|
567 | 574 |
$error = t('exactly'); |
568 | 575 |
} |
569 | 576 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules