public function replyAction() { $ticket = $this->getDi()->helpdeskTicketTable->load($this->_request->getInt('ticket_id')); if (!$this->strategy->canEditTicket($ticket)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } if ($this->_request->isPost()) { $this->reply($ticket, $this->_request->get('message_id', null)); $this->_request->set('ticket', $ticket->ticket_mask); return $this->redirect($ticket); } $message = null; $type = $this->_request->get('type', 'message'); if ($this->_request->get('message_id')) { $message = $this->getDi()->helpdeskMessageTable->load($this->_request->get('message_id')); switch ($type) { case 'message': if (!$this->strategy->canViewMessage($message)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } break; case 'comment': if (!$this->strategy->canEditMessage($message)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } break; default: throw new Am_Exception_InputError('Unknown message type : ' . $type); } } $content = $this->getReplyForm($this->_request->getInt('ticket_id'), $message, $type); if ($this->isAjax()) { header('Content-type: text/html; charset=UTF-8'); echo $content; } else { $this->view->assign('content', $content); $this->view->display($this->strategy->getTemplatePath() . '/index.phtml'); } }
public function replyAction() { $ticket = $this->getDi()->helpdeskTicketTable->load($this->getParam('ticket')); if (!$this->strategy->canEditTicket($ticket)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } $message = null; $type = $this->getParam('type', 'message'); if ($message_id = $this->getDi()->app->reveal($this->getParam('message_id'))) { $message = $this->getDi()->helpdeskMessageTable->load($message_id); switch ($type) { case 'message': if (!$this->strategy->canViewMessage($message)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } break; case 'comment': if (!$this->strategy->canEditMessage($message)) { throw new Am_Exception_AccessDenied(___('Access Denied')); } break; default: throw new Am_Exception_InputError('Unknown message type : ' . $type); } } /* @var $replyForm Am_Form */ $replyForm = $this->getReplyForm($this->getParam('ticket'), $message, $type); if ($this->isPost()) { $replyForm->setDataSources(array($this->getRequest())); $values = $replyForm->getValue(); $message_id = $this->getParam('message_id', null); $message_id = $message_id ? $this->getDi()->app->reveal($message_id) : $message_id; $this->reply($ticket, $message_id, $values); $this->getRequest()->set('ticket', $ticket->ticket_mask); return $this->redirectTicket($ticket); } $content = (string) $replyForm; if ($this->isAjax()) { header('Content-type: text/html; charset=UTF-8'); echo $content; } else { $this->view->assign('content', $content); $this->view->display($this->strategy->getTemplatePath() . '/index.phtml'); } }