summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorBjörn Geiger2011-09-14 17:15:50 +0200
committerBjörn Geiger2011-09-14 17:15:50 +0200
commit752b4dfec1c82c8b6c093260fba7f5652825b33f (patch)
tree227978aa43b2787c3aadee084d5b2151bd5eeec3 /library
parentminor (diff)
downloadpoolctrl-752b4dfec1c82c8b6c093260fba7f5652825b33f.tar.gz
poolctrl-752b4dfec1c82c8b6c093260fba7f5652825b33f.tar.xz
poolctrl-752b4dfec1c82c8b6c093260fba7f5652825b33f.zip
EventTitle Unique
Diffstat (limited to 'library')
-rwxr-xr-xlibrary/Poolctrl/Validator/TitleUnique.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/Poolctrl/Validator/TitleUnique.php b/library/Poolctrl/Validator/TitleUnique.php
new file mode 100755
index 0000000..e935736
--- /dev/null
+++ b/library/Poolctrl/Validator/TitleUnique.php
@@ -0,0 +1,25 @@
+<?php
+require_once 'Zend/Validate/Abstract.php';
+
+class Poolctrl_Validate_TitleUnique extends Zend_Validate_Abstract
+{
+ const NOT_UNIQUE = 'notUnique';
+
+ protected $_messageTemplates = array(
+ self::NOT_UNIQUE => "Title is already assigned",
+ );
+
+ public function isValid($value)
+ {
+ $this->_setValue($value);
+ $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