/** * Update a ticket * * @apiMethod PUT * @apiUri /support/tickets/{ticket} * @apiParameter { * "name": "ticket", * "description": "Ticket identifier", * "type": "integer", * "required": true, * "default": 0 * } * @apiParameter { * "name": "owner", * "description": "Ticket owner", * "type": "integer", * "required": false, * "default": null * } * @apiParameter { * "name": "status", * "description": "Ticket status", * "type": "integer", * "required": false, * "default": null * } * @apiParameter { * "name": "severity", * "description": "Ticket severity", * "type": "string", * "required": false, * "default": null, * "allowed_values": "minor, normal, major, critical" * } * @apiParameter { * "name": "group", * "description": "Alias of group ticket should be assigned to", * "type": "string", * "required": false, * "default": null * } * @return void */ public function updateTask() { $this->requiresAuthentication(); if (!$this->acl->check('edit', 'tickets')) { throw new Exception(Lang::txt('Not authorized'), 403); } // Initiate class and bind data to database fields $ticket_id = Request::getInt('id', 0); $status = Request::getInt('status', null); $owner = Request::getInt('owner', null); $severity = Request::getString('severity', null); $group = Request::getString('group', null); // Initiate class and bind data to database fields $model = \Components\Support\Models\Orm\Ticket::oneOrFail($ticket_id); if ($status) { //cheap check to see if we got a valid status $status_model = \Components\Support\Models\Orm\Status::oneOrFail($status); if (!$status_model->get('id')) { throw new Exception(Lang::txt("COM_SUPPORT_ERROR_INVALID_STATUS"), 404); } $model->set('status', $status); $model->set('open', $status_model->get('open')); } if ($owner) { //cheap check to see if we got a valid user $owner_model = \Hubzero\User\User::one($owner); if (!$owner_model->get('id')) { throw new Exception(Lang::txt("COM_SUPPORT_ERROR_INVALID_OWNER"), 404); } $model->set('owner', $owner); } if ($severity) { if (in_array($severity, ['minor', 'normal', 'major', 'critical'])) { $model->set('severity', $severity); } else { throw new Exception(Lang::txt("COM_SUPPORT_ERROR_INVALID_SEVERITY"), 404); } } if ($group) { $group_model = \Components\Groups\Models\Orm\Group::oneByCn($group); if ($group_model->get('gidNumber')) { $model->set('group', $group); } else { throw new Exception(Lang::txt("COM_SUPPORT_ERROR_INVALID_GROUP_CN"), 404); } } if ($model->save()) { $this->send(null, 204); } else { throw new Exception(Lang::txt('COM_SUPPORT_ERROR_CANNOT_SAVE'), 500); } }
<td><?php echo $document['hubtype']; ?> </td> <td><?php echo $document['title'][0]; ?> </td> <td><?php echo $document['access_level']; ?> </td> <td> <?php if ($document['owner_type'] == 'user') { $user = \Hubzero\User\User::one($document['owner'][0]); if (isset($user) && is_object($user)) { echo $user->get('name'); } else { echo Lang::txt('UNKNOWN'); } } elseif ($document['owner_type'] == 'group') { $group = \Hubzero\User\Group::getInstance($document['owner'][0]); if (isset($group) && is_object($group)) { echo $group->get('description'); } else { echo Lang::txt('UNKNOWN'); } } ?> </td>