diff --git a/module/doc/model.php b/module/doc/model.php index 3a3e71a04c..dc1161421d 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -4119,6 +4119,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('id')->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/doc/test/lib/doc.unittest.class.php b/module/doc/test/lib/doc.unittest.class.php index f3e11c4a63..619355da36 100644 --- a/module/doc/test/lib/doc.unittest.class.php +++ b/module/doc/test/lib/doc.unittest.class.php @@ -1915,4 +1915,29 @@ class docTest { return $this->objectModel->getContent($docID, $version); } + + /** + * 添加内置的模板分类。 + * Add built in template type. + * + * @param int $moduleID + * @param array $checkFields + * @access public + * @return void + */ + public function addBuiltInDocTemplateTypeTest(int $moduleID, array $checkFields) + { + if($this->objectModel->config->edition != 'ipd') return true; + + $this->objectModel->addBuiltInScopes(); + $this->objectModel->addBuiltInDocTemplateType(); + + $checkResult = false; + $module = $this->objectModel->dao->select('*')->from(TABLE_MODULE)->where('id')->eq($moduleID)->fetch(); + foreach($checkFields as $key => $value) + { + if($module->$key == $value) $checkResult = true; + } + return $checkResult; + } } diff --git a/module/doc/test/model/addbuiltindoctemplatetype.php b/module/doc/test/model/addbuiltindoctemplatetype.php new file mode 100755 index 0000000000..ad9bb50ac8 --- /dev/null +++ b/module/doc/test/model/addbuiltindoctemplatetype.php @@ -0,0 +1,59 @@ +#!/usr/bin/env php +addBuiltInDocTemplateType(); +timeout=0 +cid=1 + +- 检查计划分类 @1 +- 检查项目计划分类 @1 +- 检查需求计划分类 @1 +- 检查软件需求规格说明书分类 @1 +- 检查设计分类 @1 +- 检查概要设计说明书分类 @1 +- 检查详细设计说明书分类 @1 +- 检查数据库设计文档分类 @1 +- 检查接口设计文档分类 @1 +- 检查测试分类 @1 +- 检查集成测试用例分类 @1 +- 检查系统测试用例分类 @1 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php'; + +zenData('user')->gen(5); +su('admin'); + +zenData('doclib')->gen(0); +zenData('module')->gen(0); +$docTester = new docTest(); + +$checkPlan = array('root' => 2, 'name' => '计划', 'short' => 'plan', 'path' => ',1,'); +$checkPP = array('root' => 2, 'name' => '项目计划', 'short' => 'PP', 'path' => ',1,2,'); +$checkStory = array('root' => 2, 'name' => '需求', 'short' => 'story', 'path' => ',3,'); +$checkSRS = array('root' => 2, 'name' => '软件需求规格说明书', 'short' => 'SRS', 'path' => ',3,4,'); +$checkDesign = array('root' => 2, 'name' => '设计', 'short' => 'design', 'path' => ',5,'); +$checkHLDS = array('root' => 2, 'name' => '概要设计说明书', 'short' => 'HLDS', 'path' => ',5,6,'); +$checkDDS = array('root' => 2, 'name' => '详细设计说明书', 'short' => 'DDS', 'path' => ',5,7,'); +$checkDBDS = array('root' => 2, 'name' => '数据库设计文档', 'short' => 'DBDS', 'path' => ',5,8,'); +$checkADS = array('root' => 2, 'name' => '接口设计文档', 'short' => 'ADS', 'path' => ',5,9,'); +$checkTest = array('root' => 2, 'name' => '测试', 'short' => 'test', 'path' => ',10,'); +$checkITTC = array('root' => 2, 'name' => '集成测试用例', 'short' => 'ITTC', 'path' => ',10,11,'); +$checkSTTC = array('root' => 2, 'name' => '系统测试用例', 'short' => 'STTC', 'path' => ',10,12,'); + +r($docTester->addBuiltInDocTemplateTypeTest(1, $checkPlan)) && p() && e('1'); // 检查计划分类 +r($docTester->addBuiltInDocTemplateTypeTest(2, $checkPP)) && p() && e('1'); // 检查项目计划分类 +r($docTester->addBuiltInDocTemplateTypeTest(3, $checkStory)) && p() && e('1'); // 检查需求计划分类 +r($docTester->addBuiltInDocTemplateTypeTest(4, $checkSRS)) && p() && e('1'); // 检查软件需求规格说明书分类 +r($docTester->addBuiltInDocTemplateTypeTest(5, $checkDesign)) && p() && e('1'); // 检查设计分类 +r($docTester->addBuiltInDocTemplateTypeTest(6, $checkHLDS)) && p() && e('1'); // 检查概要设计说明书分类 +r($docTester->addBuiltInDocTemplateTypeTest(7, $checkDDS)) && p() && e('1'); // 检查详细设计说明书分类 +r($docTester->addBuiltInDocTemplateTypeTest(8, $checkDBDS)) && p() && e('1'); // 检查数据库设计文档分类 +r($docTester->addBuiltInDocTemplateTypeTest(9, $checkADS)) && p() && e('1'); // 检查接口设计文档分类 +r($docTester->addBuiltInDocTemplateTypeTest(10, $checkTest)) && p() && e('1'); // 检查测试分类 +r($docTester->addBuiltInDocTemplateTypeTest(11, $checkITTC)) && p() && e('1'); // 检查集成测试用例分类 +r($docTester->addBuiltInDocTemplateTypeTest(12, $checkSTTC)) && p() && e('1'); // 检查系统测试用例分类 diff --git a/module/install/control.php b/module/install/control.php index bdf5d9f9e4..e74f547d14 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -387,6 +387,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'))); }