diff --git a/module/branch/control.php b/module/branch/control.php index 7e0a6c65d1..0181b053e6 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -258,22 +258,19 @@ class branch extends control */ public function ajaxGetBranches($productID, $oldBranch = 0, $param = '', $projectID = 0) { + $param = $param ? $param : 'all'; $product = $this->loadModel('product')->getById($productID); if(empty($product) or $product->type == 'normal') die(); - $branches = $this->branch->getPairs($productID, $param); - - /* Remove unlinked branches of the project. */ - if($projectID) + $branches = $this->loadModel('branch')->getList($productID, $projectID, $param); + $branchOption = array(); + $branchTagOption = array(); + foreach($branches as $branchInfo) { - $projectProducts = $this->loadModel('project')->getBranchesByProject($projectID); - foreach($branches as $branchID => $branchName) - { - if(!isset($projectProducts[$productID][$branchID])) unset($branches[$branchID]); - } + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } - - die(html::select('branch', $branches, $oldBranch, "class='form-control' onchange='loadBranch(this)'")); + die(html::select('branch', strpos($param, 'active') !== false ? $branchOption : $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)'")); } /** diff --git a/module/branch/model.php b/module/branch/model.php index 4d27e1ed7e..4b1a59861d 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -85,6 +85,8 @@ class branchModel extends model $mainBranch->desc = sprintf($this->lang->branch->mainBranch, $this->lang->product->branchName[$product->type]); $mainBranch->order = 0; + if($productID) $product = $this->loadModel('product')->getById($productID); + if(isset($product) and $product->type == 'normal') return $branchList; return array($mainBranch) + $branchList; } diff --git a/module/bug/control.php b/module/bug/control.php index ae7ec573e1..87432af5c1 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -207,6 +207,16 @@ class bug extends control /* Display of branch label. */ $showBranch = $this->loadModel('branch')->showBranch($productID); + /* Display status of branch. */ + $branches = $this->loadModel('branch')->getList($productID, 0, 'all'); + $branchOption = array(); + $branchTagOption = array(); + foreach($branches as $branchInfo) + { + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } + /* Set view. */ $this->view->title = $productName . $this->lang->colon . $this->lang->bug->common; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $productName,'','title=' . $productName); @@ -229,7 +239,8 @@ 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->branchOption = $branchOption; + $this->view->branchTagOption = $branchTagOption; $this->view->executions = $executions; $this->view->plans = $this->loadModel('productplan')->getPairs($productID); $this->view->stories = $storyList; @@ -965,13 +976,17 @@ class bug extends control if($this->app->tab == 'execution' or $this->app->tab == 'project') { - $objectID = $this->app->tab == 'project' ? $bug->project : $bug->execution; - $productBranches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('execution')->getBranchByProduct($productID, $objectID, 'all') : array(); - $branches = isset($productBranches[$productID]) ? array(BRANCH_MAIN => $this->lang->branch->main) + $productBranches[$productID] : array(); + $objectID = $this->app->tab == 'project' ? $bug->project : $bug->execution; } - else + + /* Display status of branch. */ + $branches = $this->loadModel('branch')->getList($productID, isset($objectID) ? $objectID : 0, 'all'); + $branchOption = array(); + $branchTagOption = array(); + foreach($branches as $branchInfo) { - $branches = (isset($product->type) and $product->type != 'normal') ? $this->loadModel('branch')->getPairs($productID) : array(); + $branchOption[$branchInfo->id] = $branchInfo->name; + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } $this->view->bug = $bug; @@ -984,7 +999,8 @@ class bug extends control $this->view->currentModuleID = $currentModuleID; $this->view->executions = array(0 => '') + $this->product->getExecutionPairsByProduct($bug->product, $bug->branch, 'id_desc', $bug->project); $this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch); - $this->view->branches = $branches; + $this->view->branchOption = $branchOption; + $this->view->branchTagOption = $branchTagOption; $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); $this->view->testtasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask); $this->view->users = $this->user->getPairs('nodeleted', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy"); @@ -1053,12 +1069,17 @@ class bug extends control $plans = array('' => '', 'ditto' => $this->lang->bug->ditto) + $plans; /* Set branches and modules. */ - $branches = array(); + $branches = array(); + $branchTagOption = array(); $modules = array(); if($product->type != 'normal') { - $branches = $this->loadModel('branch')->getPairs($productID); - foreach($branches as $branchID => $branchName) + $branches = $this->loadModel('branch')->getList($productID, 0 ,'all'); + foreach($branches as $branchInfo) + { + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } + foreach($branchTagOption as $branchID => $branchName) { $modules[$productID][$branchID] = $this->tree->getOptionMenu($productID, 'bug', 0, $branchID); } @@ -1071,11 +1092,11 @@ class bug extends control /* Set product menu. */ $this->qa->setMenu($this->products, $productID, $branch); - $this->view->title = $product->name . $this->lang->colon . "BUG" . $this->lang->bug->batchEdit; - $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID&branch=$branch"), $this->products[$productID]); - $this->view->plans = $plans; - $this->view->branches = $branches; - $this->view->modules = $modules; + $this->view->title = $product->name . $this->lang->colon . "BUG" . $this->lang->bug->batchEdit; + $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID&branch=$branch"), $this->products[$productID]); + $this->view->plans = $plans; + $this->view->branchTagOption = $branchTagOption; + $this->view->modules = $modules; } /* The bugs of my. */ else diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index caad3f41c6..90affd48f8 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -76,14 +76,19 @@ if(!empty($this->config->user->moreLink)) $this->config->moreLinks["assignedTos[$bugID]"] = $this->config->user->moreLink; if(!$productID) { - $product = $this->product->getByID($bug->product); - $plans = $this->loadModel('productplan')->getPairs($bug->product, $branch); - $branches = $product->type == 'normal' ? array('' => '') : $this->loadModel('branch')->getPairs($product->id); + $branchTagOption = array(); + $product = $this->product->getByID($bug->product); + $plans = $this->loadModel('productplan')->getPairs($bug->product, $branch); + $branches = $product->type == 'normal' ? array('' => '') : $this->loadModel('branch')->getList($product->id, 0 ,'all');; + foreach($branches as $branchInfo) + { + $branchTagOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); + } $modules[$bug->product][0] = $this->tree->getOptionMenu($bug->product, 'bug'); if($product->type != 'normal') { - foreach($branches as $branchID => $branchName) $branches[$branchID] = '/' . $product->name . '/' . $branchName; + foreach($branchTagOption as $branchID => $branchName) $branchTagOption[$branchID] = '/' . $product->name . '/' . $branchName; $modules[$bug->product][$bug->branch] = $this->tree->getOptionMenu($bug->product, 'bug', 0, $bug->branch); } } @@ -111,7 +116,7 @@