diff --git a/module/bug/config.php b/module/bug/config.php index c691031621..5c9e880dca 100755 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -11,6 +11,8 @@ $config->bug->create->requiredFields = 'title,openedBuild'; $config->bug->edit->requiredFields = $config->bug->create->requiredFields; $config->bug->resolve->requiredFields = 'resolution'; +$config->bug->browseTypeList = array('all', 'bymodule', 'assigntome', 'openedbyme', 'resolvedbyme', 'assigntonull', 'unconfirmed', 'unresolved', 'unclosed', 'toclosed', 'longlifebugs', 'postponedbugs', 'overduebugs', 'assignedbyme', 'review', 'needconfirm'); + $config->bug->list = new stdclass(); $config->bug->list->allFields = 'id, module, execution, story, task, title, keywords, severity, pri, type, os, browser, hardware, diff --git a/module/bug/model.php b/module/bug/model.php index 8ff9bfb7fa..2c69549d20 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -305,37 +305,40 @@ class bugModel extends model } /** - * 根据浏览类型获取bug列表。 + * 根据浏览类型获取 bug 列表。 * Get bug list by browse type. * - * @param string $browseType - * @param int|array $productIdList - * @param int $projectID - * @param int[] $executionIdList - * @param int|string $branch - * @param int $moduleID - * @param int $queryID - * @param string $orderBy - * @param object $pager + * @param string $browseType + * @param int|array $productIdList + * @param int $projectID + * @param int[] $executionIdList + * @param int|string $branch + * @param int $moduleID + * @param int $queryID + * @param string $orderBy + * @param object $pager * @access public * @return array */ public function getList(string $browseType, int|array $productIdList, int $projectID, array $executionIdList, int|string $branch = 'all', int $moduleID = 0, int $queryID = 0, string $orderBy = 'id_desc', object $pager = null): array { - /* Set modules and browse type. */ - $modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : 0; - $browseType = ($browseType == 'bymodule' and $this->session->bugBrowseType and $this->session->bugBrowseType != 'bysearch') ? $this->session->bugBrowseType : $browseType; - $browseType = $browseType == 'bybranch' ? 'bymodule' : $browseType; + if($browseType == 'bymodule' && $this->session->bugBrowseType && $this->session->bugBrowseType != 'bysearch') $browseType = $this->session->bugBrowseType; - /* Set orderBy. */ - if(strpos($orderBy, 'pri_') !== false) $orderBy = str_replace('pri_', 'priOrder_', $orderBy); + /* 处理排序。*/ + /* Process sort field. */ + if(strpos($orderBy, 'pri_') !== false) $orderBy = str_replace('pri_', 'priOrder_', $orderBy); if(strpos($orderBy, 'severity_') !== false) $orderBy = str_replace('severity_', 'severityOrder_', $orderBy); - /* Get bugs by browse type. */ $bugList = array(); - if($browseType == 'bysearch') $bugList = $this->getBySearch($productIdList, $branch, $queryID, $orderBy, '', $pager, $projectID); - elseif($browseType == 'needconfirm') $bugList = $this->bugTao->getListByNeedconfirm($productIdList, $projectID, $executionIdList, $branch, $modules, $orderBy, $pager); - elseif(strpos(',all,bymodule,assigntome,openedbyme,resolvedbyme,assigntonull,unconfirmed,unresolved,unclosed,toclosed,longlifebugs,postponedbugs,overduebugs,assignedbyme,review,', ",$browseType,") !== false) $bugList = $this->bugTao->getListByBrowseType($browseType, $productIdList, $projectID, $executionIdList, $branch, $modules, $orderBy, $pager); + if($browseType == 'bysearch') + { + $bugList = $this->getBySearch($productIdList, $branch, $queryID, $orderBy, '', $pager, $projectID); + } + elseif(in_array($browseType, $this->config->bug->browseTypeList)) + { + $modules = $moduleID ? $this->loadModel('tree')->getAllChildID($moduleID) : array(); + $bugList = $this->bugTao->getListByBrowseType($browseType, $productIdList, $projectID, $executionIdList, $branch, $modules, $orderBy, $pager); + } return $this->bugTao->batchAppendDelayedDays($bugList); } @@ -351,7 +354,8 @@ class bugModel extends model { if($bug->execution and !$this->loadModel('execution')->checkPriv($bug->execution)) { - echo(js::alert($this->lang->bug->executionAccessDenied)); + echo js::alert($this->lang->bug->executionAccessDenied); + $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('bug', 'index', ''))); if($this->app->tab == 'my') print(js::reload('parent')); diff --git a/module/bug/tao.php b/module/bug/tao.php index 2446e19795..7743aa44f3 100644 --- a/module/bug/tao.php +++ b/module/bug/tao.php @@ -23,36 +23,32 @@ class bugTao extends bugModel /** * Get bug list by browse type. - * 通过浏览类型获取bug列表。 + * 通过浏览类型获取 bug 列表。 * - * @param string $browseType - * @param int|array $productIdList - * @param int|string $branch - * @param int|array $moduleIdList - * @param int[] $executionIdList - * @param string $orderBy - * @param object $pager - * @param int $projectID + * @param string $browseType + * @param int|array $productIdList + * @param int $projectID + * @param int[] $executionIdList + * @param int|string $branch + * @param array $moduleIdList + * @param string $orderBy + * @param object $pager * @access protected * @return array */ - protected function getListByBrowseType(string $browseType, int|array $productIdList, int $projectID, array $executionIdList, int|string $branch, int|array $moduleIdList, string $orderBy, object $pager = null): array + protected function getListByBrowseType(string $browseType, int|array $productIdList, int $projectID, array $executionIdList, int|string $branch, array $moduleIdList, string $orderBy, object $pager = null): array { - $browseType = strtolower($browseType); - $lastEditedDate = ''; - $bugIdListAssignedByMe = array(); + $browseType = strtolower($browseType); + if($browseType == 'needconfirm') return $this->getNeedConfirmList($productIdList, $projectID, $executionIdList, $branch, $moduleIdList, $orderBy, $pager); + + $lastEditedDate = ''; if($browseType == 'longlifebugs') $lastEditedDate = date(DT_DATE1, time() - $this->config->bug->longlife * 24 * 3600); - if($browseType == 'assignedbyme') - { - $bugIdListAssignedByMe = $this->dao->select('objectID')->from(TABLE_ACTION) - ->where('objectType')->eq('bug') - ->andWhere('action')->eq('assigned') - ->andWhere('actor')->eq($this->app->user->account) - ->fetchPairs('objectID', 'objectID'); - } - $bugList = $this->dao->select("*, IF(`pri` = 0, {$this->config->maxPriValue}, `pri`) as priOrder, IF(`severity` = 0, {$this->config->maxPriValue}, `severity`) as severityOrder")->from(TABLE_BUG) + $bugIdListAssignedByMe = array(); + if($browseType == 'assignedbyme') $bugIdListAssignedByMe = $this->dao->select('objectID')->from(TABLE_ACTION)->where('objectType')->eq('bug')->andWhere('action')->eq('assigned')->andWhere('actor')->eq($this->app->user->account)->fetchPairs(); + + $bugList = $this->dao->select("*, IF(`pri` = 0, {$this->config->maxPriValue}, `pri`) AS priOrder, IF(`severity` = 0, {$this->config->maxPriValue}, `severity`) AS severityOrder")->from(TABLE_BUG) ->where('deleted')->eq('0') ->andWhere('product')->in($productIdList) ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -93,29 +89,30 @@ class bugTao extends bugModel ->fetchAll('id'); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug'); + return $bugList; } /** - * Get bug list of story need confirm. - * 获取需要确认需求变动的bug列表。 + * 获取需要确认需求变动的 bug 列表。 + * Get bug list that related story need to be confirmed. * * @param int|array $productIdList * @param int $projectID * @param int[] $executionIdList * @param int|string $branch - * @param int|array $moduleIdList + * @param array $moduleIdList * @param string $orderBy * @param object $pager * @access protected * @return array */ - protected function getListByNeedconfirm(int|array $productIdList, int $projectID, array $executionIdList, int|string $branch, int|array $moduleIdList, string $orderBy, object $pager = null): array + protected function getNeedConfirmList(int|array $productIdList, int $projectID, array $executionIdList, int|string $branch, array $moduleIdList, string $orderBy, object $pager = null): array { - return $this->dao->select("t1.*, t2.title AS storyTitle, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder, IF(t1.`severity` = 0, {$this->config->maxPriValue}, t1.`severity`) as severityOrder")->from(TABLE_BUG)->alias('t1') + return $this->dao->select("t1.*, t2.title AS storyTitle, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) AS priOrder, IF(t1.`severity` = 0, {$this->config->maxPriValue}, t1.`severity`) AS severityOrder")->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->where('t1.deleted')->eq('0') - ->andWhere("t2.status = 'active'") + ->andWhere('t2.status')->eq('active') ->andWhere('t2.version > t1.storyVersion') ->andWhere('t1.product')->in($productIdList) ->beginIF($projectID)->andWhere('t1.project')->eq($projectID)->fi()