[xoops-cvslog 1462] CVS update: xoops2jp/html/modules/base/admin/class

アーカイブの一覧に戻る

Minahito minah****@users*****
2005年 12月 28日 (水) 22:54:30 JST


Index: xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php
diff -u xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.2 xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.3
--- xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.2	Mon Dec 19 22:59:42 2005
+++ xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php	Wed Dec 28 22:54:29 2005
@@ -26,6 +26,7 @@
 			return $ret;
 
 		$module =& $moduleHandler->create();
+		$module->setVar('weight', 1);
 		$module->loadInfoAsVar($this->mDirname);
 		
 		return $module;
@@ -108,6 +109,72 @@
 			Legacy_ModuleUtils::installBlock($this->mModule, $newBlock, $this->mLog);
 		}
 	}
+
+	function _installPreference()
+	{
+		$configInfos = $this->mModule->getInfo('config');
+
+		//
+		// Insert comment config by old style.
+		//
+		if ($this->mModule->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', $this->mModule->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)) {
+				$this->mLog->addError("ERROR: Could not insert config " . $configInfo['name']);
+			}
+			
+			unset($config);
+		}
+	}
 }
 
 ?>
\ No newline at end of file
Index: xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php
diff -u xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.3 xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.4
--- xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php:1.1.2.3	Wed Dec 21 13:08:57 2005
+++ xoops2jp/html/modules/base/admin/class/ModuleUninstaller.class.php	Wed Dec 28 22:54:29 2005
@@ -13,18 +13,19 @@
 	 */
 	function &loadModuleObject($dirname)
 	{
-		$ret = null;
+		$error = null;
 
 		$moduleHandler =& xoops_gethandler('module');
 		$module =& $moduleHandler->getByDirname($dirname);
 
 		if (!is_object($module)) {
 			$this->mLog->addError("*Module not found*");
-			return $ret;
+			return $error;
 		}
 		
-		if ($module->getVar('isactive') == 0) {
+		if ($module->getVar('isactive') != 0) {
 			$this->mLog->addError("*For uninstall, turn off the active-status of the module.*");
+			return $error;
 		}
 
 		return $module;
@@ -114,6 +115,24 @@
 			$this->mLog->addError("Could not delete block templates : " . $tplHandler->db->error());
 		}
 	}
+
+	function _installPreference()
+	{
+		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


xoops-cvslog メーリングリストの案内
アーカイブの一覧に戻る