From 19e08aafdcffd3e9ae8b86dfbeea3caf20cf3f06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Mon, 29 Nov 2021 10:29:56 +0800 Subject: [PATCH 1/4] * Finish task #45161. --- module/upgrade/control.php | 35 +++++++++++++++++++++++ module/upgrade/lang/de.php | 3 ++ module/upgrade/lang/en.php | 2 +- module/upgrade/lang/fr.php | 3 ++ module/upgrade/lang/vi.php | 3 ++ module/upgrade/lang/zh-cn.php | 4 ++- module/upgrade/model.php | 29 ++++++++++++------- module/upgrade/view/checkunique.html.php | 9 ++++++ module/upgrade/view/renameobject.html.php | 35 +++++++++++++++++++++++ 9 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 module/upgrade/view/checkunique.html.php create mode 100644 module/upgrade/view/renameobject.html.php diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 8c5c7011cc..4b66d6b0e6 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -581,6 +581,41 @@ class upgrade extends control $this->display(); } + /** + * Rename object in upgrade. + * + * @param string $type project|product|execution + * @param string $duplicateList + * @access public + * @return void + */ + public function renameObject($type = 'project', $duplicateList = '') + { + $this->app->loadLang($type); + if($_POST) + { + foreach($this->post->project as $projectID => $projectName) + { + if(!$projectName) continue; + $this->dao->update(TABLE_PROJECT)->set('name')->eq($projectName)->where('id')->eq($projectID)->exec(); + } + + die(js::closeModal('parent.parent', '')); + } + + $objectGroup = array(); + if($type == 'project' or $type == 'execution') + { + $objectGroup = $this->dao->select('id,name')->from(TABLE_PROJECT) + ->where('id')->in($duplicateList) + ->fetchGroup('name'); + } + + $this->view->type = $type; + $this->view->objectGroup = $objectGroup; + $this->display(); + } + /** * Merge Repos. * diff --git a/module/upgrade/lang/de.php b/module/upgrade/lang/de.php index cb7936ef4f..b847ceaedf 100644 --- a/module/upgrade/lang/de.php +++ b/module/upgrade/lang/de.php @@ -136,4 +136,7 @@ $lang->upgrade->createExecutionTip = <<ZenTao will upgrade existing {$lang->projectCommon} as execution.

After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; + +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/en.php b/module/upgrade/lang/en.php index e8e8c8915d..98bdd3a7db 100644 --- a/module/upgrade/lang/en.php +++ b/module/upgrade/lang/en.php @@ -138,6 +138,6 @@ $lang->upgrade->createExecutionTip = <<After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; -$lang->upgrade->projectNameUnique = "『%s』has the same『%s』. Click {$lang->projectCommon} on the left and edit the name of {$lang->projectCommon}."; +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/fr.php b/module/upgrade/lang/fr.php index 55818fbe8d..ec6f299361 100644 --- a/module/upgrade/lang/fr.php +++ b/module/upgrade/lang/fr.php @@ -137,4 +137,7 @@ $lang->upgrade->createExecutionTip = <<ZenTao will upgrade existing {$lang->projectCommon} as execution.

After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; + +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/vi.php b/module/upgrade/lang/vi.php index 7b6674ce41..1c1e63666d 100644 --- a/module/upgrade/lang/vi.php +++ b/module/upgrade/lang/vi.php @@ -137,4 +137,7 @@ $lang->upgrade->createExecutionTip = <<ZenTao will upgrade existing {$lang->projectCommon} as execution.

After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; + +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/zh-cn.php b/module/upgrade/lang/zh-cn.php index 572af4ccc8..3cb36a1061 100644 --- a/module/upgrade/lang/zh-cn.php +++ b/module/upgrade/lang/zh-cn.php @@ -138,6 +138,8 @@ $lang->upgrade->createExecutionTip = <<升级后历史的{$lang->projectCommon}数据将对应新版本中项目下的执行。

