From 27e1603f68946bca5873aae2cd9c1df20230b757 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 14 Mar 2013 09:29:21 +0000 Subject: [PATCH] * fix a bug for search with product. --- module/bug/model.php | 9 ++++++++- module/testcase/control.php | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 0a25af0290..1e6d8d3f49 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1140,7 +1140,14 @@ class bugModel extends model $this->session->set('bugQuery', "$var"); } - $bugQuery = str_replace("`product` = 'all'", '1', $this->session->bugQuery); // Search all product. + $allProduct = "`product` = 'all'"; + $bugQuery = $this->session->bugQuery; + if(strpos($this->session->bugQuery, $allProduct) !== false) + { + $products = array_keys($this->loadModel('product')->getPrivProducts()); + $bugQuery = str_replace($allProduct, '1', $this->session->bugQuery); + $bugQuery = $bugQuery . ' AND `product`' . helper::dbIN(array_keys($products)); + } $bugQuery = $this->loadModel('search')->replaceDynamic($bugQuery); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($bugQuery) ->andWhere('deleted')->eq(0) diff --git a/module/testcase/control.php b/module/testcase/control.php index 49075173f3..72efe4e41b 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -113,10 +113,20 @@ class testcase extends control if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1'); } - $caseQuery = str_replace("`product` = 'all'", '1', $this->session->testcaseQuery); // If product is all, change it to 1=1. + $queryProductID = $productID; + $allProduct = "`product` = 'all'"; + $caseQuery = $this->session->testcaseQuery; + if(strpos($this->session->testcaseQuery, $allProduct) !== false) + { + $products = array_keys($this->loadModel('product')->getPrivProducts()); + $caseQuery = str_replace($allProduct, '1', $this->session->testcaseQuery); + $caseQuery = $caseQuery . ' AND `product`' . helper::dbIN(array_keys($products)); + $queryProductID = 'all'; + } + $caseQuery = $this->loadModel('search')->replaceDynamic($caseQuery); $this->view->cases = $this->dao->select('*')->from(TABLE_CASE)->where($caseQuery) - ->andWhere('product')->eq($productID) + ->beginIF($queryProductID != 'all')->andWhere('product')->eq($productID)->fi() ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); }