summaryrefslogblamecommitdiffstats
path: root/library/Poolctrl/Validator/TitleUnique.php
blob: e9357363b74f81ab39dada0d5251e353360f3480 (plain) (tree)
























                                                                            
<?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;
		}
	}
}