public function saveAction() { $form = new Activity_Form_Text(); $table = new Tri_Db_Table('activity_text'); $session = new Zend_Session_Namespace('data'); $data = $this->_getAllParams(); $statusList = array('openButton' => 'open', 'finalize' => 'final'); if (Zend_Auth::getInstance()->getIdentity()->role == 'student') { $statusList['sendCorrection'] = 'close'; $statusList['saveDraft'] = 'open'; } if ($form->isValid($data)) { $data = $form->getValues(); $data['sender'] = Zend_Auth::getInstance()->getIdentity()->id; $data['status'] = $statusList[$data['status']]; $row = $table->createRow($data); $id = $row->save(); if (isset($data['note']) && $data['note']) { Panel_Model_Panel::addNote($row->user_id, 'activity', $data['activity_id'], $data['note']); } $this->_helper->_flashMessenger->addMessage('Success'); $this->_redirect('activity/text/index/id/' . $data['activity_id'] . '/textId/' . $id . '/userId/' . $data['user_id']); } $activity = new Tri_Db_Table('activity'); $this->view->parent = $activity->find($data['activity_id'])->current(); $this->view->messages = array('Error'); $this->view->form = $form; $this->render('index'); }
public function saveAction() { if ($this->_request->isPost()) { $exerciseNote = new Tri_Db_Table('exercise_note'); $exerciseAnswer = new Tri_Db_Table('exercise_answer'); $panelNote = new Tri_Db_Table('panel_note'); $identity = Zend_Auth::getInstance()->getIdentity(); $params = $this->_getAllParams(); $data = array(); $note = $exerciseNote->fetchRow(array('user_id = ?' => $identity->id), 'id DESC'); if (isset($params['option'])) { foreach ($params['option'] as $option) { $data['exercise_note_id'] = $note->id; $data['exercise_option_id'] = $option; $exerciseAnswer->createRow($data)->save(); } } $note->note = Exercise_Model_Reply::sumNote($note->id); $note->save(); Panel_Model_Panel::addNote($identity->id, 'exercise', $note->exercise_id, $note->note); $this->_redirect('/exercise/reply/view/id/' . $note->id); } else { $this->_helper->_flashMessenger->addMessage('Error'); $this->_redirect('/exercise'); } }