* Add API 404 handler for product and project.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user