* fix a bug for search with product.

This commit is contained in:
wangyidong
2013-03-14 09:29:21 +00:00
parent 93e4430596
commit 27e1603f68
2 changed files with 20 additions and 3 deletions
+8 -1
View File
@@ -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)
+12 -2
View File
@@ -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();
}