From b4ea03a2fde58be1831b4f9b3079eb62d34b4da9 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Thu, 29 Oct 2020 14:04:27 +0800 Subject: [PATCH] * Fix details. --- VERSION | 2 +- config/config.php | 2 +- module/doc/model.php | 2 +- module/upgrade/control.php | 46 ++++++++++++++-------- module/upgrade/lang/zh-cn.php | 4 +- module/upgrade/model.php | 13 +----- module/upgrade/view/createprogram.html.php | 1 + module/upgrade/view/mergeprogram.html.php | 6 ++- module/upgrade/view/to20.html.php | 5 ++- 9 files changed, 46 insertions(+), 35 deletions(-) diff --git a/VERSION b/VERSION index 9a7c1e503f..24f50a8fd6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -20.0 +20.0.alpha1 diff --git a/config/config.php b/config/config.php index d444ee0599..3be2f95394 100644 --- a/config/config.php +++ b/config/config.php @@ -16,7 +16,7 @@ if(!class_exists('config')){class config{}} if(!function_exists('getWebRoot')){function getWebRoot(){}} /* 基本设置。Basic settings. */ -$config->version = '20.0'; // ZenTaoPHP的版本。 The version of ZenTaoPHP. Don't change it. +$config->version = '20.0.alpha1'; // ZenTaoPHP的版本。 The version of ZenTaoPHP. Don't change it. $config->charset = 'UTF-8'; // ZenTaoPHP的编码。 The encoding of ZenTaoPHP. $config->cookieLife = time() + 2592000; // Cookie的生存时间。The cookie life time. $config->timezone = 'Asia/Shanghai'; // 时区设置。 The time zone setting, for more see http://www.php.net/manual/en/timezones.php. diff --git a/module/doc/model.php b/module/doc/model.php index d7a966ab64..6c6882b1b6 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1180,7 +1180,7 @@ class docModel extends model $objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->eq($objectID)->orderBy('`order`, id')->fetchAll('id'); if($type == 'product') { - $hasProject = $this->dao->select('DISTINCT t1.product, count(project) as projectCount')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $hasProject = $this->dao->select('DISTINCT t1.product, count(t1.project) as projectCount')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') ->where('t1.product')->eq($objectID) ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi() diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 37956f91dc..804d070940 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -23,6 +23,10 @@ class upgrade extends control $upgradeFile = $this->app->wwwRoot . 'upgrade.php'; if(!file_exists($upgradeFile)) $this->locate($this->createLink('my', 'index')); + /* Judge upgrade step. */ + $upgradeStep = $this->loadModel('setting')->getItem('owner=system&module=common§ion=global&key=upgradeStep'); + if($upgradeStep == 'mergeProgram') $this->locate(inlink('mergeProgram')); + if(version_compare($this->config->installedVersion, '20', '<')) $this->locate(inlink('to20')); if(version_compare($this->config->installedVersion, '6.4', '<=')) $this->locate(inlink('license')); $this->locate(inlink('backup')); @@ -141,7 +145,11 @@ class upgrade extends control if(!$this->upgrade->isError()) { - if(version_compare(str_replace('_', '.', $fromVersion), '20', '<') && !isset($this->config->qcVersion)) $this->locate(inlink('mergeProgram')); + if(version_compare(str_replace('_', '.', $fromVersion), '20', '<') && !isset($this->config->qcVersion)) + { + $this->loadModel('setting')->setItem('system.common.global.upgradeStep', 'mergeProgram'); + $this->locate(inlink('mergeProgram')); + } $this->locate(inlink('afterExec', "fromVersion=$fromVersion")); } @@ -159,6 +167,7 @@ class upgrade extends control */ public function mergeProgram($type = 'productline') { + $this->session->set('upgrading', true); $this->app->loadLang('program'); if($_POST) @@ -167,7 +176,6 @@ class upgrade extends control { $linkedProducts = array(); $linkedSprints = array(); - $unlinkProducts = array(); $unlinkSprints = array(); /* Compute checked products and sprints, unchecked products and sprints. */ @@ -176,7 +184,6 @@ class upgrade extends control foreach($products as $productID) { $linkedProducts[$productID] = $productID; - unset($_POST['productIdList'][$lineID][$productID]); if(isset($_POST['sprints'][$lineID][$productID])) { @@ -185,11 +192,9 @@ class upgrade extends control $linkedSprints[$sprintID] = $sprintID; unset($_POST['sprintIdList'][$lineID][$productID][$sprintID]); } - $unlinkSprints += $this->post->sprintIdList[$lineID][$productID]; + $unlinkSprints[$productID] = $this->post->sprintIdList[$lineID][$productID]; } } - - $unlinkProducts += $this->post->productIdList[$lineID]; } /* Create Program. */ @@ -199,9 +204,11 @@ class upgrade extends control /* Process merged products and projects. */ $this->upgrade->processMergedData($programID, $projectID, $linkedProducts, $linkedSprints); - /* Process unlinked product. */ - if($unlinkProducts) $this->dao->update(TABLE_PRODUCT)->set('line')->eq(0)->where('id')->in($unlinkProducts)->exec(); - if($unlinkSprints) $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($unlinkSprints)->exec(); + /* Process unlinked sprint and product. */ + foreach($linkedProducts as $productID => $product) + { + if((isset($unlinkSprints[$productID]) and empty($unlinkSprints[$productID])) || !isset($unlinkSprints[$productID])) $this->dao->update(TABLE_PRODUCT)->set('line')->eq(0)->where('id')->eq($productID)->exec(); + } } elseif($type == 'product') { @@ -262,7 +269,7 @@ class upgrade extends control } /* Get no merged product and project count. */ - $noMergedProductCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('deleted')->eq(0)->fetch('count'); + $noMergedProductCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq(0)->fetch('count'); $noMergedSprintCount = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('grade')->eq(0)->andWhere('path')->eq('')->fetch('count'); /* When all products and projects merged then finish and locate afterExec page. */ @@ -270,6 +277,7 @@ class upgrade extends control { $this->upgrade->initUserView(); $this->upgrade->setDefaultPriv(); + $this->loadModel('setting')->deleteItems('owner=system&module=common§ion=global&key=upgradeStep'); die(js::locate($this->createLink('upgrade', 'afterExec', "fromVersion=&processed=yes"))); } @@ -282,16 +290,16 @@ class upgrade extends control /* Get products and projects group by product line. */ if($type == 'productline') { - $productlines = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('line')->fetchAll('id'); + $productlines = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('line')->orderBy('id_desc')->fetchAll('id'); - $noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('line')->in(array_keys($productlines))->andWhere('deleted')->eq(0)->fetchAll('id'); + $noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('line')->in(array_keys($productlines))->orderBy('id_desc')->fetchAll('id'); if(empty($noMergedProducts)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=product')); $noMergedSprints = $this->dao->select('t1.*')->from(TABLE_PROJECT)->alias('t1') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id=t2.project') - ->where('t1.model')->eq('') - ->andWhere('t1.deleted')->eq(0) + ->where('t1.project')->eq(0) ->andWhere('t2.product')->in(array_keys($noMergedProducts)) + ->orderBy('t1.id_desc') ->fetchAll('id'); /* Remove sprint than linked more than two products */ @@ -328,21 +336,25 @@ class upgrade extends control /* Get projects group by product. */ if($type == 'product') { - $noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('program')->eq(0)->andWhere('deleted')->eq(0)->fetchAll('id'); + $noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('program')->eq(0)->fetchAll('id'); if(empty($noMergedProducts)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=sprint')); $noMergedSprints = $this->dao->select('t1.*')->from(TABLE_PROJECT)->alias('t1') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id=t2.project') ->where('t1.model')->eq('') - ->andWhere('t1.deleted')->eq(0) ->andWhere('t2.product')->in(array_keys($noMergedProducts)) ->fetchAll('id'); /* Remove project than linked more than two products */ $sprintProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->in(array_keys($noMergedSprints))->fetchGroup('project', 'product'); + $productGroup = array(); foreach($sprintProducts as $sprintID => $products) { - if(count($products) > 1) unset($noMergedSprints[$sprintID]); + if(count($products) > 1) + { + unset($noMergedSprints[$sprintID]); + $productGroup[] = array_keys($products); + } } /* Group project by product. */ diff --git a/module/upgrade/lang/zh-cn.php b/module/upgrade/lang/zh-cn.php index d43bc05472..37abedce04 100644 --- a/module/upgrade/lang/zh-cn.php +++ b/module/upgrade/lang/zh-cn.php @@ -48,6 +48,7 @@ $lang->upgrade->updateFile = '需要更新附件信息。'; $lang->upgrade->noticeSQL = '检查到你的数据库跟标准不一致,尝试修复失败。请执行以下SQL语句,再刷新页面检查。'; $lang->upgrade->afterDeleted = '以上文件未能删除, 删除后刷新!'; $lang->upgrade->mergeProgram = '数据归并'; +$lang->upgrade->to20Demo = '查看20版本Demo'; $lang->upgrade->to20Tips = '禅道20版本升级提示'; $lang->upgrade->to20Button = '我已经做好备份,开始升级吧!'; $lang->upgrade->to20TipsHeader = "

