diff --git a/module/bug/model.php b/module/bug/model.php index 1ea50fc5a5..9e275be1bc 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -384,6 +384,9 @@ class bugModel extends model $browseType = ($browseType == 'bymodule' and $this->session->bugBrowseType and $this->session->bugBrowseType != 'bysearch') ? $this->session->bugBrowseType : $browseType; $browseType = $browseType == 'bybranch' ? 'bymodule' : $browseType; + if(strpos($sort, 'pri') !== false and strpos($sort, 'priOrder') === false) $sort = str_replace('pri', 'priOrder', $sort); + if(strpos($sort, 'severity') !== false and strpos($sort, 'severityOrder') === false) $sort = str_replace('severity', 'severityOrder', $sort); + /* Get bugs by browse type. */ $bugs = array(); if($browseType == 'all') $bugs = $this->getAllBugs($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID); @@ -483,7 +486,7 @@ class bugModel extends model */ public function getModuleBugs($productIDList, $branch = 0, $moduleIdList = 0, $executions = array(), $orderBy = 'id_desc', $pager = null, $projectID = 0) { - return $this->dao->select('*')->from(TABLE_BUG) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->eq($branch)->fi() ->beginIF(!empty($moduleIdList))->andWhere('module')->in($moduleIdList)->fi() @@ -506,7 +509,8 @@ class bugModel extends model */ public function getPlanBugs($planID, $status = 'all', $orderBy = 'id_desc', $pager = null) { - $bugs = $this->dao->select('*')->from(TABLE_BUG) + if(strpos($orderBy, 'priOrder') === false) $orderBy = str_replace('pri', 'priOrder', $orderBy); + $bugs = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder')->from(TABLE_BUG) ->where('plan')->eq((int)$planID) ->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi() ->beginIF($status != 'all')->andWhere('status')->in($status)->fi() @@ -1714,6 +1718,9 @@ class bugModel extends model $queryName = $moduleName . 'Query'; $formName = $moduleName . 'Form'; + if(strpos($orderBy, 'pri') !== false and strpos($orderBy, 'priOrder') === false) $orderBy = str_replace('pri', 'priOrder', $orderBy); + if(strpos($orderBy, 'severity') !== false and strpos($orderBy, 'severityOrder') === false) $orderBy = str_replace('severity', 'severityOrder', $orderBy); + $bugIDList = array(); if($moduleName == 'contributeBug') { @@ -1742,7 +1749,7 @@ class bugModel extends model $query = preg_replace('/`(\w+)`/', 't1.`$1`', $query); if($type != 'bySearch' and !$this->loadModel('common')->checkField(TABLE_BUG, $type)) return array(); - return $this->dao->select('t1.*,t2.name as productName')->from(TABLE_BUG)->alias('t1') + return $this->dao->select('t1.*,t2.name as productName, IF(t1.`pri` = 0, 999, t1.`pri`) as priOrder, IF(t1.`severity` = 0, 999, t1.`severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->where('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq('0') @@ -1823,6 +1830,9 @@ class bugModel extends model public function getProjectBugs($projectID, $productID = 0, $branchID = 0, $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null) { $type = strtolower($type); + if(strpos($orderBy, 'pri') !== false and strpos($orderBy, 'priOrder') === false) $orderBy = str_replace('pri', 'priOrder', $orderBy); + if(strpos($orderBy, 'severity') !== false and strpos($orderBy, 'severityOrder') === false) $orderBy = str_replace('severity', 'severityOrder', $orderBy); + if($type == 'bysearch') { $queryID = (int)$param; @@ -1839,7 +1849,7 @@ class bugModel extends model $bugQuery = $this->getBugQuery($this->session->projectBugQuery); - $bugs = $this->dao->select('*')->from(TABLE_BUG) + $bugs = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where($bugQuery) ->andWhere('project')->eq((int)$projectID) ->andWhere('deleted')->eq(0) @@ -1852,7 +1862,7 @@ class bugModel extends model } else { - $bugs = $this->dao->select('t1.*')->from(TABLE_BUG)->alias('t1') + $bugs = $this->dao->select('t1.*, IF(t1.`pri` = 0, 999, t1.`pri`) as priOrder, IF(t1.`severity` = 0, 999, t1.`severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_MODULE)->alias('t2')->on('t1.module=t2.id') ->where('t1.deleted')->eq(0) ->beginIF(empty($build))->andWhere('t1.project')->eq($projectID)->fi() @@ -1891,6 +1901,9 @@ class bugModel extends model public function getExecutionBugs($executionID, $productID = 0, $branchID = 'all', $build = 0, $type = '', $param = 0, $orderBy = 'id_desc', $excludeBugs = '', $pager = null) { $type = strtolower($type); + if(strpos($orderBy, 'pri') !== false and strpos($orderBy, 'priOrder') === false) $orderBy = str_replace('pri', 'priOrder', $orderBy); + if(strpos($orderBy, 'severity') !== false and strpos($orderBy, 'severityOrder') === false) $orderBy = str_replace('severity', 'severityOrder', $orderBy); + if($type == 'bysearch') { $queryID = (int)$param; @@ -1907,7 +1920,7 @@ class bugModel extends model $bugQuery = $this->getBugQuery($this->session->executionBugQuery); - $bugs = $this->dao->select('*')->from(TABLE_BUG) + $bugs = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where($bugQuery) ->andWhere('execution')->eq((int)$executionID) ->andWhere('deleted')->eq(0) @@ -1920,7 +1933,7 @@ class bugModel extends model } else { - $bugs = $this->dao->select('t1.*')->from(TABLE_BUG)->alias('t1') + $bugs = $this->dao->select('t1.*, IF(t1.`pri` = 0, 999, t1.`pri`) as priOrder, IF(t1.`pri` = 0, 999, t1.`severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_MODULE)->alias('t2')->on('t1.module=t2.id') ->where('t1.deleted')->eq(0) ->beginIF(!empty($productID) and $branchID !== 'all')->andWhere('t1.branch')->eq($branchID)->fi() @@ -2542,7 +2555,7 @@ class bugModel extends model */ public function getAllBugs($productIDList, $branch, $modules, $executions, $orderBy, $pager = null, $projectID = 0) { - $bugs = $this->dao->select('t1.*, t2.title as planTitle')->from(TABLE_BUG)->alias('t1') + $bugs = $this->dao->select('t1.*, t2.title as planTitle, IF(t1.`pri` = 0, 999, t1.`pri`) as priOrder, IF(t1.`severity` = 0, 999, t1.`severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id') ->where('t1.product')->in($productIDList) ->andWhere('t1.execution')->in(array_keys($executions)) @@ -2573,7 +2586,9 @@ class bugModel extends model */ public function getByAssigntome($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->findByAssignedTo($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('assignedTo')->eq($this->app->user->account) + ->andWhere('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -2598,7 +2613,9 @@ class bugModel extends model */ public function getByOpenedbyme($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->findByOpenedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*,IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('openedBy')->eq($this->app->user->account) + ->andWhere('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -2623,7 +2640,9 @@ class bugModel extends model */ public function getByResolvedbyme($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->findByResolvedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*,IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('resolvedBy')->eq($this->app->user->account) + ->andWhere('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -2649,7 +2668,9 @@ class bugModel extends model public function getByAssigntonull($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->findByAssignedTo('')->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('assignedTo')->eq('') + ->andWhere('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -2674,7 +2695,7 @@ class bugModel extends model */ public function getUnconfirmed($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->select('*')->from(TABLE_BUG) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where('product')->in($productIDList) ->andWhere('execution')->in(array_keys($executions)) ->andWhere('deleted')->eq(0) @@ -2702,7 +2723,7 @@ class bugModel extends model */ public function getOverdueBugs($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->select('*')->from(TABLE_BUG) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where('product')->in($productIDList) ->andWhere('execution')->in(array_keys($executions)) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() @@ -2732,7 +2753,7 @@ class bugModel extends model */ public function getByStatus($productIDList, $branch, $modules, $executions, $status, $orderBy, $pager, $projectID) { - return $this->dao->select('*')->from(TABLE_BUG) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where('product')->in($productIDList) ->andWhere('execution')->in(array_keys($executions)) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() @@ -2763,7 +2784,9 @@ class bugModel extends model public function getByLonglifebugs($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { $lastEditedDate = date(DT_DATE1, time() - $this->config->bug->longlife * 24 * 3600); - return $this->dao->findByLastEditedDate("<", $lastEditedDate)->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('lastEditedDate')->lt($lastEditedDate) + ->andWhere('product')->in($productIDList) ->andWhere('execution')->in(array_keys($executions)) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() @@ -2789,7 +2812,9 @@ class bugModel extends model */ public function getByPostponedbugs($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->findByResolution('postponed')->from(TABLE_BUG)->andWhere('product')->in($productIDList) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) + ->where('resolution')->eq('postponed') + ->andWhere('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() ->beginIF($projectID)->andWhere('project')->eq($projectID)->fi() @@ -2814,7 +2839,7 @@ class bugModel extends model */ public function getByNeedconfirm($productIDList, $branch, $modules, $executions, $orderBy, $pager, $projectID) { - return $this->dao->select('t1.*, t2.title AS storyTitle')->from(TABLE_BUG)->alias('t1') + return $this->dao->select('t1.*, t2.title AS storyTitle, IF(t1.`pri` = 0, 999, t1.`pri`) as priOrder, IF(t1.`severity` = 0, 999, t1.`severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->where("t2.status = 'active'") ->andWhere('t1.product')->in($productIDList) @@ -2846,7 +2871,7 @@ class bugModel extends model public function getByAssignedbyme($productIDList, $branch, $modules, $executions, $sort, $pager, $projectID) { $actionIDList = $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'); - return $this->dao->select('*')->from(TABLE_BUG) + return $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG) ->where('product')->in($productIDList) ->beginIF($branch !== 'all')->andWhere('branch')->in($branch)->fi() ->beginIF($modules)->andWhere('module')->in($modules)->fi() @@ -2918,7 +2943,7 @@ class bugModel extends model if($branch !== 'all' and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('0','$branch')"; if(strpos($bugQuery, $allBranch) !== false) $bugQuery = str_replace($allBranch, '1', $bugQuery); - $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery) + $bugs = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG)->where($bugQuery) ->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi() ->beginIF($excludeBugs)->andWhere('id')->notIN($excludeBugs)->fi() @@ -2950,7 +2975,7 @@ class bugModel extends model */ public function getReviewBugs($productIDList, $branch, $modules, $executions, $orderBy, $pager = null, $projectID = 0) { - $bugs = $this->dao->select('t1.*, t2.title as planTitle')->from(TABLE_BUG)->alias('t1') + $bugs = $this->dao->select('t1.*, t2.title as planTitle, IF(`pri` = 0, 999, `pri`) as priOrder, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG)->alias('t1') ->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id') ->where('t1.product')->in($productIDList) ->andWhere('t1.execution')->in(array_keys($executions)) diff --git a/module/build/control.php b/module/build/control.php index 9dc99dcb18..6938820f10 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -233,22 +233,25 @@ class build extends control $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; + $sort = common::appendOrder($orderBy); + if(strpos($sort, 'priOrder') === false) $sort = str_replace('pri', 'priOrder', $sort); + /* Get product and bugs. */ $product = $this->loadModel('product')->getById($build->product); if($product->type != 'normal') $this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); $bugPager = new pager($type == 'bug' ? $recTotal : 0, $recPerPage, $type == 'bug' ? $pageID : 1); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($build->bugs)->andWhere('deleted')->eq(0) - ->beginIF($type == 'bug')->orderBy($orderBy)->fi() + ->beginIF($type == 'bug')->orderBy($sort)->fi() ->page($bugPager) ->fetchAll(); /* Get stories and stages. */ $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); - $stories = $this->dao->select('*')->from(TABLE_STORY) + $stories = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder')->from(TABLE_STORY) ->where('id')->in($build->stories) ->andWhere('deleted')->eq(0) - ->beginIF($type == 'story')->orderBy($orderBy)->fi() + ->beginIF($type == 'story')->orderBy($sort)->fi() ->page($storyPager) ->fetchAll('id'); @@ -273,7 +276,7 @@ class build extends control $this->view->storyPager = $storyPager; $generatedBugPager = new pager($type == 'generatedBug' ? $recTotal : 0, $recPerPage, $type == 'generatedBug' ? $pageID : 1); - $this->view->generatedBugs = $this->bug->getExecutionBugs($build->execution, $build->product, 'all', $build->id, $type, $param, $type == 'generatedBug' ? $orderBy : 'status_desc,id_desc', '', $generatedBugPager); + $this->view->generatedBugs = $this->bug->getExecutionBugs($build->execution, $build->product, 'all', $build->id, $type, $param, $type == 'generatedBug' ? $sort : 'status_desc,id_desc', '', $generatedBugPager); $this->view->generatedBugPager = $generatedBugPager; $this->executeHooks($buildID); diff --git a/module/common/model.php b/module/common/model.php index d86b3d4831..ea0b910982 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -2111,9 +2111,12 @@ EOD; $table = $this->config->objectTables[$type]; $orderBy = $type . 'OrderBy'; $orderBy = $this->session->$orderBy; + $select = ''; if($this->session->$typeOnlyCondition) { - $sql = $this->dao->select('*')->from($table) + if(strpos($orderBy, 'priOrder') !== false) $select .= ', IF(`pri` = 0, 999, `pri`) as priOrder'; + if(strpos($orderBy, 'severityOrder') !== false) $select .= ', IF(`severity` = 0, 999, `severity`) as severityOrder'; + $sql = $this->dao->select("*$select")->from($table) ->where($queryCondition) ->beginIF($orderBy != false)->orderBy($orderBy)->fi() ->get(); diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php index 572b0b934a..c46e466836 100644 --- a/module/projectrelease/control.php +++ b/module/projectrelease/control.php @@ -230,11 +230,14 @@ class projectrelease extends control return print(js::error($this->lang->notFound) . js::locate('back')); } + $sort = common::appendOrder($orderBy); + if(strpos($sort, 'priOrder') === false) $sort = str_replace('pri', 'priOrder', $sort); + $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); - $stories = $this->dao->select('*')->from(TABLE_STORY) + $stories = $this->dao->select('*, IF(`pri` = 0, 999, `pri`) as priOrder')->from(TABLE_STORY) ->where('id')->in($release->stories) ->andWhere('deleted')->eq(0) - ->beginIF($type == 'story')->orderBy($orderBy)->fi() + ->beginIF($type == 'story')->orderBy($sort)->fi() ->page($storyPager) ->fetchAll('id'); @@ -246,14 +249,16 @@ class projectrelease extends control $bugPager = new pager($type == 'bug' ? $recTotal : 0, $recPerPage, $type == 'bug' ? $pageID : 1); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->bugs)->andWhere('deleted')->eq(0) - ->beginIF($type == 'bug')->orderBy($orderBy)->fi() + ->beginIF($type == 'bug')->orderBy($sort)->fi() ->page($bugPager) ->fetchAll(); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'linkedBug'); $leftBugPager = new pager($type == 'leftBug' ? $recTotal : 0, $recPerPage, $type == 'leftBug' ? $pageID : 1); - $leftBugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->leftBugs)->andWhere('deleted')->eq(0) - ->beginIF($type == 'leftBug')->orderBy($orderBy)->fi() + if($type == 'leftBug' and strpos($orderBy, 'severity') !== false) $sort = str_replace('severity', 'severityOrder', $orderBy); + + $leftBugs = $this->dao->select('*, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG)->where('id')->in($release->leftBugs)->andWhere('deleted')->eq(0) + ->beginIF($type == 'leftBug')->orderBy($sort)->fi() ->page($leftBugPager) ->fetchAll(); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'leftBugs'); diff --git a/module/release/control.php b/module/release/control.php index 3c4c58a27d..0f8e334fa7 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -190,6 +190,9 @@ class release extends control $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; + $sort = common::appendOrder($orderBy); + if(strpos($sort, 'priOrder') === false) $sort = str_replace('pri', 'priOrder', $sort); + $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($release->stories)->andWhere('deleted')->eq(0) ->beginIF($type == 'story')->orderBy($orderBy)->fi() @@ -202,16 +205,19 @@ class release extends control $bugPager = new pager($type == 'bug' ? $recTotal : 0, $recPerPage, $type == 'bug' ? $pageID : 1); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->bugs)->andWhere('deleted')->eq(0) - ->beginIF($type == 'bug')->orderBy($orderBy)->fi() + ->beginIF($type == 'bug')->orderBy($sort)->fi() ->page($bugPager) ->fetchAll(); $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'linkedBug'); $leftBugPager = new pager($type == 'leftBug' ? $recTotal : 0, $recPerPage, $type == 'leftBug' ? $pageID : 1); - $leftBugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->leftBugs)->andWhere('deleted')->eq(0) - ->beginIF($type == 'leftBug')->orderBy($orderBy)->fi() + if($type == 'leftBug' and strpos($orderBy, 'severity') !== false) $sort = str_replace('severity', 'severityOrder', $orderBy); + + $leftBugs = $this->dao->select('*, IF(`severity` = 0, 999, `severity`) as severityOrder')->from(TABLE_BUG)->where('id')->in($release->leftBugs)->andWhere('deleted')->eq(0) + ->beginIF($type == 'leftBug')->orderBy($sort)->fi() ->page($leftBugPager) ->fetchAll(); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'leftBugs'); $this->commonAction($release->product);