Beispiel #1
0
 public function executeShow()
 {
     $this->question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
     $this->forward404Unless($this->question);
     $this->answers = $this->question->getPopularAnswers();
     $this->getResponse()->setTitle('askeet! » ' . $this->question->getTitle());
 }
Beispiel #2
0
 public function executeListInterestedBy()
 {
     $this->question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
     $this->forward404Unless($this->question instanceof Question);
     $page = $this->getRequestParameter('page', 1);
     $this->interested_users_pager = $this->question->getInterestedUsersPager($page);
 }
Beispiel #3
0
 public function executeQuestion()
 {
     $user = $this->authenticateUser();
     if (!$user) {
         $this->error_code = 1;
         $this->error_message = 'login failed';
         return array('api', 'errorSuccess');
     }
     if (!$this->getRequestParameter('stripped_title')) {
         $this->error_code = 2;
         $this->error_message = 'the API returns answers to a specific question. Please provide a stripped_title parameter';
         return array('api', 'errorSuccess');
     } else {
         // get the question
         $question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
         if ($question->getUserId() != $user->getId()) {
             $this->error_code = 3;
             $this->error_message = 'You can only use the API for the questions you asked';
             return array('api', 'errorSuccess');
         } else {
             // get the answers
             $this->answers = $question->getAnswers();
             $this->question = $question;
         }
     }
 }
 public function executeResetQuestionReports()
 {
     $question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
     $this->forward404Unless($question);
     $question->deleteReports();
     $question->save();
     $this->redirect($this->getRequest()->getReferer());
 }
Beispiel #5
0
 public function executeRemove()
 {
     // disable web debug toolbar
     sfConfig::set('sf_web_debug', false);
     $this->question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
     $this->forward404Unless($this->question);
     // remove tag for this user and question
     $user = $this->getUser()->getSubscriber();
     $tag = $this->getRequestParameter('tag');
     $user->removeTag($this->question, $tag);
     $this->tags = $this->question->getTags();
     // clear the question tag list fragment in cache
     if (sfConfig::get('sf_cache')) {
         $this->getContext()->getViewCacheManager()->remove('@question?stripped_title=' . $this->question->getStrippedTitle(), 'fragment_question_tags');
     }
 }
Beispiel #6
0
 public function executeQuestion()
 {
     $question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
     $this->forward404Unless($question);
     // answers
     $c = new Criteria();
     $c->add(AnswerPeer::QUESTION_ID, $question->getId());
     $c->addDescendingOrderByColumn(AnswerPeer::CREATED_AT);
     $c->setLimit(sfConfig::get('app_feed_max_questions'));
     $answers = AnswerPeer::doSelect($c);
     $feed = sfFeed::newInstance('rss201rev2');
     // channel
     $feed->setTitle($question->getTitle() . ' feed');
     $feed->setLink('@question?stripped_title=' . $question->getStrippedTitle());
     $feed->setFeedUrl('@feed_question?stripped_title=' . $question->getStrippedTitle());
     $feed->setDescription('Latest answers to the question: ' . $question->getTitle());
     // items
     $feed->setItems($answers);
     $this->feed = $feed;
 }
 public function executeQuestion()
 {
     $this->question = QuestionPeer::getQuestionFromTitle($this->getRequestParameter('stripped_title'));
 }