summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorBjörn Geiger2011-09-28 17:46:27 +0200
committerBjörn Geiger2011-09-28 17:46:27 +0200
commite4bfe9c7230ae5fcf78095dab008389ef4b6b1f6 (patch)
tree447698c582c8d62bacfdf87743f50213cc5abbd2 /library
parentRepeat Events getestet und korrigiert (diff)
downloadpoolctrl-e4bfe9c7230ae5fcf78095dab008389ef4b6b1f6.tar.gz
poolctrl-e4bfe9c7230ae5fcf78095dab008389ef4b6b1f6.tar.xz
poolctrl-e4bfe9c7230ae5fcf78095dab008389ef4b6b1f6.zip
verschiedene Korrekturen
Diffstat (limited to 'library')
-rwxr-xr-xlibrary/Poolctrl/Validator/TitleUnique.php44
1 files changed, 38 insertions, 6 deletions
diff --git a/library/Poolctrl/Validator/TitleUnique.php b/library/Poolctrl/Validator/TitleUnique.php
index e935736..f051438 100755
--- a/library/Poolctrl/Validator/TitleUnique.php
+++ b/library/Poolctrl/Validator/TitleUnique.php
@@ -9,17 +9,49 @@ class Poolctrl_Validate_TitleUnique extends Zend_Validate_Abstract
self::NOT_UNIQUE => "Title is already assigned",
);
+ public function __construct($option)
+ {
+ if ($option instanceof Zend_Config) {
+ $option = $option->toArray();
+ }
+
+ if (is_array($option)) {
+ if (array_key_exists('title', $option)) {
+ $this->oldTitle = $option['title'];
+ }
+ }
+ }
+
+ protected $oldTitle;
+
public function isValid($value)
{
$this->_setValue($value);
- $eventMapper = new Application_Model_EventMapper();
- $sameEvent = $eventMapper->findBy(array("title" => $value));
+ if(empty($this->oldTitle)) {
+ $eventMapper = new Application_Model_EventMapper();
+ $sameEvent = $eventMapper->findBy(array("title" => $value));
- if (count($sameEvent) > 0) {
- $this->_error(self::NOT_UNIQUE);
- return false;
+ if (count($sameEvent) > 0) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
+ } else {
+ return true;
+ }
} else {
- return true;
+ if($this->oldTitle == $value) {
+ return true;
+ } else {
+ $eventMapper = new Application_Model_EventMapper();
+ $sameEvent = $eventMapper->findBy(array("title" => $value));
+
+ if (count($sameEvent) > 0) {
+ $this->_error(self::NOT_UNIQUE);
+ return false;
+ } else {
+ return true;
+ }
+
+ }
}
}
} \ No newline at end of file