From 48f25c5eadd2a82a365b034a59b3cba4536a1e74 Mon Sep 17 00:00:00 2001 From: Tristan Zur Date: Wed, 16 May 2012 18:14:03 +0200 Subject: =?UTF-8?q?Bugfix:=20Die=20Datumsvalidierung=20funktionierte=20nic?= =?UTF-8?q?ht,=20weil=20Vergleich=20auf=20der=20Basis=20von=20Strings=20du?= =?UTF-8?q?rchgef=C3=BChrt=20wurde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protected/components/DateCompareValidator.php | 12 ++++++++++-- protected/components/DateRangeValidator.php | 4 ++-- protected/models/User.php | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/protected/components/DateCompareValidator.php b/protected/components/DateCompareValidator.php index efa6763..13a4126 100644 --- a/protected/components/DateCompareValidator.php +++ b/protected/components/DateCompareValidator.php @@ -41,15 +41,23 @@ class DateCompareValidator extends CValidator { } $start = $object->$attribute; - Yii::trace('Input value: '.$start. ' -> output timestamp: '.$object->$attribute, 'ccwn.astaf.format'); $end = $this->compareValue; - Yii::trace('Input value: '.$end. ' -> output timestamp: '.$this->compareValue, 'ccwn.astaf.format'); + + $pattern = '/[0-9]{2}\.[0-9]{2}\.[0-9]{4}\s[0-9]{2}:[0-9]{2}/'; + if (preg_match($pattern, $start)) { + $start = CDateTimeParser::parse($start, "dd.MM.yyyy HH:mm"); + } + if (preg_match($pattern, $end)) { + $end = CDateTimeParser::parse($end, "dd.MM.yyyy HH:mm"); + } //a little php trick - safe than eval and easier than a big switch statement if (version_compare($start, $end, $this->operator)) { + Yii::trace('Input value: '.$start.' - compare value: '.$end.' - operator: '.$this->operator.' - result: OK', 'ccwn.astaf.date.validate'); return; } else { + Yii::trace('Input value: '.$start.' - compare value: '.$end.' - operator: '.$this->operator.' - result: FAIL', 'ccwn.astaf.date.validate'); $message = $this->message !== null ? $this->message : Yii::t('astaf', 'The value of {attribute} ({value}) is not {operator} {compareAttribute} ({compareValue}).'); $this->addError($object, $attribute, $message, array('{operator}'=>$this->operator, '{compareValue}'=>$this->compareValue, '{value}'=>$object->$attribute, '{compareAttribute}'=>($object->getAttributeLabel($this->compareAttribute)))); } diff --git a/protected/components/DateRangeValidator.php b/protected/components/DateRangeValidator.php index 8b963a8..529f185 100644 --- a/protected/components/DateRangeValidator.php +++ b/protected/components/DateRangeValidator.php @@ -10,10 +10,10 @@ class DateRangeValidator extends DateCompareValidator { $object->clearErrors($attribute); } $this->compareValue = $this->minDate; - $this->operator = '>'; + $this->operator = '>='; parent::validateAttribute($object, $attribute); $this->compareValue = $this->maxDate; - $this->operator = '<'; + $this->operator = '<='; parent::validateAttribute($object, $attribute); $addRangeError = false; diff --git a/protected/models/User.php b/protected/models/User.php index 13163c3..e0a5eeb 100644 --- a/protected/models/User.php +++ b/protected/models/User.php @@ -85,7 +85,9 @@ class User extends CActiveRecord $this->salt = $this->generateRandomKey(); } - $this->password = $this->encryptPassword($this->password); + if (!$this->checkPassword($this->password)) { + $this->password = $this->encryptPassword($this->password); + } return parent::beforeSave(); } -- cgit v1.0-28-g1787