EOT; -$lang->upgrade->projectNameUnique = "『%s』已经有『%s』这条记录了。请至左侧{$lang->projectCommon}处修改该{$lang->projectCommon}名称。"; +$lang->upgrade->duplicateProject = "同一个项目集内项目名称不能重复,请调整重名的项目名称"; + +$lang->upgrade->editedName = '调整后名称'; include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 0cfe7e9855..9772e0ff69 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -4418,18 +4418,27 @@ class upgradeModel extends model /* Use historical projects as project upgrades. */ $projects = $this->dao->select('id,name,begin,end,status,PM,acl')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchAll('id'); - $hasExistedProjects = $this->dao->select('name')->from(TABLE_PROJECT)->where('type')->eq('project')->fetchPairs('name'); + $projectPairs = $this->dao->select('name,id')->from(TABLE_PROJECT) + ->where('deleted')->eq('0') + ->andWhere('type')->eq('project') + ->andWhere('parent')->eq($programID) + ->fetchPairs(); - $this->lang->error->unique = $this->lang->upgrade->projectNameUnique; - - $nameList = array(); - foreach($projectIdList as $projectID) + $duplicateList = ''; + foreach($projects as $projectID => $project) { - $projectName = $projects[$projectID]->name; - if(isset($hasExistedProjects[$projectName]) or isset($nameList[$projectName])) dao::$errors['name'][] = 'project#' . $projectID . sprintf($this->lang->error->unique, $this->lang->project->name, $projectName); - $nameList[$projectName] = $projectName; + if(isset($projectPairs[$project->name])) + { + $duplicateList .= "$projectID,"; + $duplicateList .= "{$projectPairs[$project->name]},"; + } + } + + if($duplicateList) + { + echo ""; + die; } - if(dao::isError()) die(js::error(dao::getError())); foreach($projectIdList as $projectID) { @@ -4492,7 +4501,7 @@ class upgradeModel extends model $this->dao->insert(TABLE_PROJECT)->data($project) ->batchcheck('name', 'notempty') - ->check('name', 'unique', "type='project'") + ->check('name', 'unique', "type='project' AND deleted=0") ->exec(); if(dao::isError()) return false; diff --git a/module/upgrade/view/checkunique.html.php b/module/upgrade/view/checkunique.html.php new file mode 100644 index 0000000000..c076b4973c --- /dev/null +++ b/module/upgrade/view/checkunique.html.php @@ -0,0 +1,9 @@ + +
+
+
+

同一个项目集下不能有重名项目

+
+
+
+ diff --git a/module/upgrade/view/renameobject.html.php b/module/upgrade/view/renameobject.html.php new file mode 100644 index 0000000000..fbd96256c1 --- /dev/null +++ b/module/upgrade/view/renameobject.html.php @@ -0,0 +1,35 @@ + + +
+
+
+

+ upgrade->duplicateProject;?> +

+
+
+ + + + + + + $objectList):?> + $object):?> + id == end($objectList)->id) echo "class='group-end'";?>> + + + + + + + + + +
$type->id;?>$type->name;?>upgrade->editedName;?>
id;?>name;?>id]", '', "class='form-control'");?>
+
+
+
+ From eb6bd799632b9947612534b4a6e991def8f753a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Mon, 29 Nov 2021 13:09:43 +0800 Subject: [PATCH 2/4] * Remove unused file. --- module/upgrade/view/checkunique.html.php | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 module/upgrade/view/checkunique.html.php diff --git a/module/upgrade/view/checkunique.html.php b/module/upgrade/view/checkunique.html.php deleted file mode 100644 index c076b4973c..0000000000 --- a/module/upgrade/view/checkunique.html.php +++ /dev/null @@ -1,9 +0,0 @@ - -
-
-
-

同一个项目集下不能有重名项目

