From 59fe4826cac7a4435dabb3c3fba2da8be0348ac6 Mon Sep 17 00:00:00 2001 From: wangyuting <851424971@qq.com> Date: Thu, 10 Nov 2022 07:36:35 +0000 Subject: [PATCH] * Finish task #75237. --- db/update17.8.sql | 2 + db/zentao.sql | 1 + module/build/config.php | 4 +- module/build/control.php | 148 +++++++++++++++-------------- module/build/js/common.js | 6 +- module/build/js/create.js | 40 ++------ module/build/js/edit.js | 36 +++++-- module/build/js/view.js | 2 +- module/build/model.php | 36 ++++--- module/build/view/create.html.php | 13 +-- module/build/view/edit.html.php | 16 ++-- module/build/view/view.html.php | 25 ++--- module/common/lang/menu.php | 2 +- module/group/lang/resource.php | 23 +++-- module/product/control.php | 21 ---- module/project/view/build.html.php | 7 +- module/projectbuild/control.php | 140 +++++++++++++++++++++++++++ module/projectbuild/lang/de.php | 15 ++- module/projectbuild/lang/en.php | 15 ++- module/projectbuild/lang/fr.php | 15 ++- module/projectbuild/lang/vi.php | 15 ++- module/projectbuild/lang/zh-cn.php | 15 ++- 22 files changed, 396 insertions(+), 201 deletions(-) diff --git a/db/update17.8.sql b/db/update17.8.sql index b06ba61f43..3df1275dbd 100644 --- a/db/update17.8.sql +++ b/db/update17.8.sql @@ -37,3 +37,5 @@ REPLACE INTO `zt_report` (`code`, `name`, `module`, `sql`, `vars`, `langs`, `par ('projectbug-type', '{\"zh-cn\":\"\\u9879\\u76eeBug\\u7c7b\\u578b\\u7edf\\u8ba1\\u8868\",\"zh-tw\":\"\\u9805\\u76eeBug\\u985e\\u578b\\u7d71\\u8a08\\u8868\",\"en\":\"Project Bug Type\",\"de\":\"Project Bug Type\",\"fr\":\"Project Bug Type\",\"vi\":\"Project Bug Type\",\"ja\":\"Project Bug Type\"}', ',project,test', 'select t1.id,t3.name as project,t3.id,IF(t3.multiple="1",t1.name,"") as execution,t2.id as bugID,t2.type from TABLE_EXECUTION as t1 \r\nleft join TABLE_BUG as t2 on t1.id=t2.execution\r\nleft join TABLE_PROJECT as t3 on t3.id=t1.project\r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\' and if($project=\'\',1,t3.id=$project) and if($execution=\'\',1,t1.id=$execution)', '{\"varName\":[\"project\",\"execution\"],\"showName\":[\"\\u9879\\u76ee\\u5217\\u8868\",\"\\u6267\\u884c\\u5217\\u8868\"],\"requestType\":[\"select\",\"select\"],\"selectList\":[\"project\",\"execution\"],\"default\":[\"\",\"\"]}', '{\"stories\":{\"zh-cn\":\"\\u9700\\u6c42\\u6570\",\"zh-tw\":\"\\u9700\\u6c42\\u6570\",\"en\":\"Stories\"},\"tasks\":{\"zh-cn\":\"\\u4efb\\u52a1\\u6570\",\"zh-tw\":\"\\u4efb\\u52a1\\u6570\",\"en\":\"Tasks\"},\"undoneStory\":{\"zh-cn\":\"\\u5269\\u4f59\\u9700\\u6c42\\u6570\",\"zh-tw\":\"\\u5269\\u4f59\\u9700\\u6c42\\u6570\",\"en\":\"Undone Story\"},\"undoneTask\":{\"zh-cn\":\"\\u5269\\u4f59\\u4efb\\u52a1\\u6570\",\"zh-tw\":\"\\u5269\\u4f59\\u4efb\\u52a1\\u6570\",\"en\":\"Undone Task\"},\"consumed\":{\"zh-cn\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"zh-tw\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"en\":\"Cost(h)\"},\"left\":{\"zh-cn\":\"\\u5269\\u4f59\\u5de5\\u65f6\",\"zh-tw\":\"\\u5269\\u4f59\\u5de5\\u65f6\",\"en\":\"Left(h)\"},\"consumedPercent\":{\"zh-cn\":\"\\u8fdb\\u5ea6\",\"zh-tw\":\"\\u8fdb\\u5ea6\",\"en\":\"Process\"},\"execution\":{\"zh-cn\":\"\\u6267\\u884c\\u540d\\u79f0\"}}', '{\"group1\":\"project\",\"group2\":\"execution\",\"reportField\":[\"type\"],\"reportType\":[\"count\"],\"sumAppend\":[\"\"]}', 2, '{\"zh-cn\":\"\\u6309\\u7167\\u9879\\u76ee\\u7edf\\u8ba1Bug\\u7684\\u7c7b\\u578b\\u5206\\u5e03\\u60c5\\u51b5\\u3002\",\"zh-tw\":\"\\u6309\\u7167\\u9805\\u76ee\\u7d71\\u8a08Bug\\u7684\\u985e\\u578b\\u5206\\u5e03\\u60c5\\u6cc1\\u3002\",\"en\":\"\",\"de\":\"\",\"fr\":\"\",\"vi\":\"\",\"ja\":\"\"}', 'admin', '2015-08-04 13:54:22'); ALTER TABLE `zt_project` ADD `division` enum('0','1') COLLATE 'utf8_general_ci' NOT NULL DEFAULT '1'; + +ALTER TABLE `zt_build` ADD `builds` varchar(255) NOT NULL AFTER `execution`; diff --git a/db/zentao.sql b/db/zentao.sql index e47069d966..2271183e05 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -323,6 +323,7 @@ CREATE TABLE IF NOT EXISTS `zt_build` ( `product` mediumint(8) unsigned NOT NULL default '0', `branch` mediumint(8) unsigned NOT NULL default '0', `execution` mediumint(8) unsigned NOT NULL default '0', + `builds` varchar(255) NOT NULL, `name` char(150) NOT NULL, `scmPath` char(255) NOT NULL, `filePath` char(255) NOT NULL, diff --git a/module/build/config.php b/module/build/config.php index c2522ab8cb..20b5917a4c 100644 --- a/module/build/config.php +++ b/module/build/config.php @@ -2,8 +2,8 @@ $config->build = new stdclass(); $config->build->create = new stdclass(); $config->build->edit = new stdclass(); -$config->build->create->requiredFields = 'product,execution,name,builder,date'; -$config->build->edit->requiredFields = 'product,execution,name,builder,date'; +$config->build->create->requiredFields = 'product,name,builder,date'; +$config->build->edit->requiredFields = 'product,name,builder,date'; $config->build->editor = new stdclass(); $config->build->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/build/control.php b/module/build/control.php index 3a69f74bba..0055b61203 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -49,13 +49,12 @@ class build extends control if(!empty($_POST)) { - $executionID = empty($executionID) ? $this->post->execution : $executionID; - if(empty($executionID)) dao::$errors['execution'] = $this->lang->build->emptyExecution; + if(empty($executionID) && $this->app->tab == 'execution') dao::$errors['execution'] = $this->lang->build->emptyExecution; if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); if(defined('TUTORIAL')) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true)); // Fix bug #21095. - $buildID = $this->build->create($executionID); + $buildID = $this->build->create($executionID, $projectID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('build', $buildID, 'opened'); @@ -67,40 +66,36 @@ class build extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID") . "#app={$this->app->tab}")); } + $this->loadModel('product'); + $this->loadModel('project'); /* Set menu. */ - $executions = array(); if($this->app->tab == 'project') { - $this->loadModel('project')->setMenu($projectID); - $executions = $this->execution->getPairs($projectID, 'all', 'stagefilter'); - $executionID = empty($executionID) ? key($executions) : $executionID; + $this->project->setMenu($projectID); + $productGroups = $this->product->getProducts($projectID); + $branchGroups = $this->project->getBranchesByProject($projectID); $this->session->set('project', $projectID); } elseif($this->app->tab == 'execution') { - $execution = $this->execution->getByID($executionID); - $executions = $this->execution->getPairs($execution->project); - $projectID = $execution->project; + $execution = $this->execution->getByID($executionID); + $projectID = $execution->project; + $productGroups = $this->product->getProducts($executionID); + $branchGroups = $this->project->getBranchesByProject($executionID); $this->execution->setMenu($executionID); $this->session->set('project', $execution->project); } elseif($this->app->tab == 'qa') { - $execution = $this->execution->getByID($executionID); - $projectID = $execution ? $execution->project : 0; - $executions = $this->execution->getPairs($projectID); + $execution = $this->execution->getByID($executionID); + $projectID = $execution ? $execution->project : 0; + $productGroups = $this->product->getProducts($executionID); + $branchGroups = $this->project->getBranchesByProject($executionID); } $this->commonActions($projectID); - $executionList = empty($executions) ? array() : $this->execution->getByIdList(array_keys($executions)); - foreach($executionList as $execution) - { - if($execution->lifetime == 'ops') unset($executions[$execution->id]); - } - $productGroups = $this->loadModel('product')->getProducts($executionID); $productID = $productID ? $productID : key($productGroups); - $branchGroups = $this->loadModel('project')->getBranchesByProject($executionID); $branchPairs = $this->loadModel('branch')->getPairs($productID, 'active'); $branches = array(); $products = array(); @@ -124,7 +119,6 @@ class build extends control $this->view->executionID = $executionID; $this->view->products = $products; $this->view->projectID = $projectID; - $this->view->executions = $executions; $this->view->lastBuild = $this->build->getLast($executionID); $this->view->productGroups = $productGroups; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); @@ -157,7 +151,7 @@ class build extends control $message = $this->executeHooks($buildID); if($message) $this->lang->saveSuccess = $message; - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "buildID=$buildID"))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID") . "#app={$this->app->tab}")); } $this->loadModel('execution'); @@ -165,30 +159,24 @@ class build extends control $build = $this->build->getById((int)$buildID); /* Set menu. */ - if($this->app->tab == 'project') - { - $this->loadModel('project')->setMenu($build->project); - } - elseif($this->app->tab == 'execution') - { - $this->execution->setMenu($build->execution); - } + if($this->app->tab == 'project') $this->loadModel('project')->setMenu($build->project); + if($this->app->tab == 'execution') $this->execution->setMenu($build->execution); - /* Get stories and bugs. */ - $orderBy = 'status_asc, stage_asc, id_desc'; - - /* Assign. */ - $execution = $this->execution->getByID($build->execution); - if(empty($execution)) + if($build->execution) { - $execution = new stdclass(); - $execution->name = ''; + $productGroups = $this->product->getProducts($build->execution); + $branches = $this->loadModel('branch')->getList($build->product, $build->execution, 'all'); + } + else + { + $productGroups = $this->product->getProducts($build->project); + $branches = $this->loadModel('branch')->getList($build->product, $build->project, 'all'); } $executions = $this->product->getExecutionPairsByProduct($build->product, $build->branch, 'id_desc', $this->session->project, 'stagefilter'); - if(!isset($executions[$build->execution])) $executions[$build->execution] = $execution->name; - $productGroups = $this->product->getProducts($build->execution); + /* Get stories and bugs. */ + $orderBy = 'status_asc, stage_asc, id_desc'; if(!isset($productGroups[$build->product])) { @@ -198,7 +186,6 @@ class build extends control } /* Display status of branch. */ - $branches = $this->loadModel('branch')->getList($build->product, $build->execution, 'all'); $branchTagOption = array(); foreach($branches as $branchInfo) { @@ -210,19 +197,17 @@ class build extends control $this->commonActions($build->project); - $this->view->title = $execution->name . $this->lang->colon . $this->lang->build->edit; - $this->view->position[] = html::a($this->createLink('execution', 'task', "executionID=$build->execution"), $execution->name); + $this->view->title = $build->name . $this->lang->colon . $this->lang->build->edit; $this->view->position[] = $this->lang->build->edit; $this->view->product = isset($productGroups[$build->product]) ? $productGroups[$build->product] : ''; $this->view->branchTagOption = $branchTagOption; - $this->view->executions = $executions; $this->view->orderBy = $orderBy; - - $this->view->productGroups = $productGroups; - $this->view->products = $products; - $this->view->users = $this->loadModel('user')->getPairs('noletter', $build->builder); - $this->view->build = $build; - $this->view->testtaskID = $this->dao->select('id')->from(TABLE_TESTTASK)->where('build')->eq($build->id)->andWhere('deleted')->eq(0)->fetch('id'); + $this->view->executions = $executions; + $this->view->productGroups = $productGroups; + $this->view->products = $products; + $this->view->users = $this->loadModel('user')->getPairs('noletter', $build->builder); + $this->view->build = $build; + $this->view->testtaskID = $this->dao->select('id')->from(TABLE_TESTTASK)->where('build')->eq($build->id)->andWhere('deleted')->eq(0)->fetch('id'); $this->display(); } @@ -310,23 +295,24 @@ class build extends control $this->executeHooks($buildID); - $objectType = 'execution'; - $objectID = $build->execution; - if($build->project and $this->app->tab == 'project') + if($this->app->tab == 'execution') { - $project = $this->project->getByID($build->project); - if(!$project->multiple) - { - $objectType = 'project'; - $objectID = $build->project; - } + $objectType = 'execution'; + $objectID = $build->execution; } + else + { + $objectType = 'project'; + $objectID = $build->project; + } + /* Assign. */ $this->view->canBeChanged = common::canBeChanged('build', $build); // Determines whether an object is editable. $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->build = $build; $this->view->buildPairs = $this->build->getBuildPairs(0, 'all', 'noempty,notrunk', $objectID, $objectType); + $this->view->builds = $this->build->getByList(array_keys($this->view->buildPairs)); $this->view->actions = $this->loadModel('action')->getList('build', $buildID); $this->view->link = $link; $this->view->param = $param; @@ -399,10 +385,11 @@ class build extends control * @param string|int $branch * @param int $index the index of batch create bug. * @param string $type get all builds or some builds belong to normal releases and executions are not done. + * @param string $extra * @access public * @return string */ - public function ajaxGetProductBuilds($productID, $varName, $build = '', $branch = 'all', $index = 0, $type = 'normal') + public function ajaxGetProductBuilds($productID, $varName, $build = '', $branch = 'all', $index = 0, $type = 'normal', $extra = '') { $isJsonView = $this->app->getViewType() == 'json'; if($varName == 'openedBuild' ) @@ -425,6 +412,11 @@ class build extends control if($isJsonView) return print(json_encode($builds)); return print(html::select($varName, $builds, $build, "class='form-control'")); } + + $builds = $this->build->getBuildPairs($productID, $branch, $type); + if($isJsonView) return print(json_encode($builds)); + if(strpos($extra, 'multiple') !== false) $varName .= '[]'; + return print(html::select($varName, $builds, $build, "class='form-control chosen' $extra")); } /** @@ -563,14 +555,11 @@ class build extends control $build = $this->build->getById($buildID); $product = $this->loadModel('product')->getById($build->product); - $this->loadModel('execution')->setMenu($build->execution); + if($build->execution) $this->loadModel('execution')->setMenu($build->execution); $this->loadModel('story'); $this->loadModel('tree'); $this->loadModel('product'); - $execution = $this->execution->getByID($build->execution); - if(empty($execution->hasProduct) and empty($execution->multiple)) unset($this->config->product->search['fields']['plan']); - /* Load pager. */ $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); @@ -589,7 +578,14 @@ class build extends control if($build->project) { $project = $this->loadModel('project')->getByID($build->project); - if(!$project->hasProduct and $project->model != 'scrum') unset($this->config->product->search['fields']['plan']); + if(!$project->hasProduct and $project->model != 'scrum') + { + unset($this->config->product->search['fields']['plan']); + } + else if(!$project->hasProduct and !$project->multiple) + { + unset($this->config->product->search['fields']['plan']); + } } if($product->type == 'normal') @@ -608,13 +604,14 @@ class build extends control } $this->loadModel('search')->setSearchParams($this->config->product->search); + $executionID = $build->execution ? $build->execution : $build->project; if($browseType == 'bySearch') { - $allStories = $this->story->getBySearch($build->product, $build->branch, $queryID, 'id', $build->execution, 'story', $build->stories, $pager); + $allStories = $this->story->getBySearch($build->product, $build->branch, $queryID, 'id', $executionID, 'story', $build->stories, $pager); } else { - $allStories = $this->story->getExecutionStories($build->execution, $build->product, 0, 't1.`order`_desc', 'byBranch', $build->branch, 'story', $build->stories, $pager); + $allStories = $this->story->getExecutionStories($executionID, $build->product, 0, 't1.`order`_desc', 'byBranch', $build->branch, 'story', $build->stories, $pager); } $this->view->allStories = $allStories; @@ -679,7 +676,7 @@ class build extends control /* Set menu. */ $build = $this->build->getByID($buildID); $product = $this->loadModel('product')->getByID($build->product); - $this->loadModel('execution')->setMenu($build->execution); + if($build->execution) $this->loadModel('execution')->setMenu($build->execution); /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -698,9 +695,6 @@ class build extends control $this->config->bug->search['params']['openedBuild']['values'] = $this->build->getBuildPairs($build->product, $branch = 'all', $params = ''); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; - $execution = $this->execution->getByID($build->execution); - if(!$execution->hasProduct and !$execution->multiple) unset($this->config->bug->search['fields']['plan']); - unset($this->config->bug->search['fields']['product']); unset($this->config->bug->search['params']['product']); unset($this->config->bug->search['fields']['project']); @@ -709,7 +703,14 @@ class build extends control if($build->project) { $project = $this->loadModel('project')->getByID($build->project); - if(!$project->hasProduct and $project->model != 'scrum') unset($this->config->bug->search['fields']['plan']); + if(!$project->hasProduct and $project->model != 'scrum') + { + unset($this->config->bug->search['fields']['plan']); + } + else if(!$project->hasProduct and !$project->multiple) + { + unset($this->config->bug->search['fields']['plan']); + } } if($product->type == 'normal') @@ -727,13 +728,14 @@ class build extends control } $this->loadModel('search')->setSearchParams($this->config->bug->search); + $executionID = $build->execution ? $build->execution : $build->project; if($browseType == 'bySearch') { $allBugs = $this->bug->getBySearch($build->product, $build->branch, $queryID, 'id_desc', $build->bugs, $pager, $build->project); } else { - $allBugs = $this->bug->getExecutionBugs($build->execution, 0, 'all', $buildID, 'noclosed', 0, 'status_desc,id_desc', $build->bugs, $pager); + $allBugs = $this->bug->getExecutionBugs($executionID, 0, 'all', $buildID, 'noclosed', 0, 'status_desc,id_desc', $build->bugs, $pager); } $this->view->allBugs = $allBugs; diff --git a/module/build/js/common.js b/module/build/js/common.js index 599c9cba24..4dbf5d9cec 100644 --- a/module/build/js/common.js +++ b/module/build/js/common.js @@ -15,8 +15,8 @@ function loadBranches(productID) oldBranch = productGroups[productID]['branches']; } - executionID = currentTab == 'execution' ? executionID : $('#execution').val(); - $.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0¶m=active&projectID=' + executionID), function(data) + projectID = currentTab == 'execution' ? executionID : projectID; + $.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0¶m=active&projectID=' + projectID), function(data) { if(data) { @@ -25,3 +25,5 @@ function loadBranches(productID) } }); } + +function loadBranch() {return false;} diff --git a/module/build/js/create.js b/module/build/js/create.js index c4bd2f6865..71e70a42c0 100644 --- a/module/build/js/create.js +++ b/module/build/js/create.js @@ -5,37 +5,15 @@ $().ready(function() $('#name').val($(this).text()).focus(); }); -}); -/** - * Load products. - * - * @param int $executionID - * @access public - * @return void - */ -function loadProducts(executionID) -{ - $('#product').remove(); - $('#product_chosen').remove(); - $('#branch').remove(); - $('#branch_chosen').remove(); - $('#noProduct').remove(); - $.get(createLink('product', 'ajaxGetProducts', 'executionID=' + executionID), function(data) + $(document).on('change', '#product, #branch', function() { - if(data) + var productID = $('#product').val(); + var branch = $('#branch').val(); + $.get(createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=builds&build=&branch=' + branch + '&index=&type=noempty,notrunk,separate,noproject&extra=multiple'), function(data) { - if(data.indexOf("required") != -1) - { - $('#productBox').addClass('required'); - } - else - { - $('#productBox').removeClass('required'); - } - - $('#productBox').append(data); - $('#product').chosen(); - loadBranches($("#product").val()); - } + if(data) $('#buildBox').html(data); + $('#builds').chosen(); + }); }); -} + $('#product').change(); +}); diff --git a/module/build/js/edit.js b/module/build/js/edit.js index 9c4a7505b0..db4faeb57d 100644 --- a/module/build/js/edit.js +++ b/module/build/js/edit.js @@ -1,16 +1,32 @@ -var oldExecutionID = $('#execution').val(); - -function loadExecutions() +$().ready(function() { - var productID = $('#product').val(); - var branchID = $('#branch').length > 0 ? $('#branch').val() : 0; + var oldExecutionID = $('#execution').val(); + $(document).on('change', '#product, #branch', function() + { + if(executionID) + { + loadExecutions(oldExecutionID); + } + else + { + var productID = $('#product').val(); + var branch = $('#branch').val(); + $.get(createLink('build', 'ajaxGetProductBuilds', 'productID=' + productID + '&varName=builds&build=' + builds + '&branch=' + branch + '&index=&type=noempty,notrunk,separate,noproject&extra=multiple'), function(data) + { + if(data) $('#buildBox').html(data); + $('#builds').chosen(); + }); + } + }); + if(!executionID) $('#product').change(); +}); + +function loadExecutions(oldExecutionID) +{ + var productID = $('#product').val(); + var branchID = $('#branch').length > 0 ? $('#branch').val() : 0; $('#executionsBox').load(createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=0&branch=' + branchID + '&number=&executionID=' + oldExecutionID), function() { $('#executionsBox #execution').chosen().removeAttr('onchange'); }); } - -$(document).on('change', '#product,#branch', function() -{ - loadExecutions(); -}) diff --git a/module/build/js/view.js b/module/build/js/view.js index 1a258ee2ca..6ed6c1032d 100644 --- a/module/build/js/view.js +++ b/module/build/js/view.js @@ -2,7 +2,7 @@ function showLink(buildID, type, param) { var method = type == 'story' ? 'linkStory' : 'linkBug'; if(typeof(param) == 'undefined') param = '&browseType=' + type + '¶m=0'; - loadURL(createLink('build', method, 'buildID=' + buildID + param), type); + loadURL(createLink(currentModule, method, 'buildID=' + buildID + param), type); $('.actions').find("a[href*='" + type + "']").addClass('hidden'); } diff --git a/module/build/model.php b/module/build/model.php index b74a23895d..95a5658f81 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -225,6 +225,7 @@ class buildModel extends model ->fetchPairs(); } + $branchs = strpos($params, 'separate') === false ? "0,$branch" : $branch; $allBuilds = $this->dao->select('t1.id, t1.name, t1.deleted, t2.status as objectStatus, t3.id as releaseID, t3.status as releaseStatus, t4.name as branchName, t5.type as productType')->from(TABLE_BUILD)->alias('t1') ->beginIF($objectType === 'execution')->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution = t2.id')->fi() ->beginIF($objectType === 'project')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')->fi() @@ -233,10 +234,11 @@ class buildModel extends model ->leftJoin(TABLE_PRODUCT)->alias('t5')->on('t1.product = t5.id') ->where(1)->eq(1) ->beginIF(strpos($params, 'hasDeleted') === false)->andWhere('t1.deleted')->eq(0)->fi() + ->beginIF(strpos($params, 'noproject') !== false)->andWhere('t1.execution')->ne(0)->fi() ->beginIF($products)->andWhere('t1.product')->in($products)->fi() ->beginIF($objectType === 'execution' and $objectID)->andWhere('t1.execution')->eq($objectID)->fi() ->beginIF($objectType === 'project' and $objectID)->andWhere('t1.project')->eq($objectID)->fi() - ->beginIF($branch !== 'all')->andWhere('t1.branch')->in("0,$branch")->fi() + ->beginIF($branch !== 'all')->andWhere('t1.branch')->in("$branchs")->fi() ->orderBy('t1.date desc, t1.id desc')->fetchAll('id'); /* Set builds and filter done executions and terminate releases. */ @@ -262,7 +264,7 @@ class buildModel extends model $releases = $this->dao->select('build, name')->from(TABLE_RELEASE) ->where('build')->in(array_keys($builds)) ->andWhere('product')->in($products) - ->beginIF($branch !== 'all')->andWhere('branch')->in("0,$branch")->fi() + ->beginIF($branch !== 'all')->andWhere('branch')->in("$branchs")->fi() ->andWhere('deleted')->eq(0) ->fetchPairs(); foreach($releases as $buildID => $releaseName) @@ -299,26 +301,27 @@ class buildModel extends model * Create a build * * @param int $executionID + * @param int $projectID * @access public * @return void */ - public function create($executionID) + public function create($executionID = 0, $projectID = 0) { $build = new stdclass(); $build->stories = ''; $build->bugs = ''; - $execution = $this->loadModel('execution')->getByID($executionID); - $build = fixer::input('post') - ->setDefault('project', $execution->project) + ->setDefault('project', $projectID) ->setDefault('product', 0) ->setDefault('branch', 0) + ->setDefault('builds', '') ->cleanInt('product,branch') - ->add('execution', (int)$executionID) + ->add('execution', $executionID) ->add('createdBy', $this->app->user->account) ->add('createdDate', helper::now()) ->stripTags($this->config->build->editor->create['id'], $this->config->allowedTags) + ->join('builds', ',') ->remove('resolvedBy,allchecker,files,labels,uid') ->get(); @@ -355,7 +358,9 @@ class buildModel extends model ->add('id', $buildID) ->setIF(!isset($_POST['branch']), 'branch', $oldBuild->branch) ->setDefault('product', $oldBuild->product) + ->setDefault('builds', '') ->cleanInt('product,branch,execution') + ->join('builds', ',') ->remove('allchecker,resolvedBy,files,labels,uid') ->get(); @@ -565,21 +570,22 @@ class buildModel extends model global $app; $tab = $app->tab; + $module = $build->execution ? 'build' : 'projectbuild'; if($type == 'browse') { $executionID = $tab == 'execution' ? $extraParams['executionID'] : $build->execution; $execution = $this->loadModel('execution')->getByID($executionID); $testtaskApp = (!empty($execution->type) and $execution->type == 'kanban') ? 'data-app="qa"' : "data-app='{$tab}'"; - if(common::hasPriv('build', 'linkstory') and common::canBeChanged('build', $build)) $menu .= $this->buildMenu('build', 'view', "{$params}&type=story&link=true", $build, $type, 'link', '', '', '', "data-app={$tab}", $this->lang->build->linkStory); + if(common::hasPriv($module, 'linkstory') and common::canBeChanged('build', $build)) $menu .= $this->buildMenu($module, 'view', "{$params}&type=story&link=true", $build, $type, 'link', '', '', '', "data-app={$tab}", $this->lang->build->linkStory); $menu .= $this->buildMenu('testtask', 'create', "product=$build->product&execution={$executionID}&build=$build->id&projectID=$build->project", $build, $type, 'bullhorn', '', '', '', $testtaskApp); if($tab == 'execution' and !empty($execution->type) and $execution->type != 'kanban') $menu .= $this->buildMenu('execution', 'bug', "execution={$extraParams['executionID']}&productID={$extraParams['productID']}&branchID=all&orderBy=status&build=$build->id", $build, $type, '', '', '', '', $this->lang->execution->viewBug); - if($tab == 'project' or empty($execution->type) or $execution->type == 'kanban') $menu .= $this->buildMenu('build', 'view', "{$params}&type=generatedBug", $build, $type, 'bug', '', '', '', "data-app='$tab'", $this->lang->project->bug); + if($tab == 'project' or empty($execution->type) or $execution->type == 'kanban') $menu .= $this->buildMenu($module, 'view', "{$params}&type=generatedBug", $build, $type, 'bug', '', '', '', "data-app='$tab'", $this->lang->project->bug); - $menu .= $this->buildMenu('build', 'edit', $params, $build, $type); - $menu .= $this->buildMenu('build', 'delete', $params, $build, $type, 'trash', 'hiddenwin'); + $menu .= $this->buildMenu($module, 'edit', $params, $build, $type); + $menu .= $this->buildMenu($module, 'delete', $params, $build, $type, 'trash', 'hiddenwin'); } else { @@ -588,10 +594,10 @@ class buildModel extends model $menu .= $this->buildFlowMenu('build', $build, 'view', 'direct'); - $editClickable = $this->buildMenu('build', 'edit', $params, $build, $type, '', '', '', '', '', '', false); - $deleteClickable = $this->buildMenu('build', 'delete', $params, $build, $type, '', '', '', '', '', '', false); - if(common::hasPriv('build', 'edit') and $editClickable) $menu .= html::a(helper::createLink('build', 'edit', $params), " " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->build->edit}' data-app='{$app->tab}'"); - if(common::hasPriv('build', 'delete') and $deleteClickable) $menu .= html::a(helper::createLink('build', 'delete', $params), " " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->build->delete}' target='hiddenwin' data-app='{$app->tab}'"); + $editClickable = $this->buildMenu($module, 'edit', $params, $build, $type, '', '', '', '', '', '', false); + $deleteClickable = $this->buildMenu($module, 'delete', $params, $build, $type, '', '', '', '', '', '', false); + if(common::hasPriv($module, 'edit') and $editClickable) $menu .= html::a(helper::createLink($module, 'edit', $params), " " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->build->edit}' data-app='{$app->tab}'"); + if(common::hasPriv($module, 'delete') and $deleteClickable) $menu .= html::a(helper::createLink($module, 'delete', $params), " " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->build->delete}' target='hiddenwin' data-app='{$app->tab}'"); } return $menu; diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index afec7286f9..be80d8aa27 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -19,12 +19,6 @@