diff --git a/module/build/model.php b/module/build/model.php index f33a8bee4e..9d522b64d3 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -73,6 +73,56 @@ class buildModel extends model ->fetchAll('id'); } + /** + * Get builds of a project in pairs. + * + * @param int $projectID + * @param int $productID + * @param int $branch + * @param string $params noempty|notrunk, can be a set of them + * @param int $buildID + * @access public + * @return array + */ + public function getProjectBuildPairs($projectID, $productID, $branch = 0, $params = '', $buildID = 0) + { + $sysBuilds = array(); + $selectedBuilds = array(); + if(strpos($params, 'noempty') === false) $sysBuilds = array('' => ''); + if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => $this->lang->trunk); + if($buildID != 0) $selectedBuilds = $this->dao->select('id, name')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchPairs(); + + $projectBuilds = $this->dao->select('t1.id, t1.name, t1.project, t2.status as projectStatus, t3.id as releaseID, t3.status as releaseStatus, 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.PRJ')->eq((int)$projectID) + ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi() + ->beginIF($branch)->andWhere('t1.branch')->in("0,$branch")->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(empty($build->releaseID) and (strpos($params, 'nodone') !== false) and ($build->projectStatus === 'done')) continue; + if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue; + $builds[$buildID] = $build->name; + } + if(!$builds) return $sysBuilds + $selectedBuilds; + + /* if the build has been released, 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(); + foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName; + + return $sysBuilds + $builds + $selectedBuilds; + } + /** * Get builds of a project by search. * @@ -169,56 +219,6 @@ class buildModel extends model return $this->getExecutionBuilds($executionID, 'bysearch', $buildQuery); } - /** - * Get builds of a project in pairs. - * - * @param int $projectID - * @param int $productID - * @param int $branch - * @param string $params noempty|notrunk, can be a set of them - * @param int $buildID - * @access public - * @return array - */ - public function getProjectBuildPairs($projectID, $productID, $branch = 0, $params = '', $buildID = 0) - { - $sysBuilds = array(); - $selectedBuilds = array(); - if(strpos($params, 'noempty') === false) $sysBuilds = array('' => ''); - if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => $this->lang->trunk); - if($buildID != 0) $selectedBuilds = $this->dao->select('id, name')->from(TABLE_BUILD)->where('id')->in($buildID)->fetchPairs(); - - $projectBuilds = $this->dao->select('t1.id, t1.name, t1.project, t2.status as projectStatus, t3.id as releaseID, t3.status as releaseStatus, 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.PRJ')->eq((int)$projectID) - ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi() - ->beginIF($branch)->andWhere('t1.branch')->in("0,$branch")->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(empty($build->releaseID) and (strpos($params, 'nodone') !== false) and ($build->projectStatus === 'done')) continue; - if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue; - $builds[$buildID] = $build->name; - } - if(!$builds) return $sysBuilds + $selectedBuilds; - - /* if the build has been released, 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(); - foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName; - - return $sysBuilds + $builds + $selectedBuilds; - } - /** * Get builds of a execution in pairs. * diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index d4da9534ed..ba552dc07f 100755 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -880,7 +880,7 @@ $lang->scrum->subMenu->morelink->program = '项目|program|edit|'; $lang->menu->waterfall = new stdclass(); $lang->menu->waterfall->programindex = array('link' => '仪表盘|program|index|project={PROJECT}'); $lang->menu->waterfall->programplan = array('link' => '计划|programplan|browse|project={PROJECT}', 'subModule' => 'programplan'); -$lang->menu->waterfall->project = array('link' => $lang->projectCommon . '|project|task|projectID={PROJECT}', 'subModule' => ',project,task,'); +$lang->menu->waterfall->project = array('link' => $lang->projectCommon . '|project|task|executionID={EXECUTION}', 'subModule' => ',project,task,'); $lang->menu->waterfall->weekly = array('link' => '报告|weekly|index|project={PROJECT}', 'subModule' => ',milestone,'); $lang->menu->waterfall->doc = array('link' => '文档|doc|index|project={PROJECT}'); $lang->menu->waterfall->projectstory = array('link' => '需求|projectstory|requirement', 'subModule' => 'requirement,story,track');