diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index 69e8704fda..524abf92d1 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -14,6 +14,7 @@ class productEntry extends Entry $control->view($productID); $data = $this->getData(); + if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404(); if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->product, 'createdDate:time')); if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); diff --git a/api/v1/entries/project.php b/api/v1/entries/project.php index 1ce4d04db8..c8af26898a 100644 --- a/api/v1/entries/project.php +++ b/api/v1/entries/project.php @@ -14,6 +14,7 @@ class projectEntry extends entry $control->view($projectID); $data = $this->getData(); + if(!$data or (isset($data->status) and $data->message == '404 Not found')) return $this->send404(); if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time')); if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); diff --git a/module/product/control.php b/module/product/control.php index 443ba574e3..0bbc0d90a3 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -687,7 +687,12 @@ class product extends control { $productID = (int)$productID; $product = $this->product->getStatByID($productID); - if(!$product) die(js::error($this->lang->notFound) . js::locate('back')); + + if(!$product) + { + if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found')); + die(js::error($this->lang->notFound) . js::locate('back')); + } $product->desc = $this->loadModel('file')->setImgSize($product->desc); $this->product->setMenu($productID); diff --git a/module/project/control.php b/module/project/control.php index 9ba6add129..ca3799d002 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -560,9 +560,13 @@ class project extends control */ public function view($projectID = 0) { - $projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram()); - $project = $this->project->getById($projectID); - if(empty($project) || strpos('scrum,waterfall', $project->model) === false) die(js::error($this->lang->notFound) . js::locate('back')); + if(!defined('RUN_MODE') || RUN_MODE != 'api') $projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram()); + $project = $this->project->getById($projectID); + if(empty($project) || strpos('scrum,waterfall', $project->model) === false) + { + if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found')); + die(js::error($this->lang->notFound) . js::locate('back')); + } $this->project->setMenu($projectID);