New audit trail records are returned in the API response

master
Mike Koch 7 years ago
parent 0670d74c1e
commit c6f4e4ce3e
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -0,0 +1,24 @@
<?php
namespace BusinessLogic\Tickets;
class AuditTrail extends \BaseClass {
/* @var $id int */
public $id;
/* @var $entityId int */
public $entityId;
/* @var $entityType string */
public $entityType;
/* @var $languageKey string */
public $languageKey;
/* @var $date string */
public $date;
/* @var $replacementValues string[] */
public $replacementValues;
}

@ -0,0 +1,8 @@
<?php
namespace BusinessLogic\Tickets;
class AuditTrailEntityType extends \BaseClass {
const TICKET = 'TICKET';
}

@ -4,7 +4,7 @@ namespace BusinessLogic\Tickets;
class Ticket extends \BaseClass { class Ticket extends \BaseClass {
static function fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $heskSettings) { static function fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $auditRecords, $heskSettings) {
$ticket = new Ticket(); $ticket = new Ticket();
$ticket->id = intval($row['id']); $ticket->id = intval($row['id']);
$ticket->trackingId = $row['trackid']; $ticket->trackingId = $row['trackid'];
@ -143,6 +143,7 @@ class Ticket extends \BaseClass {
$replies[$reply->id] = $reply; $replies[$reply->id] = $reply;
} }
$ticket->replies = $replies; $ticket->replies = $replies;
$ticket->auditTrail = $auditRecords;
return $ticket; return $ticket;
} }
@ -309,6 +310,11 @@ class Ticket extends \BaseClass {
*/ */
public $auditTrailHtml; public $auditTrailHtml;
/**
* @var AuditTrail
*/
public $auditTrail;
/** /**
* @var string[] * @var string[]
*/ */

@ -5,6 +5,8 @@ namespace DataAccess\Tickets;
use BusinessLogic\Attachments\AttachmentType; use BusinessLogic\Attachments\AttachmentType;
use BusinessLogic\Tickets\Attachment; use BusinessLogic\Tickets\Attachment;
use BusinessLogic\Tickets\AuditTrail;
use BusinessLogic\Tickets\AuditTrailEntityType;
use BusinessLogic\Tickets\Ticket; use BusinessLogic\Tickets\Ticket;
use BusinessLogic\Tickets\TicketGatewayGeneratedFields; use BusinessLogic\Tickets\TicketGatewayGeneratedFields;
use DataAccess\CommonDao; use DataAccess\CommonDao;
@ -29,7 +31,42 @@ class TicketGateway extends CommonDao {
$repliesRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "replies` WHERE `replyto` = " . intval($id) . " ORDER BY `id` ASC"); $repliesRs = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "replies` WHERE `replyto` = " . intval($id) . " ORDER BY `id` ASC");
$ticket = Ticket::fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $heskSettings); $auditTrailRs = hesk_dbQuery("SELECT `audit`.`id`, `audit`.`language_key`, `audit`.`date`,
`values`.`replacement_index`, `values`.`replacement_value`
FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "audit_trail` AS `audit`
LEFT JOIN `" . hesk_dbEscape($heskSettings['db_pfix']) . "audit_trail_to_replacement_values` AS `values`
ON `audit`.`id` = `values`.`audit_trail_id`
WHERE `entity_type` = 'TICKET' AND `entity_id` = " . intval($id) . "
ORDER BY `audit`.`date` ASC");
$auditRecords = array();
/* @var $currentAuditRecord AuditTrail|null */
$currentAuditRecord = null;
while ($auditRow = hesk_dbFetchAssoc($auditTrailRs)) {
if ($currentAuditRecord == null || $currentAuditRecord->id != $auditRow['id']) {
if ($currentAuditRecord != null) {
$auditRecords[] = $currentAuditRecord;
}
$currentAuditRecord = new AuditTrail();
$currentAuditRecord->id = $auditRow['id'];
$currentAuditRecord->entityId = $id;
$currentAuditRecord->entityType = AuditTrailEntityType::TICKET;
$currentAuditRecord->languageKey = $auditRow['language_key'];
$currentAuditRecord->date = $auditRow['date'];
$currentAuditRecord->replacementValues = array();
}
if ($auditRow['replacement_index'] != null) {
$currentAuditRecord->replacementValues[intval($auditRow['replacement_index'])] = $auditRow['replacement_value'];
}
}
if ($currentAuditRecord != null) {
$auditRecords[] = $currentAuditRecord;
}
$ticket = Ticket::fromDatabaseRow($row, $linkedTicketsRs, $repliesRs, $auditRecords, $heskSettings);
$this->close(); $this->close();

74
api/composer.lock generated

@ -155,7 +155,7 @@
"docblock", "docblock",
"parser" "parser"
], ],
"time": "2017-07-22T11:08:38+00:00" "time": "2017-07-22 11:08:38"
}, },
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
@ -231,7 +231,7 @@
"cache", "cache",
"caching" "caching"
], ],
"time": "2017-08-25T06:51:37+00:00" "time": "2017-08-25 06:51:37"
}, },
{ {
"name": "doctrine/lexer", "name": "doctrine/lexer",
@ -285,7 +285,7 @@
"lexer", "lexer",
"parser" "parser"
], ],
"time": "2017-07-24T09:37:08+00:00" "time": "2017-07-24 09:37:08"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -401,7 +401,7 @@
"keywords": [ "keywords": [
"promise" "promise"
], ],
"time": "2017-05-20T23:14:18+00:00" "time": "2017-05-20 23:14:18"
}, },
{ {
"name": "guzzlehttp/psr7", "name": "guzzlehttp/psr7",
@ -466,7 +466,7 @@
"uri", "uri",
"url" "url"
], ],
"time": "2017-07-17T09:11:21+00:00" "time": "2017-07-17 09:11:21"
}, },
{ {
"name": "mailgun/mailgun-php", "name": "mailgun/mailgun-php",
@ -765,7 +765,7 @@
"http", "http",
"httplug" "httplug"
], ],
"time": "2017-08-05T15:50:10+00:00" "time": "2017-08-05 15:50:10"
}, },
{ {
"name": "php-http/curl-client", "name": "php-http/curl-client",
@ -883,7 +883,7 @@
"message", "message",
"psr7" "psr7"
], ],
"time": "2017-09-13T14:06:45+00:00" "time": "2017-09-13 14:06:45"
}, },
{ {
"name": "php-http/guzzle6-adapter", "name": "php-http/guzzle6-adapter",
@ -943,7 +943,7 @@
"Guzzle", "Guzzle",
"http" "http"
], ],
"time": "2017-05-29T15:06:15+00:00" "time": "2017-05-29 15:06:15"
}, },
{ {
"name": "php-http/httplug", "name": "php-http/httplug",
@ -999,7 +999,7 @@
"client", "client",
"http" "http"
], ],
"time": "2017-08-18T18:51:51+00:00" "time": "2017-08-18 18:51:51"
}, },
{ {
"name": "php-http/message", "name": "php-http/message",
@ -1071,7 +1071,7 @@
"message", "message",
"psr-7" "psr-7"
], ],
"time": "2017-07-05T06:40:53+00:00" "time": "2017-07-05 06:40:53"
}, },
{ {
"name": "php-http/message-factory", "name": "php-http/message-factory",
@ -1121,7 +1121,7 @@
"stream", "stream",
"uri" "uri"
], ],
"time": "2016-02-03T08:16:31+00:00" "time": "2016-02-03 08:16:31"
}, },
{ {
"name": "php-http/multipart-stream-builder", "name": "php-http/multipart-stream-builder",
@ -1178,7 +1178,7 @@
"multipart stream", "multipart stream",
"stream" "stream"
], ],
"time": "2017-05-21T18:01:57+00:00" "time": "2017-05-21 18:01:57"
}, },
{ {
"name": "php-http/promise", "name": "php-http/promise",
@ -1228,7 +1228,7 @@
"keywords": [ "keywords": [
"promise" "promise"
], ],
"time": "2016-01-28T07:54:12+00:00" "time": "2016-01-28 07:54:12"
}, },
{ {
"name": "phpmailer/phpmailer", "name": "phpmailer/phpmailer",
@ -1354,7 +1354,7 @@
"container-interop", "container-interop",
"psr" "psr"
], ],
"time": "2017-06-28T15:35:32+00:00" "time": "2017-06-28 15:35:32"
}, },
{ {
"name": "psr/http-message", "name": "psr/http-message",
@ -1404,7 +1404,7 @@
"request", "request",
"response" "response"
], ],
"time": "2016-08-06T14:39:51+00:00" "time": "2016-08-06 14:39:51"
}, },
{ {
"name": "symfony/options-resolver", "name": "symfony/options-resolver",
@ -1458,7 +1458,7 @@
"configuration", "configuration",
"options" "options"
], ],
"time": "2017-08-03T09:34:20+00:00" "time": "2017-08-03 09:34:20"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
@ -1508,7 +1508,7 @@
"check", "check",
"validate" "validate"
], ],
"time": "2016-11-23T20:04:41+00:00" "time": "2016-11-23 20:04:41"
}, },
{ {
"name": "zendframework/zend-code", "name": "zendframework/zend-code",
@ -1614,7 +1614,7 @@
"events", "events",
"zf2" "zf2"
], ],
"time": "2017-07-11T19:19:12+00:00" "time": "2017-07-11 19:19:12"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -1710,7 +1710,7 @@
"object", "object",
"object graph" "object graph"
], ],
"time": "2017-04-12T18:52:22+00:00" "time": "2017-04-12 18:52:22"
}, },
{ {
"name": "phar-io/manifest", "name": "phar-io/manifest",
@ -1765,7 +1765,7 @@
} }
], ],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"time": "2017-04-07T07:07:10+00:00" "time": "2017-04-07 07:07:10"
}, },
{ {
"name": "phar-io/version", "name": "phar-io/version",
@ -2021,7 +2021,7 @@
"spy", "spy",
"stub" "stub"
], ],
"time": "2017-09-04T11:05:03+00:00" "time": "2017-09-04 11:05:03"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@ -2085,7 +2085,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-08-25T06:32:04+00:00" "time": "2017-08-25 06:32:04"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -2132,7 +2132,7 @@
"filesystem", "filesystem",
"iterator" "iterator"
], ],
"time": "2016-10-03T07:40:28+00:00" "time": "2016-10-03 07:40:28"
}, },
{ {
"name": "phpunit/php-text-template", "name": "phpunit/php-text-template",
@ -2222,7 +2222,7 @@
"keywords": [ "keywords": [
"timer" "timer"
], ],
"time": "2017-03-07T15:42:04+00:00" "time": "2017-03-07 15:42:04"
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
@ -2271,7 +2271,7 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"time": "2017-08-20T05:47:52+00:00" "time": "2017-08-20 05:47:52"
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
@ -2414,7 +2414,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"time": "2017-08-03T14:08:16+00:00" "time": "2017-08-03 14:08:16"
}, },
{ {
"name": "sebastian/code-unit-reverse-lookup", "name": "sebastian/code-unit-reverse-lookup",
@ -2459,7 +2459,7 @@
], ],
"description": "Looks up which function or method a line of code belongs to", "description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04T10:23:55+00:00" "time": "2017-03-04 10:23:55"
}, },
{ {
"name": "sebastian/comparator", "name": "sebastian/comparator",
@ -2523,7 +2523,7 @@
"compare", "compare",
"equality" "equality"
], ],
"time": "2017-08-20T14:03:32+00:00" "time": "2017-08-20 14:03:32"
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
@ -2575,7 +2575,7 @@
"keywords": [ "keywords": [
"diff" "diff"
], ],
"time": "2017-08-03T08:09:46+00:00" "time": "2017-08-03 08:09:46"
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
@ -2625,7 +2625,7 @@
"environment", "environment",
"hhvm" "hhvm"
], ],
"time": "2017-07-01T08:51:00+00:00" "time": "2017-07-01 08:51:00"
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
@ -2692,7 +2692,7 @@
"export", "export",
"exporter" "exporter"
], ],
"time": "2017-04-03T13:19:02+00:00" "time": "2017-04-03 13:19:02"
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
@ -2743,7 +2743,7 @@
"keywords": [ "keywords": [
"global state" "global state"
], ],
"time": "2017-04-27T15:39:26+00:00" "time": "2017-04-27 15:39:26"
}, },
{ {
"name": "sebastian/object-enumerator", "name": "sebastian/object-enumerator",
@ -2790,7 +2790,7 @@
], ],
"description": "Traverses array structures and object graphs to enumerate all referenced objects", "description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/", "homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-08-03T12:35:26+00:00" "time": "2017-08-03 12:35:26"
}, },
{ {
"name": "sebastian/object-reflector", "name": "sebastian/object-reflector",
@ -2835,7 +2835,7 @@
], ],
"description": "Allows reflection of object attributes, including inherited and non-public ones", "description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/", "homepage": "https://github.com/sebastianbergmann/object-reflector/",
"time": "2017-03-29T09:07:27+00:00" "time": "2017-03-29 09:07:27"
}, },
{ {
"name": "sebastian/recursion-context", "name": "sebastian/recursion-context",
@ -2888,7 +2888,7 @@
], ],
"description": "Provides functionality to recursively process PHP variables", "description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context", "homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2017-03-07T15:09:59+00:00" "time": "2017-03-07 15:09:59"
}, },
{ {
"name": "sebastian/resource-operations", "name": "sebastian/resource-operations",
@ -2930,7 +2930,7 @@
], ],
"description": "Provides a list of PHP built-in functions that operate on resources", "description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations", "homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2016-10-03T07:43:09+00:00" "time": "2016-10-03 07:43:09"
}, },
{ {
"name": "sebastian/version", "name": "sebastian/version",
@ -2973,7 +2973,7 @@
], ],
"description": "Library that helps with managing the version number of Git-hosted PHP projects", "description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version", "homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03T07:35:21+00:00" "time": "2016-10-03 07:35:21"
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",

Loading…
Cancel
Save