-
-
-
- From d58fb3c8e75a738bbcdcc627617cbf7111a66a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Tue, 30 Nov 2021 13:08:17 +0800 Subject: [PATCH 3/4] * Add lang and comment. --- module/upgrade/lang/de.php | 2 ++ module/upgrade/lang/en.php | 2 ++ module/upgrade/lang/fr.php | 2 ++ module/upgrade/lang/vi.php | 2 ++ module/upgrade/view/renameobject.html.php | 19 +++++++++++++------ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/module/upgrade/lang/de.php b/module/upgrade/lang/de.php index b847ceaedf..c13c67e85c 100644 --- a/module/upgrade/lang/de.php +++ b/module/upgrade/lang/de.php @@ -139,4 +139,6 @@ EOT; $lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; +$lang->upgrade->editedName = 'New Name'; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/en.php b/module/upgrade/lang/en.php index 98bdd3a7db..bdf4d5f3fa 100644 --- a/module/upgrade/lang/en.php +++ b/module/upgrade/lang/en.php @@ -140,4 +140,6 @@ EOT; $lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; +$lang->upgrade->editedName = 'New Name'; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/fr.php b/module/upgrade/lang/fr.php index ec6f299361..991999c8a9 100644 --- a/module/upgrade/lang/fr.php +++ b/module/upgrade/lang/fr.php @@ -140,4 +140,6 @@ EOT; $lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; +$lang->upgrade->editedName = 'New Name'; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/vi.php b/module/upgrade/lang/vi.php index 1c1e63666d..523c3ec030 100644 --- a/module/upgrade/lang/vi.php +++ b/module/upgrade/lang/vi.php @@ -140,4 +140,6 @@ EOT; $lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; +$lang->upgrade->editedName = 'New Name'; + include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/view/renameobject.html.php b/module/upgrade/view/renameobject.html.php index fbd96256c1..952f8d44bd 100644 --- a/module/upgrade/view/renameobject.html.php +++ b/module/upgrade/view/renameobject.html.php @@ -1,13 +1,20 @@ + + * @package upgrade + * @version $Id: renameobject.html.php 4129 2021-11-30 13:07:14Z sunguangming $ + */ +?> - +
-

- upgrade->duplicateProject;?> -

+

upgrade->duplicateProject;?>

