From 9f05692086f6636f4db4d467e602de00fbdc912e Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 20 Jun 2025 07:40:23 +0000 Subject: [PATCH] * [bug#63456] Add built-in doc template type when install. --- module/doc/model.php | 38 ++++++++++++++++++++++++++++++++++++++ module/install/control.php | 10 ++++++++++ 2 files changed, 48 insertions(+) diff --git a/module/doc/model.php b/module/doc/model.php index 54dc3f50bd..b4774e0e03 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -4088,6 +4088,44 @@ class docModel extends model } } + /** + * 添加内置的模板分类。 + * Add built in template type. + * + * @access public + * @return void + */ + public function addBuiltInDocTemplateType() + { + $rndScopeMaps = $this->loadModel('setting')->getItem('vision=rnd&owner=system&module=doc&key=builtInScopeMaps'); + $rndScopeMaps = json_decode($rndScopeMaps, true); + $projectScopeID = zget($rndScopeMaps, 'project', 0); + $builtInTemplateTypes = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('docTemplate')->andWhere('root')->eq($projectScopeID)->fetchPairs(); + if(empty($builtInTemplateTypes)) return; + + $this->app->loadLang('baseline'); + $parentTemplateTypes = array_filter($this->lang->docTemplate->types, function($key){return in_array($key, array('plan', 'story', 'design', 'test'));}, ARRAY_FILTER_USE_KEY); + foreach($parentTemplateTypes as $parentKey => $parentValue) + { + /* 创建文档模板一级分类。*/ + /* Add the parent type of doc template. */ + $parentType = $this->buildTemplateModule($projectScopeID, 0, $parentValue, $parentKey, 1); + $this->dao->insert(TABLE_MODULE)->data($parentType)->exec(); + $parentTypeID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_MODULE)->set('path')->eq(",{$parentTypeID},")->where('id')->eq($parentTypeID)->exec(); + + /* 创建文档模板二级分类。*/ + /* Add the child type of doc template. */ + foreach($this->config->docTemplate->builtInTypes[$parentKey] as $childKey) + { + $childType = $this->buildTemplateModule($projectScopeID, $parentTypeID, $this->lang->baseline->objectList[$childKey], $childKey, 2); + $this->dao->insert(TABLE_MODULE)->data($childType)->exec(); + $childTypeID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_MODULE)->set('path')->eq(",{$parentTypeID},{$childTypeID},")->where('id')->eq($childTypeID)->exec(); + } + } + } + /** * 升级文档模板的范围和类型。 * Upgrade lib and module of template. diff --git a/module/install/control.php b/module/install/control.php index 71fabf15bc..e13e418424 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -386,6 +386,16 @@ class install extends control $this->install->enableCache(); + /* 添加内置的范围、分类、文档模板。*/ + /* Add the built-in scopes and type and doc template. */ + if($this->config->edition == 'max' || $this->config->edition == 'ipd') + { + $this->loadModel('doc'); + $this->doc->addBuiltInScopes(); + $this->doc->addBuiltInDocTemplateType(); + $this->doc->addBuiltInDocTemplateByType(); + } + return $this->send(array('result' => 'success', 'load' => inlink('step6'))); }