示例#1
0
文件: Tickets.php 项目: nirix/traq
 /**
  * Handles the view ticket page.
  *
  * @param integer $ticket_id
  */
 public function showAction($id)
 {
     if (!$this->hasPermission('view_tickets')) {
         return $this->show403();
     }
     $ticket = ticketQuery()->addSelect('t.*')->where('t.project_id = ?')->andWhere('t.ticket_id = ?')->setParameter(0, $this->currentProject['id'])->setParameter(1, $id)->fetch();
     if (!$ticket) {
         return $this->show404();
     }
     $this->addCrumb($this->translate('ticket.page-title', $ticket['ticket_id'], $ticket['summary']), $this->generateUrl('ticket'));
     $history = $ticket->history()->addSelect('h.*', 'u.name AS user_name', 'u.email AS user_email')->leftJoin('h', User::tableName(), 'u', 'u.id = h.user_id')->orderBy('h.created_at', 'ASC')->fetchAll();
     return $this->respondTo(function ($format) use($ticket, $history) {
         if ($format == 'html') {
             return $this->render('tickets/show.phtml', ['ticket' => $ticket, 'history' => $history]);
         } elseif ($format == 'json') {
             return $this->jsonResponse($ticket);
         }
     });
 }
示例#2
0
文件: Wiki.php 项目: nirix/traq
 /**
  * Revisions listing.
  *
  * @param string $slug
  */
 public function revisionsAction()
 {
     $revisions = $this->page->revisions()->addSelect('u.name AS user_name')->addSelect('u.email AS user_email')->leftJoin('wiki_revision', User::tableName(), 'u', 'wiki_revision.user_id = u.id')->orderBy('revision', 'DESC')->fetchAll();
     $this->addCrumb($this->translate('revisions'), routeUrl('wiki_revisions'));
     return $this->respondTo(function ($format) use($revisions) {
         if ($format == 'html') {
             return $this->render('wiki/revisions.phtml', ['page' => $this->page, 'revisions' => $revisions]);
         } elseif ($format == 'json') {
             return $this->jsonResponse($revisions);
         }
     });
 }