From 5d116c0cf8626117886b2a4eddd6c82a7403cfcf Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 22 May 2023 02:39:27 +0000 Subject: [PATCH] * Refactor linkBugs function. --- module/bug/control.php | 61 +++++++++++++----------------------------- module/bug/zen.php | 35 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 6198fbb497..8fcdde177b 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1022,66 +1022,41 @@ class bug extends control } /** + * 关联相关 bug。 * Link related bugs. * * @param int $bugID * @param string $browseType * @param string $excludeBugs - * @param int $param + * @param int $queryID * @param int $recTotal * @param int $recPerPage * @param int $pageID * @access public * @return void */ - public function linkBugs($bugID, $browseType = '', $excludeBugs = '', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function linkBugs(int $bugID, string $browseType = '', string $excludeBugs = '', int $queryID = 0, int $recTotal = 0, int $recPerPage = 20, int $pageID = 1) { + $bug = $this->bug->getByID($bugID); + + /* 检查 bug 所属执行的权限。*/ + /* Check privilege of bug 所属执行的权限。*/ + $this->bugZen->checkBugExecutionPriv($bug); + + $this->qa->setMenu($this->products, $bug->product, $bug->branch); + + $this->bugZen->buildSearchFormForLinkBugs($bug, $excludeBugs, $queryID); + /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - /* Get bug and queryID. */ - $bug = $this->bug->getById($bugID); - $queryID = ($browseType == 'bySearch') ? (int)$param : 0; - $this->bugZen->checkBugExecutionPriv($bug); - - /* Set the menu. */ - $this->qa->setMenu($this->products, $bug->product, $bug->branch); - - /* Hide plan and product in no product project. */ - if($bug->project and $this->app->tab != 'qa') - { - $project = $this->loadModel('project')->getByID($bug->project); - if(!$project->hasProduct) - { - unset($this->config->bug->search['fields']['product']); - if(!$project->multiple) - { - unset($this->config->bug->search['fields']['execution']); - unset($this->config->bug->search['fields']['plan']); - } - } - } - - /* Build the search form. */ - $actionURL = $this->createLink('bug', 'linkBugs', "bugID=$bugID&browseType=bySearch&excludeBugs=$excludeBugs&queryID=myQueryID", '', true); - $this->bug->buildSearchForm($bug->product, $this->products, $queryID, $actionURL); - - /* Get bugs to link. */ - $bugs2Link = $this->bug->getBugs2Link($bugID, $browseType, $queryID, $pager, $excludeBugs); - /* Assign. */ - $this->view->title = $this->lang->bug->linkBugs . "BUG #$bug->id $bug->title - " . $this->products[$bug->product]; - $this->view->position[] = html::a($this->createLink('product', 'view', "productID=$bug->product"), $this->products[$bug->product]); - $this->view->position[] = html::a($this->createLink('bug', 'view', "bugID=$bugID"), $bug->title); - $this->view->position[] = $this->lang->bug->linkBugs; - $this->view->bug = $bug; - $this->view->bugs2Link = $bugs2Link; - $this->view->pager = $pager; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->recTotal = $recTotal; - $this->view->recPerPage = $recPerPage; - $this->view->pageID = $pageID; + $this->view->title = $this->lang->bug->linkBugs . "BUG #$bug->id $bug->title $this->lang->dash " . $this->products[$bug->product]; + $this->view->bug = $bug; + $this->view->bugs2Link = $this->bug->getBugs2Link($bugID, $browseType, $queryID, $pager, $excludeBugs); + $this->view->users = $this->user->getPairs('noletter'); + $this->view->pager = $pager; $this->display(); } diff --git a/module/bug/zen.php b/module/bug/zen.php index 2b58ca432b..e199a2c515 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -1937,4 +1937,39 @@ class bugZen extends bug $this->view->customFields = $customFields; $this->view->showFields = $showFields; } + + /** + * 设置关联相关 bug 页面的搜索表单。 + * Build search form for link related bugs page. + * + * @param object $bug + * @param string $excludeBugs + * @param int $queryID + * @access protected + * @return void + */ + protected function buildSearchFormForLinkBugs(object $bug, string $excludeBugs, int $queryID): void + { + /* 无产品项目搜索时隐藏产品、执行和所属计划字段。*/ + /* Hide plan, execution and product in no product project. */ + if($bug->project && $this->app->tab != 'qa') + { + $project = $this->loadModel('project')->getByID($bug->project); + if(!$project->hasProduct) + { + unset($this->config->bug->search['fields']['product']); + + /* 单迭代项目搜索时隐藏执行和所属计划字段。*/ + /* Hide execution and plan in single project. */ + if(!$project->multiple) + { + unset($this->config->bug->search['fields']['execution']); + unset($this->config->bug->search['fields']['plan']); + } + } + } + + $actionURL = $this->createLink('bug', 'linkBugs', "bugID={$bug->id}&browseType=bySearch&excludeBugs={$excludeBugs}&queryID=myQueryID", '', true); + $this->bug->buildSearchForm($bug->product, $this->products, $queryID, $actionURL); + } }