From 66142a6bf6e4f30fec714e041e33f20fa4f770f1 Mon Sep 17 00:00:00 2001 From: "chencongzhi520@gmail.com" Date: Wed, 13 Jun 2012 07:16:44 +0000 Subject: [PATCH] * Refactory the setting of testcaseQueryCondition session. * code for task#633. --- module/common/model.php | 8 ++++---- module/my/control.php | 1 + module/testcase/control.php | 25 ++++--------------------- module/testcase/view/view.html.php | 2 +- 4 files changed, 10 insertions(+), 26 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 5fd7b0dac5..dae17fada3 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -444,10 +444,10 @@ class commonModel extends model $table = ''; switch($type) { - case 'story' : $table = TABLE_STORY; break; - case 'task' : $table = TABLE_TASK; break; - case 'bug' : $table = TABLE_BUG; break; - case 'case' : $table = TABLE_CASE; break; + case 'story' : $table = TABLE_STORY; break; + case 'task' : $table = TABLE_TASK; break; + case 'bug' : $table = TABLE_BUG; break; + case 'testcase' : $table = TABLE_CASE; break; default:break; } diff --git a/module/my/control.php b/module/my/control.php index b9398c6b7b..fc66b5987f 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -288,6 +288,7 @@ class my extends control ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); } + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase'); /* Assign. */ $this->view->header->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->testCase; diff --git a/module/testcase/control.php b/module/testcase/control.php index cd6191edd9..dbe00e3e22 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -120,10 +120,7 @@ class testcase extends control } /* save session .*/ - $sql = $this->dao->get(); - $sql = explode('WHERE', $sql); - $sql = explode('ORDER', $sql[1]); - $this->session->set('testcaseReport', $sql[0]); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase'); /* Build the search form. */ $this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID], 'all' => $this->lang->testcase->allProduct); @@ -320,21 +317,6 @@ class testcase extends control $productID = $case->product; $this->testcase->setMenu($this->products, $productID); - /* Get the previous and next testcase. */ - if($this->session->testcaseReport) - { - $cases = $this->dao->select('id')->from(TABLE_CASE)->where($this->session->testcaseReport)->fetchAll(); - $tmpCaseIDs = array(); - foreach($cases as $tmpCase) $tmpCaseIDs[$tmpCase->id] = $tmpCase->id; - $caseIDs = ',' . implode(',', $tmpCaseIDs) . ','; - $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('case', $caseIDs, $caseID); - } - else - { - $this->view->preAndNext->pre = ''; - $this->view->preAndNext->next = ''; - } - $this->view->header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->view; $this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->testcase->view; @@ -344,6 +326,7 @@ class testcase extends control $this->view->modulePath = $this->tree->getParents($case->module); $this->view->users = $this->user->getPairs('noletter'); $this->view->actions = $this->loadModel('action')->getList('case', $caseID); + $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('testcase', $caseID); $this->display(); } @@ -480,11 +463,11 @@ class testcase extends control if($taskID) { $caseIDList = $this->dao->select('`case`')->from(TABLE_TESTRUN)->where('task')->eq($taskID)->fetchPairs(); - $cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1')->where($this->session->testcaseReport)->andWhere('id')->in($caseIDList)->orderBy($orderBy)->fetchAll('id'); + $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition)->andWhere('id')->in($caseIDList)->orderBy($orderBy)->fetchAll('id'); } else { - $cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1')->where($this->session->testcaseReport)->orderBy($orderBy)->fetchAll('id'); + $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition)->orderBy($orderBy)->fetchAll('id'); } /* Get users, products and projects. */ diff --git a/module/testcase/view/view.html.php b/module/testcase/view/view.html.php index 039bdda6b5..a15ad7daa4 100644 --- a/module/testcase/view/view.html.php +++ b/module/testcase/view/view.html.php @@ -34,7 +34,7 @@ } if($preAndNext->next) { - echo "next->id}{$lang->colon}{$preAndNext->pre->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . ""; + echo "next->id}{$lang->colon}{$preAndNext->next->title}>" . html::a($this->inLink('view', "storyID={$preAndNext->next->id}&version={$preAndNext->next->version}"), '>') . ""; } ?>