From 8cead79b18fe37e477f46d03eb71e8b593d9a11e Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Tue, 24 Nov 2020 10:40:18 +0800 Subject: [PATCH] * Adjust getProjectPairs to getExecutionPairsByProduct. --- module/bug/control.php | 8 +++--- module/bug/model.php | 2 +- module/build/config.php | 2 +- module/build/control.php | 47 ++++++++++++++++--------------- module/build/view/create.html.php | 2 +- module/build/view/edit.html.php | 2 +- module/product/control.php | 2 +- module/product/model.php | 29 +++++++++---------- module/project/model.php | 16 ++++++++++- module/release/control.php | 2 +- module/testtask/control.php | 6 ++-- 11 files changed, 65 insertions(+), 53 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index d8b51330fb..d45640c17e 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -451,7 +451,7 @@ class bug extends control $this->view->productName = $this->products[$productID]; $this->view->moduleOptionMenu = $moduleOptionMenu; $this->view->stories = $stories; - $this->view->projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted'); + $this->view->projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted'); $this->view->builds = $builds; $this->view->moduleID = (int)$moduleID; $this->view->projectID = $projectID; @@ -554,7 +554,7 @@ class bug extends control $this->view->stories = $stories; $this->view->builds = $builds; $this->view->users = $this->user->getPairs('devfirst|nodeleted'); - $this->view->projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : 0, $params = 'nodeleted'); + $this->view->projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'nodeleted'); $this->view->projectID = $projectID; $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $branch); $this->view->moduleID = $moduleID; @@ -727,7 +727,7 @@ class bug extends control $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $bug->branch); $this->view->currentModuleID = $currentModuleID; - $this->view->projects = $this->product->getProjectPairs($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted'); + $this->view->projects = $this->product->getExecutionPairsByProduct($bug->product, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted'); $this->view->stories = $bug->project ? $this->story->getProjectStoryPairs($bug->project) : $this->story->getProductStoryPairs($bug->product, $bug->branch); $this->view->branches = $this->session->currentProductType == 'normal' ? array() : $this->loadModel('branch')->getPairs($bug->product); $this->view->tasks = $this->task->getProjectTaskPairs($bug->project); @@ -1100,7 +1100,7 @@ class bug extends control $this->view->bug = $bug; $this->view->users = $users; $this->view->assignedTo = $assignedTo; - $this->view->projects = $this->loadModel('product')->getProjectPairs($productID, $bug->branch ? "0,{$bug->branch}" : 0, $params = 'nodeleted'); + $this->view->projects = $this->loadModel('product')->getExecutionPairsByProduct($productID, $bug->branch ? "0,{$bug->branch}" : 0, 'nodeleted'); $this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = $bug->branch, 'all'); $this->view->actions = $this->action->getList('bug', $bugID); $this->display(); diff --git a/module/bug/model.php b/module/bug/model.php index 6f8f068e38..dd3057037c 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1273,7 +1273,7 @@ class bugModel extends model $this->config->bug->search['params']['product']['values'] = array($productID => $products[$productID], 'all' => $this->lang->bug->allProduct); $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs($productID); $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0); - $this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairs($productID); + $this->config->bug->search['params']['project']['values'] = $this->product->getExecutionPairsByProduct($productID); $this->config->bug->search['params']['severity']['values'] = array(0 => '') + $this->lang->bug->severityList; //Fix bug #939. $this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID, 0, $params = ''); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; diff --git a/module/build/config.php b/module/build/config.php index bcee51e703..adc7ace046 100644 --- a/module/build/config.php +++ b/module/build/config.php @@ -13,7 +13,7 @@ global $lang; $config->build->search['module'] = 'build'; $config->build->search['fields']['name'] = $lang->build->name; $config->build->search['fields']['id'] = $lang->build->id; -$config->build->search['fields']['product'] = $lang->story->product; +$config->build->search['fields']['product'] = $lang->build->product; $config->build->search['fields']['scmPath'] = $lang->build->scmPath; $config->build->search['fields']['filePath'] = $lang->build->filePath; $config->build->search['fields']['date'] = $lang->build->date; diff --git a/module/build/control.php b/module/build/control.php index 4c78b26015..49196599dd 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -14,22 +14,22 @@ class build extends control /** * Create a build. * - * @param int $projectID + * @param int $executionID * @param int $productID * @access public * @return void */ - public function create($projectID, $productID = 0) + public function create($executionID, $productID = 0) { if(!empty($_POST)) { - $buildID = $this->build->create($projectID); + $buildID = $this->build->create($executionID); if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('build', $buildID, 'opened'); $this->executeHooks($buildID); - if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($projectID)"));//Code for task #5126. + if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($executionID)"));//Code for task #5126. $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID"))); } @@ -40,29 +40,30 @@ class build extends control $this->loadModel('user'); /* Set menu. */ - $this->project->setMenu($this->project->getExecutionPairs($this->session->PRJ), $projectID); + $executions = $this->project->getExecutionPairs($this->session->PRJ); + $this->project->setMenu($executions, $executionID); /* Get stories and bugs. */ $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($projectID); + $project = $this->loadModel('project')->getExecutionById($executionID); - $productGroups = $this->project->getProducts($projectID); + $productGroups = $this->project->getProducts($executionID); $productID = $productID ? $productID : key($productGroups); $products = array(); foreach($productGroups as $product) $products[$product->id] = $product->name; - $this->view->title = $project->name . $this->lang->colon . $this->lang->build->create; - $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$projectID"), $project->name); - $this->view->position[] = $this->lang->build->create; + $this->view->title = $project->name . $this->lang->colon . $this->lang->build->create; + $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$executionID"), $project->name); + $this->view->position[] = $this->lang->build->create; + $this->view->product = isset($productGroups[$productID]) ? $productGroups[$productID] : ''; $this->view->branches = (isset($productGroups[$productID]) and $productGroups[$productID]->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID); - $this->view->projectID = $projectID; + $this->view->executionID = $executionID; $this->view->orderBy = $orderBy; - $this->view->products = $products; - $this->view->lastBuild = $this->build->getLast($projectID); + $this->view->lastBuild = $this->build->getLast($executionID); $this->view->productGroups = $productGroups; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); $this->display(); @@ -107,15 +108,15 @@ class build extends control $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($build->project); - if(empty($project)) + $execution = $this->loadModel('project')->getExecutionById($build->project); + if(empty($execution)) { - $project = new stdclass(); - $project->name = ''; + $execution = new stdclass(); + $execution->name = ''; } - $projects = $this->loadModel('product')->getProjectPairs($build->product, $build->branch, 'nodeleted'); - if(!isset($projects[$build->project])) $projects[$build->project] = $project->name; + $executions = $this->loadModel('product')->getExecutionPairsByProduct($build->product, $build->branch, 'nodeleted'); + if(!isset($executions[$build->project])) $executions[$build->project] = $execution->name; $productGroups = $this->project->getProducts($build->project); @@ -130,12 +131,12 @@ class build extends control $products = array(); foreach($productGroups as $product) $products[$product->id] = $product->name; - $this->view->title = $project->name . $this->lang->colon . $this->lang->build->edit; - $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $project->name); + $this->view->title = $execution->name . $this->lang->colon . $this->lang->build->edit; + $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $execution->name); $this->view->position[] = $this->lang->build->edit; $this->view->product = isset($productGroups[$build->product]) ? $productGroups[$build->product] : ''; $this->view->branches = (isset($productGroups[$build->product]) and $productGroups[$build->product]->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($build->product); - $this->view->projects = $projects; + $this->view->executions = $executions; $this->view->orderBy = $orderBy; $this->view->productGroups = $productGroups; @@ -524,7 +525,7 @@ class build extends control $this->config->bug->search['style'] = 'simple'; $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product)); $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, $viewType = 'bug', $startModuleID = 0); - $this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($build->product); + $this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($build->product); $this->config->bug->search['params']['openedBuild']['values'] = $this->build->getProductBuildPairs($build->product, $branch = 0, $params = ''); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index 67c6d0ae1e..31b46fdd3c 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -36,7 +36,7 @@ - build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?> + build->noProduct, $this->createLink('project', 'manageproducts', "executionID=$executionID&from=buildCreate"));?> diff --git a/module/build/view/edit.html.php b/module/build/view/edit.html.php index c96c4dd320..44d77b4e40 100644 --- a/module/build/view/edit.html.php +++ b/module/build/view/edit.html.php @@ -45,7 +45,7 @@ build->project;?> - project, "class='form-control chosen' required");?> + project, "class='form-control chosen' required");?> build->name;?> diff --git a/module/product/control.php b/module/product/control.php index cdfcc07471..76af6618b0 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -640,7 +640,7 @@ class product extends control } else { - $projects = $this->product->getProjectPairs($productID, $branch ? "0,$branch" : $branch, $params = 'nodeleted'); + $projects = $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : $branch, 'nodeleted'); } if($this->app->getViewType() == 'json') die(json_encode($projects)); diff --git a/module/product/model.php b/module/product/model.php index 7412532284..263c7c4446 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -754,33 +754,30 @@ class productModel extends model } /** - * Get projects of a product in pairs. + * Get executions by product and project. * * @param int $productID - * @param string $param all|nodeleted + * @param int $branch + * @param string $status all|nodeleted * @access public * @return array */ - public function getProjectPairs($productID, $branch = 0, $param = 'all') + public function getExecutionPairsByProduct($productID, $branch = 0, $status = 'all') { - $projects = array(); - $datas = $this->dao->select('t2.id, t2.name, t2.deleted')->from(TABLE_PROJECTPRODUCT) + if(!$this->session->PRJ) return array(); + + $executions = $this->dao->select('t2.id, t2.name')->from(TABLE_PROJECTPRODUCT) ->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') - ->where('t1.product')->eq((int)$productID) - ->andWhere('t2.project')->eq((int)$this->session->PRJ) + ->where('t1.product')->eq($productID) + ->andWhere('t2.project')->eq($this->session->PRJ) ->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi() ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() - ->andWhere('t2.deleted')->eq(0) + ->beginIF($status == 'nodeleted')->andWhere('t2.deleted')->eq('0')->fi() ->orderBy('t1.project desc') - ->fetchAll(); + ->fetchPairs(); - foreach($datas as $data) - { - if($param == 'nodeleted' and $data->deleted) continue; - $projects[$data->id] = $data->name; - } - $projects = array('' => '') + $projects; - return $projects; + $executions = array('' => '') + $executions; + return $executions; } /** diff --git a/module/project/model.php b/module/project/model.php index 0b24267f61..1f08922c94 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1331,7 +1331,7 @@ class projectModel extends model } /** - * Get project by id. + * Get the execution by ID. * * @param int $projectID * @param bool $setImgSize @@ -1380,6 +1380,20 @@ class projectModel extends model return $project; } + /** + * Get the execution by ID. + * + * @param int $executionID + * @access public + * @return object + */ + public function getExecutionById($executionID = 0) + { + /* TODO: The getbyid method queries too much information that is not actually needed. */ + if(empty($executionID)) return array(); + return $this->dao->findById($executionID)->from(TABLE_EXECUTION)->fetch(); + } + /** * Get the default managers for a project from it's related products. * diff --git a/module/release/control.php b/module/release/control.php index 2490c20842..e712c01d03 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -521,7 +521,7 @@ class release extends control $this->config->bug->search['style'] = 'simple'; $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($release->product => $release->product)); $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($release->product, $viewType = 'bug', $startModuleID = 0); - $this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getProjectPairs($release->product); + $this->config->bug->search['params']['project']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($release->product); $this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($release->product, $branch = 0, $params = ''); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; if($this->session->currentProductType == 'normal') diff --git a/module/testtask/control.php b/module/testtask/control.php index 86d5162ed8..98aa440bb4 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -164,7 +164,7 @@ class testtask extends control /* Create testtask from testtask of test.*/ $productID = $productID ? $productID : key($this->products); - $projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted'); + $projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted'); $builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true); /* Set menu. */ @@ -592,7 +592,7 @@ class testtask extends control /* Create testtask from testtask of test.*/ $productID = $productID ? $productID : key($this->products); - $projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted'); + $projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted'); $builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true); $this->view->task = $task; @@ -1162,7 +1162,7 @@ class testtask extends control $this->app->loadLang('job'); $productID = $productID ? $productID : key($this->products); - $projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted'); + $projects = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, $params = 'nodeleted'); $builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk'); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->importUnitResult;