Merge branch 'master' into 'sprint/174_hufangzhou_45085'

# Conflicts:
#   module/story/model.php
This commit is contained in:
孙广明
2021-11-29 07:26:45 +00:00
73 changed files with 602 additions and 179 deletions
+68 -2
View File
@@ -9,7 +9,7 @@
* @version 1
* @link http://www.zentao.net
*/
class bugEntry extends entry
class bugEntry extends entry
{
/**
* GET method.
@@ -24,7 +24,73 @@ class bugEntry extends entry
$control->view($bugID);
$data = $this->getData();
$bug = $data->data->bug;
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$bug = $data->data->bug;
/* Set product name */
$bug->productName = $data->data->product->name;
/* Set module title */
$moduleTitle = '';
if(empty($bug->module)) $moduleTitle = '/';
if($bug->module)
{
$modulePath = $data->data->modulePath;
foreach($modulePath as $key => $module)
{
$moduleTitle .= $module->name;
if(isset($modulePath[$key + 1])) $moduleTitle .= '/';
}
}
$bug->moduleTitle = $moduleTitle;
if($bug->openedBy) $bug->openedBy = $this->formatUser($bug->openedBy, $data->data->users);
if($bug->resolvedBy) $bug->resolvedBy = $this->formatUser($bug->resolvedBy, $data->data->users);
if($bug->closedBy) $bug->closedBy = $this->formatUser($bug->closedBy, $data->data->users);
if($bug->lastEditedBy) $bug->lastEditedBy = $this->formatUser($bug->lastEditedBy, $data->data->users);
if($bug->assignedTo)
{
$usersWithAvatar = $this->loadModel('user')->getListByAccounts(array($bug->assignedTo), 'account');
$bug->assignedTo = zget($usersWithAvatar, $bug->assignedTo);
}
$mailto = array();
if($bug->mailto)
{
foreach(explode(',', $bug->mailto) as $account)
{
if(empty($account)) continue;
$mailto[] = $this->formatUser($account, $data->data->users);
}
}
$bug->mailto = $mailto;
$openedBuilds = array();
foreach(explode(',', $bug->openedBuild) as $buildID)
{
if(empty($buildID)) continue;
$openedBuild = new stdclass();
$openedBuild->id = $buildID;
$openedBuild->title = zget($data->data->builds, $buildID, '');
$openedBuilds[] = $openedBuild;
}
$bug->openedBuild = $openedBuilds;
if($bug->resolvedBuild)
{
$resolvedBuild = new stdclass();
$resolvedBuild->id = $bug->resolvedBuild;
$resolvedBuild->title = zget($data->data->builds, $bug->resolvedBuild, '');
$bug->resolvedBuild = $resolvedBuild;
}
$bug->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->bug);
$this->send(200, $this->format($bug, 'activatedDate:time,openedDate:time,assignedDate:time,resolvedDate:time,closedDate:time,lastEditedDate:time,deadline:date,deleted:bool'));
}
+2 -2
View File
@@ -24,7 +24,7 @@ class bugsEntry extends entry
if(empty($productID)) return $this->sendError(400, 'Need product id.');
$control = $this->loadController('bug', 'browse');
$control->browse($productID, $this->param('branch', ''), $this->param('status', 'unclosed'), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
$control->browse($productID, $this->param('branch', 'all'), $this->param('status', ''), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
@@ -59,7 +59,7 @@ class bugsEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => array_values($result)));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+1 -4
View File
@@ -27,10 +27,7 @@ class buildEntry extends Entry
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')
{
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$this->sendError(400, 'error');
}
+2 -5
View File
@@ -28,15 +28,12 @@ class buildsEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$result = array();
foreach($data->data->projectBuilds as $productID => $builds)
{
foreach($builds as $build)
{
$result[] = $this->format($build, 'bugs:idList,stories:idList,deleted:bool');
}
foreach($builds as $build) $result[] = $this->format($build, 'bugs:idList,stories:idList,deleted:bool');
}
return $this->send(200, array('total' => count($result), 'builds' => $result));
+89
View File
@@ -0,0 +1,89 @@
<?php
/**
* The doc entry point of ZenTaoPMS.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class docEntry extends entry
{
/**
* GET method.
*
* @param int $docID
* @access public
* @return void
*/
public function get($docID)
{
$control = $this->loadController('doc', 'view');
$control->view($docID);
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$doc = $data->data->doc;
unset($doc->draft);
if(!empty($doc->files)) $doc->files = array_values((array)$doc->files);
/* Set lib name */
$doc->libName = $data->data->lib->name;
/* Format user for api. */
if($doc->editedBy) $doc->editedBy = $this->formatUser($doc->editedBy, $data->data->users);
if($doc->addedBy)
{
$usersWithAvatar = $this->loadModel('user')->getListByAccounts(array($doc->addedBy), 'account');
$doc->addedBy = zget($usersWithAvatar, $doc->addedBy);
}
$this->send(200, $this->format($doc, 'addedDate:time,assignedDate:date,editedDate:time'));
}
/**
* PUT method.
*
* @param int $storyID
* @access public
* @return void
*/
public function put($storyID)
{
$oldStory = $this->loadModel('story')->getByID($storyID);
/* Set $_POST variables. */
$fields = 'type';
$this->batchSetPost($fields, $oldStory);
$this->setPost('parent', 0);
$control = $this->loadController('story', 'edit');
$control->edit($storyID);
$this->getData();
$story = $this->story->getByID($storyID);
$this->sendSuccess(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
}
/**
* DELETE method.
*
* @param int $storyID
* @access public
* @return void
*/
public function delete($storyID)
{
$control = $this->loadController('story', 'delete');
$control->delete($storyID, 'yes');
$this->getData();
$this->sendSuccess(200, 'success');
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ class executionEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$execution = $this->format($data->data->execution, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,begin:date,end:date,realBegan:date,realEnd:date,deleted:bool');
+1 -1
View File
@@ -59,7 +59,7 @@ class executionBugsEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => array_values($result)));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+41
View File
@@ -0,0 +1,41 @@
<?php
/**
* The execution builds entry point of ZenTaoPMS.
*
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package entries
* @version 1
* @link http://www.zentao.net
*/
class executionBuildsEntry extends entry
{
/**
* GET method.
*
* @param int $executionID
* @access public
* @return void
*/
public function get($executionID = 0)
{
if(empty($executionID)) $executionID = $this->param('execution', 0);
if(empty($executionID)) return $this->sendError(400, "Need execution id.");
$control = $this->loadController('execution', 'build');
$control->build($executionID, $this->param('status', 'all'), $this->param('param', 0), $this->param('order', 't1.date_desc,t1.id_desc'));
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$result = array();
foreach($data->data->executionBuilds as $builds)
{
foreach($builds as $build) $result[] = $this->format($build, 'bugs:idList,stories:idList,deleted:bool');
}
return $this->send(200, array('total' => count($result), 'builds' => $result));
}
}
+1 -1
View File
@@ -42,7 +42,7 @@ class executionCasesEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'cases' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+10 -8
View File
@@ -32,7 +32,7 @@ class executionsEntry extends entry
/* Response */
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$executions = $data->data->executionStats;
$pager = $data->data->pager;
@@ -84,15 +84,17 @@ class executionsEntry extends entry
$this->batchSetPost($fields);
$projectID = $this->param('project', $projectID);
$this->setPost('project', $projectID);
$this->setPost('acl', $this->request('acl', 'private'));
$this->setPost('project', $projectID);
$this->setPost('acl', $this->request('acl', 'private'));
$this->setPost('PO', $this->request('PO', ''));
$this->setPost('PM', $this->request('PM', ''));
$this->setPost('QD', $this->request('QD', ''));
$this->setPost('RD', $this->request('RD', ''));
$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');
$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();
+1 -1
View File
@@ -39,7 +39,7 @@ class executionStoriesEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'stories' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+17
View File
@@ -11,6 +11,23 @@
*/
class fileEntry extends Entry
{
/**
* GET method.
*
* @access public
* @return void
*/
public function get($fileID)
{
$control = $this->loadController('file', 'download');
$control->download($fileID);
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$this->send(200, $data);
}
/**
* PUT method.
*
+1 -4
View File
@@ -27,10 +27,7 @@ class filesEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'error')
{
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$this->send(200, array('id' => $data->id));
}
+1 -1
View File
@@ -30,7 +30,7 @@ class issueEntry extends Entry
$data = $this->getData();
if(!$data or (isset($data->message) 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->issue, 'createdDate:time,editedDate:time,assignedDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$this->sendError(400, 'error');
}
+1 -1
View File
@@ -28,7 +28,7 @@ class issuesEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$pager = $data->data->pager;
$result = array();
+1 -1
View File
@@ -32,7 +32,7 @@ class meetingsEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$pager = $data->data->pager;
$result = array();
+5 -5
View File
@@ -27,13 +27,13 @@ class productEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail')
{
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$product = $this->format($data->data->product, 'createdDate:time');
$this->loadModel('testcase');
$product->caseReview = ($this->config->testcase->needReview or !empty($this->config->testcase->forceReview));
$users = $data->data->users;
$product->PO = $this->formatUser($product->PO, $users);
$product->QD = $this->formatUser($product->QD, $users);
@@ -108,7 +108,7 @@ class productEntry extends Entry
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
$product = $this->product->getByID($productID);
$this->send(200, array('product' => $this->format($product, 'createdDate:time')));
$this->send(200, $this->format($product, 'createdDate:time'));
}
/**
+1 -4
View File
@@ -27,10 +27,7 @@ class productplanEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail')
{
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$plan = $this->format($data->data->plan, 'begin:date,end:date,deleted:bool');
+17 -2
View File
@@ -33,12 +33,27 @@ class productplansEntry extends entry
$result = array();
$plans = $data->data->plans;
$pager = $data->data->pager;
foreach($plans as $plan) $result[] = $plan;
foreach($plans as $plan)
{
if($plan->parent > 0 and isset($result[$plan->parent]))
{
$parentPlan = $result[$plan->parent];
if(!isset($parentPlan->children) or !is_array($parentPlan->children)) $parentPlan->children = array();
$parentPlan->children[] = $plan;
$result[$plan->parent] = $parentPlan;
}
else
{
$result[$plan->id] = $plan;
}
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'plans' => array_values($result)));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+1 -1
View File
@@ -49,7 +49,7 @@ class productProjectsEntry extends entry
return $this->send(200, $data);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
// TODO There is no handle for 401.
return $this->sendError(400, 'error');
+3 -3
View File
@@ -34,7 +34,7 @@ class productsEntry extends entry
/* Response */
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$products = $data->data->products;
@@ -113,7 +113,7 @@ class productsEntry extends entry
$control->create($this->request('program', 0));
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
/* Response */
$product = $this->loadModel('product')->getByID($data->id);
@@ -134,7 +134,7 @@ class productsEntry extends entry
$control->ajaxGetDropMenu($this->request('productID', 0), $this->request('module', 'product'), $this->request('method', 'browse'), $this->request('extra', ''), $this->request('from', ''));
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$dropMenu = array('owner' => array(), 'other' => array(), 'closed' => array());
foreach($data->data->products as $programID => $products)
+56
View File
@@ -11,4 +11,60 @@
*/
class programEntry extends Entry
{
/**
* GET method.
*
* @param int $programID
* @access public
* @return void
*/
public function get($programID)
{
$program = $this->loadModel('program')->getByID($programID);
if(!$program) return $this->send404();
$this->send(200, $this->format($program, 'openedDate:time,realBegan:date,realEnd:date,deleted:bool'));
}
/**
* PUT method.
*
* @param int $programID
* @access public
* @return void
*/
public function put($programID)
{
$oldProgram = $this->loadModel('program')->getByID($programID);
/* Set $_POST variables. */
$fields = 'name,PM,budget,budgetUnit,desc,parent,begin,end,realBegan,realEnd,acl,whitelist';
$this->batchSetPost($fields, $oldProgram);
$this->setPost('parent', $this->request('parent', 0));
$control = $this->loadController('program', 'edit');
$control->edit($programID);
$this->getData();
$program = $this->program->getByID($programID);
$this->send(200, $this->format($program, 'openedDate:time'));
}
/**
* DELETE method.
*
* @param int $programID
* @access public
* @return void
*/
public function delete($programID)
{
$control = $this->loadController('program', 'delete');
$control->delete(0, $programID, 'true');
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
$this->sendSuccess(200, 'success');
}
}
+26 -2
View File
@@ -30,7 +30,7 @@ class programsEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$programs = $data->data->programs;
$progressList = $data->data->progressList;
@@ -72,6 +72,31 @@ class programsEntry extends Entry
return $this->send(200, array('programs' => array_values($result)));
}
/**
* POST method.
*
* @access public
* @return void
*/
public function post()
{
$fields = 'name,PM,budget,budgetUnit,desc,begin,end';
$this->batchSetPost($fields);
$this->setPost('acl', $this->request('acl', 'open'));
$this->setPost('whitelist', $this->request('whitelist', array()));
$control = $this->loadController('program', 'create');
$this->requireFields('name,begin,end');
$control->create($this->request('parent', 0));
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
$program = $this->loadModel('program')->getByID($data->id);
$this->send(201, $this->format($program, 'openedDate:time,whitelist:stringList'));
}
/**
* Get drop menu.
*
@@ -80,7 +105,6 @@ class programsEntry extends Entry
*/
public function getDropMenu()
{
$programs = $this->dao->select('id,name,parent,path,grade,`order`')->from(TABLE_PROJECT)
->where('deleted')->eq('0')
->andWhere('type')->eq('program')
+2 -2
View File
@@ -28,7 +28,7 @@ class projectEntry extends entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$project = $this->format($data->data->project, 'begin:date,end:date,realBegan:date,realEnd:date,openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,deleted:bool');
@@ -114,7 +114,7 @@ class projectEntry extends entry
$control->edit($projectID);
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
if(!isset($data->result)) return $this->sendError(400, 'error');
$project = $this->project->getByID($projectID);
+1 -1
View File
@@ -59,7 +59,7 @@ class projectBugsEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => array_values($result)));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+1 -2
View File
@@ -45,8 +45,7 @@ class projectCasesEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'cases' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
}
+1 -2
View File
@@ -37,8 +37,7 @@ class projectReleasesEntry extends entry
return $this->send(200, array('total' => count($result), 'releases' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+2 -4
View File
@@ -64,9 +64,7 @@ class projectsEntry extends entry
return $this->send(200, $data);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
// TODO There is no handle for 401.
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
@@ -99,7 +97,7 @@ class projectsEntry extends entry
$project = $this->loadModel('project')->getByID($data->id);
$this->send(201, $this->format($project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time'));
$this->send(201, $this->format($project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,budget:int'));
}
/**
+1 -2
View File
@@ -39,8 +39,7 @@ class projectStoriesEntry extends entry
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'stories' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
}
+1 -4
View File
@@ -25,10 +25,7 @@ class releaseEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail')
{
return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$release = $this->format($data->data->release, 'date:date,deleted:bool');
+1 -2
View File
@@ -37,8 +37,7 @@ class releasesEntry extends entry
return $this->send(200, array('total' => count($result), 'releases' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ class riskEntry extends Entry
$data = $this->getData();
if(!$data or (isset($data->message) 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->risk, 'createdDate:time,editedDate:time'));
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$this->sendError(400, 'error');
}
+1 -1
View File
@@ -39,7 +39,7 @@ class risksEntry extends entry
}
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$pager = $data->data->pager;
$result = array();
+1 -3
View File
@@ -55,9 +55,7 @@ class stakeholdersEntry extends entry
return $this->send(200, $data);
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
// TODO There is no handle for 401.
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+2 -2
View File
@@ -28,7 +28,7 @@ class storiesEntry extends entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$stories = $data->data->stories;
$pager = $data->data->pager;
@@ -68,7 +68,7 @@ class storiesEntry extends entry
$control->create($productID);
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);
$story = $this->loadModel('story')->getByID($data->id);
+82 -2
View File
@@ -23,8 +23,88 @@ class storyEntry extends Entry
$control = $this->loadController('story', 'view');
$control->view($storyID);
$data = $this->getData();
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$story = $data->data->story;
if(!empty($story->children)) $story->children = array_values((array)$story->children);
if(isset($story->planTitle)) $story->planTitle = array_values((array)$story->planTitle);
if($story->parent > 0) $story->parentPri = $this->dao->select('pri')->from(TABLE_STORY)->where('id')->eq($story->parent)->fetch('pri');
/* Set product name */
$story->productName = $data->data->product->name;
/* Set module title */
$moduleTitle = '';
if(empty($story->module)) $moduleTitle = '/';
if($story->module)
{
$modulePath = $data->data->modulePath;
foreach($modulePath as $key => $module)
{
$moduleTitle .= $module->name;
if(isset($modulePath[$key + 1])) $moduleTitle .= '/';
}
}
$story->moduleTitle = $moduleTitle;
/* Format user for api. */
if($story->assignedTo) $story->assignedTo = $this->formatUser($story->assignedTo, $data->data->users);
if($story->closedBy) $story->closedBy = $this->formatUser($story->closedBy, $data->data->users);
if($story->lastEditedBy) $story->lastEditedBy = $this->formatUser($story->lastEditedBy, $data->data->users);
if($story->openedBy)
{
$usersWithAvatar = $this->loadModel('user')->getListByAccounts(array($story->openedBy), 'account');
$story->openedBy = zget($usersWithAvatar, $story->openedBy);
}
$mailto = array();
if($story->mailto)
{
foreach(explode(',', $story->mailto) as $account)
{
if(empty($account)) continue;
$mailto[] = $this->formatUser($account, $data->data->users);
}
}
$story->mailto = $mailto;
$reviewedBy = array();
if($story->reviewer)
{
foreach($story->reviewer as $account)
{
if(empty($account)) continue;
$reviewedBy[] = $this->formatUser($account, $data->data->users);
}
}
$story->reviewedBy = $reviewedBy;
$storyTasks = array();
foreach($story->tasks as $executionTasks)
{
foreach($executionTasks as $task)
{
if(!isset($data->data->executions->{$task->execution})) continue;
$storyTasks[] = $this->filterFields($task, 'id,name,type');
}
}
$story->tasks = $storyTasks;
$story->bugs = array();
foreach($data->data->bugs as $bug) $story->bugs[] = $this->filterFields($bug, 'id,title');
$story->cases = array();
foreach($data->data->cases as $case) $story->cases[] = $this->filterFields($case, 'id,title');
$story->requirements = array();
foreach($data->data->relations as $relation) $story->requirements[] = $this->filterFields($relation, 'id,title');
$story->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->story);
$this->send(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time'));
}
@@ -49,7 +129,7 @@ class storyEntry extends Entry
$this->getData();
$story = $this->story->getByID($storyID);
$this->sendSuccess(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
$this->send(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time,deleted:bool'));
}
/**
+4 -3
View File
@@ -35,12 +35,13 @@ class storyChangeEntry extends Entry
}
$control = $this->loadController('story', 'change');
$this->requireFields('title,spec');
$this->requireFields('title,spec,verify');
$control->change($storyID);
$data = $this->getData();
if($data->status == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$story = $this->loadModel('story')->getByID($storyID);
+8 -2
View File
@@ -26,7 +26,7 @@ class taskEntry extends Entry
$data = $this->getData();
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$task = $data->data->task;
@@ -38,6 +38,7 @@ class taskEntry extends Entry
/* Set module title */
$moduleTitle = '';
if(empty($task->module)) $moduleTitle = '/';
if($task->module)
{
$modulePath = $data->data->modulePath;
@@ -84,7 +85,12 @@ class taskEntry extends Entry
$user = zget($usersWithAvatar, $account, '');
$team->realname = $user ? $user->realname : $account;
$team->avatar = $user ? $user->avatar : '';
$team->progress = (empty($team->consumed) and empty($team->left)) ? 0 : round($team->consumed / ($team->consumed + $team->left) * 100, 1);
$team->estimate = round($team->estimate, 1);
$team->consumed = round($team->consumed, 1);
$team->left = round($team->left, 1);
$allHours = $team->consumed + $team->left;
$team->progress = empty($allHours) ? 0 : round($team->consumed / $allHours * 100, 1);
$teams[] = $team;
}
+3 -2
View File
@@ -29,9 +29,10 @@ class taskAssignToEntry extends Entry
$this->requireFields('assignedTo');
$control->assignTo($task->execution, $taskID);
$data = $this->getData();
if($data->result == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$task = $this->loadModel('task')->getByID($taskID);
+3 -2
View File
@@ -34,9 +34,10 @@ class taskFinishEntry extends Entry
$control = $this->loadController('task', 'finish');
$this->requireFields('assignedTo,currentConsumed,realStarted,finishedDate');
$control->finish($taskID);
$data = $this->getData();
if($data->result == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$task = $this->loadModel('task')->getByID($taskID);
+2 -3
View File
@@ -43,13 +43,12 @@ class tasksEntry extends entry
foreach($tasks as $task)
{
if(isset($task->children)) $task->children = array_values((array)$task->children);
$result[] = $this->format($task, 'openedDate:time,assignedDate:time,realStarted:time,finishedDate:time,canceledDate:time,closedDate:time,lastEditedDate:time,deleted:bool');
$result[] = $this->format($task, 'deadline:date,openedDate:time,assignedDate:time,realStarted:time,finishedDate:time,canceledDate:time,closedDate:time,lastEditedDate:time,deleted:bool');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'tasks' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+3 -2
View File
@@ -28,9 +28,10 @@ class taskStartEntry extends Entry
$control = $this->loadController('task', 'start');
$this->requireFields('left');
$control->start($taskID);
$data = $this->getData();
if($data->result == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$task = $this->loadModel('task')->getByID($taskID);
+2 -2
View File
@@ -9,7 +9,7 @@
* @version 1
* @link http://www.zentao.net
*/
class testcaseEntry extends entry
class testcaseEntry extends entry
{
/**
* GET method.
@@ -25,7 +25,7 @@ class testcaseEntry extends entry
$data = $this->getData();
if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
if(!isset($data->case)) $this->sendError(400, 'error');
$case = $data->case;
+3 -3
View File
@@ -24,7 +24,7 @@ class testcasesEntry extends entry
if(empty($productID)) return $this->sendError(400, 'Need product id.');
$control = $this->loadController('testcase', 'browse');
$control->browse($productID, $this->param('branch', ''), $this->param('status', 'all'), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1), $projectID);
$control->browse($productID, $this->param('branch', ''), $this->param('status', 'all'), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
$data = $this->getData();
@@ -35,14 +35,14 @@ class testcasesEntry extends entry
$result = array();
foreach($cases as $case)
{
$case->status = array('code' => $case->status, 'name' => $this->lang->testcase->statusList[$case->status]);
$result[] = $this->format($case, 'openedDate:time,lastEditedDate:time,lastRunDate:time,scriptedDate:date,reviewedDate:date,deleted:bool');
}
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testcases' => $result));
}
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
return $this->sendError(400, 'error');
}
+2 -2
View File
@@ -9,7 +9,7 @@
* @version 1
* @link http://www.zentao.net
*/
class testtaskEntry extends entry
class testtaskEntry extends entry
{
/**
* GET method.
@@ -24,7 +24,7 @@ class testtaskEntry extends entry
$control->view($testtaskID);
$data = $this->getData();
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
if(!isset($data->data->task)) $this->sendError(400, 'error');
$testtask = $data->data->task;
+1 -1
View File
@@ -29,7 +29,7 @@ class testtasksEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$pager = $data->data->pager;
$result = array();
+5 -4
View File
@@ -9,7 +9,7 @@
* @version 1
* @link http://www.zentao.net
*/
class todoEntry extends entry
class todoEntry extends entry
{
/**
* GET method.
@@ -25,7 +25,8 @@ class todoEntry extends entry
$data = $this->getData();
if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404();
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$todo = $data->data->todo;
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
@@ -45,7 +46,7 @@ class todoEntry extends entry
/* Set $_POST variables. */
$fields = 'date,type,name,pri,desc,status,begin,end,private';
$this->batchSetPost($fields, $oldTodo);
$this->setPost('idvalue', 0);
$this->setPost('date', $this->request('date', date("Y-m-d", strtotime($oldTodo->date))));
$this->setPost('begin', $this->request('begin') ? str_replace(':', '', $this->request('begin')) : $oldTodo->begin);
@@ -57,7 +58,7 @@ class todoEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$todo = $this->todo->getByID($todoID);
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
+2 -1
View File
@@ -24,7 +24,8 @@ class todoActivateEntry extends Entry
$control->activate($todoID);
$data = $this->getData();
if($data->status == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$todo = $this->loadModel('todo')->getByID($todoID);
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
+2 -1
View File
@@ -24,7 +24,8 @@ class todoFinishEntry extends Entry
$control->finish($todoID);
$data = $this->getData();
if($data->status == 'fail') return $this->sendError(400, $data->message);
if(!$data or !isset($data->status)) return $this->send400('error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$todo = $this->loadModel('todo')->getByID($todoID);
$this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'));
+1 -1
View File
@@ -24,7 +24,7 @@ class todosEntry extends entry
$data = $this->getData();
if(!isset($data->status)) return $this->sendError(400, 'error');
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
$pager = $data->data->pager;
$result = array();
+1 -1
View File
@@ -73,7 +73,7 @@ class usersEntry extends entry
$control->create();
$data = $this->getData();
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 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');
+14 -13
View File
@@ -50,16 +50,16 @@ $routes['/products/:id/projects'] = 'productProjects';
$routes['/projects'] = 'projects';
$routes['/projects/:id'] = 'project';
$routes['/projects/:project/executions'] = 'executions';
$routes['/executions'] = 'executions';
$routes['/executions/:id'] = 'execution';
$routes['/projects/:id/executions'] = 'executions';
$routes['/executions'] = 'executions';
$routes['/executions/:id'] = 'execution';
$routes['/executions/:execution/tasks'] = 'tasks';
$routes['/tasks'] = 'tasks';
$routes['/tasks/:id'] = 'task';
$routes['/tasks/:id/assignto'] = 'taskAssignTo';
$routes['/tasks/:id/start'] = 'taskStart';
$routes['/tasks/:id/finish'] = 'taskFinish';
$routes['/executions/:id/tasks'] = 'tasks';
$routes['/tasks'] = 'tasks';
$routes['/tasks/:id'] = 'task';
$routes['/tasks/:id/assignto'] = 'taskAssignTo';
$routes['/tasks/:id/start'] = 'taskStart';
$routes['/tasks/:id/finish'] = 'taskFinish';
$routes['/users'] = 'users';
$routes['/users/:id'] = 'user';
@@ -73,16 +73,17 @@ $routes['/programs/:id/stakeholders'] = 'stakeholders';
$routes['/products/:id/issues'] = 'productIssues';
$routes['/projects/:id/issues'] = 'issues';
$routes['/issues'] = 'issues';
$routes['/issues/:issueID'] = 'issue';
$routes['/issues/:id'] = 'issue';
$routes['/todos'] = 'todos';
$routes['/todos/:id'] = 'todo';
$routes['/todos/:id/finish'] = 'todoFinish';
$routes['/todos/:id/activate'] = 'todoActivate';
$routes['/projects/:projectID/builds'] = 'builds';
$routes['/builds'] = 'builds';
$routes['/builds/:id'] = 'build';
$routes['/projects/:id/builds'] = 'builds';
$routes['/executions/:id/builds'] = 'executionBuilds';
$routes['/builds'] = 'builds';
$routes['/builds/:id'] = 'build';
$routes['/products/:id/testcases'] = 'testcases';
$routes['/projects/:id/testcases'] = 'projectCases';
+12
View File
@@ -589,6 +589,8 @@ class baseEntry
return $value;
case 'bool':
return !empty($value);
case 'int':
return (int) $value;
case 'idList':
$values = explode(',', $value);
if(empty($values)) return array();
@@ -599,6 +601,16 @@ class baseEntry
if($val !== '') $idList[] = (int) $val;
}
return $idList;
case 'stringList':
$values = explode(',', $value);
if(empty($values)) return array();
$stringList = array();
foreach($values as $val)
{
if($val !== '') $stringList[] = $val;
}
return $stringList;
default:
return $value;
}
+5 -5
View File
@@ -82,13 +82,13 @@ class api extends router
$this->httpMethod = strtolower($_SERVER['REQUEST_METHOD']);
$fileName = substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT']));
$this->path = substr($_SERVER['REQUEST_URI'], strlen($fileName) + 1);
$fileName = ltrim(substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])), '/');
$this->path = substr(ltrim($_SERVER['REQUEST_URI'], '/'), strlen($fileName) + 1);
if(strpos($this->path, '?') > 0) $this->path = strstr($this->path, '?', true);
$subPos = $this->path ? strpos($this->path, '/') : 0;
$this->version = $subPos ? substr($this->path, 0, $subPos) : '';
$this->path = $subPos ? substr($this->path, $subPos) : '';
$subPos = $this->path ? strpos($this->path, '/') : false;
$this->version = $subPos !== false ? substr($this->path, 0, $subPos) : '';
$this->path = $subPos !== false ? substr($this->path, $subPos) : '';
$this->loadApiLang();
}
+2 -2
View File
@@ -1205,7 +1205,7 @@ class bugModel extends model
$this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec();
$this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq((int)$bugID)->exec();
$openedBuilds = $this->post->openedBuild;
$openedBuilds = explode(',', $oldBug->openedBuild);
if($openedBuilds)
{
$this->loadModel('build');
@@ -2499,7 +2499,7 @@ class bugModel extends model
}
$allBranch = "`branch` = 'all'";
if($branch !== 'all' and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('$branch')";
if($branch !== 'all' and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('0','$branch')";
if(strpos($bugQuery, $allBranch) !== false) $bugQuery = str_replace($allBranch, '1', $bugQuery);
$allProject = "`project` = 'all'";
+15 -11
View File
@@ -492,8 +492,8 @@ class build extends control
$this->config->product->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=story&link=true&param=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID"));
$this->config->product->search['queryID'] = $queryID;
$this->config->product->search['style'] = 'simple';
$this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product));
$this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($build->product, 'story', 0);
$this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairsForStory($build->product, $build->branch, 'skipParent');
$this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($build->product, 'story', 0, $build->branch);
$this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList);
if($product->type == 'normal')
@@ -503,9 +503,11 @@ class build extends control
}
else
{
$this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
$branches = array('' => '') + $this->loadModel('branch')->getPairs($build->product, 'noempty');
if($build->branch) $branches = array('' => '', $build->branch => $branches[$build->branch]);
$branchPairs = $this->loadModel('branch')->getPairs($build->product, 'noempty');
$branches = array('' => '') + array(BRANCH_MAIN => $this->lang->branch->main);
if($build->branch) $branches += array($build->branch => $branchPairs[$build->branch]);
$this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
$this->config->product->search['params']['branch']['values'] = $branches;
}
$this->loadModel('search')->setSearchParams($this->config->product->search);
@@ -516,7 +518,7 @@ class build extends control
}
else
{
$allStories = $this->story->getExecutionStories($build->execution, 0, 0, 't1.`order`_desc', 'byProduct', $build->product, 'story', $build->stories, $pager);
$allStories = $this->story->getExecutionStories($build->execution, $build->product, 0, 't1.`order`_desc', 'byBranch', $build->branch, 'story', $build->stories, $pager);
}
$this->view->allStories = $allStories;
@@ -609,8 +611,8 @@ class build extends control
$this->config->bug->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=bug&link=true&param=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID"));
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product));
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairsForStory($build->product, $build->branch, 'skipParent');
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, 'bug', 0, $build->branch);
$this->config->bug->search['params']['execution']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($build->product, 0, 'id_desc', $this->session->project);
$this->config->bug->search['params']['openedBuild']['values'] = $this->build->getProductBuildPairs($build->product, $branch = 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
@@ -624,9 +626,11 @@ class build extends control
}
else
{
$this->config->bug->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
$branches = array('' => '') + $this->loadModel('branch')->getPairs($build->product, 'noempty');
if($build->branch) $branches = array('' => '', $build->branch => $branches[$build->branch]);
$branchPairs = $this->loadModel('branch')->getPairs($build->product, 'noempty');
$branches = array('' => '') + array(BRANCH_MAIN => $this->lang->branch->main);
if($build->branch) $branches += array($build->branch => $branchPairs[$build->branch]);
$this->config->bug->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
$this->config->bug->search['params']['branch']['values'] = $branches;
}
$this->loadModel('search')->setSearchParams($this->config->bug->search);
+1 -1
View File
@@ -15,7 +15,7 @@ function loadBranches(productID)
oldBranch = productGroups[productID]['branches'];
}
executionID = $('#execution').val();
executionID = currentTab == 'execution' ? executionID : $('#execution').val();
$.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0&param=active&projectID=' + executionID), function(data)
{
if(data)
+3 -2
View File
@@ -160,10 +160,11 @@ class buildModel extends model
* @param int $executionID
* @param string $type all|product|bysearch
* @param int|string $param productID|buildQuery
* @param string $orderBy
* @access public
* @return array
*/
public function getExecutionBuilds($executionID, $type = '', $param = '')
public function getExecutionBuilds($executionID, $type = '', $param = '', $orderBy = 't1.date_desc,t1.id_desc')
{
return $this->dao->select('t1.*, t2.name as executionName, t3.name as productName, t4.name as branchName')
->from(TABLE_BUILD)->alias('t1')
@@ -174,7 +175,7 @@ class buildModel extends model
->andWhere('t1.deleted')->eq(0)
->beginIF($type == 'product' and $param)->andWhere('t1.product')->eq($param)->fi()
->beginIF($type == 'bysearch')->andWhere($param)->fi()
->orderBy('t1.date DESC, t1.id desc')
->orderBy($orderBy)
->fetchAll('id');
}
+3 -1
View File
@@ -92,5 +92,7 @@
</form>
</div>
</div>
<?php js::set('productGroups', $productGroups)?>
<?php js::set('productGroups', $productGroups);?>
<?php js::set('executionID', $executionID);?>
<?php js::set('currentTab', $this->app->tab);?>
<?php include '../../common/view/footer.html.php';?>
+2 -1
View File
@@ -1865,9 +1865,10 @@ EOD;
{
$queryObjects = $this->dao->query($sql);
$objectList = array();
$key = 'id';
while($object = $queryObjects->fetch())
{
$key = (!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) ? 'case' : 'id';
if(!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) $key = 'case';
$id = $object->$key;
$objectList[$id] = $id;
}
+6 -2
View File
@@ -476,7 +476,11 @@ class doc extends control
/* Get doc. */
$docID = (int)$docID;
$doc = $this->doc->getById($docID, $version, true);
if(!$doc) die(js::error($this->lang->notFound) . js::locate($this->createLink('doc', 'index')));
if(!$doc)
{
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($this->createLink('doc', 'index')));
}
/* The global search opens in the document library. */
if(!isonlybody())
@@ -496,7 +500,7 @@ class doc extends control
}
$browseLink = inLink('objectLibs', "type=$type&objectID=$objectID&libID=$libID&docID=$docID");
$this->locate($browseLink);
if(!(defined('RUN_MODE') && RUN_MODE == 'api')) $this->locate($browseLink);
}
if($doc->contentType == 'markdown')
+4 -3
View File
@@ -986,10 +986,11 @@ class execution extends control
* @param int $executionID
* @param string $type all|product|bysearch
* @param int $param
* @param string $orderBy
* @access public
* @return void
*/
public function build($executionID = 0, $type = 'all', $param = 0)
public function build($executionID = 0, $type = 'all', $param = 0, $orderBy = 't1.date_desc,t1.id_desc')
{
/* Load module and set session. */
$this->loadModel('testtask');
@@ -1015,7 +1016,7 @@ class execution extends control
}
else
{
$builds = $this->loadModel('build')->getExecutionBuilds((int)$executionID, $type, $param);
$builds = $this->loadModel('build')->getExecutionBuilds((int)$executionID, $type, $param, $orderBy);
}
/* Set execution builds. */
@@ -2507,7 +2508,7 @@ class execution extends control
if($browseType == 'bySearch')
{
$allStories = $this->story->getBySearch('', 0, $queryID, 'id', $objectID);
$allStories = $this->story->getBySearch('', '', $queryID, 'id', $objectID);
}
else
{
+6 -1
View File
@@ -115,7 +115,11 @@ class file extends control
{
if(session_id() != $this->app->sessionID) helper::restartSession($this->app->sessionID);
$file = $this->file->getById($fileID);
if(empty($file)) die("<html><head><meta charset='utf-8'></head><body>{$this->lang->file->fileNotFound}</body></html>");
if(empty($file))
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => $this->lang->file->fileNotFound));
die("<html><head><meta charset='utf-8'></head><body>{$this->lang->file->fileNotFound}</body></html>");
}
/* Judge the mode, down or open. */
$mode = 'down';
@@ -156,6 +160,7 @@ class file extends control
}
else
{
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => $this->lang->file->fileNotFound));
die("<html><head><meta charset='utf-8'></head><body>{$this->lang->file->fileNotFound}</body></html>");
}
}
+6 -3
View File
@@ -156,10 +156,9 @@ class program extends control
{
$programID = $this->program->create();
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $programID));
$this->loadModel('action')->create('program', $programID, 'opened');
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $programID, 'locate' => inlink('browse')));
}
$extra = str_replace(array(',', ' '), array('&', ''), $extra);
@@ -386,7 +385,11 @@ class program extends control
public function delete($programID, $confirm = 'no')
{
$childrenCount = $this->dao->select('count(*) as count')->from(TABLE_PROGRAM)->where('parent')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count');
if($childrenCount) die(js::alert($this->lang->program->hasChildren));
if($childrenCount)
{
if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => 'Cannot delete the program has children'));
die(js::alert($this->lang->program->hasChildren));
}
$productCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count');
if($productCount) die(js::alert($this->lang->program->hasProduct));
+4
View File
@@ -11,3 +11,7 @@ td.c-PM {white-space: nowrap; overflow: hidden;}
.icon-cards-view {padding-left: 7px; font-size: 16px;}
.icon-list {padding-left: 7px;}
.panel-actions {position: relative; padding: 0 0;}
@media screen and (max-width: 1460px)
{
th.c-name {width: 360px !important;}
}
+13 -6
View File
@@ -47,7 +47,7 @@ class storyModel extends model
->andWhere('t2.type')->in('sprint,stage')
->orderBy('t1.`order` DESC')
->fetchAll('project');
$story->tasks = $this->dao->select('id, name, assignedTo, execution, status, consumed, `left`')->from(TABLE_TASK)->where('story')->eq($storyID)->andWhere('deleted')->eq(0)->orderBy('id DESC')->fetchGroup('execution');
$story->tasks = $this->dao->select('id, name, assignedTo, execution, status, consumed, `left`,type')->from(TABLE_TASK)->where('story')->eq($storyID)->andWhere('deleted')->eq(0)->orderBy('id DESC')->fetchGroup('execution');
$story->stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->eq($storyID)->fetchPairs('branch', 'stage');
//$story->bugCount = $this->dao->select('COUNT(*)')->alias('count')->from(TABLE_BUG)->where('story')->eq($storyID)->fetch('count');
//$story->caseCount = $this->dao->select('COUNT(*)')->alias('count')->from(TABLE_CASE)->where('story')->eq($storyID)->fetch('count');
@@ -2446,10 +2446,18 @@ class storyModel extends model
$branches = array();
foreach($products as $product)
{
foreach($product->branches as $branchID) $branches[$branchID] = $branchID;
if($product->type != 'normal')
{
$branches[BRANCH_MAIN] = BRANCH_MAIN;
foreach($product->branches as $branchID)
{
if($branch == BRANCH_MAIN and $branchID) continue;
$branches[$branchID] = $branchID;
}
}
}
$branches = join(',', $branches);
if($branches) $storyQuery .= " AND `branch`" . helper::dbIN($branches);
$storyQuery .= " AND `branch`" . helper::dbIN($branches);
if($this->app->moduleName == 'release' or $this->app->moduleName == 'build')
{
@@ -2590,7 +2598,7 @@ class storyModel extends model
else
{
$productParam = ($type == 'byproduct' and $param) ? $param : $this->cookie->storyProductParam;
$branchParam = $branchID = ($type == 'bybranch' and $param !== '') ? $param : $this->cookie->storyBranchParam;
$branchParam = ($type == 'bybranch' and $param !== '') ? $param : $this->cookie->storyBranchParam;
$moduleParam = ($type == 'bymodule' and $param) ? $param : $this->cookie->storyModuleParam;
$modules = (empty($moduleParam) or strpos(',all,unclosed,bymodule,', ",$type,") === false) ? array() : $this->dao->select('id')->from(TABLE_MODULE)->where('path')->like("%,$moduleParam,%")->andWhere('type')->eq('story')->andWhere('deleted')->eq(0)->fetchPairs();
if(strpos($branchParam, ',') !== false) list($productParam, $branchParam) = explode(',', $branchParam);
@@ -2617,7 +2625,7 @@ class storyModel extends model
->beginIF($excludeStories)->andWhere('t2.id')->notIN($excludeStories)->fi()
->beginIF($execution->type == 'project')
->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID)
->beginIF($type == 'bybranch' and $branchParam !== '')->andWhere('t2.branch')->eq($branchParam)->fi()
->beginIF($type == 'bybranch' and $branchParam !== '')->andWhere('t2.branch')->in("0,$branchParam")->fi()
->beginIF(strpos('changed|closed', $type) !== false)->andWhere('t2.status')->eq($type)->fi()
->beginIF($type == 'unclosed')->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi()
->beginIF($type == 'linkedexecution')->andWhere('t2.id')->in($storyIdList)->fi()
@@ -2628,7 +2636,6 @@ class storyModel extends model
->beginIF($this->session->executionStoryBrowseType and strpos('changed|', $this->session->executionStoryBrowseType) !== false)->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi()
->fi()
->beginIF($this->session->storyBrowseType and strpos('changed|', $this->session->storyBrowseType) !== false)->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi()
->beginIF(!empty($branchParam))->andWhere('t2.branch')->eq($branchParam)->fi()
->beginIF($modules)->andWhere('t2.module')->in($modules)->fi()
->andWhere('t2.deleted')->eq(0)
->orderBy($orderBy)
+3 -3
View File
@@ -172,7 +172,7 @@ class testcase extends control
$actionURL = $this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID");
$this->config->testcase->search['onMenuBar'] = 'yes';
$this->testcase->buildSearchForm($productID, $this->products, $queryID, $actionURL);
$this->testcase->buildSearchForm($productID, $this->products, $queryID, $actionURL, $projectID);
$showModule = !empty($this->config->datatable->testcaseBrowse->showModule) ? $this->config->datatable->testcaseBrowse->showModule : '';
@@ -1713,7 +1713,7 @@ class testcase extends control
* @access public
* @return void
*/
public function importFromLib($productID, $branch = 0, $libID = 0, $orderBy = 'id_desc', $browseType = '', $queryID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function importFromLib($productID, $branch = 0, $libID = 0, $orderBy = 'id_desc', $browseType = '', $queryID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0)
{
$browseType = strtolower($browseType);
$queryID = (int)$queryID;
@@ -1764,7 +1764,7 @@ class testcase extends control
$this->view->libModules = $this->tree->getOptionMenu($libID, 'caselib');
$this->view->pager = $pager;
$this->view->orderBy = $orderBy;
$this->view->branches = $this->loadModel('branch')->getPairs($productID);
$this->view->branches = array('0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, '', $projectID);
$this->view->browseType = $browseType;
$this->view->queryID = $queryID;
+4 -3
View File
@@ -465,7 +465,7 @@ class testcaseModel extends model
/* Cases need confirmed. */
elseif($browseType == 'needconfirm')
{
$cases = $this->dao->select('t1.*, t2.title AS storyTitle')->from(TABLE_CASE)->alias('t1')
$cases = $this->dao->select('distinct t1.*, t2.title AS storyTitle')->from(TABLE_CASE)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->leftJoin(TABLE_PROJECTCASE)->alias('t3')->on('t1.id = t3.case')
->where("t2.status = 'active'")
@@ -1446,10 +1446,11 @@ class testcaseModel extends model
* @param array $products
* @param int $queryID
* @param string $actionURL
* @param string $projectID
* @access public
* @return void
*/
public function buildSearchForm($productID, $products, $queryID, $actionURL)
public function buildSearchForm($productID, $products, $queryID, $actionURL, $projectID)
{
$product = ($this->app->tab == 'project' and empty($productID)) ? $products : array($productID => $products[$productID]) + array('all' => $this->lang->testcase->allProduct);
$this->config->testcase->search['params']['product']['values'] = $product;
@@ -1473,7 +1474,7 @@ class testcaseModel extends model
{
$productInfo = $this->loadModel('product')->getByID($productID);
$this->config->testcase->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$productInfo->type]);
$this->config->testcase->search['params']['branch']['values'] = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, 'noempty') + array('all' => $this->lang->branch->all);
$this->config->testcase->search['params']['branch']['values'] = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, '', $projectID) + array('all' => $this->lang->branch->all);
}
if(!$this->config->testcase->needReview) unset($this->config->testcase->search['params']['status']['values']['wait']);
$this->config->testcase->search['actionURL'] = $actionURL;
+1 -1
View File
@@ -143,7 +143,7 @@
$class = common::hasPriv('testcase', 'importFromLib') ? '' : "class=disabled";
$misc = common::hasPriv('testcase', 'importFromLib') ? "data-app='{$this->app->tab}'" : "class=disabled";
$link = common::hasPriv('testcase', 'importFromLib') ? $this->createLink('testcase', 'importFromLib', "productID=$productID&branch=$branch") : '#';
$link = common::hasPriv('testcase', 'importFromLib') ? $this->createLink('testcase', 'importFromLib', "productID=$productID&branch=$branch&libID=0&orderBy=id_desc&browseType=&queryID=10&recTotal=0&recPerPage=20&pageID=1&projectID=$projectID") : '#';
echo "<li $class>" . html::a($link, $lang->testcase->importFromLib, '', $misc . "data-app={$this->app->tab}") . "</li>";
?>
</ul>
+1 -2
View File
@@ -118,10 +118,9 @@ $lang->testtask->statusList['doing'] = '进行中';
$lang->testtask->statusList['done'] = '已关闭';
$lang->testtask->statusList['blocked'] = '被阻塞';
$lang->testtask->priList[0] = '';
$lang->testtask->priList[3] = '3';
$lang->testtask->priList[1] = '1';
$lang->testtask->priList[2] = '2';
$lang->testtask->priList[3] = '3';
$lang->testtask->priList[4] = '4';
$lang->testtask->unlinkedCases = '未关联';
+1 -1
View File
@@ -60,7 +60,7 @@
<div id='ownerAndPriBox' class='input-group'>
<?php echo html::select('owner', $users, '', "class='form-control chosen'");?>
<span class='input-group-addon fix-border'><?php echo $lang->testtask->pri;?></span>
<?php echo html::select('pri', $lang->testtask->priList, 0, "class='form-control chosen'");?>
<?php echo html::select('pri', $lang->testtask->priList, 3, "class='form-control chosen'");?>
</div>
</td>
</tr>
+10 -9
View File
@@ -136,17 +136,14 @@ class treeModel extends model
if($type == 'line') $rootID = 0;
$branches = array($branch => '');
$branches = array();
if(strpos('story|bug|case', $type) !== false)
{
$product = $this->loadModel('product')->getById($rootID);
if($product and $product->type != 'normal')
{
$branchList = array('null' => '') + $this->loadModel('branch')->getPairs($rootID, 'all');
if(!$branch) $newBranches['null'] = '';
$newBranches[$branch] = $branchList[$branch];
$branches = $branch === 'all' ? $branchList : $newBranches;
$branchPairs = $this->loadModel('branch')->getPairs($rootID, 'all');
$branches = $branch === 'all' ? $branchPairs : array($branch => $branchPairs[$branch]);
}
elseif($product and $product->type == 'normal')
{
@@ -157,11 +154,15 @@ class treeModel extends model
$treeMenu = array();
foreach($branches as $branchID => $branch)
{
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID));
$modules = array();
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID));
$modules = array();
while($module = $stmt->fetch()) $modules[$module->id] = $module;
foreach($modules as $module) $this->buildTreeArray($treeMenu, $modules, $module, (empty($branch) or $branch == 'null') ? '/' : "/$branch/");
foreach($modules as $module)
{
$branchName = ($product->type != 'normal' and $module->branch == BRANCH_MAIN) ? $this->lang->branch->main : $branch;
$this->buildTreeArray($treeMenu, $modules, $module, (empty($branchName)) ? '/' : "/$branchName/");
}
}
ksort($treeMenu);
-2
View File
@@ -60,8 +60,6 @@ class userModel extends model
return $this->dao->select('id,account,realname,avatar,role')->from(TABLE_USER)
->where('account')->in($accounts)
->andWhere('deleted')->eq(0)
->andWhere('type')->eq('inside')
->fetchAll($keyField);
}