From d56cfd1da6087f328cc812f642cd9ecde88b3a34 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 19 Dec 2012 10:08:20 +0000 Subject: [PATCH] * finish task #983. --- module/common/model.php | 26 ++++++++++++++++++-------- module/company/config.php | 2 ++ module/project/control.php | 2 +- module/story/control.php | 2 +- module/testcase/control.php | 2 +- module/testtask/control.php | 16 ++++++++++++++-- module/testtask/lang/en.php | 1 + module/testtask/lang/zh-cn.php | 1 + module/testtask/view/runcase.html.php | 1 + 9 files changed, 40 insertions(+), 13 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index daead207ff..3acd80ad18 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -506,17 +506,27 @@ class commonModel extends model else { /* Get objectIDs. */ - $queryCondition = $type . 'QueryCondition'; + $queryCondition = $type . 'QueryCondition'; + $typeOnlyCondition = $type . 'OnlyCondition'; $queryCondition = $this->session->$queryCondition; $orderBy = $type . 'OrderBy'; $orderBy = $this->session->$orderBy; $orderBy = str_replace('`left`', 'left', $orderBy); // process the `left` to left. - $objects = $this->dao->select('*')->from($table) - ->beginIF($queryCondition != false)->where($queryCondition)->fi() - ->beginIF($orderBy != false)->orderBy($orderBy)->fi() - ->fetchAll(); + + if($this->session->$typeOnlyCondition) + { + $objects = $this->dao->select('*')->from($table) + ->beginIF($queryCondition != false)->where($queryCondition)->fi() + ->beginIF($orderBy != false)->orderBy($orderBy)->fi() + ->fetchAll(); + } + else + { + $objects = $this->dbh->query($queryCondition . " ORDER BY $orderBy")->fetchAll(); + } + $tmpObjectIDs = array(); - foreach($objects as $object) $tmpObjectIDs[$object->id] = $object->id; + foreach($objects as $object) $tmpObjectIDs[$object->id] = (!$this->session->$typeOnlyCondition and $type == 'testcase') ? $object->case : $object->id; $objectIDs = ',' . implode(',', $tmpObjectIDs) . ','; $this->session->set($type . 'IDs', $objectIDs); } @@ -563,10 +573,10 @@ class commonModel extends model * @access public * @return void */ - public function saveQueryCondition($sql, $objectType, $onlyCondition = 'true') + public function saveQueryCondition($sql, $objectType, $onlyCondition = true) { /* Set the query condition session. */ - if($onlyCondition == 'true') + if($onlyCondition) { $queryCondition = explode('WHERE', $sql); $queryCondition = explode('ORDER', $queryCondition[1]); diff --git a/module/company/config.php b/module/company/config.php index 0b687d4440..2d17671493 100644 --- a/module/company/config.php +++ b/module/company/config.php @@ -32,6 +32,7 @@ $config->company->browse->search['fields']['realname'] = $lang->user->realname; $config->company->browse->search['fields']['email'] = $lang->user->email; $config->company->browse->search['fields']['dept'] = $lang->user->dept; $config->company->browse->search['fields']['account'] = $lang->user->account; +$config->company->browse->search['fields']['role'] = $lang->user->role; $config->company->browse->search['fields']['phone'] = $lang->user->phone; $config->company->browse->search['fields']['join'] = $lang->user->join; $config->company->browse->search['fields']['id'] = $lang->user->id; @@ -51,6 +52,7 @@ $config->company->browse->search['params']['realname'] = array('operator' => 'in $config->company->browse->search['params']['email'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->company->browse->search['params']['dept'] = array('operator' => 'belong', 'control' => 'select', 'values' => ''); $config->company->browse->search['params']['account'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->company->browse->search['params']['role'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->user->roleList); $config->company->browse->search['params']['phone'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->company->browse->search['params']['join'] = array('operator' => '>=', 'control' => 'input', 'values' => '', 'class' => 'date'); $config->company->browse->search['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => ''); diff --git a/module/project/control.php b/module/project/control.php index 5311ba7e38..0024094ddd 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -503,7 +503,7 @@ class project extends control /* The pager. */ $stories = $this->story->getProjectStories($projectID, $orderBy); - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', 'false'); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story', false); $storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID); $users = $this->user->getPairs('noletter'); diff --git a/module/story/control.php b/module/story/control.php index 51b209a168..d48c9e4305 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -878,7 +878,7 @@ class story extends control /* Get stories. */ $stories = array(); - if($this->session->storyOnlyCondition == 'true') + if($this->session->storyOnlyCondition) { $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition) ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() diff --git a/module/testcase/control.php b/module/testcase/control.php index d176756711..02f1f3026a 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -530,7 +530,7 @@ class testcase extends control } /* Get cases. */ - if($this->session->testcaseOnlyCondition == 'true') + if($this->session->testcaseOnlyCondition) { if($taskID) { diff --git a/module/testtask/control.php b/module/testtask/control.php index d4cfd0e04b..b4c6f0c7d3 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -230,7 +230,7 @@ class testtask extends control { $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $orderBy, $pager); } - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', 'false'); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); /* Save testcaseIDs session for get the pre and next testcase. */ $testcaseIDs = ''; @@ -443,7 +443,19 @@ class testtask extends control if(!$caseID) $run = $this->testtask->getRunById($runID); if($caseID) $run->case = $this->loadModel('testcase')->getById($caseID, $version); - $this->view->run = $run; + $nextCase = ''; + $caseID = $caseID ? $caseID : $run->case->id; + $preAndNext = $this->loadModel('common')->getPreAndNextObject('testcase', $caseID); + if($runID and $preAndNext->next) $preAndNext->next = $this->dao->select('*')->from(TABLE_TESTRUN)->where('`case`')->eq($preAndNext->next->id)->fetch(); + if($preAndNext->next) + { + $nextCase['runID'] = $runID ? $preAndNext->next->id : 0; + $nextCase['caseID'] = $runID ? $preAndNext->next->case : $preAndNext->next->id; + $nextCase['version'] = $preAndNext->next->version; + } + + $this->view->run = $run; + $this->view->nextCase = $nextCase; die($this->display()); } diff --git a/module/testtask/lang/en.php b/module/testtask/lang/en.php index 9af6d39cd8..7680487b43 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -25,6 +25,7 @@ $lang->testtask->results = "Result"; $lang->testtask->createBug = "Bug(+)"; $lang->testtask->assign = 'Assign'; $lang->testtask->cases = 'Cases'; +$lang->testtask->next = 'Next'; $lang->testtask->common = 'Test task'; $lang->testtask->id = 'ID'; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index 27162d16f0..b1eeb456dd 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -25,6 +25,7 @@ $lang->testtask->results = "结果"; $lang->testtask->createBug = "提Bug"; $lang->testtask->assign = '指派'; $lang->testtask->cases = '用例'; +$lang->testtask->next = '下一个'; $lang->testtask->common = '测试任务'; $lang->testtask->id = '任务编号'; diff --git a/module/testtask/view/runcase.html.php b/module/testtask/view/runcase.html.php index f206738fd8..dad1aedd25 100644 --- a/module/testtask/view/runcase.html.php +++ b/module/testtask/view/runcase.html.php @@ -50,6 +50,7 @@ echo html::hidden('case', $run->case->id); echo html::hidden('version', $run->case->version); if($run->case->steps) echo html::hidden('passall', 0); + if($nextCase) echo html::linkButton($lang->testtask->next, inlink('runCase', "runID={$nextCase['runID']}&caseID={$nextCase['caseID']}&version={$nextCase['version']}")); if(!$run->case->steps) echo html::hidden('result', ''); ?>