Ejemplo n.º 1
0
 /**
  * Make a user voting for a poll
  * 
  **/
 public function executeVote()
 {
     $poll_id = $this->getRequestParameter('poll_id');
     $poll = sfPollPeer::retrieveByPK($poll_id);
     $answer_id = $this->getRequestParameter('answer_id');
     $answer = sfPollAnswerPeer::retrieveByPK($answer_id);
     $this->forward404Unless($poll && $answer);
     $poll->addUserAnswer(null, $answer->getId(), $_SERVER['REMOTE_ADDR']);
     $this->setFlash('notice', 'Thanks for your vote');
     $this->redirect('@sf_propel_polls_results?id=' . $poll_id);
 }
Ejemplo n.º 2
0
 /**
  * Displays poll form
  * 
  * @throws sfException
  */
 public function executePoll_form()
 {
     if (!isset($this->poll_id)) {
         throw new sfException('poll_id is missing');
     }
     $poll = sfPollPeer::retrieveByPK($this->poll_id);
     if (!$poll) {
         throw new sfException('Unable to retrieve poll object');
     }
     $this->poll = $poll;
 }
Ejemplo n.º 3
0
 /**
  * Displays a poll answer creation form through an ajax call
  * 
  **/
 public function executeAddAnswer()
 {
     $answer_text = $this->getRequestParameter('answer_text');
     $answer_text = $answer_text === 'null' ? NULL : $answer_text;
     $poll_id = $this->getRequestParameter('poll_id');
     $poll = sfPollPeer::retrieveByPK($poll_id);
     $answer_exists = sfPollAnswerPeer::exists($poll_id, $answer_text);
     $this->count_user_answers = $poll->getCountUserAnswers();
     if ($poll && trim($answer_text) != '' && !$answer_exists) {
         $this->answer = $poll->addAnswer($answer_text);
     }
 }
Ejemplo n.º 4
0
 public function getsfPoll($con = null)
 {
     if ($this->asfPoll === null && $this->poll_id !== null) {
         include_once 'plugins/sfPropelPollsPlugin/lib/model/om/BasesfPollPeer.php';
         $this->asfPoll = sfPollPeer::retrieveByPK($this->poll_id, $con);
     }
     return $this->asfPoll;
 }