diff --git a/module/my/model.php b/module/my/model.php index 47897980b6..3f5493fdc5 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -336,12 +336,13 @@ class myModel extends model if($objectType == 'task') { - $objectList = $this->dao->select('t1.*, t2.name as executionName, t2.type as executionType')->from($this->config->objectTables[$module])->alias('t1') + $orderBy = strpos($orderBy, 'pri_') !== false ? str_replace('pri_', 'priOrder_', $orderBy) : 't1.' . $orderBy; + $objectList = $this->dao->select("t1.*, t2.name as executionName, t2.type as executionType, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder")->from($this->config->objectTables[$module])->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") ->where('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq(0) ->andWhere('t1.id')->in(array_keys($objectIDList)) - ->orderBy('t1.' . $orderBy) + ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); } @@ -582,7 +583,8 @@ class myModel extends model $query = preg_replace('/`(\w+)`/', 't1.`$1`', $query); $query = str_replace('t1.`project`', 't2.`project`', $query); - $tasks = $this->dao->select('t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion') + $orderBy = str_replace('pri_', 'priOrder_', $orderBy); + $tasks = $this->dao->select("t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") ->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id') diff --git a/module/task/model.php b/module/task/model.php index 23b614e688..ddd6ccf98c 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -2367,7 +2367,8 @@ class taskModel extends model public function getExecutionTasks($executionID, $productID = 0, $type = 'all', $modules = 0, $orderBy = 'status_asc, id_desc', $pager = null) { if(is_string($type)) $type = strtolower($type); - $fields = 'DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName'; + $orderBy = str_replace('pri_', 'priOrder_', $orderBy); + $fields = "DISTINCT t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.product, t2.branch, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS assignedToRealName, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder"; $this->config->edition == 'max' && $fields .= ', t6.name as designName, t6.version as latestDesignVersion'; $actionIDList = array(); @@ -2510,7 +2511,8 @@ class taskModel extends model public function getUserTasks($account, $type = 'assignedTo', $limit = 0, $pager = null, $orderBy = "id_desc", $projectID = 0) { if(!$this->loadModel('common')->checkField(TABLE_TASK, $type)) return array(); - $tasks = $this->dao->select('t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion') + $orderBy = str_replace('pri_', 'priOrder_', $orderBy); + $tasks = $this->dao->select("t1.*, t2.id as executionID, t2.name as executionName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder") ->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on("t1.execution = t2.id") ->leftJoin(TABLE_STORY)->alias('t3')->on('t1.story = t3.id')