+ Add user and bug api.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的bug资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The bug entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class bugEntry extends entry
|
||||
{
|
||||
public function get($bugID)
|
||||
{
|
||||
$control = $this->loadController('bug', 'view');
|
||||
$control->view($bugID);
|
||||
|
||||
$data = $this->getData();
|
||||
$bug = $data->data->bug;
|
||||
$this->send(200, $bug);
|
||||
}
|
||||
|
||||
public function put($bugID)
|
||||
{
|
||||
$oldBug = $this->loadModel('bug')->getByID($bugID);
|
||||
|
||||
/* Set $_POST variables. */
|
||||
$fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,resolvedBy,closedBy,resolution,product,plan,task';
|
||||
$this->batchSetPost($fields, $oldBug);
|
||||
|
||||
$control = $this->loadController('bug', 'edit');
|
||||
$control->edit($bugID);
|
||||
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
if(!isset($data->status)) return $this->sendError(400, 'error');
|
||||
|
||||
$bug = $this->bug->getByID($bugID);
|
||||
$this->send(200, $bug);
|
||||
}
|
||||
|
||||
public function delete($bugID)
|
||||
{
|
||||
$control = $this->loadController('bug', 'delete');
|
||||
$control->delete($bugID, 'yes');
|
||||
|
||||
$this->getData();
|
||||
$this->sendSuccess(200, 'success');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的bugs资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The bugs entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class bugsEntry extends entry
|
||||
{
|
||||
public function get($productID)
|
||||
{
|
||||
$control = $this->loadController('bug', 'browse');
|
||||
$control->browse($productID);
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
$bugs = $data->data->bugs;
|
||||
$result = array();
|
||||
foreach($bugs as $bug)
|
||||
{
|
||||
$result[] = $bug;
|
||||
}
|
||||
return $this->send(200, $result);
|
||||
}
|
||||
if(isset($data->status) and $data->status == 'fail')
|
||||
{
|
||||
return $this->sendError(400, $data->message);
|
||||
}
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
public function post($productID)
|
||||
{
|
||||
$fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$this->setPost('product', $productID);
|
||||
|
||||
$control = $this->loadController('bug', 'create');
|
||||
$this->requireFields('title,pri,severity,type,openedBuild');
|
||||
|
||||
$control->create($productID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);
|
||||
|
||||
$bug = $this->loadModel('bug')->getByID($data->id);
|
||||
|
||||
$this->send(200, $bug);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的execution资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The execution entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class executionEntry extends Entry
|
||||
{
|
||||
public function get($executionID)
|
||||
{
|
||||
$control = $this->loadController('execution', 'view');
|
||||
$control->view($executionID);
|
||||
|
||||
$data = $this->getData();
|
||||
$execution = $data->data->execution;
|
||||
$this->send(200, $execution);
|
||||
}
|
||||
|
||||
public function put($executionID)
|
||||
{
|
||||
$oldExecution = $this->loadModel('execution')->getByID($executionID);
|
||||
|
||||
/* Set $_POST variables. */
|
||||
$fields = 'project,code,name,begin,end,lifetime,desc,days,acl';
|
||||
$this->batchSetPost($fields, $oldExecution);
|
||||
|
||||
$this->setPost('whitelist', $this->request('whitelist', explode(',', $oldExecution->whitelist)));
|
||||
|
||||
$control = $this->loadController('execution', 'edit');
|
||||
$control->edit($executionID);
|
||||
|
||||
$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');
|
||||
|
||||
$execution = $this->execution->getByID($executionID);
|
||||
$this->sendSuccess(200, $execution);
|
||||
}
|
||||
|
||||
public function delete($executionID)
|
||||
{
|
||||
$control = $this->loadController('execution', 'delete');
|
||||
$control->delete($executionID, 'true');
|
||||
|
||||
$this->getData();
|
||||
$this->sendSuccess(200, 'success');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的executions资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The executions entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class executionsEntry extends entry
|
||||
{
|
||||
public function get($projectID = 0)
|
||||
{
|
||||
$control = $this->loadController('execution', 'all');
|
||||
$control->all($this->param('status', 'all'), $this->param('project', $projectID));
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success') return $this->send(200, $data->data->executionStats);
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
public function post($projectID = 0)
|
||||
{
|
||||
$fields = 'project,code,name,begin,end,lifetime,desc,days';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$projectID = $this->param('project', $projectID);
|
||||
$this->setPost('project', $projectID);
|
||||
$this->setPost('acl', $this->request('acl', 'private'));
|
||||
$this->setPost('whitelist', $this->request('whitelist', array()));
|
||||
$this->setPost('products', $this->request('products', array()));
|
||||
$this->setPost('plans', $this->request('plans', array()));
|
||||
|
||||
$control = $this->loadController('execution', 'create');
|
||||
$this->requireFields('name,code,begin,end,days');
|
||||
|
||||
$control->create($projectID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$execution = $this->loadModel('execution')->getByID($data->id);
|
||||
|
||||
$this->send(200, $execution);
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@ class taskEntry extends Entry
|
||||
$control->edit($taskID);
|
||||
|
||||
$this->getData();
|
||||
$this->sendSuccess(200, 'success');
|
||||
$task = $this->task->getByID($taskID);
|
||||
$this->send(200, $task);
|
||||
}
|
||||
|
||||
public function delete($taskID)
|
||||
|
||||
@@ -23,7 +23,7 @@ class taskAssignToEntry extends Entry
|
||||
$data = $this->getData();
|
||||
if($data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$task = $this->loadModel('task')->getByID($dataID);
|
||||
$task = $this->loadModel('task')->getByID($taskID);
|
||||
|
||||
$this->send(200, $task);
|
||||
}
|
||||
|
||||
@@ -8,13 +8,31 @@
|
||||
*/
|
||||
class tasksEntry extends entry
|
||||
{
|
||||
public function get()
|
||||
public function get($executionID)
|
||||
{
|
||||
$control = $this->loadController('execution', 'task');
|
||||
$control->task($executionID);
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
$tasks = $data->data->tasks;
|
||||
$result = array();
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
$result[] = $task;
|
||||
}
|
||||
return $this->send(200, $result);
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
public function post($executionID)
|
||||
{
|
||||
$fields = 'name,type,assignedTo,estimate,story,parent,execution,module';
|
||||
$fields = 'name,type,assignedTo,estimate,story,parent,execution,module,pri,desc';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$control = $this->loadController('task', 'create');
|
||||
@@ -27,6 +45,6 @@ class tasksEntry extends entry
|
||||
|
||||
$task = $this->loadModel('task')->getByID($data->id);
|
||||
|
||||
$this->send(200, $task);
|
||||
$this->send(201, $task);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class taskStartEntry extends Entry
|
||||
$data = $this->getData();
|
||||
if($data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$task = $this->loadModel('task')->getByID($dataID);
|
||||
$task = $this->loadModel('task')->getByID($taskID);
|
||||
|
||||
$this->send(200, $task);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的user资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The user entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class userEntry extends Entry
|
||||
{
|
||||
public function get($userID = 0)
|
||||
{
|
||||
$control = $this->loadController('user', 'profile');
|
||||
$control->profile($userID);
|
||||
|
||||
$data = $this->getData();
|
||||
$user = $data->data->user;
|
||||
unset($user->password);
|
||||
|
||||
$this->send(200, $user);
|
||||
}
|
||||
|
||||
public function put($userID)
|
||||
{
|
||||
$oldUser = $this->loadModel('user')->getByID($userID, 'id');
|
||||
|
||||
/* Set $_POST variables. */
|
||||
$fields = 'account,dept,realname,email,commiter,gender';
|
||||
$this->batchSetPost($fields, $oldUser);
|
||||
|
||||
$this->setPost('password1', $this->request('password', ''));
|
||||
$this->setPost('password2', $this->request('password', ''));
|
||||
$this->setPost('verifyPassword', md5($this->app->user->password . $this->app->session->rand));
|
||||
|
||||
$control = $this->loadController('user', 'edit');
|
||||
$control->edit($userID);
|
||||
|
||||
$this->getData();
|
||||
$user = $this->user->getByID($userID, 'id');
|
||||
unset($user->password);
|
||||
|
||||
$this->send(200, $user);
|
||||
}
|
||||
|
||||
public function delete($userID)
|
||||
{
|
||||
$this->setPost('verifyPassword', md5($this->app->user->password . $this->app->session->rand));
|
||||
|
||||
$control = $this->loadController('user', 'delete');
|
||||
$control->delete($userID);
|
||||
|
||||
$this->getData();
|
||||
$this->sendSuccess(200, 'success');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的users资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The users entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class usersEntry extends entry
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
$control = $this->loadController('company', 'browse');
|
||||
$control->browse();
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
$users = $data->data->users;
|
||||
$result = array();
|
||||
foreach($users as $user)
|
||||
{
|
||||
$result[] = $user;
|
||||
}
|
||||
return $this->send(200, $result);
|
||||
}
|
||||
if(isset($data->status) and $data->status == 'fail')
|
||||
{
|
||||
return $this->sendError(400, $data->message);
|
||||
}
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
public function post()
|
||||
{
|
||||
$fields = 'account,dept,realname,email,commiter,gender';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$this->setPost('password1', $this->request('password'));
|
||||
$this->setPost('password2', $this->request('password'));
|
||||
$this->setPost('passwordStrength', 3);
|
||||
$this->setPost('verifyPassword', md5($this->app->user->password . $this->app->session->rand));
|
||||
|
||||
$control = $this->loadController('user', 'create');
|
||||
$this->requireFields('account,password1,realname');
|
||||
|
||||
$control->create();
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);
|
||||
|
||||
$user = $this->loadModel('user')->getByID($data->id, 'id');
|
||||
unset($user->password);
|
||||
|
||||
$this->send(201, $user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user