From 6f12e34d25262dced5d25d5a25cf330839a3d219 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 12 Nov 2015 09:54:00 +0800 Subject: [PATCH] * finish task #2398. --- module/build/model.php | 34 +++++++++++++---------------- module/release/control.php | 4 ++-- module/release/model.php | 8 +++++++ module/release/view/create.html.php | 6 ----- module/release/view/edit.html.php | 6 ----- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/module/build/model.php b/module/build/model.php index bf175e8c56..5c7c544c85 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -70,23 +70,21 @@ class buildModel extends model if(strpos($params, 'noempty') === false) $sysBuilds = array('' => ''); if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => 'Trunk'); - $projectBuilds = $this->dao->select('t1.id, t1.name, t3.status as releaseStatus')->from(TABLE_BUILD)->alias('t1') + $projectBuilds = $this->dao->select('t1.id, t1.name, t4.name as branchName')->from(TABLE_BUILD)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build') + ->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id') ->where('t1.project')->eq((int)$projectID) ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi() ->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi() ->beginIF(strpos($params, 'nodone') !== false)->andWhere('t2.status')->ne('done')->fi() + ->beginIF(strpos($params, 'noterminate') !== false)->andWhere('t3.status')->ne('terminate')->fi() ->andWhere('t1.deleted')->eq(0) ->orderBy('t1.date desc, t1.id desc')->fetchAll('id'); /* Set builds and filter terminate releases. */ $builds = array(); - foreach($projectBuilds as $buildID => $build) - { - if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue; - $builds[$buildID] = $build->name; - } + foreach($projectBuilds as $buildID => $build) $builds[$buildID] = $build->name; if(!$builds) return $sysBuilds; /* if the build has been released, replace build name with release name. */ @@ -114,33 +112,31 @@ class buildModel extends model if(strpos($params, 'noempty') === false) $sysBuilds = array('' => ''); if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => 'Trunk'); - $productBuilds = $this->dao->select('t1.id, t1.name, t1.project, t2.status as projectStatus, t3.status as releaseStatus')->from(TABLE_BUILD)->alias('t1') + $productBuilds = $this->dao->select('t1.id, t1.name, t1.project, t4.name as branchName')->from(TABLE_BUILD)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build') + ->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id') ->where('t1.product')->in($products) ->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi() + ->beginIF(strpos($params, 'nodone') !== false)->andWhere('t2.status')->ne('none')->fi() + ->beginIF(strpos($params, 'noterminate') !== false)->andWhere('t3.status')->ne('terminate')->fi() ->andWhere('t1.deleted')->eq(0) ->orderBy('t1.date desc, t1.id desc')->fetchAll('id'); /* Set builds and filter done projects and terminate releases. */ $builds = array(); - foreach($productBuilds as $key => $build) - { - if((strpos($params, 'nodone') !== false) and ($build->projectStatus === 'done')) continue; - if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue; - $builds[$key] = $build->name; - } + foreach($productBuilds as $key => $build) $builds[$key] = ((strpos($params, 'withbranch') !== false and $build->branchName) ? $build->branchName . '/' : '') . $build->name; if(!$builds) return $sysBuilds; /* if the build has been released and replace is true, replace build name with release name. */ - $releases = $this->dao->select('build, name')->from(TABLE_RELEASE) - ->where('build')->in(array_keys($builds)) - ->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi() - ->andWhere('deleted')->eq(0) - ->fetchPairs(''); if($replace) { - foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName; + $releases = $this->dao->select('build, name')->from(TABLE_RELEASE) + ->where('build')->in(array_keys($builds)) + ->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi() + ->andWhere('deleted')->eq(0) + ->fetchPairs(); + foreach($releases as $buildID => $releaseName) $builds[$buildID] = ((strpos($params, 'withbranch') !== false and $productBuilds[$buildID]->branchName) ? $productBuilds[$buildID]->branchName . '/' : '') . $releaseName; } return $sysBuilds + $builds; diff --git a/module/release/control.php b/module/release/control.php index ae74831ca6..7a8b96e6b2 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -64,7 +64,7 @@ class release extends control die(js::locate(inlink('view', "releaseID=$releaseID"), 'parent')); } - $builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch); + $builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch, 'notrunk|withbranch', false); $releaseBuilds = $this->release->getReleaseBuilds($productID, $branch); foreach($releaseBuilds as $build) unset($builds[$build]); unset($builds['trunk']); @@ -114,7 +114,7 @@ class release extends control $this->view->position[] = $this->lang->release->edit; $this->view->release = $release; $this->view->build = $build; - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk', false); + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk|withbranch', false); $this->display(); } diff --git a/module/release/model.php b/module/release/model.php index 7db0f3edf4..d02251e8ff 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -116,8 +116,11 @@ class releaseModel extends model $buildID = $this->dao->lastInsertID(); } + $branch = 0; + if($this->post->build) $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch'); $release = fixer::input('post') ->add('product', (int)$productID) + ->add('branch', (int)$branch) ->setDefault('stories', '') ->join('stories', ',') ->join('bugs', ',') @@ -149,7 +152,12 @@ class releaseModel extends model public function update($releaseID) { $oldRelease = $this->getByID($releaseID); + + $branch = $oldRelease->branch; + if($oldRelease->build != $this->post->build) $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch'); + $release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags) + ->add('branch', (int)$branch) ->remove('files,labels,allchecker') ->get(); $release = $this->loadModel('file')->processEditor($release, $this->config->release->editor->edit['id']); diff --git a/module/release/view/create.html.php b/module/release/view/create.html.php index 8dcd537bcf..c00c77ec29 100644 --- a/module/release/view/create.html.php +++ b/module/release/view/create.html.php @@ -26,12 +26,6 @@ js::set('page' , 'create');
- type != 'normal'):?> - - - - -
product->branch;?>
release->name;?> diff --git a/module/release/view/edit.html.php b/module/release/view/edit.html.php index 7fe4b08e15..e53286ca48 100644 --- a/module/release/view/edit.html.php +++ b/module/release/view/edit.html.php @@ -28,12 +28,6 @@ js::set('oldReleasedBuild' , $release->build); - type != 'normal'):?> - - - - -
product->branch;?>
release->name;?> name, "class='form-control'");?>