public function saveAction()
 {
     $form = new Faq_Form_Faq();
     $table = new Tri_Db_Table('faq');
     $session = new Zend_Session_Namespace('data');
     $data = $this->_getAllParams();
     if ($form->isValid($data)) {
         $data = $form->getValues();
         $data['user_id'] = Zend_Auth::getInstance()->getIdentity()->id;
         $data['classroom_id'] = $session->classroom_id;
         if (isset($data['id']) && $data['id']) {
             $row = $table->find($data['id'])->current();
             $row->setFromArray($data);
             $id = $row->save();
         } else {
             unset($data['id']);
             $row = $table->createRow($data);
             $id = $row->save();
             Application_Model_Timeline::save('created a new FAQ', $data['question']);
         }
         $this->_helper->_flashMessenger->addMessage('Success');
         $this->_redirect('faq/index/form/id/' . $id);
     }
     $this->_helper->_flashMessenger->addMessage('Error');
     $this->view->form = $form;
     $this->render('form');
 }
 public function saveAction()
 {
     $form = new Chat_Form_Room();
     $table = new Tri_Db_Table('chat_room');
     $session = new Zend_Session_Namespace('data');
     $data = $this->_getAllParams();
     if ($form->isValid($data)) {
         $data = $form->getValues();
         $data['user_id'] = Zend_Auth::getInstance()->getIdentity()->id;
         $data['classroom_id'] = $session->classroom_id;
         if (isset($data['id']) && $data['id']) {
             $row = $table->find($data['id'])->current();
             $row->setFromArray($data);
             $id = $row->save();
         } else {
             unset($data['id']);
             $row = $table->createRow($data);
             $id = $row->save();
             Application_Model_Timeline::save('created a new chat room', $data['title']);
         }
         $this->_helper->_flashMessenger->addMessage('Success');
         $this->_redirect('chat/room');
     }
     $this->_response->prepend('messages', $this->view->translate('Error'));
     $this->view->form = $form;
     $this->render('form');
 }
 public function saveAction()
 {
     $form = new File_Form_File();
     $table = new Tri_Db_Table('file');
     $session = new Zend_Session_Namespace('data');
     $data = $this->_getAllParams();
     if ($form->isValid($data)) {
         if (!$form->location->receive()) {
             $this->_helper->_flashMessenger->addMessage('File fail');
         }
         $data = $form->getValues();
         $data['user_id'] = Zend_Auth::getInstance()->getIdentity()->id;
         $data['classroom_id'] = $session->classroom_id;
         $row = $table->createRow($data);
         $id = $row->save();
         Application_Model_Timeline::save('saved a new file', $data['name']);
     } else {
         $this->_response->prepend('messages', $this->view->translate('Error'));
         $this->view->form = $form;
         $this->render('form');
     }
 }