diff --git a/api/v1/entries/bug.php b/api/v1/entries/bug.php index 2e79f9889a..46deccc7d1 100644 --- a/api/v1/entries/bug.php +++ b/api/v1/entries/bug.php @@ -91,6 +91,11 @@ class bugEntry extends entry $bug->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->bug); + $preAndNext = $data->data->preAndNext; + $bug->preAndNext = array(); + $bug->preAndNext['pre'] = $preAndNext->pre ? $preAndNext->pre->id : ''; + $bug->preAndNext['next'] = $preAndNext->next ? $preAndNext->next->id : ''; + $this->send(200, $this->format($bug, 'activatedDate:time,openedDate:time,assignedDate:time,resolvedDate:time,closedDate:time,lastEditedDate:time,deadline:date,deleted:bool')); } diff --git a/api/v1/entries/doc.php b/api/v1/entries/doc.php index 7be2c0d40b..6d8e2e57ed 100644 --- a/api/v1/entries/doc.php +++ b/api/v1/entries/doc.php @@ -44,6 +44,11 @@ class docEntry extends entry $doc->addedBy = zget($usersWithAvatar, $doc->addedBy); } + $preAndNext = $data->data->preAndNext; + $doc->preAndNext = array(); + $doc->preAndNext['pre'] = $preAndNext->pre ? $preAndNext->pre->id : ''; + $doc->preAndNext['next'] = $preAndNext->next ? $preAndNext->next->id : ''; + $this->send(200, $this->format($doc, 'addedDate:time,assignedDate:date,editedDate:time')); } diff --git a/api/v1/entries/story.php b/api/v1/entries/story.php index 87b51ba6aa..f2f04d0723 100644 --- a/api/v1/entries/story.php +++ b/api/v1/entries/story.php @@ -105,6 +105,11 @@ class storyEntry extends Entry $story->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->story); + $preAndNext = $data->data->preAndNext; + $story->preAndNext = array(); + $story->preAndNext['pre'] = $preAndNext->pre ? $preAndNext->pre->id : ''; + $story->preAndNext['next'] = $preAndNext->next ? $preAndNext->next->id : ''; + $this->send(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time')); } diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index a900057719..2728fc895a 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -99,6 +99,11 @@ class taskEntry extends Entry $task->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->task); + $preAndNext = $data->data->preAndNext; + $task->preAndNext = array(); + $task->preAndNext['pre'] = $preAndNext->pre ? $preAndNext->pre->id : ''; + $task->preAndNext['next'] = $preAndNext->next ? $preAndNext->next->id : ''; + $this->send(200, $this->format($task, 'openedDate:time,assignedDate:time,realStarted:time,finishedDate:time,canceledDate:time,closedDate:time,lastEditedDate:time,deleted:bool')); } diff --git a/module/common/model.php b/module/common/model.php index d6c7678326..ab3e1d7e8f 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1845,13 +1845,18 @@ EOD; $typeOnlyCondition = $type . 'OnlyCondition'; $queryCondition = $this->session->$queryCondition; + $preAndNextObject = new stdClass(); + $preAndNextObject->pre = ''; + $preAndNextObject->next = ''; + if(empty($queryCondition)) return $preAndNextObject; + $table = $this->config->objectTables[$type]; $orderBy = $type . 'OrderBy'; $orderBy = $this->session->$orderBy; - if(empty($queryCondition) or $this->session->$typeOnlyCondition) + if($this->session->$typeOnlyCondition) { $sql = $this->dao->select('*')->from($table) - ->beginIF($queryCondition != false)->where($queryCondition)->fi() + ->where($queryCondition) ->beginIF($orderBy != false)->orderBy($orderBy)->fi() ->get(); } @@ -1879,10 +1884,6 @@ EOD; $existsObjectList = $this->session->$objectIdListKey; } - $preAndNextObject = new stdClass(); - $preAndNextObject->pre = ''; - $preAndNextObject->next = ''; - $preObj = false; if(isset($existsObjectList['objectList'])) {