diff options
| author | Tristan Zur <tzur@ccwn.org> | 2012-04-28 17:06:39 +0200 |
|---|---|---|
| committer | Tristan Zur <tzur@ccwn.org> | 2012-04-28 17:06:39 +0200 |
| commit | 139dbc9cc21fb1d419c6ecc80380f723e613efbc (patch) | |
| tree | 3bfa5c3ee5c84e2ff9ec7ccef2b27f1f378a6a19 /protected/components/DateRangeValidator.php | |
| parent | 2d4bddcbf7b816f86db6f308a4d11bc9787c1f99 (diff) | |
- AuditTrail Berechtigungen gesetzt (Nur Admin)
- Fehler in Extension "CJuiDateTimePicker" beseitigt
- DateCompareValidator hinzugefügt
- DateRangeValidator hinzugefügt
- Datenbanktabellennamen geändert
- Views für die Veranstaltungen bearbeitet
Diffstat (limited to 'protected/components/DateRangeValidator.php')
| -rw-r--r-- | protected/components/DateRangeValidator.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/protected/components/DateRangeValidator.php b/protected/components/DateRangeValidator.php new file mode 100644 index 0000000..8b963a8 --- /dev/null +++ b/protected/components/DateRangeValidator.php @@ -0,0 +1,32 @@ +<?php +class DateRangeValidator extends DateCompareValidator { + public $minDate; + public $maxDate; + + protected function validateAttribute($object, $attribute) { + $errors = null; + if ($object->hasErrors($attribute)) { + $errors = $object->getErrors($attribute); + $object->clearErrors($attribute); + } + $this->compareValue = $this->minDate; + $this->operator = '>'; + parent::validateAttribute($object, $attribute); + $this->compareValue = $this->maxDate; + $this->operator = '<'; + parent::validateAttribute($object, $attribute); + + $addRangeError = false; + if ($object->hasErrors($attribute)) { + $object->clearErrors($attribute); + $addRangeError = true; + } + if (!empty($errors)) { + $object->addErrors($errors); + } + if ($addRangeError) { + $message = $this->message !== null ? $this->message : Yii::t('astaf', 'The value of {attribute} ({value}) is not between {minDate} and {maxDate}.'); + $this->addError($object, $attribute, $message, array('{operator}'=>$this->operator, '{minDate}'=>$this->minDate, '{value}'=>$object->$attribute, '{maxDate}'=>$this->maxDate)); + } + } +}
\ No newline at end of file |
