From edda32ba7239c1dbe2258208b9f386783d85ea41 Mon Sep 17 00:00:00 2001 From: mayue Date: Thu, 9 Jun 2022 17:15:44 +0800 Subject: [PATCH] * Finish task #56550,56553. --- module/my/control.php | 27 +++++++-- module/my/model.php | 99 +++++++++++++++++++++++++++++++- module/my/view/testcase.html.php | 2 +- 3 files changed, 120 insertions(+), 8 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index 5c4b1c29fa..23ac17cfb8 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -643,8 +643,8 @@ EOF; $cases = array(); if($type == 'assigntome') $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip'); if($type == 'openedbyme') $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip'); - if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'openedbyme', $orderBy, $pager); - if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'assigntome', $orderBy, $pager); + if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'contribute', $orderBy, $pager); + if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'work', $orderBy, $pager); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', $type == 'assigntome' ? false : true); @@ -832,18 +832,37 @@ EOF; * @param int $pageID * @return void */ - public function risk($type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function risk($type = 'assignedTo', $param = 0,$orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Set the pager. */ $this->loadModel('risk'); $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); + /* Build the search form. */ + $currentMethod = $this->app->rawMethod; + $queryID = ($type == 'bysearch') ? (int)$param : 0; + $actionURL = $this->createLink('my', $currentMethod, "mode=risk&type=bysearch¶m=myQueryID"); + $this->my->buildRiskSearchForm($queryID, $actionURL, $currentMethod); + + /* Get risks by type*/ + if($type == 'assignedBy') + { + $risks = $this->my->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk'); + } + else + { + if($type != 'bysearch') $risks = $this->risk->getUserRisks($type, $this->app->user->account, $orderBy, $pager); + } + + if($type == 'bysearch' and $currentMethod == 'contribute') $risks = $this->my->getRisksBySearch($queryID, $currentMethod, $orderBy, $pager); + if($type == 'bysearch' and $currentMethod == 'work') $risks = $this->my->getRisksBySearch($queryID, $currentMethod, $orderBy, $pager); + $this->app->session->set('riskList', $this->app->getURI(true), 'project'); $this->view->title = $this->lang->my->risk; $this->view->position[] = $this->lang->my->risk; - $this->view->risks = $type == 'assignedBy' ? $this->loadModel('my')->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk') : $this->loadModel('risk')->getUserRisks($type, $this->app->user->account, $orderBy, $pager); + $this->view->risks = $risks; $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); $this->view->orderBy = $orderBy; $this->view->pager = $pager; diff --git a/module/my/model.php b/module/my/model.php index c7181096c3..038356bee6 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -376,7 +376,7 @@ class myModel extends model } /** - * Build search form. + * Build case search form. * * @param int $queryID * @param string $actionURL @@ -417,7 +417,7 @@ class myModel extends model */ public function getTestcasesBySearch($queryID, $type, $orderBy, $pager) { - $queryName = $type == 'openedbyme' ? 'contributeTestcaseQuery' : 'workTestcaseQuery'; + $queryName = $type == 'contribute' ? 'contributeTestcaseQuery' : 'workTestcaseQuery'; if($queryID) { $query = $this->loadModel('search')->getQuery($queryID); @@ -439,7 +439,7 @@ class myModel extends model $myTestcaseQuery = $this->session->$queryName; $myTestcaseQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myTestcaseQuery); - if($type == 'openedbyme') + if($type == 'contribute') { $cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1') ->where($myTestcaseQuery) @@ -622,4 +622,97 @@ class myModel extends model $this->loadModel('search')->setSearchParams($this->config->bug->search); } + + /* + * Build risk search form. + * + * @param int $queryID + * @param string $actionURL + * @param string $type risk|contribute + * @access public + * @return void + */ + public function buildRiskSearchForm($queryID, $actionURL, $type) + { + $projects = $this->loadModel('project')->getPairsByProgram(); + $queryName = $type == 'contribute' ? 'contributeRisk' : 'workRisk'; + + $this->app->loadConfig('risk'); + $this->config->risk->search['module'] = $queryName; + $this->config->risk->search['actionURL'] = $actionURL; + $this->config->risk->search['queryID'] = $queryID; + + $this->config->risk->search['params']['project']['value'] = array('') + $projects; + + if($this->config->systemMode == 'classic') unset($this->config->risk->search['fields']['project']); + unset($this->config->risk->search['fields']['module']); + + $this->loadModel('search')->setSearchParams($this->config->risk->search); + } + + /** + * Get risks by search. + * + * @param int $queryID + * @param string $type + * @param string $orderBy + * @param int $pager + * @access public + * @return array + */ + public function getRisksBySearch($queryID, $type, $orderBy, $pager) + { + $queryName = $type == 'contribute' ? 'contributeRiskQuery' : 'workRiskQuery'; + if($queryID && $queryID != 'myQueryID') + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set($queryName, $query->sql); + $this->session->set($queryName . 'Form', $query->form); + } + else + { + $this->session->set($queryName, ' 1 = 1'); + } + } + else + { + if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1'); + } + + $riskQuery = $this->session->$queryName; + + if($type == 'contribute') + { + $riskIDList = array(); + $AssignedByMe = $this->getAssignedByMe($this->app->user->account, '', $pager, $orderBy, '', 'risk'); + foreach($AssignedByMe as $riskID => $risk) + { + $riskIDList[$riskID] = $riskID; + } + + $risks = $this->dao->select('*')->from(TABLE_RISK) + ->where($riskQuery) + ->andWhere('deleted')->eq('0') + ->orWhere('createdBy',1)->eq($this->app->user->account) + ->orWhere('id')->in($riskIDList) + ->orWhere('closedBy')->eq($this->app->user->account) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + } + elseif($type == 'work') + { + $risks = $this->dao->select('*')->from(TABLE_RISK) + ->where($riskQuery) + ->andWhere('deleted')->eq('0') + ->andWhere('assignedTo')->eq($this->app->user->account) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll('id'); + } + + return $risks; + } } diff --git a/module/my/view/testcase.html.php b/module/my/view/testcase.html.php index 0aae03d69e..13d813aebf 100644 --- a/module/my/view/testcase.html.php +++ b/module/my/view/testcase.html.php @@ -32,7 +32,7 @@
-
rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>>
+
rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>>

testcase->noCase;?>