コード例 #1
0
ファイル: Controller.php プロジェクト: grlf/eyedock
 public function viewAction()
 {
     $ticketIdentity = $this->getParam('ticket');
     $ticket = $this->getDi()->helpdeskTicketTable->load($ticketIdentity);
     if (!$this->strategy->canViewTicket($ticket)) {
         throw new Am_Exception_AccessDenied(___('Access Denied'));
     }
     $grid = new Am_Helpdesk_Grid_Admin($this->getRequest(), $this->getView());
     $grid->getDataSource()->getDataSourceQuery()->addWhere('m.user_id=?d', $ticket->user_id);
     $grid->actionsClear();
     $grid->removeField('m_login');
     $grid->addCallback(Am_Grid_ReadOnly::CB_TR_ATTRIBS, function (&$ret, $record) use($ticket) {
         if ($record->pk() == $ticket->pk()) {
             $ret['class'] = isset($ret['class']) ? $ret['class'] . ' emphase' : 'emphase';
         }
     });
     $grid->isAjax($this->isAjax() && $this->isGridRequest('_grid'));
     if ($grid->isAjax()) {
         echo $grid->run();
         return;
     }
     $category = $ticket->getCategory();
     $t = new Am_View();
     $t->assign('ticket', $ticket);
     $t->assign('category', $category);
     $t->assign('user', $ticket->getUser());
     $t->assign('strategy', $this->strategy);
     $t->assign('historyGrid', $grid->render());
     $content = $t->render($this->strategy->getTemplatePath() . '/ticket.phtml');
     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');
     }
 }