diff --git a/module/bug/model.php b/module/bug/model.php index 1f9aad0f76..7666ca712c 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -900,7 +900,7 @@ class bugModel extends model if($browseType == 'bySearch') { $bug = $this->getById($bugID); - $bugs2Link = $this->getBySearch($bug->product, $queryID, 'id', null); + $bugs2Link = $this->getBySearch($bug->product, $queryID, 'id', null, $bug->branch); foreach($bugs2Link as $key => $bug2Link) { if($bug2Link->id == $bugID) unset($bugs2Link[$key]); @@ -980,7 +980,7 @@ class bugModel extends model else { $this->config->bug->search['fields']['branch'] = $this->lang->product->branch; - $this->config->bug->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty'); + $this->config->bug->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty') + array('all' => $this->lang->branch->all); } $this->loadModel('search')->setSearchParams($this->config->bug->search); @@ -1941,7 +1941,9 @@ class bugModel extends model $bugQuery = str_replace($allProduct, '1', $bugQuery); $bugQuery = $bugQuery . ' AND `product` ' . helper::dbIN($products); } - if($branch) $bugQuery .= " AND `branch` in('0','$branch')"; + $allBranch = "`branch` = 'all'"; + if($branch and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('0','$branch')"; + if(strpos($bugQuery, $allBranch) !== false) $bugQuery = str_replace($allBranch, '1', $bugQuery); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery) ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); diff --git a/module/build/control.php b/module/build/control.php index 8d317090bb..331f09ac93 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -333,7 +333,7 @@ class build extends control if($browseType == 'bySearch') { - $allStories = $this->story->getBySearch($build->product, $queryID, 'id', null, $build->project); + $allStories = $this->story->getBySearch($build->product, $queryID, 'id', null, $build->project, $build->branch); } else { diff --git a/module/product/model.php b/module/product/model.php index a00de27ab1..44ac2c7d30 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -464,7 +464,7 @@ class productModel extends model else { $this->config->product->search['fields']['branch'] = $this->lang->product->branch; - $this->config->product->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty'); + $this->config->product->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty') + array('all' => $this->lang->branch->all); } $this->loadModel('search')->setSearchParams($this->config->product->search); diff --git a/module/story/model.php b/module/story/model.php index 3e08d7ff0d..8bdfd690ce 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1184,7 +1184,7 @@ class storyModel extends model if($browseType == 'bySearch') { $story = $this->getById($storyID); - $stories2Link = $this->getBySearch($story->product, $queryID, 'id', null); + $stories2Link = $this->getBySearch($story->product, $queryID, 'id', null, '', $story->branch); foreach($stories2Link as $key => $story2Link) { if($story2Link->id == $storyID) unset($stories2Link[$key]); @@ -1473,7 +1473,9 @@ class storyModel extends model } elseif($branch) { - $storyQuery .= " AND `branch`" . helper::dbIN("0,$branch"); + $allBranch = "`branch` = 'all'"; + if($branch and strpos($storyQuery, '`branch` =') === false) $storyQuery .= " AND `branch` in('0','$branch')"; + if(strpos($storyQuery, $allBranch) !== false) $storyQuery = str_replace($allBranch, '1', $storyQuery); } $storyQuery = preg_replace("/`plan` +LIKE +'%([0-9]+)%'/i", "CONCAT(',', `plan`, ',') LIKE '%,$1,%'", $storyQuery); diff --git a/module/testcase/model.php b/module/testcase/model.php index 02885e59dc..862855b072 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -288,7 +288,7 @@ class testcaseModel extends model /* By search. */ elseif($browseType == 'bysearch') { - $cases = $this->getBySearch($productID, $queryID, $sort, $pager); + $cases = $this->getBySearch($productID, $queryID, $sort, $pager, $branch); } return $cases; @@ -304,7 +304,7 @@ class testcaseModel extends model * @access public * @return array */ - public function getBySearch($productID, $queryID, $orderBy, $pager = null) + public function getBySearch($productID, $queryID, $orderBy, $pager = null, $branch = 0) { if($queryID) { @@ -334,6 +334,10 @@ class testcaseModel extends model $caseQuery = $caseQuery . ' AND `product` ' . helper::dbIN($products); $queryProductID = 'all'; } + + $allBranch = "`branch` = 'all'"; + if($branch and strpos($caseQuery, '`branch` =') === false) $caseQuery .= " AND `branch` in('0','$branch')"; + if(strpos($caseQuery, $allBranch) !== false) $caseQuery = str_replace($allBranch, '1', $caseQuery); $caseQuery .= ')'; $cases = $this->dao->select('*')->from(TABLE_CASE)->where($caseQuery) @@ -539,7 +543,7 @@ class testcaseModel extends model if($browseType == 'bySearch') { $case = $this->getById($caseID); - $cases2Link = $this->getBySearch($case->product, $queryID, 'id', null); + $cases2Link = $this->getBySearch($case->product, $queryID, 'id', null, $case->branch); foreach($cases2Link as $key => $case2Link) { if($case2Link->id == $caseID) unset($cases2Link[$key]); @@ -966,7 +970,7 @@ class testcaseModel extends model else { $this->config->testcase->search['fields']['branch'] = $this->lang->product->branch; - $this->config->testcase->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty'); + $this->config->testcase->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($productID, 'noempty') + array('all' => $this->lang->branch->all); } $this->config->testcase->search['actionURL'] = $actionURL; $this->config->testcase->search['queryID'] = $queryID; diff --git a/module/testtask/control.php b/module/testtask/control.php index 8801a72f04..76f59c5b0d 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -569,12 +569,15 @@ class testtask extends control /* Get cases. */ if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1'); - $query = str_replace("`product` = 'all'", '1', $this->session->testcaseQuery); // If search all product, replace product = all to 1=1 + $query = $this->session->testcaseQuery; + $allProduct = "`product` = 'all'"; + if(strpos($query, '`product` =') === false) $query .= " AND `product` = $productID"; + if(strpos($query, $allProduct) !== false) $query = str_replace($allProduct, '1', $query); + $linkedCases = $this->dao->select('`case`')->from(TABLE_TESTRUN)->where('task')->eq($taskID)->fetchPairs('case'); if($param == 'all') { $cases = $this->dao->select('*')->from(TABLE_CASE)->where($query) - ->andWhere('product')->eq($productID) ->andWhere('id')->notIN($linkedCases) ->beginIF($task->branch)->andWhere('branch')->in("0,$task->branch")->fi() ->andWhere('deleted')->eq(0)