尊敬的用户,感谢对禅道的支持。自20版本开始,禅道全面升级成为通用的项目管理平台。相关介绍请看如下视频:


"; @@ -58,7 +59,6 @@ $lang->upgrade->to20Desc = <<您可以先安装一个20版本的禅道,体验一下里边的概念和流程。
  • 20版本禅道改动比较大,升级之前请做好备份。
  • 请放心升级,即使第一次升级不到位,后续还可以再调整,不会影响系统数据。
  • -
  • 点击查看20.0版系统demo。
  • EOD; @@ -71,7 +71,7 @@ $lang->upgrade->product = $lang->productCommon; $lang->upgrade->project = '迭代'; $lang->upgrade->newProgram = '新建'; -$lang->upgrade->mergeSummary = "尊敬的用户,您的系统中共有%s个产品,%s个迭代等待迁移。经系统计算,我们推荐您的迁移方案如下,您也可以根据自己的情况进行调整:"; +$lang->upgrade->mergeSummary = "尊敬的用户,您的系统中共有%s个产品,%s个迭代等待迁移。"; $lang->upgrade->mergeByProductLine = "以产品线组织的产品和迭代:将整个产品线及其下面的产品和迭代归并到一个项目集和项目中,也可以分开归并。"; $lang->upgrade->mergeByProduct = "以产品组织的迭代:可以选择多个产品及其下面的迭代归并到一个项目集和项目中,也可以选择某一个产品将其下面所属的迭代归并到项目集和项目中。"; $lang->upgrade->mergeByProject = "独立的迭代:可以选择若干迭代归并到一个项目中,也可以独立归并。"; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index b7e075e7b7..779648976b 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -3945,17 +3945,6 @@ class upgradeModel extends model */ public function processMergedData($programID, $projectID, $productIdList = array(), $sprintIdList = array()) { - /* Product linked objects. */ - $this->dao->update(TABLE_PRODUCT)->set('program')->eq($programID)->where('id')->in($productIdList)->exec(); - $this->dao->update(TABLE_STORY)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_BUG)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_RELEASE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_CASE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_TESTREPORT)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_TESTSUITE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_BUILD)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_DOC)->set('PRJ')->eq($projectID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'product' and product " . helper::dbIN($productIdList) . ')')->exec(); - /* Project linked objects. */ $this->dao->update(TABLE_TASK)->set('PRJ')->eq($projectID)->where('project')->in($sprintIdList)->exec(); $this->dao->update(TABLE_DOC)->set('PRJ')->eq($projectID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'project' and project " . helper::dbIN($sprintIdList) . ')')->exec(); @@ -3964,6 +3953,8 @@ class upgradeModel extends model $products = $this->dao->select('id, acl')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll(); foreach($products as $product) { + if($product->program) continue; + $data = new stdclass(); $data->program = $programID; $data->acl = $product->acl == 'custom' ? 'private' : $product->acl; diff --git a/module/upgrade/view/createprogram.html.php b/module/upgrade/view/createprogram.html.php index 1b20ced680..9fe84c2195 100644 --- a/module/upgrade/view/createprogram.html.php +++ b/module/upgrade/view/createprogram.html.php @@ -69,3 +69,4 @@ program->PGMPRJAclList, 'open', "onclick='setWhite(this.value);'", 'block'));?> +
    diff --git a/module/upgrade/view/mergeprogram.html.php b/module/upgrade/view/mergeprogram.html.php index 29497eb0c1..0491a52d9e 100644 --- a/module/upgrade/view/mergeprogram.html.php +++ b/module/upgrade/view/mergeprogram.html.php @@ -49,10 +49,14 @@ + + + + + - diff --git a/module/upgrade/view/to20.html.php b/module/upgrade/view/to20.html.php index fc2a44c34d..32a12ee1bf 100644 --- a/module/upgrade/view/to20.html.php +++ b/module/upgrade/view/to20.html.php @@ -18,7 +18,10 @@ upgrade->to20TipsHeader;?> upgrade->to20Desc;?> - +