Minahito
minah****@users*****
2005年 12月 28日 (水) 23:16:03 JST
Index: xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.4 xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.5 --- xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.4 Tue Dec 27 14:31:15 2005 +++ xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php Wed Dec 28 23:16:03 2005 @@ -278,6 +278,95 @@ return $tplHandler->insert($tplfile); } + + function insertAllConfig(&$module, &$log) + { + $configInfos = $module->getInfo('config'); + + // + // Insert comment config by old style. + // + if ($module->getVar('hascomments') !=0 ) { + require_once XOOPS_ROOT_PATH . "/include/comment_constants.php"; + + $configInfos[] = array('name' => 'com_rule', + 'title' => '_CM_COMRULES', + 'description' => '', + 'formtype' => 'select', + 'valuetype' => 'int', + 'default' => 1, + 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN) + ); + + $configInfos[] = array('name' => 'com_anonpost', + 'title' => '_CM_COMANONPOST', + 'description' => '', + 'formtype' => 'yesno', + 'valuetype' => 'int', + 'default' => 0 + ); + } + + // TODO comment + + // TODO notification + + $configHandler =& xoops_gethandler('config'); + + $count = 0; + foreach ($configInfos as $configInfo) { + $config =& $configHandler->createConfig(); + + $config->setVar('conf_modid', $module->getVar('mid')); + $config->setVar('conf_catid', 0); + $config->setVar('conf_name', $configInfo['name']); + $config->setVar('conf_title', $configInfo['title'], true); + $config->setVar('conf_desc', $configInfo['description'], true); + $config->setVar('conf_formtype', $configInfo['formtype'], true); + $config->setVar('conf_valuetype', $configInfo['valuetype'], true); + $config->setConfValueForInput($configInfo['default'], true); + $config->setVar('conf_order', $count++); + + if (isset($configInfo['options']) && is_array($configInfo['options'])) { + foreach ($configInfo['options'] as $key => $value) { + $configOption =& $configHandler->createConfigOption(); + $configOption->setVar('confop_name', $key, true); + $configOption->setVar('confop_value', $value, true); + $config->setConfOptions($configOption); + unset($configOption); + } + } + + if (!$configHandler->insertConfig($config)) { + $log->addError("ERROR: Could not insert config " . $configInfo['name']); + } + + unset($config); + } + } + + /** + * Delete all configs of $module. + * + * @param $module XoopsModule + */ + function deleteAllConfig(&$module, &$log) + { + if ($this->mModule->getVar('hasconfig') == 0) { + return; + } + + $configHandler =& xoops_gethandler('config'); + $configs =& $configHandler->getConfigs(new Criteria('conf_modid', $this->mModule->getVar('mid'))); + + if (count($configs) == 0) { + return; + } + + foreach ($configs as $config) { + $configHandler->deleteConfig($config); + } + } } ?> \ No newline at end of file