diff --git a/module/product/control.php b/module/product/control.php index a0b0f663a9..4de96f9d57 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -807,6 +807,13 @@ class product extends control $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; if(is_bool($branch)) $branch = (string)(int)$branch; + $rawModule = $this->app->rawModule; + if($browseType == 'bysearch' && isset($_SESSION[$rawModule . 'TrackQuery'])) + { + if($rawModule == 'product') $this->session->set('storyQuery', $_SESSION[$rawModule . 'TrackQuery']); + if($rawModule == 'projectstory') $this->session->set('projectstoryQuery', $_SESSION[$rawModule . 'TrackQuery']); + } + /* Set menu. The projectstory module does not execute. */ $this->productZen->setTrackMenu($productID, $branch, $projectID); diff --git a/module/product/model.php b/module/product/model.php index c56238eceb..60e31b3bd8 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -771,6 +771,11 @@ class productModel extends model $searchConfig['params']['branch']['values'] = array('' => '', '0' => $this->lang->branch->main) + $this->loadModel('branch')->getPairs($productID, 'noempty'); } } + else + { + unset($searchConfig['fields']['branch']); + unset($searchConfig['params']['branch']); + } $this->loadModel('search')->setSearchParams($searchConfig); } diff --git a/module/story/tao.php b/module/story/tao.php index 4b269e478b..7f96cd7370 100644 --- a/module/story/tao.php +++ b/module/story/tao.php @@ -458,15 +458,18 @@ class storyTao extends storyModel $storyQuery = preg_replace_callback("/t2.`grade` (=|!=) '(\w+)(\d+)'/", function($matches){return "t2.`grade` {$matches[1]} '" . $matches[3] . "' AND t2.`type` = '" . $matches[2] . "'";}, $storyQuery); if(strpos($storyQuery, 'result') !== false) $storyQuery = str_replace('t2.`result`', 't4.`result`', $storyQuery); + $hasExecution = strpos($storyQuery, 't2.`execution`') !== false; + if($hasExecution) $storyQuery = str_replace('t2.`execution`', 't1.`project`', $storyQuery); + return $this->dao->select("distinct t1.*, t2.*, IF(t2.`pri` = 0, {$this->config->maxPriValue}, t2.`pri`) as priOrder, t3.type as productType, t2.version as version")->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t2.product = t3.id') ->beginIF(strpos($storyQuery, 'result') !== false)->leftJoin(TABLE_STORYREVIEW)->alias('t4')->on('t2.id = t4.story and t2.version = t4.version')->fi() ->where($storyQuery) - ->andWhere('t1.project')->eq($executionID) + ->beginIF(!$hasExecution)->andWhere('t1.project')->eq($executionID)->fi() ->andWhere('t2.deleted')->eq(0) ->andWhere('t3.deleted')->eq(0) - ->andWhere('t2.type')->in($storyType) + ->beginIF($storyType != 'all')->andWhere('t2.type')->in($storyType)->fi() ->beginIF($sqlCondition)->andWhere($sqlCondition)->fi() ->beginIF($excludeStories)->andWhere('t2.id')->notIN($excludeStories)->fi() ->orderBy($orderBy)