diff --git a/config/zentaopms.php b/config/zentaopms.php index 8933ef5f0f..7468f54b80 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -127,3 +127,5 @@ $config->objectTables['custom'] = TABLE_LANG; $config->objectTables['branch'] = TABLE_BRANCH; $config->objectTables['module'] = TABLE_MODULE; $config->objectTables['caselib'] = TABLE_TESTSUITE; +$config->objectTables['entry'] = TABLE_ENTRY; +$config->objectTables['webhook'] = TABLE_WEBHOOK; diff --git a/module/custom/config.php b/module/custom/config.php index 68704b8316..ac2db60060 100644 --- a/module/custom/config.php +++ b/module/custom/config.php @@ -8,3 +8,40 @@ $config->custom->canAdd['testtask'] = 'priList'; $config->custom->canAdd['todo'] = 'priList,typeList'; $config->custom->canAdd['user'] = 'roleList'; $config->custom->canAdd['block'] = ''; + +$config->custom->requiredModules[10] = 'todo'; + +$config->custom->requiredModules[15] = 'product'; +$config->custom->requiredModules[20] = 'story'; +$config->custom->requiredModules[25] = 'productplan'; +$config->custom->requiredModules[30] = 'release'; + +$config->custom->requiredModules[35] = 'project'; +$config->custom->requiredModules[40] = 'task'; +$config->custom->requiredModules[45] = 'build'; + +$config->custom->requiredModules[50] = 'bug'; +$config->custom->requiredModules[55] = 'testcase'; +$config->custom->requiredModules[60] = 'testsuite'; +$config->custom->requiredModules[65] = 'testreport'; +$config->custom->requiredModules[70] = 'testtask'; + +$config->custom->requiredModules[75] = 'doc'; + +$config->custom->requiredModules[80] = 'group'; +$config->custom->requiredModules[85] = 'user'; + +$config->custom->requiredModules[95] = 'entry'; +$config->custom->requiredModules[100] = 'webhook'; + +$config->custom->fieldList['group'] = 'name,desc'; + +$config->custom->excludeFieldList['product'] = 'order'; +$config->custom->excludeFieldList['story'] = 'version,duplicateStory,linkStories,childStories,toBug,fromBug'; +$config->custom->excludeFieldList['project'] = 'order'; +$config->custom->excludeFieldList['task'] = 'fromBug'; +$config->custom->excludeFieldList['bug'] = 'storyVersion,toTask,toStory,hardware,found,confirmed,activatedCount,activatedDate,linkBug,case,caseVersion,result,testtask,repo'; +$config->custom->excludeFieldList['testcase'] = 'version,lastRunResult,lastRunDate,lastRunner,linkCase,fromBug'; +$config->custom->excludeFieldList['testreport'] = 'objectType'; +$config->custom->excludeFieldList['doc'] = 'version'; +$config->custom->excludeFieldList['user'] = 'ranzhi,visits,ip,last'; diff --git a/module/custom/control.php b/module/custom/control.php index c57bd58301..f6d9afdd76 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -230,6 +230,51 @@ class custom extends control $this->display(); } + /** + * Set Required. + * + * @param string $moduleName + * @access public + * @return void + */ + public function required($moduleName = '') + { + if($_POST) + { + $this->custom->saveRequiredFields($moduleName); + die(js::reload('parent.parent')); + } + + if(empty($moduleName)) $moduleName = current($this->config->custom->requiredModules); + + foreach($this->config->custom->requiredModules as $requiredModule) $this->app->loadLang($requiredModule); + + /* Get this module requiredFields. */ + $this->loadModel($moduleName); + $requiredFields = $this->custom->getRequiredFields($this->config->$moduleName); + + if($moduleName == 'doc') + { + unset($requiredFields['createLib']); + unset($requiredFields['editLib']); + } + + $fields = $this->custom->getDBFields($moduleName); + if($moduleName == 'testsuite') + { + $this->app->loadLang('testcase'); + $this->view->caseFields = $this->custom->getDBFields('testcase'); + } + + $this->view->title = $this->lang->custom->required; + $this->view->position[] = $this->lang->custom->required; + + $this->view->requiredFields = $requiredFields; + $this->view->moduleName = $moduleName; + $this->view->fields = $fields; + $this->display(); + } + /** * Ajax save custom fields. * @@ -383,4 +428,20 @@ class custom extends control $this->loadModel('setting')->deleteItems("owner={$account}&module=common§ion=customMenu"); die(js::reload('parent.parent')); } + + /** + * Reset required. + * + * @param srting $module + * @param string $confirm + * @access public + * @return void + */ + public function resetRequired($module, $confirm = 'no') + { + if($confirm == 'no') die(js::confirm($this->lang->custom->confirmRestore, inlink('resetRequired', "module=$module&confirm=yes"))); + + $this->loadModel('setting')->deleteItems("owner=system&module={$module}&key=requiredFields"); + die(js::reload('parent.parent')); + } } diff --git a/module/custom/lang/en.php b/module/custom/lang/en.php index 5fe8a27fe1..e8e23962d1 100644 --- a/module/custom/lang/en.php +++ b/module/custom/lang/en.php @@ -14,6 +14,7 @@ $lang->custom->module = 'Module'; $lang->custom->section = 'Section'; $lang->custom->lang = 'Language'; $lang->custom->setPublic = 'Set Public'; +$lang->custom->required = 'Required'; $lang->custom->object['story'] = 'Story'; $lang->custom->object['task'] = 'Task'; diff --git a/module/custom/lang/zh-cn.php b/module/custom/lang/zh-cn.php index b443b578a0..fad9789299 100644 --- a/module/custom/lang/zh-cn.php +++ b/module/custom/lang/zh-cn.php @@ -14,6 +14,7 @@ $lang->custom->module = '模块'; $lang->custom->section = '附加部分'; $lang->custom->lang = '所属语言'; $lang->custom->setPublic = '设为公共'; +$lang->custom->required = '必填项'; $lang->custom->object['story'] = '需求'; $lang->custom->object['task'] = '任务'; diff --git a/module/custom/model.php b/module/custom/model.php index 1d10e5b9f8..56357abac1 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -375,4 +375,100 @@ class customModel extends model $this->loadModel('setting')->setItem($settingKey, $menu); } + + /** + * Get required fields by config. + * + * @param object $moduleConfig + * @access public + * @return array + */ + public function getRequiredFields($moduleConfig) + { + $requiredFields = array(); + foreach($moduleConfig as $method => $subConfig) + { + if(is_object($subConfig) and isset($subConfig->requiredFields)) $requiredFields[$method] = trim(str_replace(' ', '', $subConfig->requiredFields)); + } + + return $requiredFields; + } + + /** + * Get module fields. + * + * @param string $moduleName + * @param string $method + * @access public + * @return array + */ + public function getDBFields($moduleName, $method = '') + { + $fields = array(); + $moduleLang = $this->lang->$moduleName; + $customFields = $this->config->custom->fieldList; + if(isset($customFields[$moduleName])) + { + $fieldList = isset($customFields[$moduleName][$method]) ? $customFields[$moduleName][$method] : $customFields[$moduleName]; + foreach(explode(',', $fieldList) as $fieldName) + { + if(isset($moduleLang->$fieldName) and is_string($moduleLang->$fieldName)) $fields[$fieldName] = $moduleLang->$fieldName; + } + } + else + { + $table = zget($this->config->objectTables, $moduleName, ''); + if($table) + { + $excludeFieldList = zget($this->config->custom->excludeFieldList, $moduleName, ''); + foreach($this->dao->query("DESC $table")->fetchAll() as $field) + { + $fieldName = $field->Field; + if($fieldName == 'id' or $fieldName == 'deleted') continue; + if($fieldName == 'openedBy' or $fieldName == 'createdBy' or $fieldName == 'addedBy') continue; + if($fieldName == 'openedDate' or $fieldName == 'createdDate' or $fieldName == 'addedDate') continue; + if($fieldName == 'lastEditedBy' or $fieldName == 'editedBy') continue; + if($fieldName == 'lastEditedDate' or $fieldName == 'editedDate') continue; + if(isset($excludeFieldList) and strpos(",{$excludeFieldList},", ",$fieldName,") !== false) continue; + if(isset($moduleLang->$fieldName) and is_string($moduleLang->$fieldName)) $fields[$fieldName] = $moduleLang->$fieldName; + } + } + } + return $fields; + } + + /** + * Save required fields. + * + * @param int $moduleName + * @access public + * @return void + */ + public function saveRequiredFields($moduleName) + { + if(isset($this->config->system->$moduleName)) unset($this->config->system->$moduleName); + if(isset($this->config->personal->$moduleName)) unset($this->config->personal->$moduleName); + + $this->loadModel($moduleName); + $systemFields = $this->getRequiredFields($this->config->$moduleName); + + $data = fixer::input('post')->get(); + $requiredFields = array(); + foreach($data->requiredFields as $method => $fields) + { + $method = strtolower($method); + $systemField = $this->config->$moduleName->$method->requiredFields; + + $fields = join(',', $fields); + foreach(explode(',', $systemField) as $field) + { + $field = trim($field); + if(strpos(",$fields,", ",$field,") === false) $fields .= ",$field"; + } + + $requiredFields[$method]['requiredFields'] = $fields; + } + + $this->loadModel('setting')->setItems("system.{$moduleName}", $requiredFields); + } } diff --git a/module/custom/view/flow.html.php b/module/custom/view/flow.html.php index 136f901914..b906fd201d 100644 --- a/module/custom/view/flow.html.php +++ b/module/custom/view/flow.html.php @@ -10,24 +10,7 @@ * @link http://www.zentao.net */ ?> - -
- -
+
@@ -49,4 +32,10 @@
+ diff --git a/module/custom/view/header.html.php b/module/custom/view/header.html.php new file mode 100644 index 0000000000..53e96d64b7 --- /dev/null +++ b/module/custom/view/header.html.php @@ -0,0 +1,20 @@ + +
+ +
diff --git a/module/custom/view/required.html.php b/module/custom/view/required.html.php new file mode 100644 index 0000000000..71161126a7 --- /dev/null +++ b/module/custom/view/required.html.php @@ -0,0 +1,69 @@ + + * @package custom + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+ custom->requiredModules as $requiredModule) + { + echo "
  • " . html::a(inlink('required', "module=$requiredModule"), $lang->$requiredModule->common) . "
  • "; + } + ?> +
    +
    +
    +
    +
    +
    + $moduleName->common?> +
    + + $requiredField):?> + + + + + + + + + + +
    + $moduleName->$method; + ?> +
    + custom->restore, 'hiddenwin', "class='btn'"); + ?> +
    +
    +
    +
    + + diff --git a/module/custom/view/set.html.php b/module/custom/view/set.html.php index baafa0006d..726474c997 100644 --- a/module/custom/view/set.html.php +++ b/module/custom/view/set.html.php @@ -10,7 +10,7 @@ * @link http://www.zentao.net */ ?> - + @@ -31,23 +31,6 @@ EOT; -
    - -
    - -
    - -
    +
    @@ -39,4 +22,10 @@
    +