From b2eb6f13d40fa1848e2d5db06ac4de4532aab3f8 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Mon, 18 Jan 2010 09:44:57 +0000 Subject: [PATCH] + bug: when create a bug, add the build field. * adjust the user::getPairs() method. --- module/bug/control.php | 35 +++++++++++++++++---------------- module/bug/model.php | 2 +- module/bug/view/create.html.php | 29 ++++++++++++++++++++------- module/build/control.php | 13 ++++++++++++ module/build/model.php | 18 ++++++++++++++++- module/group/control.php | 2 +- module/my/control.php | 2 +- module/product/control.php | 4 ++-- module/project/control.php | 6 +++--- module/testcase/control.php | 8 ++++---- module/user/control.php | 10 +++++----- module/user/model.php | 2 +- 12 files changed, 88 insertions(+), 43 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 0ac87cbf85..4b54450a37 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -106,7 +106,7 @@ class bug extends control $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQuery)->andWhere('product')->eq($productID)->orderBy($orderBy)->page($pager)->fetchAll(); } - $users = $this->user->getPairs($this->app->company->id, 'noletter'); + $users = $this->user->getPairs('noletter'); $header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->bug->common; $position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); @@ -142,25 +142,26 @@ class bug extends control die(js::locate($this->createLink('bug', 'browse', "productID={$this->post->product}&type=byModule¶m={$this->post->module}"), 'parent')); } + /* 设置当前的产品和模块。*/ $productID = common::saveProductState($productID, key($this->products)); $currentModuleID = (int)$moduleID; /* 设置菜单。*/ $this->bug->setMenu($this->products, $productID); - $header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create; - $position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); - $position[] = $this->lang->bug->create; + /* 位置信息。*/ + $this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create; + $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); + $this->view->position[] = $this->lang->bug->create; - $this->assign('header', $header); - $this->assign('position', $position); - $this->assign('productID', $productID); - $this->assign('productName', $this->products[$productID]); - $this->assign('moduleOptionMenu', $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0)); - $this->assign('currentModuleID', $currentModuleID); - $this->assign('stories', $this->story->getProductStoryPairs($productID)); - $this->assign('users', $this->user->getPairs($this->app->company->id, 'noclosed')); - $this->assign('projects', $this->product->getProjectPairs($productID)); + $this->view->productID = $productID; + $this->view->productName = $this->products[$productID]; + $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $rooteModuleID = 0); + $this->view->currentModuleID = $currentModuleID; + $this->view->stories = $this->story->getProductStoryPairs($productID); + $this->view->users = $this->user->getPairs('noclosed'); + $this->view->projects = $this->product->getProjectPairs($productID); + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID); $this->display(); } @@ -178,7 +179,7 @@ class bug extends control $position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $productName); $position[] = $this->lang->bug->view; - $users = $this->user->getPairs($this->app->company->id, 'noletter'); + $users = $this->user->getPairs('noletter'); $actions = $this->action->getList('bug', $bugID); $this->assign('header', $header); $this->assign('position', $position); @@ -227,7 +228,7 @@ class bug extends control $stories = $bug->project ? $this->story->getProjectStoryPairs($bug->project) : $this->story->getProductStoryPairs($bug->product); $tasks = $this->task->getProjectTaskPairs($bug->project); - $users = $this->user->getPairs($this->app->company->id); + $users = $this->user->getPairs(); $this->assign('header', $header); $this->assign('position', $position); $this->assign('productID', $productID); @@ -270,7 +271,7 @@ class bug extends control /* 设置菜单。*/ $this->bug->setMenu($this->products, $productID); - $users = $this->user->getPairs($this->app->company->id); + $users = $this->user->getPairs(); $this->assign('header', $header); $this->assign('position', $position); $this->assign('bug', $bug); @@ -294,7 +295,7 @@ class bug extends control /* 生成表单。*/ $bug = $this->bug->getById($bugID); $productID = $bug->product; - $users = $this->user->getPairs($this->app->company->id); + $users = $this->user->getPairs(); /* 设置菜单。*/ $this->bug->setMenu($this->products, $productID); diff --git a/module/bug/model.php b/module/bug/model.php index 85846197ba..e949ad9144 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -49,7 +49,7 @@ class bugModel extends model ->join('mailto', ',') ->remove('files, labels') ->get(); - $this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck('title,type', 'notempty')->exec(); + $this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck('title,type,openedBuild', 'notempty')->exec(); if(!dao::isError()) { $bugID = $this->dao->lastInsertID(); diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index c6b0d7e546..639e901690 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -27,6 +27,7 @@ #project{width:245px} #product{width:245px} #story{width:245px} +#openedBuild{width:245px}
@@ -104,7 +120,7 @@ function loadProjectStories(projectID) bug->labProjectAndTask;?> - + @@ -114,13 +130,12 @@ function loadProjectStories(projectID) - bug->labTypeAndSeverity;?> diff --git a/module/build/control.php b/module/build/control.php index 7e8e41e57c..347fd524f5 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -96,4 +96,17 @@ class build extends control die(js::locate($this->createLink('project', 'build', "projectID=$build->project"), 'parent')); } } + + /* AJAX接口:获得产品的build列表。*/ + public function ajaxGetProductBuilds($productID, $varName) + { + die(html::select($varName, $this->build->getProductBuildPairs($productID))); + } + + /* AJAX接口:获得项目的build列表。*/ + public function ajaxGetProjectBuilds($projectID, $varName) + { + die(html::select($varName, $this->build->getProjectBuildPairs($projectID))); + } + } diff --git a/module/build/model.php b/module/build/model.php index 0bc86250fd..e5714ca3ba 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -49,10 +49,26 @@ class buildModel extends model ->fetchAll(); } + /* 查找项目中的build key=>value对。*/ + public function getProjectBuildPairs($projectID) + { + $sysBuilds = array('' => '', 'trunk' => 'Trunk'); + $builds = $this->dao->select('id,name')->from(TABLE_BUILD)->where('project')->eq((int)$projectID)->orderBy('id desc')->fetchPairs(); + if(!$builds) return $sysBuilds; + $releases = $this->dao->select('build,name')->from(TABLE_RELEASE)->where('build')->in(array_keys($builds))->fetchPairs(); + foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName; + return $sysBuilds + $builds; + } + /* 查找产品中的build列表。*/ public function getProductBuildPairs($productID) { - return $this->dao->select('id,name')->from(TABLE_BUILD)->where('product')->eq((int)$productID)->fetchPairs(); + $sysBuilds = array('' => '', 'trunk' => 'Trunk'); + $builds = $this->dao->select('id,name')->from(TABLE_BUILD)->where('product')->eq((int)$productID)->orderBy('id desc')->fetchPairs(); + if(!$builds) return $sysBuilds; + $releases = $this->dao->select('build,name')->from(TABLE_RELEASE)->where('build')->in(array_keys($builds))->fetchPairs(); + foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName; + return $sysBuilds + $builds; } /* 创建。*/ diff --git a/module/group/control.php b/module/group/control.php index 67a724361e..ed67415207 100644 --- a/module/group/control.php +++ b/module/group/control.php @@ -123,7 +123,7 @@ class group extends control $group = $this->group->getById($groupID); $groupUsers = $this->group->getUserPairs($groupID); $groupUsers = join(',', array_keys($groupUsers)); - $allUsers = $this->user->getPairs($this->app->company->id, 'noclosed|noempty|noletter'); + $allUsers = $this->user->getPairs('noclosed|noempty|noletter'); $header['title'] = $this->lang->admin->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->manageMember; $position[] = html::a($this->createLink('admin', 'browsegroup', "companyid={$this->app->company->id}"), $this->lang->admin->group); diff --git a/module/my/control.php b/module/my/control.php index af2bcfcdca..9f1cbf2548 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -76,7 +76,7 @@ class my extends control /* 赋值。*/ $this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, 'doing,wait'); - $this->view->users = $this->user->getPairs($this->app->company->id, 'noletter'); + $this->view->users = $this->user->getPairs('noletter'); $this->display(); } diff --git a/module/product/control.php b/module/product/control.php index bf8fdc94e1..2427778b69 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -97,7 +97,7 @@ class product extends control $this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'product', $rooteModuleID = 0, array('treeModel', 'createStoryLink'))); $this->assign('parentModules', $this->tree->getParents($moduleID)); $this->assign('pager', $pager); - $this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter')); + $this->assign('users', $this->user->getPairs('noletter')); $this->assign('orderBy', $orderBy); $this->assign('browseType', $browseType); $this->assign('moduleID', $moduleID); @@ -186,6 +186,6 @@ class product extends control public function ajaxGetProjects($productID, $projectID = 0) { $projects = $this->product->getProjectPairs($productID); - die(html::select('project', $projects, $projectID, 'onchange=loadProjectStoriesAndTasks(this.value)')); + die(html::select('project', $projects, $projectID, 'onchange=loadProjectRelated(this.value)')); } } diff --git a/module/project/control.php b/module/project/control.php index 0e704a4238..097262ca6b 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -133,7 +133,7 @@ class project extends control $pager = new pager($recTotal, $recPerPage, $pageID); $stories = $this->story->getProjectStories($projectID, $orderBy, $pager); $storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID); - $users = $this->user->getPairs($this->app->company->id, 'noletter'); + $users = $this->user->getPairs('noletter'); /* 赋值。*/ $this->assign('header', $header); @@ -170,7 +170,7 @@ class project extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); $bugs = $this->bug->getProjectBugs($projectID, $orderBy, $pager); - $users = $this->user->getPairs($this->app->company->id, 'noletter'); + $users = $this->user->getPairs('noletter'); /* 赋值。*/ $this->assign('header', $header); @@ -421,7 +421,7 @@ class project extends control $this->loadModel('user'); $project = $this->project->findById($projectID); - $users = $this->user->getPairs($this->app->company->id, 'noclosed'); + $users = $this->user->getPairs('noclosed'); $users = array('' => '') + $users; $members = $this->project->getTeamMembers($projectID); diff --git a/module/testcase/control.php b/module/testcase/control.php index e85d9e3a07..15f61029f7 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -82,7 +82,7 @@ class testcase extends control $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $rooteModuleID = 0, array('treeModel', 'createCaseLink')); $this->view->moduleID = $moduleID; $this->view->pager = $pager; - $this->view->users = $this->user->getPairs($this->app->company->id, 'noletter'); + $this->view->users = $this->user->getPairs('noletter'); $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->param = $param; @@ -114,7 +114,7 @@ class testcase extends control $position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]); $position[] = $this->lang->testcase->create; - $users = $this->user->getPairs($this->app->company->id); + $users = $this->user->getPairs(); $this->assign('header', $header); $this->assign('position', $position); $this->assign('productID', $productID); @@ -140,7 +140,7 @@ class testcase extends control /* 设置菜单。*/ $this->testcase->setMenu($this->products, $productID); - $users = $this->user->getPairs($this->app->company->id, 'noletter'); + $users = $this->user->getPairs('noletter'); $actions = $this->action->getList('case', $caseID); $this->assign('header', $header); @@ -184,7 +184,7 @@ class testcase extends control /* 设置菜单。*/ $this->testcase->setMenu($this->products, $productID); - $users = $this->user->getPairs($this->app->company->id); + $users = $this->user->getPairs(); $this->assign('header', $header); $this->assign('position', $position); $this->assign('productID', $productID); diff --git a/module/user/control.php b/module/user/control.php index aef6060be5..33a6c0533f 100644 --- a/module/user/control.php +++ b/module/user/control.php @@ -47,7 +47,7 @@ class user extends control $user = $this->dao->findByAccount($account)->from(TABLE_USER)->fetch(); /* ò˵*/ - $this->user->setMenu($this->user->getPairs($this->app->company->id, 'noempty|noclosed'), $account); + $this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account); $todos = $this->todo->getList($type, $account, $status); $date = (int)$type == 0 ? $this->todo->today() : $type; @@ -79,7 +79,7 @@ class user extends control $user = $this->dao->findByAccount($account)->from(TABLE_USER)->fetch(); /* ò˵*/ - $this->user->setMenu($this->user->getPairs($this->app->company->id, 'noempty|noclosed'), $account); + $this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account); /* 趨headerpositionϢ*/ $header['title'] = $this->lang->user->common . $this->lang->colon . $this->lang->user->task; @@ -104,7 +104,7 @@ class user extends control $user = $this->dao->findByAccount($account)->from(TABLE_USER)->fetch(); /* ò˵*/ - $this->user->setMenu($this->user->getPairs($this->app->company->id, 'noempty|noclosed'), $account); + $this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account); /* 趨headerpositionϢ*/ $header['title'] = $this->lang->user->common . $this->lang->colon . $this->lang->user->bug; @@ -129,7 +129,7 @@ class user extends control $user = $this->dao->findByAccount($account)->from(TABLE_USER)->fetch(); /* ò˵*/ - $this->user->setMenu($this->user->getPairs($this->app->company->id, 'noempty|noclosed'), $account); + $this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account); /* 趨headerpositionϢ*/ $header['title'] = $this->lang->user->common . $this->lang->colon . $this->lang->user->project; @@ -152,7 +152,7 @@ class user extends control $position[] = $this->lang->user->profile; /* ò˵*/ - $this->user->setMenu($this->user->getPairs($this->app->company->id, 'noempty|noclosed'), $account); + $this->user->setMenu($this->user->getPairs('noempty|noclosed'), $account); $this->assign('header', $header); $this->assign('position', $position); diff --git a/module/user/model.php b/module/user/model.php index ef746ddbbb..56d0e3416c 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -44,7 +44,7 @@ class userModel extends model } /* account=>realnameбparams: noletter|noempty|noclosed*/ - public function getPairs($companyID = 0, $params = '') + public function getPairs($params = '', $companyID = 0) { if($companyID == 0) $companyID = $this->app->company->id; $users = $this->dao->select('account, realname')->from(TABLE_USER)->where('company')->eq((int)$companyID)->orderBy('account')->fetchPairs();