From a529227bf5fbdeeaea19fcd939e90b3551faab9e Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 29 Aug 2023 05:55:15 +0000 Subject: [PATCH] * Splict build search form function. --- module/testcase/control.php | 28 +++---------------- module/testcase/zen.php | 56 ++++++++++++++++++++++++++++++++++--- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/module/testcase/control.php b/module/testcase/control.php index c2fa3bc824..a85e7916ea 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -879,14 +879,8 @@ class testcase extends control /* 构建搜索表单。*/ /* Build the search form. */ - $queryID = ($browseType == 'bySearch') ? (int)$param : 0; - $actionURL = $this->createLink('testcase', 'linkCases', "caseID=$caseID&browseType=bySearch&queryID=myQueryID", '', true); - $objectID = 0; - if($this->app->tab == 'project') $objectID = $case->project; - if($this->app->tab == 'execution') $objectID = $case->execution; - - unset($this->config->testcase->search['fields']['product']); - $this->testcase->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); + $queryID = ($browseType == 'bySearch') ? (int)$param : 0; + $this->testcaseZen->buildLinkCasesSearchForm($case, $queryID); /* 获取可关联的用例。*/ /* Get cases to link. */ @@ -930,22 +924,8 @@ class testcase extends control /* 构建搜索表单。*/ /* Build the search form. */ - $queryID = ($browseType == 'bySearch') ? (int)$param : 0; - $actionURL = $this->createLink('testcase', 'linkBugs', "caseID=$caseID&browseType=bySearch&queryID=myQueryID", '', true); - $objectID = 0; - if($this->app->tab == 'project') $objectID = $case->project; - if($this->app->tab == 'execution') $objectID = $case->execution; - - /* 删除单一项目的计划字段。*/ - /* Unset search field 'plan' in single project. */ - unset($this->config->bug->search['fields']['product']); - if($case->project && ($this->app->tab == 'project' || $this->app->tab == 'execution')) - { - $project = $this->loadModel('project')->getByID($case->project); - if(!$project->hasProduct && $project->model == 'waterfall') unset($this->config->bug->search['fields']['plan']); - } - - $this->bug->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); + $queryID = ($browseType == 'bySearch') ? (int)$param : 0; + $this->testcaseZen->buildLinkBugsSearchForm($case, $queryID); /* 获取关联的bug。*/ /* Get bugs to link. */ diff --git a/module/testcase/zen.php b/module/testcase/zen.php index cdf4c99f8d..611e828f35 100644 --- a/module/testcase/zen.php +++ b/module/testcase/zen.php @@ -1268,12 +1268,12 @@ class testcaseZen extends testcase * 处理评审数据。 * Prepare review data. * - * @param int $caseID - * @param object $oldCase + * @param int $caseID + * @param object $oldCase * @access protected - * @return void + * @return bool|object */ - protected function prepareReviewData(int $caseID, object $oldCase) + protected function prepareReviewData(int $caseID, object $oldCase): bool|object { $now = helper::now(); $status = $this->testcase->getStatus('review', $oldCase); @@ -1295,4 +1295,52 @@ class testcaseZen extends testcase return $this->loadModel('file')->processImgURL($case, $this->config->testcase->editor->review['id'], $this->post->uid); } + + /** + * 构建关联用例页面的搜索表单。 + * Build search form for link cases. + * + * @param object $case + * @param int $queryID + * @access protected + * @return void + */ + protected function buildLinkCasesSearchForm(object $case, int $queryID): void + { + $actionURL = $this->createLink('testcase', 'linkCases', "caseID={$case->id}&browseType=bySearch&queryID=myQueryID", '', true); + $objectID = 0; + if($this->app->tab == 'project') $objectID = $case->project; + if($this->app->tab == 'execution') $objectID = $case->execution; + + unset($this->config->testcase->search['fields']['product']); + $this->testcase->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); + } + + /** + * 构建关联 bug 页面的搜索表单。 + * Build search form for link bugs. + * + * @param object $case + * @param int $queryID + * @access protected + * @return void + */ + protected function buildLinkBugsSearchForm(object $case, int $queryID): void + { + $actionURL = $this->createLink('testcase', 'linkBugs', "caseID={$case->id}&browseType=bySearch&queryID=myQueryID", '', true); + $objectID = 0; + if($this->app->tab == 'project') $objectID = $case->project; + if($this->app->tab == 'execution') $objectID = $case->execution; + + /* 删除单一项目的计划字段。*/ + /* Unset search field 'plan' in single project. */ + unset($this->config->bug->search['fields']['product']); + if($case->project && ($this->app->tab == 'project' || $this->app->tab == 'execution')) + { + $project = $this->loadModel('project')->getByID($case->project); + if(!$project->hasProduct && $project->model == 'waterfall') unset($this->config->bug->search['fields']['plan']); + } + + $this->bug->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID); + } }