* Distinguish project execution from bug module.

This commit is contained in:
tianshujie98
2021-03-05 13:35:01 +08:00
parent 21a340c39d
commit 7e1c35f09d
22 changed files with 547 additions and 559 deletions
+170 -170
View File
@@ -69,16 +69,16 @@ class bugModel extends model
$bug = fixer::input('post')
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', $now)
->setDefault('project,story,task', 0)
->setDefault('execution,story,task', 0)
->setDefault('openedBuild', '')
->setDefault('deadline', '0000-00-00')
->setIF($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa', 'PRJ', $this->session->PRJ)
->setIF($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa', 'project', $this->session->project)
->setIF(strpos($this->config->bug->create->requiredFields, 'deadline') !== false, 'deadline', $this->post->deadline)
->setIF($this->post->assignedTo != '', 'assignedDate', $now)
->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))
->setIF(strpos($this->config->bug->create->requiredFields, 'project') !== false, 'project', $this->post->project)
->setIF(strpos($this->config->bug->create->requiredFields, 'execution') !== false, 'execution', $this->post->execution)
->stripTags($this->config->bug->editor->create['id'], $this->config->allowedTags)
->cleanInt('product,project,module,severity')
->cleanInt('product,execution,module,severity')
->join('openedBuild', ',')
->join('mailto', ',')
->remove('files, labels,uid,oldTaskID,contactListMenu')
@@ -132,23 +132,23 @@ class bugModel extends model
$moduleOwners = array();
while($module = $stmt->fetch()) $moduleOwners[$module->id] = $module->owner;
$module = 0;
$project = 0;
$type = '';
$pri = 0;
$os = '';
$browser = '';
$module = 0;
$execution = 0;
$type = '';
$pri = 0;
$os = '';
$browser = '';
foreach($data->title as $i => $title)
{
if($data->modules[$i] != 'ditto') $module = (int)$data->modules[$i];
if($data->projects[$i] != 'ditto') $project = (int)$data->projects[$i];
if($data->types[$i] != 'ditto') $type = $data->types[$i];
if($data->pris[$i] != 'ditto') $pri = $data->pris[$i];
if($data->oses[$i] != 'ditto') $os = $data->oses[$i];
if($data->browsers[$i] != 'ditto') $browser = $data->browsers[$i];
if($data->modules[$i] != 'ditto') $module = (int)$data->modules[$i];
if($data->executions[$i] != 'ditto') $execution = (int)$data->executions[$i];
if($data->types[$i] != 'ditto') $type = $data->types[$i];
if($data->pris[$i] != 'ditto') $pri = $data->pris[$i];
if($data->oses[$i] != 'ditto') $os = $data->oses[$i];
if($data->browsers[$i] != 'ditto') $browser = $data->browsers[$i];
$data->modules[$i] = (int)$module;
$data->projects[$i] = (int)$project;
$data->executions[$i] = (int)$execution;
$data->types[$i] = $type;
$data->pris[$i] = $pri;
$data->oses[$i] = $os;
@@ -169,7 +169,7 @@ class bugModel extends model
$bug->product = (int)$productID;
$bug->branch = (int)$data->branches[$i];
$bug->module = (int)$data->modules[$i];
$bug->project = (int)$data->projects[$i];
$bug->execution = (int)$data->executions[$i];
$bug->openedBuild = implode(',', $data->openedBuilds[$i]);
$bug->color = $data->color[$i];
$bug->title = $data->title[$i];
@@ -234,7 +234,7 @@ class bugModel extends model
}
}
if($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa') $bug->PRJ = $this->session->PRJ;
if($this->config->systemMode == 'new' && $this->lang->navGroup->bug != 'qa') $bug->project = $this->session->project;
$this->dao->insert(TABLE_BUG)->data($bug)
->autoCheck()
->batchCheck($this->config->bug->create->requiredFields, 'notempty')
@@ -278,7 +278,7 @@ class bugModel extends model
* Get bugs.
*
* @param int $productID
* @param array $projects
* @param array $executions
* @param int $branch
* @param string $browseType
* @param int $moduleID
@@ -288,7 +288,7 @@ class bugModel extends model
* @access public
* @return array
*/
public function getBugs($productID, $projects, $branch, $browseType, $moduleID, $queryID, $sort, $pager)
public function getBugs($productID, $executions, $branch, $browseType, $moduleID, $queryID, $sort, $pager)
{
/* Set modules and browse type. */
$modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
@@ -297,21 +297,21 @@ class bugModel extends model
/* Get bugs by browse type. */
$bugs = array();
if($browseType == 'all') $bugs = $this->getAllBugs($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'bymodule') $bugs = $this->getModuleBugs($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'assigntome') $bugs = $this->getByAssigntome($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'openedbyme') $bugs = $this->getByOpenedbyme($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'resolvedbyme') $bugs = $this->getByResolvedbyme($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'assigntonull') $bugs = $this->getByAssigntonull($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'unconfirmed') $bugs = $this->getUnconfirmed($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'unresolved') $bugs = $this->getByStatus($productID, $branch, $modules, $projects, 'unresolved', $sort, $pager);
elseif($browseType == 'unclosed') $bugs = $this->getByStatus($productID, $branch, $modules, $projects, 'unclosed', $sort, $pager);
elseif($browseType == 'toclosed') $bugs = $this->getByStatus($productID, $branch, $modules, $projects, 'toclosed', $sort, $pager);
elseif($browseType == 'longlifebugs') $bugs = $this->getByLonglifebugs($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'postponedbugs') $bugs = $this->getByPostponedbugs($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'needconfirm') $bugs = $this->getByNeedconfirm($productID, $branch, $modules, $projects, $sort, $pager);
if($browseType == 'all') $bugs = $this->getAllBugs($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'bymodule') $bugs = $this->getModuleBugs($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'assigntome') $bugs = $this->getByAssigntome($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'openedbyme') $bugs = $this->getByOpenedbyme($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'resolvedbyme') $bugs = $this->getByResolvedbyme($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'assigntonull') $bugs = $this->getByAssigntonull($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'unconfirmed') $bugs = $this->getUnconfirmed($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'unresolved') $bugs = $this->getByStatus($productID, $branch, $modules, $executions, 'unresolved', $sort, $pager);
elseif($browseType == 'unclosed') $bugs = $this->getByStatus($productID, $branch, $modules, $executions, 'unclosed', $sort, $pager);
elseif($browseType == 'toclosed') $bugs = $this->getByStatus($productID, $branch, $modules, $executions, 'toclosed', $sort, $pager);
elseif($browseType == 'longlifebugs') $bugs = $this->getByLonglifebugs($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'postponedbugs') $bugs = $this->getByPostponedbugs($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'needconfirm') $bugs = $this->getByNeedconfirm($productID, $branch, $modules, $executions, $sort, $pager);
elseif($browseType == 'bysearch') $bugs = $this->getBySearch($productID, $branch, $queryID, $sort, '', $pager);
elseif($browseType == 'overduebugs') $bugs = $this->getOverdueBugs($productID, $branch, $modules, $projects, $sort, $pager);
elseif($browseType == 'overduebugs') $bugs = $this->getOverdueBugs($productID, $branch, $modules, $executions, $sort, $pager);
return $this->checkDelayBugs($bugs);
}
@@ -358,17 +358,17 @@ class bugModel extends model
}
/**
* Check bug project priv.
*
* @param object $bug
* Check bug execution priv.
*
* @param object $bug
* @access public
* @return void
*/
public function checkBugProjectPriv($bug)
public function checkBugExecutionPriv($bug)
{
if($bug->project and !$this->loadModel('project')->checkPriv($bug->project))
if($bug->execution and !$this->loadModel('execution')->checkPriv($bug->execution))
{
echo(js::alert($this->lang->bug->projectAccessDenied));
echo(js::alert($this->lang->bug->executionAccessDenied));
$loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login";
if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(helper::createLink('bug', 'index', '')));
die(js::locate('back'));
@@ -385,13 +385,13 @@ class bugModel extends model
* @access public
* @return array
*/
public function getModuleBugs($productID, $branch = 0, $moduleIdList = 0, $projects, $orderBy = 'id_desc', $pager = null)
public function getModuleBugs($productID, $branch = 0, $moduleIdList = 0, $executions, $orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('product')->eq((int)$productID)
->beginIF(!empty($branch))->andWhere('branch')->eq($branch)->fi()
->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -410,7 +410,7 @@ class bugModel extends model
{
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('plan')->eq((int)$planID)
->beginIF(!$this->app->user->admin)->andWhere('project')->in('0,' . $this->app->user->view->projects)->fi()
->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi()
->beginIF($status != 'all')->andWhere('status')->in($status)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll('id');
@@ -430,9 +430,9 @@ class bugModel extends model
*/
public function getById($bugID, $setImgSize = false)
{
$bug = $this->dao->select('t1.*, t2.name AS projectName, t3.title AS storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, t4.name AS taskName, t5.title AS planName')
$bug = $this->dao->select('t1.*, t2.name AS executionName, t3.title AS storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, t4.name AS taskName, t5.title AS planName')
->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution = t2.id')
->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id')
->leftJoin(TABLE_TASK)->alias('t4')->on('t1.task = t4.id')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t5')->on('t1.plan = t5.id')
@@ -479,13 +479,13 @@ class bugModel extends model
*
* @param array $products
* @param int $branch
* @param int $projectID
* @param array $executions
* @param array $excludeBugs
* @param object $pager
* @access public
* @return array
*/
public function getActiveBugs($products, $branch, $projects, $excludeBugs, $pager = null)
public function getActiveBugs($products, $branch, $executions, $excludeBugs, $pager = null)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('status')->eq('active')
@@ -493,7 +493,7 @@ class bugModel extends model
->andWhere('toTask')->eq(0)
->beginIF(!empty($products))->andWhere('product')->in($products)->fi()
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->beginIF(!empty($projects))->andWhere('project')->in($projects)->fi()
->beginIF(!empty($executions))->andWhere('execution')->in($executions)->fi()
->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi()
->andWhere('deleted')->eq(0)
->orderBy('id desc')
@@ -502,15 +502,15 @@ class bugModel extends model
}
/**
* get Active And Postponed Bugs
* Get active and postponed bugs.
*
* @param int $products
* @param int $projectID
* @param int $executionID
* @param int $pager
* @access public
* @return void
*/
public function getActiveAndPostponedBugs($products, $projectID, $pager = null)
public function getActiveAndPostponedBugs($products, $executionID, $pager = null)
{
return $this->dao->select('t1.*')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.product = t2.product')
@@ -518,8 +518,8 @@ class bugModel extends model
->andWhere('t1.toTask')->eq(0)
->andWhere('t1.toStory')->eq(0)
->beginIF(!empty($products))->andWhere('t1.product')->in($products)->fi()
->beginIF(empty($products))->andWhere('t1.project')->eq($projectID)->fi()
->andWhere('t2.project')->eq($projectID)
->beginIF(empty($products))->andWhere('t1.execution')->eq($executionID)->fi()
->andWhere('t2.execution')->eq($executionID)
->andWhere("(t2.branch = '0' OR t1.branch = '0' OR t2.branch = t1.branch)")
->andWhere('t1.deleted')->eq(0)
->orderBy('id desc')
@@ -585,9 +585,9 @@ class bugModel extends model
$now = helper::now();
$bug = fixer::input('post')
->cleanInt('product,module,severity,project,story,task,branch')
->cleanInt('product,module,severity,execution,story,task,branch')
->stripTags($this->config->bug->editor->edit['id'], $this->config->allowedTags)
->setDefault('product,module,project,story,task,duplicateBug,branch', 0)
->setDefault('product,module,execution,story,task,duplicateBug,branch', 0)
->setDefault('openedBuild', '')
->setDefault('plan', 0)
->setDefault('deadline', '0000-00-00')
@@ -941,16 +941,16 @@ class bugModel extends model
if($bug->resolution == 'duplicate' and !$this->post->duplicateBug) dao::$errors[] = sprintf($this->lang->error->notempty, $this->lang->bug->duplicateBug);
if(empty($bug->buildName)) dao::$errors['buildName'][] = sprintf($this->lang->error->notempty, $this->lang->bug->placeholder->newBuildName);
if(empty($bug->buildProject)) dao::$errors['buildProject'][] = sprintf($this->lang->error->notempty, $this->lang->bug->project);
if(empty($bug->buildExecution)) dao::$errors['buildExecution'][] = sprintf($this->lang->error->notempty, $this->lang->bug->execution);
if(dao::isError()) return false;
$buildData = new stdclass();
$buildData->product = (int)$oldBug->product;
$buildData->branch = (int)$oldBug->branch;
$buildData->project = $bug->buildProject;
$buildData->name = $bug->buildName;
$buildData->date = date('Y-m-d');
$buildData->builder = $this->app->user->account;
$buildData->product = (int)$oldBug->product;
$buildData->branch = (int)$oldBug->branch;
$buildData->execution = $bug->buildExecution;
$buildData->name = $bug->buildName;
$buildData->date = date('Y-m-d');
$buildData->builder = $this->app->user->account;
$this->dao->insert(TABLE_BUILD)->data($buildData)->autoCheck()
->check('name', 'unique', "product = {$buildData->product} AND branch = {$buildData->branch} AND deleted = '0'")
->exec();
@@ -962,7 +962,7 @@ class bugModel extends model
if($bug->resolvedBuild and $bug->resolvedBuild != 'trunk') $bug->testtask = (int) $this->dao->select('id')->from(TABLE_TESTTASK)->where('build')->eq($bug->resolvedBuild)->orderBy('id_desc')->limit(1)->fetch('id');
$this->dao->update(TABLE_BUG)->data($bug, 'buildName,createBuild,buildProject,comment')
$this->dao->update(TABLE_BUG)->data($bug, 'buildName,createBuild,buildExecution,comment')
->autoCheck()
->batchCheck($this->config->bug->resolve->requiredFields, 'notempty')
->checkIF($bug->resolution == 'duplicate', 'duplicateBug', 'notempty')
@@ -1232,13 +1232,13 @@ class bugModel extends model
*/
public function buildSearchForm($productID, $products, $queryID, $actionURL)
{
$projectID = $this->lang->navGroup->bug == 'qa' ? 0 : $this->session->PRJ;
$projectID = $this->lang->navGroup->bug == 'qa' ? 0 : $this->session->project;
$this->config->bug->search['actionURL'] = $actionURL;
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['params']['product']['values'] = array($productID => $products[$productID], 'all' => $this->lang->bug->allProduct);
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs($productID);
$this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0);
$this->config->bug->search['params']['project']['values'] = $this->product->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID);
$this->config->bug->search['params']['execution']['values'] = $this->product->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID);
$this->config->bug->search['params']['severity']['values'] = array(0 => '') + $this->lang->bug->severityList; //Fix bug #939.
$this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID, 0, $params = '');
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
@@ -1333,17 +1333,17 @@ class bugModel extends model
* @param string $orderBy
* @param int $limit
* @param object $pager
* @param int $projectID
* @param int $executionID
* @access public
* @return void
*/
public function getUserBugs($account, $type = 'assignedTo', $orderBy = 'id_desc', $limit = 0, $pager = null, $projectID = 0)
public function getUserBugs($account, $type = 'assignedTo', $orderBy = 'id_desc', $limit = 0, $pager = null, $executionID = 0)
{
if(!$this->loadModel('common')->checkField(TABLE_BUG, $type)) return array();
$bugs = $this->dao->select('t1.*,t2.name as productName')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->where('t1.deleted')->eq(0)
->beginIF($projectID)->andWhere('t1.PRJ')->eq($projectID)->fi()
->beginIF($executionID)->andWhere('t1.execution')->eq($executionID)->fi()
->beginIF($type != 'closedBy' and $this->app->moduleName == 'block')->andWhere('t1.status')->ne('closed')->fi()
->beginIF($type != 'all')->andWhere("t1.`$type`")->eq($account)->fi()
->orderBy($orderBy)
@@ -1360,11 +1360,11 @@ class bugModel extends model
* @param bool $appendProduct
* @param int $limit
* @param array $skipProductIDList
* @param array $skipProjectIDList
* @param array $skipExecutionIDList
* @access public
* @return array
*/
public function getUserBugPairs($account, $appendProduct = true, $limit = 0, $skipProductIDList = array(), $skipProjectIDList = array())
public function getUserBugPairs($account, $appendProduct = true, $limit = 0, $skipProductIDList = array(), $skipExecutionIDList = array())
{
$bugs = array();
$stmt = $this->dao->select('t1.id, t1.title, t2.name as product')
@@ -1373,7 +1373,7 @@ class bugModel extends model
->on('t1.product=t2.id')
->where('t1.assignedTo')->eq($account)
->beginIF(!empty($skipProductIDList))->andWhere('t1.product')->notin($skipProductIDList)->fi()
->beginIF(!empty($skipProjectIDList))->andWhere('t1.project')->notin($skipProjectIDList)->fi()
->beginIF(!empty($skipExecutionIDList))->andWhere('t1.execution')->notin($skipExecutionIDList)->fi()
->andWhere('t1.deleted')->eq(0)
->orderBy('id desc')
->beginIF($limit > 0)->limit($limit)->fi()
@@ -1387,47 +1387,47 @@ class bugModel extends model
}
/**
* Get bugs of a project.
* Get bugs of a execution.
*
* @param int $projectID
* @param int $executionID
* @param int $build
* @param string $type
* @param int $param
* @param string $orderBy
* @param string $excludeBugs
* @param string $excludeBugs
* @param object $pager
* @access public
* @return array
*/
public function getProjectBugs($projectID, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null)
public function getExecutionBugs($executionID, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null)
{
$type = strtolower($type);
if($type == 'bysearch')
{
$queryID = (int)$param;
$products = $this->loadModel('project')->getProducts($projectID);
$products = $this->loadModel('execution')->getProducts($executionID);
if($this->session->projectBugQuery == false) $this->session->set('projectBugQuery', ' 1 = 1');
if($this->session->executionBugQuery == false) $this->session->set('executionBugQuery', ' 1 = 1');
if($queryID)
{
$query = $this->loadModel('search')->getQuery($queryID);
if($query)
{
$this->session->set('projectBugQuery', $query->sql);
$this->session->set('projectBugForm', $query->form);
$this->session->set('executionBugQuery', $query->sql);
$this->session->set('executionBugForm', $query->form);
}
}
$allProduct = "`product` = 'all'";
$bugQuery = $this->session->projectBugQuery;
if(strpos($this->session->projectBugQuery, $allProduct) !== false)
$bugQuery = $this->session->executionBugQuery;
if(strpos($this->session->executionBugQuery, $allProduct) !== false)
{
$bugQuery = str_replace($allProduct, '1', $this->session->projectBugQuery);
$bugQuery = str_replace($allProduct, '1', $this->session->executionBugQuery);
}
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where($bugQuery)
->andWhere('project')->eq((int)$projectID)
->andWhere('execution')->eq((int)$executionID)
->andWhere('deleted')->eq(0)
->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi()
->orderBy($orderBy)
@@ -1438,7 +1438,7 @@ class bugModel extends model
{
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('deleted')->eq(0)
->beginIF(empty($build))->andWhere('project')->eq($projectID)->fi()
->beginIF(empty($build))->andWhere('execution')->eq($executionID)->fi()
->beginIF($type == 'unresolved')->andWhere('status')->eq('active')->fi()
->beginIF($type == 'noclosed')->andWhere('status')->ne('closed')->fi()
->beginIF($build)->andWhere("CONCAT(',', openedBuild, ',') like '%,$build,%'")->fi()
@@ -1456,33 +1456,33 @@ class bugModel extends model
*
* @param int $build
* @param int $productID
* @param int $branch
* @param string $linkedBugs
* @param object $pager
* @param int $branch
* @param string $linkedBugs
* @param object $pager
* @access public
* @return array
*/
public function getProductLeftBugs($build, $productID, $branch = 0, $linkedBugs = '', $pager = null)
{
$build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($build)->fetch();
if(empty($build->project)) return array();
if(empty($build->execution)) return array();
$project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($build->project)->fetch();
$execution = $this->dao->select('*')->from(TABLE_EXECUTION)->where('id')->eq($build->execution)->fetch();
$beforeBuilds = $this->dao->select('t1.id')->from(TABLE_BUILD)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->leftJoin(TABLE_EXECTUION)->alias('t2')->on('t1.execution=t2.id')
->where('t1.product')->eq($productID)
->andWhere('t2.status')->ne('done')
->andWhere('t2.deleted')->eq(0)
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.date')->lt($project->begin)
->andWhere('t1.date')->lt($execution->begin)
->fetchPairs('id', 'id');
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('deleted')->eq(0)
->andWhere('product')->eq($productID)
->andWhere('toStory')->eq(0)
->andWhere('openedDate')->ge($project->begin)
->andWhere('openedDate')->le($project->end)
->andWhere("(status = 'active' OR resolvedDate > '{$project->end}')")
->andWhere('openedDate')->ge($execution->begin)
->andWhere('openedDate')->le($execution->end)
->andWhere("(status = 'active' OR resolvedDate > '{$execution->end}')")
->andWhere('openedBuild')->notin($beforeBuilds)
->beginIF($linkedBugs)->andWhere('id')->notIN($linkedBugs)->fi()
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
@@ -1504,7 +1504,7 @@ class bugModel extends model
$bugs = array('' => '');
$data = $this->dao->select('id, title')->from(TABLE_BUG)
->where('product')->eq((int)$productID)
->beginIF(!$this->app->user->admin)->andWhere('project')->in('0,' . $this->app->user->view->projects)->fi()
->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi()
->andWhere('deleted')->eq(0)
->orderBy('id desc')
->fetchAll();
@@ -1525,17 +1525,17 @@ class bugModel extends model
*/
public function getReleaseBugs($buildID, $productID, $branch = 0, $linkedBugs = '', $pager = null)
{
$project = $this->dao->select('t1.id,t1.begin')->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.id = t2.project')
$execution = $this->dao->select('t1.id,t1.begin')->from(TABLE_EXECUTION)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.id = t2.execution')
->where('t2.id')->eq($buildID)
->fetch();
$bugs = $this->dao->select('*')->from(TABLE_BUG)
->where('resolvedDate')->ge($project->begin)
->where('resolvedDate')->ge($execution->begin)
->andWhere('resolution')->ne('postponed')
->andWhere('product')->eq($productID)
->beginIF($linkedBugs)->andWhere('id')->notIN($linkedBugs)->fi()
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->andWhere("(project != '$project->id' OR (project = '$project->id' and openedDate < '$project->begin'))")
->andWhere("(execution != '$execution->id' OR (execution = '$execution->id' and openedDate < '$execution->begin'))")
->andWhere('deleted')->eq(0)
->orderBy('openedDate ASC')
->page($pager)
@@ -1547,16 +1547,16 @@ class bugModel extends model
* Get bugs of a story.
*
* @param int $storyID
* @param int $projectID
* @param int $executionID
* @access public
* @return array
*/
public function getStoryBugs($storyID, $projectID = 0)
public function getStoryBugs($storyID, $executionID = 0)
{
return $this->dao->select('id, title, pri, type, status, assignedTo, resolvedBy, resolution')
->from(TABLE_BUG)
->where('story')->eq((int)$storyID)
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
->beginIF($executionID)->andWhere('execution')->eq($executionID)->fi()
->andWhere('deleted')->eq(0)
->fetchAll('id');
}
@@ -1585,17 +1585,17 @@ class bugModel extends model
* Get counts of some stories' bugs.
*
* @param array $stories
* @param int $projectID
* @param int $executionID
* @access public
* @return int
*/
public function getStoryBugCounts($stories, $projectID = 0)
public function getStoryBugCounts($stories, $executionID = 0)
{
$bugCounts = $this->dao->select('story, COUNT(*) AS bugs')
->from(TABLE_BUG)
->where('story')->in($stories)
->andWhere('deleted')->eq(0)
->beginIF($projectID)->andWhere('project')->eq($projectID)->fi()
->beginIF($executionID)->andWhere('execution')->eq($executionID)->fi()
->groupBy('story')
->fetchPairs();
foreach($stories as $storyID) if(!isset($bugCounts[$storyID])) $bugCounts[$storyID] = 0;
@@ -1669,22 +1669,22 @@ class bugModel extends model
}
/**
* Get report data of bugs per project
* Get report data of bugs per execution.
*
* @access public
* @return array
*/
public function getDataOfBugsPerProject()
public function getDataOfBugsPerExecution()
{
$datas = $this->dao->select('project as name, count(project) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('project')->orderBy('value DESC')->fetchAll('name');
$datas = $this->dao->select('execution as name, count(execution) as value')->from(TABLE_BUG)->where($this->reportCondition())->groupBy('execution')->orderBy('value DESC')->fetchAll('name');
if(!$datas) return array();
$projects = $this->loadModel('project')->getExecutionPairs($this->session->PRJ);
$executions = $this->loadModel('execution')->getExecutionPairs($this->session->project);
$maxLength = 12;
if(common::checkNotCN()) $maxLength = 22;
foreach($datas as $projectID => $data)
foreach($datas as $executionID => $data)
{
$data->name = isset($projects[$projectID]) ? $projects[$projectID] : $this->lang->report->undefined;
$data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined;
$data->title = $data->name;
if(mb_strlen($data->name) > $maxLength) $data->name = mb_substr($data->name, 0, $maxLength) . '...';
}
@@ -2000,18 +2000,18 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getAllBugs($productID, $branch, $modules, $projects, $orderBy, $pager = null)
public function getAllBugs($productID, $branch, $modules, $executions, $orderBy, $pager = null)
{
$bugs = $this->dao->select('t1.*, t2.title as planTitle')->from(TABLE_BUG)->alias('t1')
->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id')
->where('t1.product')->eq($productID)
->andWhere('t1.project')->in(array_keys($projects))
->andWhere('t1.execution')->in(array_keys($executions))
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->andWhere('t1.deleted')->eq(0)
@@ -2028,18 +2028,18 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByAssigntome($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByAssigntome($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->findByAssignedTo($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2050,18 +2050,18 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByOpenedbyme($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByOpenedbyme($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->findByOpenedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2072,18 +2072,18 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByResolvedbyme($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByResolvedbyme($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->findByResolvedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2094,19 +2094,19 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByAssigntonull($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByAssigntonull($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->findByAssignedTo('')->from(TABLE_BUG)->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2117,20 +2117,20 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param int $projects
* @param int $executions
* @param int $orderBy
* @param int $pager
* @access public
* @return void
*/
public function getUnconfirmed($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getUnconfirmed($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('confirmed')->eq(0)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('product')->eq($productID)
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2141,17 +2141,17 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $status
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getOverdueBugs($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getOverdueBugs($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('project')->in(array_keys($projects))
->where('execution')->in(array_keys($executions))
->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
@@ -2168,17 +2168,17 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $status
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByStatus($productID, $branch, $modules, $projects, $status, $orderBy, $pager)
public function getByStatus($productID, $branch, $modules, $executions, $status, $orderBy, $pager)
{
return $this->dao->select('*')->from(TABLE_BUG)
->where('project')->in(array_keys($projects))
->where('execution')->in(array_keys($executions))
->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
@@ -2195,17 +2195,17 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByLonglifebugs($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByLonglifebugs($productID, $branch, $modules, $executions, $orderBy, $pager)
{
$lastEditedDate = date(DT_DATE1, time() - $this->config->bug->longlife * 24 * 3600);
return $this->dao->findByLastEditedDate("<", $lastEditedDate)->from(TABLE_BUG)->andWhere('product')->eq($productID)
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('openedDate')->lt($lastEditedDate)
@@ -2219,18 +2219,18 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByPostponedbugs($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByPostponedbugs($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->findByResolution('postponed')->from(TABLE_BUG)->andWhere('product')->eq($productID)
->beginIF($branch)->andWhere('branch')->in($branch)->fi()
->beginIF($modules)->andWhere('module')->in($modules)->fi()
->andWhere('project')->in(array_keys($projects))
->andWhere('execution')->in(array_keys($executions))
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
}
@@ -2241,13 +2241,13 @@ class bugModel extends model
* @param int $productID
* @param int $branch
* @param array $modules
* @param array $projects
* @param array $executions
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getByNeedconfirm($productID, $branch, $modules, $projects, $orderBy, $pager)
public function getByNeedconfirm($productID, $branch, $modules, $executions, $orderBy, $pager)
{
return $this->dao->select('t1.*, t2.title AS storyTitle')->from(TABLE_BUG)->alias('t1')->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
->where("t2.status = 'active'")
@@ -2255,7 +2255,7 @@ class bugModel extends model
->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi()
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
->andWhere('t2.version > t1.storyVersion')
->andWhere('t1.project')->in(array_keys($projects))
->andWhere('t1.execution')->in(array_keys($executions))
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager)
@@ -2313,7 +2313,7 @@ class bugModel extends model
if(strpos($bugQuery, ' `closedDate` ') !== false) $bugQuery = str_replace(' `closedDate` ', " `closedDate` != '0000-00-00 00:00:00' AND `closedDate` ", $bugQuery);
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery)
->beginIF(!$this->app->user->admin)->andWhere('project')->in('0,' . $this->app->user->view->projects)->fi()
->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi()
->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi()
->andWhere('deleted')->eq(0)
->orderBy($orderBy)->page($pager)->fetchAll();
@@ -2334,29 +2334,29 @@ class bugModel extends model
$relatedStoryIdList = array();
$relatedTaskIdList = array();
$relatedCaseIdList = array();
$relatedProjectIdList = array();
$relatedExecutionIdList = array();
foreach($bugs as $bug)
{
$relatedModuleIdList[$bug->module] = $bug->module;
$relatedStoryIdList[$bug->story] = $bug->story;
$relatedTaskIdList[$bug->task] = $bug->task;
$relatedCaseIdList[$bug->case] = $bug->case;
$relatedProjectIdList[$bug->project] = $bug->project;
$relatedModuleIdList[$bug->module] = $bug->module;
$relatedStoryIdList[$bug->story] = $bug->story;
$relatedTaskIdList[$bug->task] = $bug->task;
$relatedCaseIdList[$bug->case] = $bug->case;
$relatedExecutionIdList[$bug->execution] = $bug->execution;
/* Get related objects title or names. */
$relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs();
$relatedStories = $this->dao->select('id, title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedTasks = $this->dao->select('id, name')->from(TABLE_TASK)->where('id')->in($relatedTaskIdList)->fetchPairs();
$relatedCases = $this->dao->select('id, title')->from(TABLE_CASE)->where('id')->in($relatedCaseIdList)->fetchPairs();
$relatedProjects = $this->dao->select('id, name')->from(TABLE_PROJECT)->where('id')->in($relatedProjectIdList)->fetchPairs();
$relatedModules = $this->dao->select('id, name')->from(TABLE_MODULE)->where('id')->in($relatedModuleIdList)->fetchPairs();
$relatedStories = $this->dao->select('id, title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedTasks = $this->dao->select('id, name')->from(TABLE_TASK)->where('id')->in($relatedTaskIdList)->fetchPairs();
$relatedCases = $this->dao->select('id, title')->from(TABLE_CASE)->where('id')->in($relatedCaseIdList)->fetchPairs();
$relatedExecutions = $this->dao->select('id, name')->from(TABLE_EXECUTION)->where('id')->in($relatedExecutionIdList)->fetchPairs();
/* fill some field with useful value. */
if(isset($relatedModules[$bug->module])) $bug->module = $relatedModules[$bug->module];
if(isset($relatedStories[$bug->story])) $bug->story = $relatedStories[$bug->story];
if(isset($relatedTasks[$bug->task])) $bug->task = $relatedTasks[$bug->task];
if(isset($relatedCases[$bug->case])) $bug->case = $relatedCases[$bug->case];
if(isset($relatedProjects[$bug->project])) $bug->project = $relatedProjects[$bug->project];
if(isset($relatedModules[$bug->module])) $bug->module = $relatedModules[$bug->module];
if(isset($relatedStories[$bug->story])) $bug->story = $relatedStories[$bug->story];
if(isset($relatedTasks[$bug->task])) $bug->task = $relatedTasks[$bug->task];
if(isset($relatedCases[$bug->case])) $bug->case = $relatedCases[$bug->case];
if(isset($relatedExecutions[$bug->execution])) $bug->execution = $relatedExecutions[$bug->execution];
}
return $bugs;
}
@@ -2438,7 +2438,7 @@ class bugModel extends model
* @param array $builds
* @param array $branches
* @param array $modulePairs
* @param array $projects
* @param array $executions
* @param array $plans
* @param array $stories
* @param array $tasks
@@ -2446,7 +2446,7 @@ class bugModel extends model
* @access public
* @return void
*/
public function printCell($col, $bug, $users, $builds, $branches, $modulePairs, $projects = array(), $plans = array(), $stories = array(), $tasks = array(), $mode = 'datatable')
public function printCell($col, $bug, $users, $builds, $branches, $modulePairs, $executions = array(), $plans = array(), $stories = array(), $tasks = array(), $mode = 'datatable')
{
/* Check the product is closed. */
$canBeChanged = common::canBeChanged('bug', $bug);
@@ -2511,7 +2511,7 @@ class bugModel extends model
$title = "title='" . zget($users, $bug->resolvedBy) . "'";
}
if($id == 'deadline' && isset($bug->delay)) $class .= ' delayed';
if(strpos(',type,project,story,plan,task,openedBuild,', ",{$id},") !== false) $class .= ' text-ellipsis';
if(strpos(',type,execution,story,plan,task,openedBuild,', ",{$id},") !== false) $class .= ' text-ellipsis';
echo "<td class='" . $class . "' $title>";
if(isset($this->config->bizVersion)) $this->loadModel('flow')->printFlowCell('bug', $bug, $id);
@@ -2556,8 +2556,8 @@ class bugModel extends model
case 'branch':
echo zget($branches, $bug->branch, '');
break;
case 'project':
echo zget($projects, $bug->project, '');
case 'execution':
echo zget($executions, $bug->execution, '');
break;
case 'plan':
echo zget($plans, $bug->plan, '');
@@ -2823,9 +2823,9 @@ class bugModel extends model
}
/**
* Summary
*
* @param array $bugs
* Summary
*
* @param array $bugs
* @access public
* @return string
*/