2016-09-29 19:34:20 +02:00
|
|
|
<?php
|
2017-04-20 05:55:38 +02:00
|
|
|
/**
|
|
|
|
* @api {OBJECT} TicketEvent TicketEvent
|
2019-10-08 01:21:43 +02:00
|
|
|
* @apiVersion 4.5.0
|
2017-04-20 05:55:38 +02:00
|
|
|
* @apiGroup Data Structures
|
2017-05-11 21:37:03 +02:00
|
|
|
* @apiParam {String} type The type of the ticket event. It can be COMMENT, ASSIGN, UN_ASSIGN, CLOSE, RE_OPEN, DEPARTMENT_CHANGED or PRIORITY_CHANGED
|
2017-04-21 05:34:20 +02:00
|
|
|
* @apiParam {String} content The content of the ticket event.
|
|
|
|
* @apiParam {Object} author The author of the ticket event.
|
|
|
|
* @apiParam {Number} author.id The author's id of the ticket event.
|
|
|
|
* @apiParam {String} author.name The author's name of the ticket event.
|
|
|
|
* @apiParam {String} author.email The author's email of the ticket event.
|
|
|
|
* @apiParam {String} author.profilePic The author's profilePic of the ticket event.
|
2017-05-11 21:37:03 +02:00
|
|
|
* @apiParam {Boolean} author.staff Indicates if the author is a staff.
|
2017-04-21 05:34:20 +02:00
|
|
|
* @apiParam {String} date The date of the ticket event.
|
|
|
|
* @apiParam {String} file The file of the ticket event.
|
2018-09-28 02:19:34 +02:00
|
|
|
* @apiParam {Boolean} private Indicates if this event is not shown to users.
|
2017-04-20 05:55:38 +02:00
|
|
|
*/
|
2016-09-29 19:34:20 +02:00
|
|
|
|
|
|
|
class Ticketevent extends DataStore {
|
|
|
|
const TABLE = 'ticketevent';
|
|
|
|
|
|
|
|
const COMMENT = 'COMMENT';
|
|
|
|
const ASSIGN = 'ASSIGN';
|
2016-10-23 20:31:48 +02:00
|
|
|
const UN_ASSIGN = 'UN_ASSIGN';
|
2016-09-29 19:34:20 +02:00
|
|
|
const CLOSE = 'CLOSE';
|
2016-10-23 20:31:48 +02:00
|
|
|
const RE_OPEN = 'RE_OPEN';
|
2016-09-29 19:34:20 +02:00
|
|
|
const DEPARTMENT_CHANGED = 'DEPARTMENT_CHANGED';
|
|
|
|
const PRIORITY_CHANGED = 'PRIORITY_CHANGED';
|
|
|
|
|
|
|
|
private static function getEventTypes() {
|
|
|
|
return [
|
|
|
|
'COMMENT',
|
2016-10-23 20:31:48 +02:00
|
|
|
'ASSIGN',
|
|
|
|
'UN_ASSIGN',
|
2016-09-29 19:34:20 +02:00
|
|
|
'CLOSE',
|
2016-10-23 20:31:48 +02:00
|
|
|
'RE_OPEN',
|
2016-09-29 19:34:20 +02:00
|
|
|
'DEPARTMENT_CHANGED',
|
2016-10-23 20:31:48 +02:00
|
|
|
'PRIORITY_CHANGED'
|
2016-09-29 19:34:20 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getEvent($type) {
|
|
|
|
if (!in_array($type, Ticketevent::getEventTypes())) {
|
|
|
|
return new NullDataStore();
|
|
|
|
}
|
|
|
|
|
|
|
|
$ticketEvent = new Ticketevent();
|
|
|
|
$ticketEvent->setProperties([
|
|
|
|
'type' => $type
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $ticketEvent;
|
|
|
|
}
|
|
|
|
|
2017-01-15 05:36:04 +01:00
|
|
|
public static function getProps() {
|
2016-09-29 19:34:20 +02:00
|
|
|
return [
|
|
|
|
'type',
|
|
|
|
'content',
|
|
|
|
'file',
|
|
|
|
'authorUser',
|
|
|
|
'authorStaff',
|
2018-09-28 02:19:34 +02:00
|
|
|
'date',
|
2019-06-27 03:04:56 +02:00
|
|
|
'private',
|
|
|
|
'editedContent'
|
2016-09-29 19:34:20 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAuthor() {
|
|
|
|
if($this->authorUser) {
|
|
|
|
return $this->authorUser;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($this->authorStaff) {
|
|
|
|
return $this->authorStaff;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new NullDataStore();
|
|
|
|
}
|
2019-06-27 03:04:56 +02:00
|
|
|
|
|
|
|
public static function getTicketEvent($value, $property = 'id') {
|
|
|
|
return parent::getDataStore($value, $property);
|
|
|
|
}
|
2017-01-03 22:52:18 +01:00
|
|
|
|
|
|
|
public function toArray() {
|
2017-03-29 23:46:26 +02:00
|
|
|
$user = ($this->authorStaff) ? $this->authorStaff : $this->authorUser;
|
2017-01-03 22:52:18 +01:00
|
|
|
|
|
|
|
return [
|
|
|
|
'type' => $this->type,
|
|
|
|
'ticketNumber' => $this->ticket->ticketNumber,
|
|
|
|
'author' => [
|
2017-03-29 23:46:26 +02:00
|
|
|
'name' => $user ? $user->name : null,
|
2017-01-05 17:31:09 +01:00
|
|
|
'staff' => $user instanceOf Staff,
|
2019-02-03 20:47:29 +01:00
|
|
|
'id' => $user ? $user->id : null,
|
|
|
|
'customfields' => $user->xownCustomfieldvalueList ? $user->xownCustomfieldvalueList->toArray() : [],
|
2019-06-27 03:04:56 +02:00
|
|
|
],
|
|
|
|
'edited' => $this->editedContent
|
2017-01-03 22:52:18 +01:00
|
|
|
];
|
|
|
|
}
|
2018-09-28 02:19:34 +02:00
|
|
|
}
|