/**
  * Displays details for a ticket
  *
  * @apiMethod GET
  * @apiUri    /support/{ticket}
  * @apiParameter {
  * 		"name":        "ticket",
  * 		"description": "Ticket identifier",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     0
  * }
  * @return    void
  */
 public function readTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('read', 'tickets')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     // Initiate class and bind data to database fields
     $ticket_id = Request::getInt('ticket', 0);
     // Initiate class and bind data to database fields
     $ticket = new \Components\Support\Models\Ticket($ticket_id);
     $response = new stdClass();
     $response->id = $ticket->get('id');
     $response->owner = new stdClass();
     $response->owner->username = $ticket->owner('username');
     $response->owner->name = $ticket->owner('name');
     $response->owner->id = $ticket->owner('id');
     $response->reporter = new stdClass();
     $response->reporter->name = $ticket->submitter('name');
     $response->reporter->username = $ticket->submitter('username');
     $response->reporter->email = $ticket->submitter('email');
     $response->status = new stdClass();
     $response->status->alias = $ticket->status('class');
     $response->status->title = $ticket->status('text');
     $response->status->id = $ticket->get('status');
     foreach (array('created', 'severity', 'os', 'browser', 'ip', 'hostname', 'uas', 'referrer', 'open', 'closed') as $prop) {
         $response->{$prop} = $ticket->get($prop);
     }
     $response->report = $ticket->content('raw');
     $response->url = str_replace('/api', '', rtrim(Request::base(), '/') . '/' . ltrim(Route::url('index.php?option=com_support&controller=tickets&task=tickets&id=' . $response->id), '/'));
     $response->comments = array();
     foreach ($ticket->comments() as $comment) {
         $c = new stdClass();
         $c->id = $comment->get('id');
         $c->created = $comment->get('created');
         $c->creator = new stdClass();
         $c->creator->username = $comment->creator('username');
         $c->creator->name = $comment->creator('name');
         $c->creator->id = $comment->creator('id');
         $c->private = $comment->access ? true : false;
         $c->content = $comment->content('raw');
         $response->comments[] = $c;
     }
     $this->send($response);
 }