From 1627f130449fd12a2fae72bc2bf939cdc01ea2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=94=E5=93=A5?= Date: Tue, 25 Sep 2018 12:14:53 +0800 Subject: [PATCH] * Task#4796. --- module/bug/control.php | 16 ++++++++++++++-- www/api.php | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index f145caaa5d..292476543b 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -294,6 +294,8 @@ class bug extends control $this->action->create('todo', $output['todoID'], 'finished', '', "BUG:$bugID"); } + if($this->viewType == 'json') $this->send(array('status' => 'success', 'data' => $bugID)); + $location = $this->createLink('bug', 'browse', "productID={$this->post->product}&branch=$branch&type=byModule¶m={$this->post->module}"); $response['locate'] = isset($_SESSION['bugList']) ? $this->session->bugList : $location; $this->send($response); @@ -577,7 +579,17 @@ class bug extends control if($comment == false) { $changes = $this->bug->update($bugID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) + { + if($this->viewType == 'json') + { + $this->send(array('status' => 'error', 'message' => dao::getError())); + } + else + { + die(js::error(dao::getError())); + } + } $files = $this->loadModel('file')->saveUpload('bug', $bugID); } if($this->post->comment != '' or !empty($changes) or !empty($files)) @@ -588,7 +600,7 @@ class bug extends control $actionID = $this->action->create('bug', $bugID, $action, $fileAction . $this->post->comment); $this->action->logHistory($actionID, $changes); } - + if($this->viewType == 'json') $this->send(array('status' => 'success', 'data' => $bugID)); $bug = $this->bug->getById($bugID); if($bug->toTask != 0) { diff --git a/www/api.php b/www/api.php index 565bf7aeb2..abe85d249b 100644 --- a/www/api.php +++ b/www/api.php @@ -44,8 +44,8 @@ $common->checkPriv(); $app->loadModule(); $output = json_decode(ob_get_clean()); -$data = new stdClass(); -$data->status = $output->status; +$data = new stdClass(); +$data->status = isset($output->status) ? $output->status : $output->result; if(isset($output->message)) $data->message = $output->message; if(isset($output->data)) $data->data = json_decode($output->data); $output = json_encode($data);