From 65c97ea1957a0487201995ca679a2c740495dd1d Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Sat, 9 Jan 2010 03:37:02 +0000 Subject: [PATCH] * adjust the code of bug and product's search feature. --- module/bug/control.php | 54 ++++++++++++++-------------- module/bug/view/browse.html.php | 40 +++++++++++---------- module/product/control.php | 16 ++++----- module/product/view/browse.html.php | 14 ++++---- module/testcase/view/browse.html.php | 2 +- 5 files changed, 65 insertions(+), 61 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 5fe4d53bc2..db55aa331e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -47,58 +47,60 @@ class bug extends control } /* 浏览一个产品下面的bug。*/ - public function browse($productID = 0, $type = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($productID = 0, $browseType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - $this->config->bug->search['actionURL'] = $this->createLink('bug', 'browse', "productID=$productID&type=byQuery"); - $this->assign('searchForm', $this->fetch('search', 'buildForm', $this->config->bug->search)); + /* 设置搜索表单。*/ + $this->config->bug->search['actionURL'] = $this->createLink('bug', 'browse', "productID=$productID&browseType=bySearch"); + $this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->bug->search); - $type = strtolower($type); + /* 设置产品id和模块id。*/ + $browseType = strtolower($browseType); + $productID = common::saveProductState($productID, key($this->products)); + $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; + + /* 设置菜单,登记session。*/ + $this->bug->setMenu($this->products, $productID); $this->session->set('bugList', $this->app->getURI(true)); - $productID = common::saveProductState($productID, key($this->products)); - $moduleID = ($type == 'bymodule') ? (int)$param : 0; - - /* 设置菜单。*/ - $this->bug->setMenu($this->products, $productID); - + /* 加载分页类。*/ $this->app->loadClass('pager', $static = true); $pager = pager::init($recTotal, $recPerPage, $pageID); $bugs = array(); - if($type == 'all') + if($browseType == 'all') { $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == "bymodule") + elseif($browseType == "bymodule") { $childModuleIds = $this->tree->getAllChildId($moduleID); $bugs = $this->bug->getModuleBugs($productID, $childModuleIds, $orderBy, $pager); } - elseif($type == 'assigntome') + elseif($browseType == 'assigntome') { - $bugs = $this->dao->findByAssignedTo($this->app->user->account)->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByAssignedTo($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'openedbyme') + elseif($browseType == 'openedbyme') { - $bugs = $this->dao->findByOpenedBy($this->app->user->account)->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByOpenedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'resolvedbyme') + elseif($browseType == 'resolvedbyme') { - $bugs = $this->dao->findByResolvedBy($this->app->user->account)->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByResolvedBy($this->app->user->account)->from(TABLE_BUG)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'assigntonull') + elseif($browseType == 'assigntonull') { - $bugs = $this->dao->findByAssignedTo('')->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByAssignedTo('')->from(TABLE_BUG)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'longlifebugs') + elseif($browseType == 'longlifebugs') { - $bugs = $this->dao->findByLastEditedDate("<", date('Y-m-d', strtotime('-7 days')))->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByLastEditedDate("<", date('Y-m-d', strtotime('-7 days')))->from(TABLE_BUG)->andWhere('product')->eq($productID)->andWhere('status')->ne('closed')->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'postponedbugs') + elseif($browseType == 'postponedbugs') { - $bugs = $this->dao->findByResolution('postponed')->from(TABLE_BUG)->orderBy($orderBy)->page($pager)->fetchAll(); + $bugs = $this->dao->findByResolution('postponed')->from(TABLE_BUG)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - elseif($type == 'byquery') + elseif($browseType == 'bysearch') { if($this->session->bugQuery == false) $this->session->set('bugQuery', ' 1 = 1'); $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQuery)->orderBy($orderBy)->page($pager)->fetchAll(); @@ -115,7 +117,7 @@ class bug extends control $this->assign('productID', $productID); $this->assign('productName', $this->products[$productID]); $this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'bug', $rooteModuleID = 0, array('treeModel', 'createBugLink'))); - $this->assign('type', $type); + $this->assign('browseType', $browseType); $this->assign('bugs', $bugs); $this->assign('users', $users); $this->assign('recTotal', $pager->recTotal); diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 85e3f9661f..1393590033 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -26,22 +26,24 @@ @@ -50,22 +52,22 @@ function search(active)
" . $lang->bug->moduleBugs . " "; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=assignToMe¶m=0"), $lang->bug->assignToMe) . ""; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=openedByMe¶m=0"), $lang->bug->openedByMe) . ""; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=resolvedByMe¶m=0"), $lang->bug->resolvedByMe) . ""; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=assignToNull¶m=0"), $lang->bug->assignToNull) . ""; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=longLifeBugs¶m=0"), $lang->bug->longLifeBugs) . ""; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=postponedBugs¶m=0"), $lang->bug->postponedBugs) . ""; - echo "{$lang->bug->byQuery} "; - echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=all¶m=0"), $lang->bug->allBugs) . ""; + echo "" . $lang->bug->moduleBugs . " "; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=assignToMe¶m=0"), $lang->bug->assignToMe) . ""; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=openedByMe¶m=0"), $lang->bug->openedByMe) . ""; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=resolvedByMe¶m=0"), $lang->bug->resolvedByMe) . ""; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=assignToNull¶m=0"), $lang->bug->assignToNull) . ""; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=longLifeBugs¶m=0"), $lang->bug->longLifeBugs) . ""; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=postponedBugs¶m=0"), $lang->bug->postponedBugs) . ""; + echo "{$lang->bug->byQuery} "; + echo "" . html::a($this->createLink('bug', 'browse', "productid=$productID&type=all¶m=0&orderBy=$orderBy&recTotal=$recTotal&recPerPage=200"), $lang->bug->allBugs) . ""; ?>
bug->create); ?>
-
'>
+
'>
' id='mainbox'> @@ -81,13 +83,13 @@ function search(active)
- + - + @@ -113,7 +115,7 @@ function search(active) diff --git a/module/product/control.php b/module/product/control.php index 7a8da9ef49..6b3cc574f2 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -49,19 +49,19 @@ class product extends control } /* 浏览某一个产品。*/ - public function browse($productID = 0, $queryType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function browse($productID = 0, $browseType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* 设置搜索条件。*/ - $this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&type=bySearch"); + $this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&browseType=bySearch"); $this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->product->search); /* 设置查询格式。*/ - $queryType = strtolower($queryType); + $browseType = strtolower($browseType); /* 设置当前的产品id和模块id。*/ $this->session->set('storyList', $this->app->getURI(true)); $productID = common::saveProductState($productID, key($this->products)); - $moduleID = ($queryType == 'bymodule') ? (int)$param : 0; + $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; /* 设置菜单。*/ $this->product->setMenu($this->products, $productID); @@ -75,16 +75,16 @@ class product extends control $pager = new pager($recTotal, $recPerPage, $pageID); $stories = array(); - if($queryType == 'all') + if($browseType == 'all') { $stories = $this->story->getProductStories($productID, 0, 'all', $orderBy, $pager); } - elseif($queryType == 'bymodule') + elseif($browseType == 'bymodule') { $childModuleIds = $this->tree->getAllChildID($moduleID); $stories = $this->story->getProductStories($productID, $childModuleIds, 'all', $orderBy, $pager); } - elseif($queryType == 'bysearch') + elseif($browseType == 'bysearch') { if($this->session->storyQuery == false) $this->session->set('storyQuery', ' 1 = 1'); $stories = $this->story->getByQuery($this->session->storyQuery, $orderBy, $pager); @@ -99,7 +99,7 @@ class product extends control $this->assign('pager', $pager); $this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter')); $this->assign('orderBy', $orderBy); - $this->assign('queryType', $queryType); + $this->assign('browseType', $browseType); $this->assign('moduleID', $moduleID); $this->display(); diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index d18ab05622..f6bcc12b9e 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -52,18 +52,18 @@ function search(active)
product->moduleStory;?> - product->searchStory;?> - createLink('product', 'browse', "productID=$productID&type=all"), $lang->product->allStory);?> + product->searchStory;?> + createLink('product', 'browse', "productID=$productID&browseType=all¶m=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage=200"), $lang->product->allStory);?>
createLink('story', 'create', "productID=$productID&moduleID=$moduleID"), $lang->story->create); ?>
-
'>
+
'>
-
' id='mainbox'> -
' id='treebox'> +
' id='mainbox'> +
' id='treebox'>
@@ -80,7 +80,7 @@ function search(active)
bug->id);?> bug->severity);?>bug->title);?>bug->title);?> bug->openedBy);?> bug->assignedTo);?> bug->resolvedBy);?>
- recTotal}&recPerPage={$pager->recPerPage}";?> + recTotal}&recPerPage={$pager->recPerPage}";?> @@ -123,6 +123,6 @@ function search(active) diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index ac6b7f6e2e..117442980f 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -53,7 +53,7 @@ function browseBySearch(active) " . $lang->testcase->moduleCases . " "; echo "{$lang->testcase->bySearch} "; - echo "" . html::a($this->createLink('testcase', 'browse', "productid=$productID&browseType=all¶m=0&orderBy=$orderBy&recTotal=0&recPerPage=500"), $lang->testcase->allCases) . ""; + echo "" . html::a($this->createLink('testcase', 'browse', "productid=$productID&browseType=all¶m=0&orderBy=$orderBy&recTotal=0&recPerPage=200"), $lang->testcase->allCases) . ""; ?>
story->id);?> story->pri);?> story->title);?>