+ Fix project entry points of API.
This commit is contained in:
+23
-10
@@ -20,27 +20,40 @@ class projectEntry extends entry
|
||||
$this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
public function put($productID)
|
||||
public function put($projectID)
|
||||
{
|
||||
$oldProduct = $this->loadModel('product')->getByID($productID);
|
||||
$oldProject = $this->loadModel('project')->getByID($projectID);
|
||||
$linkedProducts = $this->project->getProducts($projectID);
|
||||
|
||||
/* Set $_POST variables. */
|
||||
$fields = 'program,line,name,PO,QD,RD,type,desc,whitelist,status,acl';
|
||||
$this->batchSetPost($fields, $oldProduct);
|
||||
$fields = 'name,begin,end,acl,parent,desc,PM,whitelist';
|
||||
$this->batchSetPost($fields, $oldProject);
|
||||
|
||||
$control = $this->loadController('product', 'edit');
|
||||
$control->edit($productID);
|
||||
$products = array();
|
||||
$plans = array();
|
||||
foreach($linkedProducts as $product)
|
||||
{
|
||||
$products[] = $product->id;
|
||||
$plans[] = $product->plan;
|
||||
}
|
||||
$this->setPost('products', $products);
|
||||
$this->setPost('plans', $plans);
|
||||
|
||||
$control = $this->loadController('project', 'edit');
|
||||
$control->edit($projectID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
if(!isset($data->result)) return $this->sendError(400, 'error');
|
||||
|
||||
$this->sendSuccess(200, 'success');
|
||||
$project = $this->project->getByID($projectID);
|
||||
$this->send(200, $project);
|
||||
}
|
||||
|
||||
public function delete($productID)
|
||||
public function delete($projectID)
|
||||
{
|
||||
$control = $this->loadController('product', 'delete');
|
||||
$control->delete($productID, 'yes');
|
||||
$control = $this->loadController('project', 'delete');
|
||||
$control->delete($projectID, 'yes');
|
||||
|
||||
$this->getData();
|
||||
$this->sendSuccess(200, 'success');
|
||||
|
||||
@@ -1416,12 +1416,19 @@ class project extends control
|
||||
|
||||
/* Delete the execution under the project. */
|
||||
$executionIdList = $this->loadModel('execution')->getByProject($projectID);
|
||||
if(empty($executionIdList)) die(js::reload('parent'));
|
||||
|
||||
if(empty($executionIdList))
|
||||
{
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
|
||||
$this->dao->update(TABLE_EXECUTION)->set('deleted')->eq(1)->where('id')->in(array_keys($executionIdList))->exec();
|
||||
foreach($executionIdList as $executionID => $execution) $this->action->create('execution', $executionID, 'deleted', '', ACTIONMODEL::CAN_UNDELETED);
|
||||
$this->user->updateUserView($executionIdList, 'sprint');
|
||||
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
|
||||
|
||||
$this->session->set('project', '');
|
||||
die(js::reload('parent'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user