diff --git a/module/bug/control.php b/module/bug/control.php index 6fb228090f..2e66175d58 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -2643,7 +2643,7 @@ class bug extends control $product = $this->loadModel('product')->getById($productID); $bug = $this->bug->getById($bugID); $branch = $product->type == 'branch' ? ($bug->branch > 0 ? $bug->branch . ',0' : '0') : ''; - $productBugs = $this->bug->getProductBugPairs($productID, $branch, $search, $limit); + $productBugs = $this->bug->getProductBugPairs($productID, $branch, $search, $limit, 'all'); unset($productBugs[$bugID]); diff --git a/module/bug/model.php b/module/bug/model.php index 4e3f1b6537..b23f256d8c 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2049,24 +2049,27 @@ class bugModel extends model * @param int|string $branch * @param string $search * @param int $limit + * @param string $range single|all * @access public * @return void */ - public function getProductBugPairs($productID, $branch = '', $search = '', $limit = 0) + public function getProductBugPairs($productID, $branch = '', $search = '', $limit = 0, $range = 'single') { - $bugs = $this->dao->select("id, CONCAT(id, ':', title) AS title")->from(TABLE_BUG) - ->where('product')->eq((int)$productID) + $productID = (int)$productID; + $bugs = $this->dao->select("id, CONCAT(IF(product = $productID, '', CONCAT('{$this->lang->product->common}#', product, '@')), id, ':', title) AS title, IF(product = $productID, 0, product) AS `order`")->from(TABLE_BUG) + ->where('deleted')->eq(0) + ->beginIF($range == 'single')->andWhere('product')->eq($productID)->fi() ->beginIF(!$this->app->user->admin)->andWhere('execution')->in('0,' . $this->app->user->view->sprints)->fi() + ->beginIF($range == 'all' && !$this->app->user->admin)->andWhere('product')->in($this->app->user->view->products)->fi() ->beginIF($branch !== '')->andWhere('branch')->in($branch)->fi() ->beginIF(strlen(trim($search))) ->andWhere('id', true)->like('%' . $search . '%') ->orWhere('title')->like('%' . $search . '%') ->markRight(1) ->fi() - ->andWhere('deleted')->eq(0) - ->orderBy('id desc') + ->orderBy('`order`, id desc') ->beginIF($limit)->limit($limit)->fi() - ->fetchPairs(); + ->fetchPairs('id', 'title'); return array('' => '') + $bugs; }