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版本开始,禅道全面升级成为通用的项目管理平台。相关介绍请看如下视频: