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);