Esempio n. 1
0
 public function editMessageAction()
 {
     //Edit Message
     $messageId = $this->_getParam('messageid');
     $this->view->message_id = $messageId;
     $model1 = new Application_Model_Message();
     $model = $model1->find($messageId);
     if (false === $model) {
         $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('admin/log/message'));
     }
     $options['categoryId'] = $model->getCategoryId();
     $options['severityId'] = $model->getSeverityId();
     $options['typeId'] = $model->getTypeId();
     $options['userMessage'] = $model->getUserMessage();
     $options['sysMessage'] = $model->getSysMessage();
     $request = $this->getRequest();
     $form = new Application_Form_Message();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($options['user_message'] == $model->getUserMessage()) {
             $form->getElement('userMessage')->removeValidator("Db_NoRecordExists");
         }
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save();
             $this->_flashMessenger->addMessage(array('success' => 'Message has been updated successfully!'));
             $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/log/edit-message/messageid/' . $messageId));
         } else {
             $this->_flashMessenger->addMessage(array('error' => 'Unable to save the data. Please provide valid inputs and try again.'));
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }