* Fix GET builds and projects of API.
This commit is contained in:
@@ -24,14 +24,14 @@ class buildEntry extends Entry
|
||||
$control->view($buildID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->status) and $data->status == 'success') return $this->send(200, $data->data->build);
|
||||
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->build, 'stories:idList,bugs:idList,deleted:bool'));
|
||||
|
||||
/* Exception handling. */
|
||||
if(isset($data->status) and $data->status == 'fail')
|
||||
{
|
||||
if($data->message == '404 Not found') return $this->send404();
|
||||
else return $this->sendError(400, $data->message);
|
||||
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
|
||||
}
|
||||
|
||||
$this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class buildsEntry extends entry
|
||||
{
|
||||
foreach($builds as $build)
|
||||
{
|
||||
$result[] = $build;
|
||||
$result[] = $this->format($build, 'bugs:idList,stories:idList,deleted:bool');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,14 @@ 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);
|
||||
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
|
||||
|
||||
if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->project, 'begin:date,end:date,realBegan:date,realEnd:date,openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,deleted:bool'));
|
||||
if(isset($data->status) and $data->status == 'fail')
|
||||
{
|
||||
if(isset($data->code) and $data->code == 404) $this->send404();
|
||||
return $this->sendError(400, $data->message);
|
||||
}
|
||||
|
||||
$this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
@@ -14,13 +14,16 @@ class projectsEntry extends entry
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get()
|
||||
public function get($programID = 0)
|
||||
{
|
||||
if(!$programID) $programID = $this->param('program', 0);
|
||||
|
||||
$control = $this->loadController('project', 'browse');
|
||||
$control->browse(0, $this->param('status', 'all'), 0, $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$control->browse($programID, $this->param('status', 'all'), 0, $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
|
||||
+3
-2
@@ -33,8 +33,9 @@ $routes['/stories/:id/change'] = 'storyChange';
|
||||
$routes['/products/:id/bugs'] = 'bugs';
|
||||
$routes['/bugs/:id'] = 'bug';
|
||||
|
||||
$routes['/projects'] = 'projects';
|
||||
$routes['/projects/:id'] = 'project';
|
||||
$routes['/programs/:id/projects'] = 'projects';
|
||||
$routes['/projects'] = 'projects';
|
||||
$routes['/projects/:id'] = 'project';
|
||||
|
||||
$routes['/projects/:project/executions'] = 'executions';
|
||||
$routes['/executions'] = 'executions';
|
||||
|
||||
@@ -534,6 +534,16 @@ class baseEntry
|
||||
return $value;
|
||||
case 'bool':
|
||||
return boolval($value) ? true : false;
|
||||
case 'idList':
|
||||
$values = explode(',', $value);
|
||||
if(empty($values)) return array();
|
||||
|
||||
$idList = array();
|
||||
foreach($values as $val)
|
||||
{
|
||||
if($val !== '') $idList[] = (int) $val;
|
||||
}
|
||||
return $idList;
|
||||
default:
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ class build extends control
|
||||
$build = $this->build->getByID($buildID, true);
|
||||
if(!$build)
|
||||
{
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found'));
|
||||
die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
}
|
||||
$this->session->project = $build->project;
|
||||
|
||||
@@ -623,10 +623,11 @@ class project extends control
|
||||
public function view($projectID = 0)
|
||||
{
|
||||
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'));
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found'));
|
||||
die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user