From 9e9c02498218f41165f5766f60a333cfce71151a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Tue, 30 Nov 2021 13:10:51 +0800 Subject: [PATCH 4/4] * Adjust lang. --- module/upgrade/lang/de.php | 6 ++---- module/upgrade/lang/en.php | 6 ++---- module/upgrade/lang/fr.php | 6 ++---- module/upgrade/lang/vi.php | 6 ++---- module/upgrade/lang/zh-cn.php | 6 ++---- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/module/upgrade/lang/de.php b/module/upgrade/lang/de.php index c13c67e85c..628852ef83 100644 --- a/module/upgrade/lang/de.php +++ b/module/upgrade/lang/de.php @@ -113,6 +113,7 @@ $lang->upgrade->selectProject = 'The target project'; $lang->upgrade->projectName = 'Project Name'; $lang->upgrade->newProgram = 'Create'; +$lang->upgrade->editedName = 'New Name'; $lang->upgrade->projectEmpty = 'Project must be not empty.'; $lang->upgrade->mergeSummary = "Dear users, there are %s {$lang->productCommon} and %s {$lang->projectCommon} in your system waiting for Migration. By System Calculation, we recommend your migration plan as follows, you can also adjust according to your own situation:"; $lang->upgrade->mergeByProductLine = "PRODUCTLINE-BASED {$lang->projectCommon}: Consolidate the entire {$lang->productCommon} line and the {$lang->productCommon} and {$lang->projectCommon} below it into one large project."; @@ -123,6 +124,7 @@ $lang->upgrade->mergeRepoTips = "Merge the selected version library under t $lang->upgrade->needBuild4Add = 'Full text retrieval has been added in this upgrad. Please create an index.'; $lang->upgrade->errorEngineInnodb = 'Your MySQL version is too low to support InnoDB data table engine. Please modify it to MyISAM and try again.'; $lang->upgrade->errorEngineInnodb = 'Your MySQL does not support InnoDB data table engine. Please modify it to MyISAM and try again.'; +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; $lang->upgrade->projectType['project'] = "Upgrade the historical {$lang->projectCommon} as a project"; $lang->upgrade->projectType['execution'] = "Upgrade the historical {$lang->projectCommon} as an execution"; @@ -137,8 +139,4 @@ $lang->upgrade->createExecutionTip = <<After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; -$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; - -$lang->upgrade->editedName = 'New Name'; - include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/en.php b/module/upgrade/lang/en.php index bdf4d5f3fa..32130971f4 100644 --- a/module/upgrade/lang/en.php +++ b/module/upgrade/lang/en.php @@ -115,6 +115,7 @@ $lang->upgrade->programName = 'Program Name'; $lang->upgrade->projectName = 'Project Name'; $lang->upgrade->newProgram = 'Create'; +$lang->upgrade->editedName = 'New Name'; $lang->upgrade->projectEmpty = 'Project must be not empty.'; $lang->upgrade->mergeSummary = "Dear users, there are %s {$lang->productCommon} and %s {$lang->projectCommon} in your system waiting for Migration. By System Calculation, we recommend your migration plan as follows, you can also adjust according to your own situation:"; $lang->upgrade->mergeByProductLine = "PRODUCTLINE-BASED {$lang->projectCommon}: Consolidate the entire {$lang->productCommon} line and the {$lang->productCommon} and {$lang->projectCommon} below it into one large project."; @@ -124,6 +125,7 @@ $lang->upgrade->mergeByMoreLink = "{$lang->projectCommon} that relates multip $lang->upgrade->mergeRepoTips = "Merge the selected version library under the selected product."; $lang->upgrade->needBuild4Add = 'Full text retrieval has been added in this upgrade. Need create index. Please go [Admin->System->BuildIndex] page to build index.'; $lang->upgrade->errorEngineInnodb = 'Your MySQL does not support InnoDB data table engine. Please modify it to MyISAM and try again.'; +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; $lang->upgrade->projectType['project'] = "Upgrade the historical {$lang->projectCommon} as a project"; $lang->upgrade->projectType['execution'] = "Upgrade the historical {$lang->projectCommon} as an execution"; @@ -138,8 +140,4 @@ $lang->upgrade->createExecutionTip = <<After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; -$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; - -$lang->upgrade->editedName = 'New Name'; - include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/fr.php b/module/upgrade/lang/fr.php index 991999c8a9..24ef3c903c 100644 --- a/module/upgrade/lang/fr.php +++ b/module/upgrade/lang/fr.php @@ -115,6 +115,7 @@ $lang->upgrade->programName = 'Program Name'; $lang->upgrade->projectName = 'Project Name'; $lang->upgrade->newProgram = 'Create'; +$lang->upgrade->editedName = 'New Name'; $lang->upgrade->projectEmpty = 'Project must be not empty.'; $lang->upgrade->mergeSummary = "Dear users, there are %s {$lang->productCommon} and %s {$lang->projectCommon} in your system waiting for Migration. By System Calculation, we recommend your migration plan as follows, you can also adjust according to your own situation:"; $lang->upgrade->mergeByProductLine = "PRODUCTLINE-BASED {$lang->projectCommon}: Consolidate the entire {$lang->productCommon} line and the {$lang->productCommon} and {$lang->projectCommon} below it into one large project."; @@ -124,6 +125,7 @@ $lang->upgrade->mergeByMoreLink = "{$lang->projectCommon} that relates multip $lang->upgrade->mergeRepoTips = "Merge the selected version library under the selected product."; $lang->upgrade->needBuild4Add = 'Full text retrieval has been added in this upgrade. Need create index. Please go [Admin->System->BuildIndex] page to build index.'; $lang->upgrade->errorEngineInnodb = 'Your MySQL does not support InnoDB data table engine. Please modify it to MyISAM and try again.'; +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; $lang->upgrade->projectType['project'] = "Upgrade the historical {$lang->projectCommon} as a project"; $lang->upgrade->projectType['execution'] = "Upgrade the historical {$lang->projectCommon} as an execution"; @@ -138,8 +140,4 @@ $lang->upgrade->createExecutionTip = <<After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; -$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; - -$lang->upgrade->editedName = 'New Name'; - include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/vi.php b/module/upgrade/lang/vi.php index 523c3ec030..bcbaa09df8 100644 --- a/module/upgrade/lang/vi.php +++ b/module/upgrade/lang/vi.php @@ -115,6 +115,7 @@ $lang->upgrade->programName = 'Program Name'; $lang->upgrade->projectName = 'Project Name'; $lang->upgrade->newProgram = 'Create'; +$lang->upgrade->editedName = 'New Name'; $lang->upgrade->projectEmpty = 'Project must be not empty.'; $lang->upgrade->mergeSummary = "Dear users, there are %s {$lang->productCommon} and %s {$lang->projectCommon} in your system waiting for Migration. By System Calculation, we recommend your migration plan as follows, you can also adjust according to your own situation:"; $lang->upgrade->mergeByProductLine = "PRODUCTLINE-BASED {$lang->projectCommon}: Consolidate the entire {$lang->productCommon} line and the {$lang->productCommon} and {$lang->projectCommon} below it into one large project."; @@ -124,6 +125,7 @@ $lang->upgrade->mergeByMoreLink = "{$lang->projectCommon} that relates multip $lang->upgrade->mergeRepoTips = "Merge the selected version library under the selected product."; $lang->upgrade->needBuild4Add = 'Full text retrieval has been added in this upgrade. Need create index. Please go [Admin->System->BuildIndex] page to build index.'; $lang->upgrade->errorEngineInnodb = 'Your MySQL version is too low to support InnoDB data table engine. Please modify it to MyISAM and try again.'; +$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; $lang->upgrade->projectType['project'] = "Upgrade the historical {$lang->projectCommon} as a project"; $lang->upgrade->projectType['execution'] = "Upgrade the historical {$lang->projectCommon} as an execution"; @@ -138,8 +140,4 @@ $lang->upgrade->createExecutionTip = <<After the upgrade, the data of existing {$lang->projectCommon} will be in a Project - Execute of the new version .

