protected function doClean($value)
 {
     $value = PetitionText::getIdByHash($value);
     if ($value !== false) {
         if ($this->getOption('petition_text_id') == $value) {
             return $value;
         }
         if (Doctrine_Core::getTable('PetitionText')->createQuery('pt')->where('pt.petition_id = ?', $this->getOption('petition_id'))->andWhere('pt.status = ?', PetitionText::STATUS_ACTIVE)->andWhere('pt.id = ?', $value)->limit(1)->count()) {
             return $value;
         }
     }
     throw new sfValidatorError($this, 'invalid');
 }
Пример #2
0
 public function executeText(sfWebRequest $request)
 {
     $hash = $request->getParameter('hash');
     $id = PetitionText::getIdByHash($hash);
     if ($id === false) {
         $this->forward404();
     }
     $petition_text = Doctrine_Core::getTable('PetitionText')->createQuery('pt')->where('pt.id = ?', $id)->andWhere('pt.status = ?', PetitionText::STATUS_ACTIVE)->fetchOne();
     $result = array();
     foreach (array('title', 'target', 'background', 'intro', 'body', 'footer', 'email_subject', 'email_body') as $field) {
         $result[$field] = $petition_text[$field];
     }
     $this->getResponse()->setContentType('text/javascript');
     $this->setLayout(false);
     $this->setContentTags($petition_text);
     return $this->renderText(json_encode($result));
 }