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'");?>
+
+
+
+