From 5d1e3bd65e2eb901447bfb7ac51ebf06fde217f3 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Mon, 8 Nov 2021 13:14:44 +0800 Subject: [PATCH] * Finish task #43904. --- module/story/model.php | 48 ++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/module/story/model.php b/module/story/model.php index 186f2642d6..ba6ef4c7ca 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2170,7 +2170,7 @@ class storyModel extends model $stories = $this->dao->select('*')->from(TABLE_STORY) ->where('product')->in($productID) ->beginIF(!$hasParent)->andWhere("parent")->ge(0)->fi() - ->beginIF($branch)->andWhere("branch")->in($branch)->fi() + ->beginIF($branch !== 'all')->andWhere("branch")->in($branch)->fi() ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() ->beginIF(!empty($excludeStories))->andWhere('id')->notIN($excludeStories)->fi() ->beginIF($status and $status != 'all')->andWhere('status')->in($status)->fi() @@ -2316,13 +2316,15 @@ class storyModel extends model /** * Get stories by a field. * - * @param int $productID - * @param string $fieldName - * @param mixed $fieldValue - * @param string $type requirement|story - * @param string $orderBy - * @param object $pager - * @param string $operator equal|include + * @param int $productID + * @param int|string $branch + * @param string $modules + * @param string $fieldName + * @param mixed $fieldValue + * @param string $type requirement|story + * @param string $orderBy + * @param object $pager + * @param string $operator equal|include * @access public * @return array */ @@ -2333,7 +2335,7 @@ class storyModel extends model ->where('product')->in($productID) ->andWhere('deleted')->eq(0) ->andWhere('type')->eq($type) - ->beginIF($branch)->andWhere("branch")->eq($branch)->fi() + ->beginIF($branch != 'all')->andWhere("branch")->eq($branch)->fi() ->beginIF($modules)->andWhere("module")->in($modules)->fi() ->beginIF($operator == 'equal')->andWhere($fieldName)->eq($fieldValue)->fi() ->beginIF($operator == 'include')->andWhere($fieldName)->like("%$fieldValue%")->fi() @@ -2373,18 +2375,18 @@ class storyModel extends model * Get stories through search. * * @access public - * @param int $productID - * @param int $branch - * @param int $queryID - * @param string $orderBy - * @param string $executionID - * @param string $type requirement|story - * @param string $excludeStories - * @param object $pager + * @param int $productID + * @param int|string $branch + * @param int $queryID + * @param string $orderBy + * @param string $executionID + * @param string $type requirement|story + * @param string $excludeStories + * @param object $pager * @access public * @return array */ - public function getBySearch($productID, $branch = 0, $queryID, $orderBy, $executionID = '', $type = 'story', $excludeStories = '', $pager = null) + public function getBySearch($productID, $branch = '', $queryID, $orderBy, $executionID = '', $type = 'story', $excludeStories = '', $pager = null) { if(!empty($executionID)) { @@ -2424,21 +2426,21 @@ class storyModel extends model if($branches) $storyQuery .= " AND `branch`" . helper::dbIN("0,$branches"); if($this->app->moduleName == 'release' or $this->app->moduleName == 'build') { - $storyQuery .= " AND `status` NOT IN ('draft')";// Fix bug #990. + $storyQuery .= " AND `status` NOT IN ('draft')"; // Fix bug #990. } else { $storyQuery .= " AND `status` NOT IN ('draft', 'closed')"; } } - elseif($branch) - { - if($branch and strpos($storyQuery, '`branch` =') === false) $storyQuery .= " AND `branch` in('0','$branch')"; - } elseif(strpos($storyQuery, $allBranch) !== false) { $storyQuery = str_replace($allBranch, '1', $storyQuery); } + elseif($branch) + { + if($branch and strpos($storyQuery, '`branch` =') === false) $storyQuery .= " AND `branch` in('$branch')"; + } $storyQuery = preg_replace("/`plan` +LIKE +'%([0-9]+)%'/i", "CONCAT(',', `plan`, ',') LIKE '%,$1,%'", $storyQuery); return $this->getBySQL($queryProductID, $storyQuery, $orderBy, $pager, $type);