summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapplication/controllers/EventController.php6
-rwxr-xr-xapplication/forms/EventAdd.php2
-rwxr-xr-xapplication/forms/EventEdit.php2
-rwxr-xr-xlibrary/Poolctrl/Validator/TitleUnique.php25
4 files changed, 32 insertions, 3 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index bf6fa65..af34e75 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -467,7 +467,7 @@ class EventController extends Zend_Controller_Action
* START CALENDAR FUNCTIONS
* ------------------------
*/
-
+
public function deleteallAction() {
if (!$this->acl->checkRight('ed')) {
$this->_redirect('/');
@@ -491,8 +491,8 @@ class EventController extends Zend_Controller_Action
try {
foreach($events as $event) {
$this->eventMapper->delete($event);
- }
-
+ }
+
} catch (Zend_Exception $e) {
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index e7f0465..90d25f6 100755
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -123,10 +123,12 @@ class Application_Form_EventAdd extends Zend_Form
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 30)),
+ array('TitleUnique', false, array()),
),
'required' => true,
'label' => 'Title:',
));
+ $this->getElement('title')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');
$this->addElement('checkbox', 'immediate', array(
'onchange' => 'immediateChanged("immediate")',
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
index e6a4c7a..1aa7d1d 100755
--- a/application/forms/EventEdit.php
+++ b/application/forms/EventEdit.php
@@ -78,11 +78,13 @@ class Application_Form_EventEdit extends Zend_Form
'filters' => array('StringTrim'),
'validators' => array(
array('StringLength', false, array(0, 30)),
+ array('TitleUnique', false, array()),
),
'required' => true,
'label' => 'Title:',
'value' => $this->params['title'],
));
+ $this->getElement('title')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');
$this->addElement('text', 'start', array(
'filters' => array('StringTrim'),
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