CompareFields.php 932 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * QuickForm rule to check a date
  5. */
  6. class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare
  7. {
  8. /**
  9. * Function to check an array of fields
  10. * @param array of field names
  11. * @param string operator ==, >=, etc
  12. * @param string the value to compare
  13. * @return boolean True if date is valid
  14. */
  15. function validate($values, $operator_and_max_value) {
  16. if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) {
  17. $final_value = 0;
  18. foreach ($values as $value) {
  19. $final_value += $value;
  20. }
  21. $params = explode('@', $operator_and_max_value);
  22. $operator = $params[0];
  23. $max_value = $params[1];
  24. return parent::validate(array($final_value, $max_value), $operator);
  25. }
  26. return false;
  27. }
  28. }