diff --git a/module/story/model.php b/module/story/model.php index 8bd99e2f90..cc4bf06a92 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1288,6 +1288,7 @@ class storyModel extends model ->leftJoin(TABLE_PRODUCT)->alias('t4')->on('t2.product = t4.id') ->where('t1.project')->eq((int)$projectID) ->beginIF($type == 'byProduct')->andWhere('t1.product')->eq($param)->fi() + ->beginIF($type == 'byBrach')->andWhere('t2.branch')->eq($param)->fi() ->beginIF($type == 'byModule' and $param)->andWhere('t2.module')->in($modules)->fi() ->andWhere('t2.deleted')->eq(0) ->orderBy($orderBy) diff --git a/module/tree/model.php b/module/tree/model.php index ac40473241..28bf019034 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -44,7 +44,7 @@ class treeModel extends model if($startModule) $startModulePath = $startModule->path . '%'; } - if($type == 'bug' or $type == 'case') + if($type == 'bug' or $type == 'case' or $type == 'task') { /* Get createdVersion. */ $createdVersion = $this->dao->select('createdVersion')->from(TABLE_PRODUCT) @@ -64,7 +64,7 @@ class treeModel extends model } } - /* $createdVersion < 4.1 or $type == 'story','task'. */ + /* $createdVersion < 4.1 or $type == 'story'. */ return $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) ->andWhere('type')->eq($type) @@ -186,9 +186,9 @@ class treeModel extends model { $parentModules = explode(',', trim($module->path, ',')); if($type == 'product' and isset($noProductModules[$parentModules[0]])) continue; - $rootName = $rootModule; - if($type == 'product' and $module->branch and isset($branchGroups[$id][$module->branch])) $rootName .= '/' . $branchGroups[$id][$module->branch]; - $this->buildTreeArray($treeMenu, $modules, $module, $productNum > 1 ? "/$rootName/" : '/'); + $rootName = $productNum > 1 ? "/$rootModule" : '/'; + if($type == 'product' and $module->branch and isset($branchGroups[$id][$module->branch])) $rootName .= $branchGroups[$id][$module->branch] . '/'; + $this->buildTreeArray($treeMenu, $modules, $module, $rootName); } ksort($treeMenu); @@ -329,7 +329,8 @@ class treeModel extends model ->where('id')->eq($rootID) ->fetch('openedVersion'); $products = $this->loadModel('product')->getProductsByProject($rootID); - $productGroups = $this->dao->select('product,branch')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($rootID)->fetchGroup('product', 'branch'); + $branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); + if(!$createdVersion or version_compare($createdVersion, '4.1', '<=') or !$products) { $extra['tip'] = false; @@ -368,20 +369,25 @@ class treeModel extends model } /* tree menu. */ - $treeMenu = array(); - $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $rootID and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch in(0," . (isset($productGroups[$id]) ? join(',', array_keys($productGroups[$id])) : 0) . ")))") - ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() - ->orderBy('grade desc, type, `order`') - ->get(); - $stmt = $this->dbh->query($query); - while($module = $stmt->fetch()) + $tree = ''; + foreach($branchGroups[$id] as $branch => $branchName) { - /* if not manage, ignore unused modules. */ - if(!$manage and !isset($projectModules[$module->id])) continue; - $this->buildTree($treeMenu, $module, 'task', $userFunc, $extra); + $treeMenu = array(); + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = $rootID and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") + ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() + ->orderBy('grade desc, type, `order`') + ->get(); + $stmt = $this->dbh->query($query); + while($module = $stmt->fetch()) + { + /* if not manage, ignore unused modules. */ + if(!$manage and !isset($projectModules[$module->id])) continue; + $this->buildTree($treeMenu, $module, 'task', $userFunc, $extra); + } + if(isset($treeMenu[0]) and $branch) $treeMenu[0] = "