예제 #1
0
 /**
  * Validate 2 dates
  * @param array $values Array with the 2 dates. Each element in this array
  * should be an array width keys  F (month), d (day) and Y (year)
  * @param string $operator The operator to use (default '==')
  * @return boolean True if the 2 given dates match the operator
  */
 function validate($values, $operator = null)
 {
     $date1 = $values[0];
     $date2 = $values[1];
     $time1 = mktime($date1['H'], $date1['i'], 0, $date1['F'], $date1['d'], $date1['Y']);
     $time2 = mktime($date2['H'], $date2['i'], 0, $date2['F'], $date2['d'], $date2['Y']);
     return parent::validate(array($time1, $time2), $operator);
 }
 /**
  * Validate 2 dates
  * @param string $operator The operator to use (default '==')
  * @return boolean True if the 2 given dates match the operator
  */
 function validate($values, $operator = null)
 {
     $datetime1 = api_strtotime($values[0]);
     $datetime2 = api_strtotime($values[1]);
     if (strpos($operator, 'allow_empty') !== false) {
         $operator = str_replace('allow_empty', '', $operator);
         if (!$datetime2 || empty($datetime2)) {
             return true;
         }
     }
     $result = parent::validate(array($datetime1, $datetime2), $operator);
     return $result;
 }
예제 #3
0
 /**
  * Function to check an array of fields 	 
  * @param   array of field names
  * @param   string operator ==, >=, etc
  * @param   string the value to compare
  * @return boolean True if date is valid
  */
 function validate($values, $operator_and_max_value)
 {
     if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) {
         $final_value = 0;
         foreach ($values as $value) {
             $final_value += $value;
         }
         $params = explode('@', $operator_and_max_value);
         $operator = $params[0];
         $max_value = $params[1];
         return parent::validate(array($final_value, $max_value), $operator);
     }
     return false;
 }