public function validateAdd() { if ($this->isPOST()) { $c = new Criteria(); $c->add(DomainPeer::NAME, $this->getRequestParameter('name')); if (DomainPeer::doSelectOne($c)) { $this->getRequest()->setError('name', 'This name is already in use.'); return false; } if (!($this->template = TemplatePeer::retrieveByPK($this->getRequestParameter('template_id')))) { $this->getRequest()->setError('template_id', 'Invalid template id.'); return false; } } return true; }
public function getTemplate($con = null) { if ($this->aTemplate === null && $this->template_id !== null) { include_once 'lib/model/om/BaseTemplatePeer.php'; $this->aTemplate = TemplatePeer::retrieveByPK($this->template_id, $con); } return $this->aTemplate; }
public function validateEdit() { if ($this->isPOST()) { if (!($this->template = TemplatePeer::retrieveByPK($this->getRequestParameter('id')))) { $this->getRequest()->setError('id', 'Invalid template id.'); return false; } $c = new Criteria(); $c->add(TemplatePeer::ID, $this->getRequestParameter('id'), Criteria::NOT_EQUAL); $c->add(TemplatePeer::NAME, $this->getRequestParameter('name')); if (TemplatePeer::doSelectOne($c)) { $this->getRequest()->setError('name', 'Name already in use.'); return false; } return $this->commonValidate(); } return true; }