From 4163d17335b87933953c1de99ee902738359ab13 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 11 Nov 2021 15:31:37 +0800 Subject: [PATCH 1/2] * Fix bug #16169, bug#16179. --- module/product/control.php | 12 ++++++------ module/product/model.php | 1 + module/product/view/browse.html.php | 2 +- module/tree/model.php | 18 +++++++++--------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index aa6a60210a..8c59cdeec5 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -148,19 +148,19 @@ class product extends control if($this->cookie->preProductID != $productID or $this->cookie->preBranch != $branch or $browseType == 'bybranch') { - $_COOKIE['storyModule'] = 0; - setcookie('storyModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); + $_COOKIE['storyModule'] = 'all'; + setcookie('storyModule', 'all', 0, $this->config->webRoot, '', $this->config->cookieSecure, false); } if($browseType == 'bymodule' or $browseType == '') { setcookie('storyModule', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); if($this->app->tab == 'project') setcookie('storyModuleParam', (int)$param, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); - $_COOKIE['storyBranch'] = 0; - setcookie('storyBranch', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); + $_COOKIE['storyBranch'] = 'all'; + setcookie('storyBranch', 'all', 0, $this->config->webRoot, '', $this->config->cookieSecure, false); if($browseType == '') setcookie('treeBranch', $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); } - if($browseType == 'bybranch') setcookie('storyBranch', (int)$branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); + if($browseType == 'bybranch') setcookie('storyBranch', $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, false); $cookieModule = $this->app->tab == 'project' ? $this->cookie->storyModuleParam : $this->cookie->storyModule; $moduleID = ($browseType == 'bymodule') ? (int)$param : (($browseType == 'bysearch' or $browseType == 'bybranch') ? 0 : ($cookieModule ? $cookieModule : 0)); @@ -294,7 +294,7 @@ class product extends control $this->view->browseType = $browseType; $this->view->modules = $this->tree->getOptionMenu($productID, 'story', 0, $branch); $this->view->moduleID = $moduleID; - $this->view->moduleName = $moduleID ? $this->tree->getById($moduleID)->name : $this->lang->tree->all; + $this->view->moduleName = ($moduleID and $moduleID !== 'all') ? $this->tree->getById($moduleID)->name : $this->lang->tree->all; $this->view->branch = $branch; $this->view->branches = $this->loadModel('branch')->getPairs($productID); $this->view->storyStages = $this->product->batchGetStoryStage($stories); diff --git a/module/product/model.php b/module/product/model.php index d1b3955633..07a84a2345 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -2027,6 +2027,7 @@ class productModel extends model { $branchLink = $this->lang->product->menu->settings['subMenu']->branch['link']; $this->lang->product->menu->settings['subMenu']->branch['link'] = str_replace('@branch@', $this->lang->product->branchName[$product->type], $branchLink); + $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); } } } diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index cd2fe96d19..c52fbbc6af 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -46,7 +46,7 @@ $projectIDParam = $isProjectStory ? "projectID=$projectID&" : '';
createLink($this->app->rawModule, $this->app->rawMethod, $projectIDParam . "productID=$productID&branch=$branch&browseType=$browseType¶m=0&storyType=$storyType&orderBy=$orderBy&recTotal=0&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("storyModule")'; echo html::a($removeLink, "", '', "class='text-muted'"); diff --git a/module/tree/model.php b/module/tree/model.php index 0b16bd6734..ff3f0d25ae 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -65,6 +65,7 @@ class treeModel extends model * @param int $rootID * @param string $type * @param int $startModule + * @param int $branch * @access public * @return void */ @@ -86,7 +87,7 @@ class treeModel extends model ->beginIF($type != 'task')->andWhere('type')->in("story,$type")->fi() ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF((!empty($branch) and $branch != 'null'))->andWhere("branch")->eq($branch)->fi() + ->beginIF(((!empty($branch) or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type desc') ->get(); @@ -98,7 +99,7 @@ class treeModel extends model ->andWhere('type')->eq($type) ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF((!empty($branch) and $branch != 'null'))->andWhere("branch")->eq($branch)->fi() + ->beginIF(((!empty($branch) or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`') ->get(); @@ -381,11 +382,11 @@ class treeModel extends model $extra = array('rootID' => $rootID, 'branch' => $branch); } - $manage = $userFunc[1] == 'createManageLink' ? true : false; - $product = $this->loadModel('product')->getById($rootID); - if(strpos('story|bug|case', $type) !== false and empty($branch)) + $manage = $userFunc[1] == 'createManageLink' ? true : false; + $product = $this->loadModel('product')->getById($rootID); + if(strpos('story|bug|case', $type) !== false and $branch === 'all') { - if($product->type != 'normal') $branches = array('null' => '') + $this->loadModel('branch')->getPairs($rootID, 'noempty'); + if($product->type != 'normal') $branches = array('null' => '', BRANCH_MAIN => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($rootID, 'noempty'); } /* Add for task #1945. check the module has case or no. */ @@ -395,12 +396,11 @@ class treeModel extends model foreach($branches as $branchID => $branch) { $treeMenu = array(); - if($branchID == 0) $branchID = 'null'; $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID)); while($module = $stmt->fetch()) $this->buildTree($treeMenu, $module, $type, $userFunc, $extra, $branchID); if(!empty($extra) and empty($treeMenu)) continue; ksort($treeMenu); - if(!empty($branchID) and $branch and $branchID != 'null') + if((!empty($branchID) or $branchID === 0) and $branch and $branchID !== 'null') { $linkHtml = ($type == 'case' and !empty($extra)) ? '' . $branch . '' : $this->createBranchLink($type, $rootID, $branchID, $branch); $linkHtml = $manage ? html::a(inlink('browse', "root=$rootID&viewType=$type¤tModuleID=0&branch=$branchID"), $branch) : $linkHtml; @@ -887,7 +887,7 @@ class treeModel extends model public function buildTree(& $treeMenu, $module, $type, $userFunc, $extra, $branch = 0) { /* Add for task #1945. check the module has case or no. */ - if((isset($extra['rootID']) and isset($extra['branch']) and $branch == 'null') or ($type == 'case' and is_numeric($extra))) + if((isset($extra['rootID']) and isset($extra['branch']) and $branch === 'null') or ($type == 'case' and is_numeric($extra))) { static $objects = array(); if(empty($objects)) From a8f6836d46852f8e09d23d2b69ab83f6c8198056 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 11 Nov 2021 16:30:41 +0800 Subject: [PATCH 2/2] * Remove the unused code. --- module/tree/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/tree/model.php b/module/tree/model.php index ff3f0d25ae..8c0f1d2b5a 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -87,7 +87,7 @@ class treeModel extends model ->beginIF($type != 'task')->andWhere('type')->in("story,$type")->fi() ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF(((!empty($branch) or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() + ->beginIF((($branch or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type desc') ->get(); @@ -99,7 +99,7 @@ class treeModel extends model ->andWhere('type')->eq($type) ->beginIF($startModulePath)->andWhere('path')->like($startModulePath)->fi() ->beginIF($branch === 'null')->andWhere('branch')->eq(0)->fi() - ->beginIF(((!empty($branch) or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() + ->beginIF((($branch or $branch === 0) and $branch !== 'null'))->andWhere("branch")->eq($branch)->fi() ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`') ->get();