From d7110d4ea8f606abfbc4f2ac12ac9367f8d76e35 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 1 Dec 2021 08:16:32 +0800 Subject: [PATCH 01/11] * Code for task #45079. --- module/product/control.php | 2 +- module/product/model.php | 66 ++++++++++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 7 deletions(-) diff --git a/module/product/control.php b/module/product/control.php index c1d38e293b..cb8b92f088 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -279,7 +279,7 @@ class product extends control $actionURL = $this->createLink($rawModule, $rawMethod, $params . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID&storyType=$storyType"); $this->config->product->search['onMenuBar'] = 'yes'; - $this->product->buildSearchForm($productID, $this->products, $queryID, $actionURL); + $this->product->buildSearchForm($productID, $this->products, $queryID, $actionURL, $branch); $showModule = !empty($this->config->datatable->productBrowse->showModule) ? $this->config->datatable->productBrowse->showModule : ''; diff --git a/module/product/model.php b/module/product/model.php index dad456e69e..ca00a82cbb 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -886,24 +886,78 @@ class productModel extends model * @param array $products * @param int $queryID * @param int $actionURL + * @param int $branch * @access public * @return void */ - public function buildSearchForm($productID, $products, $queryID, $actionURL) + public function buildSearchForm($productID, $products, $queryID, $actionURL, $branch = 0) { + $productIdList = ($this->app->tab == 'project' and empty($productID)) ? array_keys($products) : $productID; + $branchParam = ($this->app->tab == 'project' and empty($productID)) ? '' : $branch; + $this->config->product->search['actionURL'] = $actionURL; $this->config->product->search['queryID'] = $queryID; - $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs(($this->app->tab == 'project' and empty($productID)) ? array_keys($products) : $productID); + $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs($productIdList, $branchParam); $product = ($this->app->tab == 'project' and empty($productID)) ? $products : array($productID => $products[$productID]); $this->config->product->search['params']['product']['values'] = $product + array('all' => $this->lang->product->allProduct); - /* Get module of all products.*/ - $module = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'story', $startModuleID = 0); + /* Get module of all products. */ + $module = $this->loadModel('tree')->getOptionMenu($productID, 'story', 0, $branch); + if($this->app->tab == 'project' and $productID) + { + $module = array(); + $modules = array(); + + $branchList = $this->loadModel('branch')->getPairs($productID, '', $this->session->project); + $modules[$productID] = $this->tree->getOptionMenu($productID, 'story', 0, array_keys($branchList)); + foreach($modules as $branchList) + { + foreach($branchList as $branchID => $moduleList) + { + foreach($moduleList as $moduleID => $moduleName) $module[$moduleID] = $moduleName; + } + } + } if(!$productID) { - $module = array(); - foreach($products as $id => $product) $module += $this->loadModel('tree')->getOptionMenu($id, $viewType = 'story', $startModuleID = 0); + $module = array(); + $modules = array(); + + if($this->app->tab == 'project') + { + $branchGroup = $this->loadModel('execution')->getBranchByProduct(array_keys($products), $this->session->project); + foreach($products as $productID => $productName) + { + if(isset($branchGroup[$productID])) + { + $branches = array_keys($branchGroup[$productID]); + $modules = $this->tree->getOptionMenu($productID, 'story', 0, $branches); + foreach($modules as $branchID => $moduleList) + { + foreach($moduleList as $moduleID => $moduleName) + { + $modules[$moduleID] = $productName . $moduleName; + } + } + + } + else + { + //$modules[$productID] = $this->tree->getOptionMenu($productID, 'story', 0, $branch); + } + } + + //foreach($modules as $branchList) + //{ + // foreach($branchList as $branchID => $moduleList) + // { + // foreach($moduleList as $moduleID => $moduleName) $module[$moduleID] = $moduleName; + // } + //} + } + + foreach($products as $id => $product) $module += $this->loadModel('tree')->getOptionMenu($id, 'story', 0); } $this->config->product->search['params']['module']['values'] = $module; From 985599a98a3feb68bcd8e8701007a356fd57bf97 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 1 Dec 2021 14:57:53 +0800 Subject: [PATCH 02/11] * Code for task#45026. --- module/product/model.php | 63 ++++++++++++++-------------------------- module/story/model.php | 2 +- 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/module/product/model.php b/module/product/model.php index ca00a82cbb..d7935835b8 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -902,64 +902,43 @@ class productModel extends model $product = ($this->app->tab == 'project' and empty($productID)) ? $products : array($productID => $products[$productID]); $this->config->product->search['params']['product']['values'] = $product + array('all' => $this->lang->product->allProduct); - /* Get module of all products. */ - $module = $this->loadModel('tree')->getOptionMenu($productID, 'story', 0, $branch); - if($this->app->tab == 'project' and $productID) + /* Get modules. */ + $modules = $this->loadModel('tree')->getOptionMenu($productID, 'story', 0, $branch); + if($this->app->tab == 'project') { - $module = array(); - $modules = array(); - - $branchList = $this->loadModel('branch')->getPairs($productID, '', $this->session->project); - $modules[$productID] = $this->tree->getOptionMenu($productID, 'story', 0, array_keys($branchList)); - foreach($modules as $branchList) + if($productID) { - foreach($branchList as $branchID => $moduleList) - { - foreach($moduleList as $moduleID => $moduleName) $module[$moduleID] = $moduleName; - } + $modules = array(); + $branchList = $this->loadModel('branch')->getPairs($productID, '', $this->session->project); + $branchModuleList = $this->tree->getOptionMenu($productID, 'story', 0, array_keys($branchList)); + foreach($branchModuleList as $branchID => $branchModules) $modules += $branchModules; } - } - if(!$productID) - { - $module = array(); - $modules = array(); - - if($this->app->tab == 'project') + else { + $moduleList = array(); + $modules = array('' => '/'); $branchGroup = $this->loadModel('execution')->getBranchByProduct(array_keys($products), $this->session->project); foreach($products as $productID => $productName) { if(isset($branchGroup[$productID])) { - $branches = array_keys($branchGroup[$productID]); - $modules = $this->tree->getOptionMenu($productID, 'story', 0, $branches); - foreach($modules as $branchID => $moduleList) - { - foreach($moduleList as $moduleID => $moduleName) - { - $modules[$moduleID] = $productName . $moduleName; - } - } - + $branchModuleList = $this->tree->getOptionMenu($productID, 'story', 0, array_keys($branchGroup[$productID])); + foreach($branchModuleList as $branchID => $branchModules) $moduleList += $branchModules; } else { - //$modules[$productID] = $this->tree->getOptionMenu($productID, 'story', 0, $branch); + $moduleList = $this->tree->getOptionMenu($productID, 'story', 0, $branch); + } + + foreach($moduleList as $moduleID => $moduleName) + { + if(empty($moduleID)) continue; + $modules[$moduleID] = $productName . $moduleName; } } - - //foreach($modules as $branchList) - //{ - // foreach($branchList as $branchID => $moduleList) - // { - // foreach($moduleList as $moduleID => $moduleName) $module[$moduleID] = $moduleName; - // } - //} } - - foreach($products as $id => $product) $module += $this->loadModel('tree')->getOptionMenu($id, 'story', 0); } - $this->config->product->search['params']['module']['values'] = $module; + $this->config->product->search['params']['module']['values'] = $modules; $productInfo = $this->getById($productID); if(!$productID or $productInfo->type == 'normal' or $this->app->tab == 'assetlib') diff --git a/module/story/model.php b/module/story/model.php index b178fa8cb2..d539d4f382 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2491,7 +2491,7 @@ class storyModel extends model { $storyQuery = str_replace($allBranch, '1', $storyQuery); } - elseif($branch) + elseif($branch !== 'all') { if($branch and strpos($storyQuery, '`branch` =') === false) $storyQuery .= " AND `branch` in($branch)"; } From 36fa35d3d1f91cbf61e07a3995fc590a7fb25282 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 1 Dec 2021 17:09:52 +0800 Subject: [PATCH 03/11] * Fix bug #15832. --- module/tree/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/tree/control.php b/module/tree/control.php index 0fd909702d..92c5cf060c 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -31,7 +31,7 @@ class tree extends control if($this->app->tab == 'product') { - $this->product->setMenu($rootID, $branch, 0, '', $viewType); + $this->product->setMenu($this->session->product, $branch, 0, '', $viewType); } else if($this->app->tab == 'qa' and $viewType != 'caselib') { From 32a526275d83d463a2ef5bf6dea16f9627b000d0 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 1 Dec 2021 18:13:27 +0800 Subject: [PATCH 04/11] * There is a problem with the drop-down of test cases. --- module/product/model.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/product/model.php b/module/product/model.php index d7935835b8..d793973115 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1969,7 +1969,9 @@ class productModel extends model } elseif(($module == 'testcase' and $method == 'groupCase') or ($module == 'story' and $method == 'zeroCase') and $this->app->tab == 'project') { - $link = helper::createLink($module, $method, "productID=%s" . ($branch ? "&branch=%s" : '')) . "#app=project"; + parse_str($extra, $output); + $projectID = isset($output['projectID']) ? $output['projectID'] : 0; + $link = helper::createLink($module, $method, "productID=%s" . ($branch ? "&branch=%s" : '') . "&groupBy=&projectID=$projectID"); } else { From d68810fd4abc30cf9fa1365beda25d87767bffd4 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Thu, 2 Dec 2021 08:54:51 +0800 Subject: [PATCH 05/11] * Fix bug #16893. --- module/repo/control.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/repo/control.php b/module/repo/control.php index 96de1cd557..d962d04c4b 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -169,7 +169,8 @@ class repo extends control if(strtolower($repo->SCM) == 'gitlab') { - $projects = $this->loadModel('gitlab')->apiGetProjects($repo->gitlab); + $gitlabID = isset($repo->gitlab) ? $repo->gitlab : 0; + $projects = $this->loadModel('gitlab')->apiGetProjects($gitlabID); $options = array(); foreach($projects as $project) $options[$project->id] = $project->name_with_namespace; From c3b824d946cc922726d6b9c5bc1fdb491dae9750 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Thu, 2 Dec 2021 09:06:23 +0800 Subject: [PATCH 06/11] * Fix bug #16997. --- module/repo/view/maintain.html.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/module/repo/view/maintain.html.php b/module/repo/view/maintain.html.php index 4c1408bfaf..000c42f1d9 100644 --- a/module/repo/view/maintain.html.php +++ b/module/repo/view/maintain.html.php @@ -53,10 +53,13 @@ id&objectID=$objectID", '', 'list', 'edit'); - echo html::a($this->createLink('gitlab', 'createWebhook', "repoID=$repo->id"), '', 'hiddenwin', "title='{$lang->repo->addWebHook}'"); - if(strtolower($repo->SCM) == "gitlab") common::printIcon('gitlab', 'importIssue', "repo={$repo->id}", '', 'list', 'link'); - if(strtolower($repo->SCM) == "gitlab") common::printIcon('gitlab', 'manageProjectMembers', "repo={$repo->id}", '', 'list', 'team'); - if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'"); + if(strtolower($repo->SCM) == "gitlab") + { + common::printIcon('gitlab', 'createWebhook', "repoID=$repo->id", '', 'list', 'change', 'hiddenwin'); + common::printIcon('gitlab', 'importIssue', "repo={$repo->id}", '', 'list', 'link'); + common::printIcon('gitlab', 'manageProjectMembers', "repo={$repo->id}", '', 'list', 'team'); + } + common::printIcon('repo', 'delete', "repoID=$repo->id&objectID=$objectID", '', 'list', 'trash', 'hiddenwin'); ?> From 3755502cf554e3bf9ef3b85230caaa1ddafefd09 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Thu, 2 Dec 2021 09:12:50 +0800 Subject: [PATCH 07/11] * Fix bug : Unit test product drop-down error. --- module/branch/view/ajaxgetdropmenu.html.php | 2 +- module/product/model.php | 2 +- module/product/view/ajaxgetdropmenu.html.php | 3 ++- module/story/control.php | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/module/branch/view/ajaxgetdropmenu.html.php b/module/branch/view/ajaxgetdropmenu.html.php index 92114b05af..e31ed3807b 100644 --- a/module/branch/view/ajaxgetdropmenu.html.php +++ b/module/branch/view/ajaxgetdropmenu.html.php @@ -13,7 +13,7 @@ foreach($branches as $branchID => $branch) if($branchID == 'all' or empty($branchID) or $statusList[$branchID] == 'active') { - $activeBranchesHtml .= html::a($linkHtml, $branch, '', "class='$selected' data-key='{$branchesPinyin[$branch]}' data-app='{$this->app->tab}'"); + $activeBranchesHtml .= html::a($linkHtml, $branch, '', "class='$selected' data-key='{$branchesPinyin[$branch]}'"); } else { diff --git a/module/product/model.php b/module/product/model.php index d793973115..f6a9fc665b 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1971,7 +1971,7 @@ class productModel extends model { parse_str($extra, $output); $projectID = isset($output['projectID']) ? $output['projectID'] : 0; - $link = helper::createLink($module, $method, "productID=%s" . ($branch ? "&branch=%s" : '') . "&groupBy=&projectID=$projectID"); + $link = helper::createLink($module, $method, "productID=%s&branch=" . ($branch ? "%s" : '') . "&groupBy=&projectID=$projectID") . "#app=project"; } else { diff --git a/module/product/view/ajaxgetdropmenu.html.php b/module/product/view/ajaxgetdropmenu.html.php index fd55464514..e5e4614385 100644 --- a/module/product/view/ajaxgetdropmenu.html.php +++ b/module/product/view/ajaxgetdropmenu.html.php @@ -78,10 +78,11 @@ foreach($products as $programID => $programProducts) $selected = $product->id == $productID ? 'selected' : ''; $productName = $product->line ? zget($lines, $product->line, '') . ' / ' . $product->name : $product->name; $linkHtml = $this->product->setParamsForLink($module, $link, $projectID, $product->id); + $locateTab = ($module == 'testtask' and $method == 'browseUnits' and $app->tab == 'project') ? '' : "data-app='$app->tab'"; if($product->status == 'normal' and $product->PO == $this->app->user->account) { - $myProductsHtml .= '
  • ' . html::a($linkHtml, $productName, '', "class='$selected productName' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' data-app='$app->tab'") . '
  • '; + $myProductsHtml .= '
  • ' . html::a($linkHtml, $productName, '', "class='$selected productName' title='{$productName}' data-key='" . zget($productsPinYin, $product->name, '') . "' " . $locateTab) . '
  • '; if($selected == 'selected') $tabActive = 'myProduct'; diff --git a/module/story/control.php b/module/story/control.php index 5b47f55529..a7d2e27a2c 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1724,6 +1724,7 @@ class story extends control */ public function zeroCase($productID = 0, $branchID = 0, $orderBy = 'id_desc', $projectID = 0) { + $orderBy = empty($orderBy) ? 'id_desc' : $orderBy; $this->session->set('storyList', $this->app->getURI(true) . '#app=' . $this->app->tab, 'product'); $this->session->set('caseList', $this->app->getURI(true), $this->app->tab); From e0b03a60a7833882f43a473c17a9a817bb963152 Mon Sep 17 00:00:00 2001 From: liyuchun Date: Thu, 2 Dec 2021 09:54:03 +0800 Subject: [PATCH 08/11] * Fix bug #16999. --- module/gitlab/control.php | 4 ++-- module/repo/model.php | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index bb0006ee1a..6dcbf1b576 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -727,8 +727,8 @@ class gitlab extends control $projectID = $repo->project; $gitlab = $this->gitlab->getByID($gitlabID); - $user = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token); - if(!isset($user->is_admin) or !$user->is_admin) die(js::alert($this->lang->gitlab->tokenLimit) . js::locate($this->createLink('gitlab', 'edit', array('gitlabID' => $gitlabID)))); + if($gitlab) $user = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token); + if(empty($user->is_admin)) die(js::alert($this->lang->gitlab->tokenLimit) . js::locate($this->createLink('gitlab', 'edit', array('gitlabID' => $gitlabID)))); if($_POST) diff --git a/module/repo/model.php b/module/repo/model.php index e186d55704..63a29d1dcf 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -1783,13 +1783,12 @@ class repoModel extends model public function processGitlab($repo) { $gitlab = $this->loadModel('gitlab')->getByID($repo->client); // The $repo->client is gitlabID. - if(!$gitlab) return $repo; - $repo->gitlab = $gitlab->id; - $repo->project = $repo->path; // The projectID in gitlab. - $repo->path = sprintf($this->config->repo->gitlab->apiPath, $gitlab->url, $repo->path); - $repo->client = $gitlab->url; - $repo->password = $gitlab->token; + $repo->gitlab = $gitlab ? $gitlab->id : 0; + $repo->project = $gitlab ? $repo->path : ''; // The projectID in gitlab. + $repo->path = $gitlab ? sprintf($this->config->repo->gitlab->apiPath, $gitlab->url, $repo->path) : ''; + $repo->client = $gitlab ? $gitlab->url : ''; + $repo->password = $gitlab ? $gitlab->token : ''; return $repo; } From 3c8e265ab7148f74632569117e2e98eee851368e Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Thu, 2 Dec 2021 10:04:14 +0800 Subject: [PATCH 09/11] * Fix bug #16986. --- module/doc/view/tablecontents.html.php | 4 ++-- module/tree/control.php | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 783a8fa074..3306993b9f 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -44,7 +44,7 @@ if(empty($type)) $type = 'product'; echo "