EOT; -$lang->upgrade->duplicateProject = "Project name in the same program cannot be duplicate. Please adjust the duplicate names."; - -$lang->upgrade->editedName = 'New Name'; - include dirname(__FILE__) . '/version.php'; diff --git a/module/upgrade/lang/zh-cn.php b/module/upgrade/lang/zh-cn.php index 3cb36a1061..c27c9d38e4 100644 --- a/module/upgrade/lang/zh-cn.php +++ b/module/upgrade/lang/zh-cn.php @@ -115,6 +115,7 @@ $lang->upgrade->programName = '项目集名称'; $lang->upgrade->projectName = '项目名称'; $lang->upgrade->newProgram = '新建'; +$lang->upgrade->editedName = '调整后名称'; $lang->upgrade->projectEmpty = '所属项目不能为空!'; $lang->upgrade->mergeSummary = "尊敬的用户,您的系统中共有%s个{$lang->productCommon},%s个{$lang->projectCommon}等待迁移。"; $lang->upgrade->mergeByProductLine = "以{$lang->productCommon}线组织的{$lang->productCommon}和{$lang->projectCommon}:将整个{$lang->productCommon}线及其下面的{$lang->productCommon}和{$lang->projectCommon}归并到一个项目集和项目中,也可以分开归并。"; @@ -124,6 +125,7 @@ $lang->upgrade->mergeByMoreLink = "关联多个{$lang->productCommon}的{$lan $lang->upgrade->mergeRepoTips = "将选中的版本库归并到所选产品下。"; $lang->upgrade->needBuild4Add = '本次升级需要创建索引。请到 [后台->系统->重建索引] 页面,重新创建索引。'; $lang->upgrade->errorEngineInnodb = '您当前的数据库不支持使用InnoDB数据表引擎,请修改为MyISAM后重试。'; +$lang->upgrade->duplicateProject = "同一个项目集内项目名称不能重复,请调整重名的项目名称"; $lang->upgrade->projectType['project'] = "把历史的{$lang->projectCommon}作为项目升级"; $lang->upgrade->projectType['execution'] = "把历史的{$lang->projectCommon}作为执行升级"; @@ -138,8 +140,4 @@ $lang->upgrade->createExecutionTip = <<升级后历史的{$lang->projectCommon}数据将对应新版本中项目下的执行。

EOT; -$lang->upgrade->duplicateProject = "同一个项目集内项目名称不能重复,请调整重名的项目名称"; - -$lang->upgrade->editedName = '调整后名称'; - include dirname(__FILE__) . '/version.php';