From 3fbc826d42dd4f12bdf8da07e2ba19f85e32345d Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 31 Aug 2021 15:24:12 +0800 Subject: [PATCH] * Format user detail and date. --- api/v1/entries/productissue.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/api/v1/entries/productissue.php b/api/v1/entries/productissue.php index 4f4c6f496f..f6a92de5bb 100644 --- a/api/v1/entries/productissue.php +++ b/api/v1/entries/productissue.php @@ -135,7 +135,7 @@ class productIssueEntry extends entry $actions = $this->loadModel('action')->getList($type, $id); - $issue->comments = $this->processActions($type, $actions); + $issue->comments = array_values($this->processActions($type, $actions)); /** * Get all users in issues so that we can bulk get user detail later. @@ -176,7 +176,7 @@ class productIssueEntry extends entry $accountsList = array(); foreach($actions as $action) { - $accountsListp[] = $action->actor; + $accountsList[] = $action->actor; ob_start(); $this->action->printAction($action); $action->title = ob_get_contents(); @@ -188,16 +188,26 @@ class productIssueEntry extends entry { ob_start(); $this->action->printChanges($action->objectType, $action->history); - $action->body_html = json_encode(ob_get_contents()); + $action->body_html = ob_get_contents(); ob_clean(); } if(!empty($action->comment)) { $comment = strip_tags($action->comment) == $action->comment ? nl2br($action->comment) : $action->comment; - $action->body_html = json_encode("
{$comment}
"); + $action->body_html = "
{$comment}
"; } } + + /* Format user detail and date. */ + $accountsList = array_unique($accountsList); + $userDetails = $this->loadModel('user')->getUserDetailsForAPI($accountsList); + foreach($actions as $action) + { + $action->actor = $userDetails[$action->actor]; + $action->date = gmdate("Y-m-d\TH:i:s\Z", strtotime($action->date)); + } + return $actions; } }