Exemplo n.º 1
0
 /**
  * Display a list of tickets
  *
  * @apiMethod GET
  * @apiUri    /support/tickets
  * @apiParameter {
  * 		"name":          "owner",
  * 		"description":   "List tickets with a specific owner (userid)",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       null
  * }
  * @apiParameter {
  * 		"name":          "status",
  * 		"description":   "List tickets with a specific status id",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       null
  * }
  * @apiParameter {
  * 		"name":          "severity",
  * 		"description":   "List tickets with a specific severity",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       null
  * }
  * @apiParameter {
  * 		"name":          "group",
  * 		"description":   "List tickets with a specific group (by alias)",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       null
  * }
  * @return    void
  */
 public function listTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('read', 'tickets')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     $tickets = \Components\Support\Models\Orm\Ticket::all();
     if (Request::getInt('owner', null)) {
         $tickets = $tickets->whereEquals('owner', Request::get('owner'));
     }
     if (Request::getInt('status', null)) {
         $tickets = $tickets->whereEquals('status', Request::get('status'));
     }
     if (Request::getString('severity', null)) {
         $tickets = $tickets->whereEquals('severity', Request::get('severity'));
     }
     if (Request::getString('group', null)) {
         $tickets = $tickets->whereEquals('group', Request::getString('group'));
     }
     $response = new StdClass();
     $response->total = $tickets->count();
     $response->tickets = array();
     foreach ($tickets->rows() as $row) {
         $temp = array();
         $temp['id'] = $row->id;
         $temp['name'] = $row->name;
         $temp['login'] = $row->login;
         $temp['email'] = $row->email;
         $temp['status'] = $row->status;
         $temp['severity'] = $row->severity;
         $temp['owner'] = $row->owner;
         $temp['summary'] = $row->summary;
         $temp['group'] = $row->group;
         $temp['target_date'] = $row->target_date;
         $response->tickets[] = $temp;
     }
     $this->send($response);
 }