From 39a273978c3cc3fc99bce9103a937bf84d98a6d9 Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Fri, 12 Mar 2021 15:01:08 +0800 Subject: [PATCH] * Fix task #36447. --- module/branch/model.php | 48 ++++++++++++++++++++++------------------- module/bug/control.php | 2 +- module/tree/model.php | 10 ++++++--- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index d0cf8246ec..67274e61c2 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -13,8 +13,8 @@ class branchModel extends model { /** * Get name by id. - * - * @param int $branchID + * + * @param int $branchID * @access public * @return string */ @@ -32,15 +32,19 @@ class branchModel extends model /** * Get pairs. - * - * @param int $productID - * @param string $params + * + * @param int $productID + * @param string $params * @access public * @return array */ public function getPairs($productID, $params = '') { - $branches = $this->dao->select('*')->from(TABLE_BRANCH)->where('product')->eq($productID)->andWhere('deleted')->eq(0)->orderBy('`order`')->fetchPairs('id', 'name'); + $branches = $this->dao->select('*')->from(TABLE_BRANCH) + ->where('deleted')->eq(0) + ->beginIF($productID)->andWhere('product')->eq($productID)->fi() + ->orderBy('`order`') + ->fetchPairs('id', 'name'); foreach($branches as $branchID => $branchName) $branches[$branchID] = htmlspecialchars_decode($branchName); if(strpos($params, 'noempty') === false) @@ -55,8 +59,8 @@ class branchModel extends model /** * Get all pairs. - * - * @param string $params + * + * @param string $params * @access public * @return array */ @@ -85,9 +89,9 @@ class branchModel extends model } /** - * Manage branch - * - * @param int $productID + * Manage branch + * + * @param int $productID * @access public * @return bool */ @@ -112,11 +116,11 @@ class branchModel extends model } /** - * Get branch group by products - * - * @param array $products - * @param string $params - * @param array $appendBranch + * Get branch group by products + * + * @param array $products + * @param string $params + * @param array $appendBranch * @access public * @return array */ @@ -152,8 +156,8 @@ class branchModel extends model /** * Get product bype by branch. - * - * @param int $branchID + * + * @param int $branchID * @access public * @return void */ @@ -166,8 +170,8 @@ class branchModel extends model } /** - * Sort branch. - * + * Sort branch. + * * @access public * @return void */ @@ -183,8 +187,8 @@ class branchModel extends model /** * Check branch data. - * - * @param int $branchID + * + * @param int $branchID * @access public * @return bool */ diff --git a/module/bug/control.php b/module/bug/control.php index 6d773c0e7d..0064887470 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -211,7 +211,7 @@ class bug extends control $this->view->moduleID = $moduleID; $this->view->memberPairs = $this->user->getPairs('noletter|nodeleted'); $this->view->branch = $branch; - $this->view->branches = $this->loadModel('branch')->getPairs($productID); + $this->view->branches = $this->loadModel('branch')->getPairs($productID, 'noempty'); $this->view->executions = $executions; $this->view->plans = $this->loadModel('productplan')->getPairs($productID); $this->view->stories = $storyList; diff --git a/module/tree/model.php b/module/tree/model.php index 3afa42172e..895ac0ba93 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -193,8 +193,12 @@ class treeModel extends model { /* When case with libIdList then append lib modules. */ $modules = array(); - if($this->isMergeModule($rootID, $viewType)) $viewType .= ',story'; - $modules += $this->dao->select('id,name,path,short')->from(TABLE_MODULE)->where('root')->eq($rootID)->andWhere('type')->in($viewType)->andWhere('deleted')->eq(0)->fetchAll('id'); + if($this->isMergeModule($rootID, $viewType) or !$rootID) $viewType .= ',story'; + $modules += $this->dao->select('id,name,path,short')->from(TABLE_MODULE) + ->where('type')->in($viewType) + ->beginIF($rootID)->andWhere('root')->eq($rootID)->fi() + ->andWhere('deleted')->eq(0) + ->fetchAll('id'); } $modulePairs = array(); @@ -659,7 +663,7 @@ class treeModel extends model foreach($branchGroups[$id] as $branch => $branchName) { $treeMenu = array(); - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'bug' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $id and type = 'bug') OR (root = $id and type = 'story' and branch ='$branch'))") ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type')