Exemplo n.º 1
0
 public function sendAction()
 {
     $request = $this->getRequest();
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index', 'index');
     }
     // Get our form and validate it
     $form = $this->getSendForm();
     if (!$form->isValid($request->getPost())) {
         $this->view->form = $form;
         $val = $form->getValues();
         return $this->_helper->redirector->gotoUrl($val['goto']);
     }
     $val = $form->getValues();
     // create a tweet and store it in the Database
     $profile = Zend_Auth::getInstance()->getIdentity();
     $t = new Tweet();
     $t->setMessage($val['message']);
     TweetTable::store($t, $profile->getId());
     // then redirect to the previous page
     return $this->_helper->redirector->gotoUrl($val['goto']);
 }