[xoops-cvslog 5099] CVS update: xoops2jp/html/modules/legacy/admin/class

Zurück zum Archiv-Index

Minahito minah****@users*****
2006年 10月 14日 (土) 23:55:23 JST


Index: xoops2jp/html/modules/legacy/admin/class/ModuleInstaller.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/ModuleInstaller.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleInstaller.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,239 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_BASE_PATH."/admin/class/AbstractModuleInstaller.class.php";
+
+/**
+ * This class extends a base class for the process of install module. This is added
+ * some private functions.
+ */
+class Legacy_ModuleInstaller extends Legacy_AbstractModuleInstaller
+{
+    var $mAgree = false;
+	
+	function Legacy_ModuleInstaller($dirname)
+	{
+		parent::Legacy_AbstractModuleInstaller($dirname);
+		
+		$this->mProcessScript->register('Legacy_ModuleInstaller.ProcessScript');
+		$this->mProcessScript->add('Legacy_ModuleInstaller::_processScript');
+		
+		$this->mInstallTable->register('Legacy_ModuleInstaller.InstallTable');
+		$this->mInstallTable->add('Legacy_ModuleUtils::installTable');
+		
+		$this->mInstallTemplate->register('Legacy_ModuleInstaller.InstallTemplate');
+		$this->mInstallTemplate->add('Legacy_ModuleInstaller::_installTemplate');
+	}
+
+    /**
+     * Load xoops module object that isn't installed and return it.
+     * @static
+     * @access public
+     * @param $dirname string
+     * @return XoopsModule
+     */
+    function &loadModuleObject($dirname)
+    {
+        $ret = null;
+
+        $moduleHandler =& xoops_gethandler('module');
+        $module =& $moduleHandler->getByDirname($dirname);
+
+        if (is_object($module))
+            return $ret;
+
+        $module =& $moduleHandler->create();
+        $module->setVar('weight', 1);
+        $module->loadInfoAsVar($this->mDirname);
+        
+        if ($module->get('dirname') == null) {
+            return $ret;
+        }
+        
+        if ($module->get('dirname') == 'system') {
+            $module->setVar('mid', 1);
+        }
+        
+        if (isset($module->modinfo['installer']) && isset($module->modinfo['installer']['licence']) ) {
+            $this->mAgree = true;
+        }
+        
+        return $module;
+    }
+    
+    function _installModule()
+    {
+        if (parent::_installModule()) {
+            $gpermHandler =& xoops_gethandler('groupperm');
+
+            //
+            // Add a permission which administrators can manage.
+            //
+            if ($this->mModule->getInfo('hasAdmin')) {
+                $adminPerm =& $this->_createPermission(XOOPS_GROUP_ADMIN);
+                $adminPerm->setVar('gperm_name', 'module_admin');
+
+                if (!$gpermHandler->insert($adminPerm)) {
+                    $log->addError(_AD_BASE_ERROR_COULD_NOT_SET_ADMIN_PERMISSION);
+                }
+            }
+
+            //
+            // Add a permission which administrators can manage. (Special for Legacy System Module)
+            //
+            if ($this->mModule->getVar('dirname') == 'system') {
+				$root =& XCube_Root::getSingleton();
+				$root->mLanguageManager->loadModuleAdminMessageCatalog('system');
+
+                require_once XOOPS_ROOT_PATH . "/modules/system/constants.php";
+				
+                $fileHandler = opendir(XOOPS_ROOT_PATH . "/modules/system/admin");
+                while ($file = readdir($fileHandler)) {
+                    $infoFile = XOOPS_ROOT_PATH . "/modules/system/admin/" . $file . "/xoops_version.php";
+                    if (file_exists($infoFile)) {
+                        require_once $infoFile;
+                        if (!empty($modversion['category'])) {
+                            $sysAdminPerm  =& $this->_createPermission(XOOPS_GROUP_ADMIN);
+                            $adminPerm->setVar('gperm_itemid', $modversion['category']);
+                            $adminPerm->setVar('gperm_name', 'system_admin');
+                            if (!$gpermHandler->insert($adminPerm)) {
+                                $log->addError(_AD_BASE_ERROR_COULD_NOT_SET_SYSTEM_PERMISSION);
+                            }
+                            unset($sysAdminPerm);
+                        }
+                        unset($modversion);
+                    }
+                }
+            }
+            
+            if ($this->mModule->getInfo('hasMain')) {
+                $read_any = $this->mModule->getInfo('read_any');
+                if ($read_any) {
+                    $memberHandler =& xoops_gethandler('member');
+                    $groupObjects =& $memberHandler->getGroups();
+                    //
+                    // Add a permission all group members and guest can read.
+                    //
+                    foreach($groupObjects as $group) {
+                        $readPerm =& $this->_createPermission($group->getVar('groupid'));
+                        $readPerm->setVar('gperm_name', 'module_read');
+
+                        if (!$gpermHandler->insert($readPerm)) {
+                            $log->addError(_AD_BASE_ERROR_COULD_NOT_SET_READ_PERMISSION);
+                        }
+                    }
+                } else {
+                    //
+                    // Add a permission which administrators can read.
+                    //
+                    $root =& XCube_Root::getSingleton();
+                    $groups = $root->mContext->mXoopsUser->getGroups();
+                    foreach($groups as $mygroup) {
+                        $readPerm =& $this->_createPermission($mygroup);
+                        $readPerm->setVar('gperm_name', 'module_read');
+
+                        if (!$gpermHandler->insert($readPerm)) {
+                            $log->addError(_AD_BASE_ERROR_COULD_NOT_SET_READ_PERMISSION);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Create a permission object which has been initialized for admin.
+     * For flexibility, creation only and not save it.
+     * @access private
+     * @param $group
+     */
+    function &_createPermission($group)
+    {
+        $gpermHandler =& xoops_gethandler('groupperm');
+
+        $perm =& $gpermHandler->create();
+
+        $perm->setVar('gperm_groupid', $group);
+        $perm->setVar('gperm_itemid', $this->mModule->getVar('mid'));
+        $perm->setVar('gperm_modid', 1);
+        
+        return $perm;
+    }
+
+	/**
+	 * @static
+	 */
+	function _installTemplate(&$module, &$log)
+	{
+        $templates = $module->getInfo('templates');
+        if ($templates != false) {
+            foreach ($templates as $template) {
+                Legacy_ModuleUtils::installTemplate($module, $template, $log);
+            }
+        }
+	}
+
+    function _installBlock()
+    {
+        $definedBlocks = $this->mModule->getInfo('blocks');
+        if($definedBlocks == false)
+            return true;
+
+        $blockHandler =& xoops_gethandler('block');
+
+        $func_num=0;
+        foreach ($definedBlocks as $block) {
+            $func_num++;
+            $newBlock =& Legacy_ModuleUtils::createBlockByInfo($this->mModule, $block);
+            $newBlock->setVar('func_num', $func_num);
+
+            Legacy_ModuleUtils::installBlock($this->mModule, $newBlock, $block, $this->mLog);
+        }
+    }
+
+	function _installNotification()
+	{
+	}
+	
+    function _installPreference()
+    {
+        Legacy_ModuleUtils::insertAllConfigs($this->mModule, $this->mLog);
+    }
+    
+    function _processScript(&$module, &$log)
+    {
+        $installScript = trim($module->getInfo('onInstall'));
+        if ($installScript != false) {
+            require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript;
+            $funcName = 'xoops_module_install_' . $module->getVar('dirname');
+            if (function_exists($funcName)) {
+                if (!call_user_func($funcName, $module)) {
+                    $log->addError(XCUbe_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName));
+                }
+            }
+        }
+    }
+	
+	function _processReport()
+	{
+		if (!$this->mLog->hasError()) {
+			$this->mLog->add(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_INSTALLATION_MODULE_SUCCESSFUL, $this->mModule->get('name')));
+		}
+		else {
+			if (is_object($this->mModule)) {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_INSTALLATION_MODULE_FAILURE, $this->mModule->get('name')));
+			}
+			else {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_INSTALLATION_MODULE_FAILURE, $this->mDirname));
+			}
+		}
+	}
+
+    function hasAgree()
+    {
+        return $this->mAgree;
+    }
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/AbstractModuleInstaller.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/AbstractModuleInstaller.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/AbstractModuleInstaller.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,205 @@
+<?php
+/**
+ * @version
+ */
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_BASE_PATH."/admin/class/ModuleUtils.class.php";
+
+/**
+ * This is a abstract class for the process of install, update and uninstall.
+ */
+class Legacy_AbstractModuleInstaller
+{
+	/**
+	 * @var XCube_Delegate
+	 */
+	var $mProcessScript = null;
+	
+	/**
+	 * Install or uninstall templates of this target module, this function is
+	 * called by own execute().
+	 *
+	 * @var XCube_Delegate
+	 */
+	var $mInstallTemplate = null;
+	
+	/**
+	 * Create or drop tables, this function is called by own execute().
+	 * 
+	 * @var XCube_Delegate
+	 */
+	var $mInstallTable = null;
+	
+	var $mDirname = null;
+
+	/**
+	 * XoopsModule
+	 */
+	var $mModule = null;
+
+	/**
+	 * Legacy_ModuleUtilsSimpleLog
+	 */
+	var $mLog = null;
+
+	/**
+	 * If this flag is true, never stop processing.
+	 */
+	var $mForceMode = false;
+
+	function Legacy_AbstractModuleInstaller($dirname)
+	{
+		$this->mDirname = $dirname;
+		$this->mLog =& new Legacy_ModuleUtilsSimpleLog();
+		
+		//
+		// Load message catalog for the required module installer of 'common'
+		// process.
+		//
+		$root =& XCube_Root::getSingleton();
+		if (is_object($root->mLanguageManager)) {
+			$root->mLanguageManager->loadModuleAdminMessageCatalog('base');
+		}
+		
+		$this->mProcessScript =& new XCube_Delegate();
+		$this->mInstallTable =& new XCube_Delegate();
+		$this->mInstallTemplate =& new XCube_Delegate();
+	}
+	
+	/**
+	 * Start callback to required member functions with module install
+	 * framework.
+	 * 
+	 * @return bool
+	 */
+	function execute()
+	{
+		$this->mModule =& $this->loadModuleObject($this->mDirname);
+		
+		if (!is_object($this->mModule)) {
+			$this->_processReport();
+			return false;
+		}
+
+		$this->mInstallTable->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog));
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+
+		$this->_installModule();
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+
+		$this->mInstallTemplate->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog));
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+
+		$this->_installBlock();
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+		
+		$this->_installNotification();
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+
+		$this->_installPreference();
+		if (!$this->mForceMode && $this->mLog->hasError()) {
+			$this->_processReport();
+			return false;
+		}
+		
+		$this->mProcessScript->call(new XCube_Ref($this->mModule), new XCube_Ref($this->mLog));
+		
+		$this->_processReport();
+		
+		return true;
+	}
+
+	/**
+	 * Load xoops module object and return it.
+	 * @static
+	 * @access public
+	 * @param $dirname string
+	 * @return XoopsModule
+	 */
+	function &loadModuleObject($dirname)
+	{
+	}
+
+	function _installModule()
+	{
+		$moduleHandler =& xoops_gethandler('module');
+		if (!$moduleHandler->insert($this->mModule)) {
+			$this->mLog->addError("*Could not install module information*");
+			return false;
+		}
+
+		return true;
+	}
+
+	/**
+	 * Install or uninstall blocks and their templates, this function is called by own execute().
+	 */
+	function _installBlock()
+	{
+	}
+	
+	/**
+	 * Install or uninstall notifications, this member function is called by
+	 * own execute().
+	 * 
+	 * @access protected
+	 */
+	function _installNotification()
+	{
+	}
+	
+	/**
+	 * Install or uninstall blocks and their preference, this function is called by own execute().
+	 */
+	function _installPreference()
+	{
+	}
+
+	/**
+	 * If set true, this class may never stop for error.
+	 */
+	function setForceMode($flag)
+	{
+		$this->mForceMode = $flag;
+	}
+
+	/**
+	 * This member function is called back at the last part of execute().
+	 * Report the conclusion to the log.
+	 */	
+	function _processReport()
+	{
+	}
+	
+	/**
+	 * Return log instance.
+	 */
+	function &getLog()
+	{
+		return $this->mLog;
+	}
+	
+	function hasAgree()
+	{
+		return false;
+	}
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleUpdater.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,310 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_BASE_PATH."/admin/class/AbstractModuleInstaller.class.php";
+
+class Legacy_ModuleUpdater extends Legacy_AbstractModuleInstaller
+{
+	var $mPreVersion = 0;
+
+	function Legacy_ModuleUpdater($dirname)
+	{
+		parent::Legacy_AbstractModuleInstaller($dirname);
+		
+		$this->mProcessScript->register('Legacy_ModuleUpdater.ProcessScript');
+		$this->mProcessScript->add(array(&$this, '_processScript'));
+		
+		$this->mInstallTable->register('Legacy_ModuleUpdater.InstallTable');
+
+		$this->mInstallTemplate->register('Legacy_ModuleUpdater.InstallTemplate');
+		$this->mInstallTemplate->add('Legacy_ModuleUpdater::_uninstallTemplate');
+	}
+
+	/**
+	 * @return bool
+	 */
+	function execute()
+	{
+		$this->mLog->addReport(_AD_BASE_MESSAGE_UPDATE_STARTED);
+		
+		parent::execute();
+	}
+	
+	/**
+	 * Load xoops module object installed and return it.
+	 * @static
+	 * @access public
+	 * @param $dirname string
+	 * @return XoopsModule
+	 */
+	function &loadModuleObject($dirname)
+	{
+		$ret = null;
+
+		$moduleHandler =& xoops_gethandler('module');
+		$module =& $moduleHandler->getByDirname($dirname);
+
+		if (!is_object($module))
+			return $ret;
+
+		$this->mPreVersion = $module->getVar('version');
+        $name = $module->getVar('name','n');
+		$module->loadInfoAsVar($dirname);
+		$module->setVar('name', $name, true);
+		return $module;
+	}
+
+	/**
+	 * @static
+	 */
+	function _uninstallTemplate(&$module, &$log)
+	{
+		$tplHandler =& xoops_gethandler('tplfile');
+
+		//
+		// The following processing depends on the structure of Legacy_RenderSystem.
+		//
+		$tplHandler =& xoops_gethandler('tplfile');
+		$delTemplates =& $tplHandler->find('default', 'module', $module->getVar('mid'));
+		if(is_array($delTemplates) && count($delTemplates) > 0) {
+			//
+			// clear cache
+			//
+			$xoopsTpl=new XoopsTpl();
+			$xoopsTpl->clear_cache(null, "mod_" . $module->getVar('dirname'));
+			
+			foreach ($delTemplates as $tpl) {
+				if (!$tplHandler->delete($tpl)) {
+					$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file')));
+				}
+			}
+		}
+
+		//
+		// install Template All
+		//
+		$templates = $module->getInfo('templates');
+		if ($templates != false) {
+			foreach ($templates as $template) {
+				Legacy_ModuleUtils::installTemplate($module, $template, $log);
+			}
+		}
+	}
+
+	/**
+	 * @return bool
+	 */
+	function _installBlock()
+	{
+		// XoopsBlock[]
+		$installBlocks = array();
+
+		// XoopsBlock[]
+		$unInstallBlocks = array();
+
+		$definedBlocks = $this->mModule->getInfo('blocks');
+		if($definedBlocks == false)
+			return false;
+
+		$blockHandler =& xoops_gethandler('block');
+
+		$func_num=0;
+		$showfuncs = array();
+        $funcfiles = array();
+		for ($i=1; $i<= count($definedBlocks); $i++) {
+		    $block =&  $definedBlocks[$i];
+			$func_num = $i;
+		    $showfuncs[] = isset($block['class']) ? ('cl::' . $block['class']) : $block['show_func'];
+		    $funcfiles[]=$block['file'];
+			$newBlock =& Legacy_ModuleUtils::createBlockByInfo($this->mModule, $block);
+			//
+			// Get a installed block by mid and name.
+			//
+			$criteria = new CriteriaCompo();
+			$criteria->add(new Criteria('mid', $this->mModule->getVar('mid')));
+			$criteria->add(new Criteria('func_num', $func_num));
+			$criteria->add(new Criteria('show_func', isset($block['class']) ? ('cl::' . $block['class']) : $block['show_func']));
+			$criteria->add(new Criteria('func_file', $block['file']));
+			$installedBlocks =& $blockHandler->getObjectsDirectly($criteria);
+			//
+			// If a installed block is not found, push it to new install block list.
+			//
+			if (count($installedBlocks) == 0) {
+				$newBlock->setVar('func_num', $func_num);
+				$installBlocks[] = array($newBlock, $block);
+				unset($newBlock);
+
+				continue;
+			}
+
+			$changedFlag = false;
+
+			$oldBlock =& $installedBlocks[0];
+            $newBlock =& Legacy_ModuleUtils::mergeBlockObject($oldBlock, $newBlock, $changedFlag);
+
+			if ($changedFlag) {
+				$installBlocks[] = array($newBlock, $block);
+			}
+			else {
+				if (!Legacy_ModuleUtils::installBlockTemplate($this->mModule, $oldBlock)) {
+					$this->mLog->addError("ERROR : Could not update block template ".$oldBlock->getVar('name'));
+				}
+			}
+
+			unset($newBlock);
+			unset($oldBlock);
+		}
+		$criteria = new CriteriaCompo();
+		$criteria->add(new Criteria('mid', $this->mModule->getVar('mid')));
+		$installedBlocks =& $blockHandler->getObjectsDirectly($criteria);
+		foreach ($installedBlocks as $blockObj) {
+            if (!in_array($blockObj->getVar('show_func'), $showfuncs) || !in_array($blockObj->getVar('func_file'), $funcfiles)) {
+				$unInstallBlocks[] =& $blockObj;
+				unset($blockObj);
+            }
+        }
+
+		foreach ($installBlocks as $block) {
+			Legacy_ModuleUtils::installBlock($this->mModule, $block[0], $block[1], $this->mLog);
+		}
+        
+		foreach ($unInstallBlocks as $block) {
+			Legacy_ModuleUtils::unInstallBlock($block, $this->mLog);
+		}
+
+	}
+	
+	function _installPreference()
+	{
+		$configHandler =& xoops_gethandler('config');
+		
+		//
+		// At the start, load config items of this time.
+		//
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('conf_modid', $this->mModule->get('mid')));
+		$criteria->add(new Criteria('conf_catid', 0));
+		
+		$activeConfigArr =& $configHandler->getConfigs($criteria);
+		
+		//
+		// Next, load config item from xoops_version.php.
+		//
+		$newConfigArr = array();
+		$t_configInfoArr = Legacy_ModuleUtils::getConfigInfosFromManifesto($this->mModule);
+		
+		$count = 0;
+		if (is_array($t_configInfoArr)) {
+			foreach ($t_configInfoArr as $t_configInfo) {
+				$config =& $configHandler->createConfig();
+				$config->loadFromConfigInfo($this->mModule->get('mid'), $t_configInfo, $count++);
+				$newConfigArr[] =& $config;
+				unset($config);
+			}
+		}
+		
+		//
+		// If some active configs were deleted, remove them form database.
+		//
+		foreach (array_keys($activeConfigArr) as $t_actkey) {
+			$findFlag = false;
+			foreach (array_keys($newConfigArr) as $t_newkey) {
+				
+				if ($activeConfigArr[$t_actkey]->get('conf_name') == $newConfigArr[$t_newkey]->get('conf_name')) {
+					$findFlag = true;
+					if (!$activeConfigArr[$t_actkey]->isEqual($newConfigArr[$t_newkey])) {
+						//
+						// Update object
+						//
+						$activeConfigArr[$t_actkey]->set('conf_title', $newConfigArr[$t_newkey]->get('conf_title'));
+						$activeConfigArr[$t_actkey]->set('conf_value', $newConfigArr[$t_newkey]->get('conf_value'));
+						$activeConfigArr[$t_actkey]->set('conf_desc', $newConfigArr[$t_newkey]->get('conf_desc'));
+						$activeConfigArr[$t_actkey]->set('conf_formtype', $newConfigArr[$t_newkey]->get('conf_formtype'));
+						$activeConfigArr[$t_actkey]->set('conf_valuetype', $newConfigArr[$t_newkey]->get('conf_valuetype'));
+						
+						//
+						// Delete config options.
+						//
+						$t_optionArr =& $activeConfigArr[$t_actkey]->getOptionItems();
+						foreach (array_keys($t_optionArr) as $t_optionKey) {
+							$configHandler->_oHandler->delete($t_optionArr[$t_optionKey]);	//< Exception!!
+						}
+						
+						$activeConfigArr[$t_actkey]->setConfOptions($newConfigArr[$t_newkey]->getConfOptions());
+						
+						$configHandler->insertConfig($activeConfigArr[$t_actkey]);	//< FIXME need log.
+					}
+				}
+			}
+			
+			if (!$findFlag) {
+				$configHandler->deleteConfig($activeConfigArr[$t_actkey]);
+				unset($activeConfigArr[$t_actkey]);
+			}
+		}
+		
+		//
+		// If some new configs were registered, insert them into database.
+		//
+		$maxOrder = 0;
+		foreach (array_keys($activeConfigArr) as $t_actkey) {
+			if ($activeConfigArr[$t_actkey]->get('conf_order') > $maxOrder) {
+				$maxOrder = $activeConfigArr[$t_actkey]->get('conf_order');
+			}
+		}
+		
+		$order = $maxOrder + 1;
+		
+		foreach (array_keys($newConfigArr) as $t_newkey) {
+			$newFlag = true;
+			foreach (array_keys($activeConfigArr) as $t_actkey) {
+				if ($newConfigArr[$t_newkey]->isEqual($activeConfigArr[$t_actkey])) {
+					$newFlag = false;
+					break;
+				}
+			}
+			
+			if ($newFlag) {
+				$newConfigArr[$t_newkey]->set('conf_order', $order);
+				if ($configHandler->insertConfig($newConfigArr[$t_newkey])) {
+					$this->mLog->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_INSERT_CONFIG, $newConfigArr[$t_newkey]->get('conf_name')));
+				}
+				else {
+					$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_INSERT_CONFIG, $newConfigArr[$t_newkey]->get('conf_name')));
+				}
+			}
+		}
+	}
+
+	function _processScript(&$module, &$log)
+	{
+		$installScript = trim($module->getInfo('onUpdate'));
+		if ($installScript != false) {
+			require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript;
+			$funcName = 'xoops_module_update_' . $module->getVar('dirname');
+			if (function_exists($funcName)) {
+				if (!call_user_func($funcName, $module, $this->mPreVersion)) {
+					$log->addError("Failed to execute " . $funcName);
+				}
+			}
+		}
+	}
+	
+	function _processReport()
+	{
+		if (!$this->mLog->hasError()) {
+			$this->mLog->add(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_UPDATING_MODULE_SUCCESSFUL, $this->mModule->get('name')));
+		}
+		else {
+			if (is_object($this->mModule)) {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_UPDATING_MODULE_FAILURE, $this->mModule->get('name')));
+			}
+			else {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_UPDATING_MODULE_FAILURE, $this->mDirname));
+			}
+		}
+	}
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/Legacy_SQLScanner.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/Legacy_SQLScanner.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/Legacy_SQLScanner.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,79 @@
+<?php
+
+require_once dirname(__FILE__) . "/EasyLex_SQLScanner.class.php";
+
+class Legacy_SQLScanner extends EasyLex_SQLScanner
+{
+	var $mDB_PREFIX = "";
+	
+	function setDB_PREFIX($prefix)
+	{
+		$this->mDB_PREFIX = $prefix;
+	}
+
+	/**
+	 * Override.
+	 */	
+	function &getOperations()
+	{
+		$t_lines = array();
+		$t_tokens = array();
+		$depth = 0;
+		
+		foreach (array_keys($this->mTokens) as $key) {
+			if ($this->mTokens[$key]->mType == EASYLEX_SQL_OPEN_PARENTHESIS) {
+				$depth++;
+			}
+			elseif ($this->mTokens[$key]->mType == EASYLEX_SQL_CLOSE_PARENTHESIS) {
+				$depth--;
+			}
+			
+			$t_tokens[] =& $this->mTokens[$key];
+			
+			if (count($t_tokens) > 1 && $depth == 0) {
+				if ($this->mTokens[$key]->mType == EASYLEX_SQL_SEMICOLON) {
+					$t_lines[] =& $t_tokens;
+					unset($t_tokens);
+					$t_tokens = array();
+				}
+				elseif ($this->mTokens[$key]->mType == EASYLEX_SQL_LETTER && (strtoupper($this->mTokens[$key]->mValue) =='CREATE' || strtoupper($this->mTokens[$key]->mValue) =='ALTER' || strtoupper($this->mTokens[$key]->mValue) =='INSERT')) {
+					array_pop($t_tokens);
+					$t_lines[] =& $t_tokens;
+					unset($t_tokens);
+					$t_tokens = array();
+					$t_tokens[] =& $this->mTokens[$key];
+				}
+			}
+		}
+		
+		if (count($t_tokens) > 0) {
+			$t_lines[] =& $t_tokens;
+			unset($t_tokens);
+		}
+		
+		foreach ($t_lines as $op) {
+			if (count($op) >= 3) {
+				if ($op[0]->mType == EASYLEX_SQL_LETTER && strtoupper($op[0]->mValue) == 'CREATE' &&
+				    $op[1]->mType == EASYLEX_SQL_LETTER && strtoupper($op[1]->mValue) == 'TABLE' &&
+				    ($op[2]->mType == EASYLEX_SQL_LETTER || $op[2]->mType == EASYLEX_SQL_STRING_LITERAL)) {
+						$op[2]->mValue = $this->mDB_PREFIX . '_' . $op[2]->getValue();
+				}
+				if ($op[0]->mType == EASYLEX_SQL_LETTER && strtoupper($op[0]->mValue) == 'ALTER' &&
+				    $op[1]->mType == EASYLEX_SQL_LETTER && strtoupper($op[1]->mValue) == 'TABLE' &&
+				    ($op[2]->mType == EASYLEX_SQL_LETTER || $op[2]->mType == EASYLEX_SQL_STRING_LITERAL)) {
+						$op[2]->mValue = $this->mDB_PREFIX . '_' . $op[2]->getValue();
+				}
+				if ($op[0]->mType == EASYLEX_SQL_LETTER && strtoupper($op[0]->mValue) == 'INSERT' &&
+				    $op[1]->mType == EASYLEX_SQL_LETTER && strtoupper($op[1]->mValue) == 'INTO' &&
+				    ($op[2]->mType == EASYLEX_SQL_LETTER || $op[2]->mType == EASYLEX_SQL_STRING_LITERAL)) {
+						$op[2]->mValue = $this->mDB_PREFIX . '_' . $op[2]->getValue();
+				}
+			}
+		}
+		
+		return $t_lines;
+	}
+}
+
+
+?>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/index.html
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/index.html:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/index.html	Sat Oct 14 23:55:23 2006
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/ModuleUtils.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/ModuleUtils.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleUtils.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,533 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_ROOT_PATH."/class/template.php";
+
+define("MODINSTALL_LOGTYPE_REPORT", "report");
+define("MODINSTALL_LOGTYPE_WARNING", "warning");
+define("MODINSTALL_LOGTYPE_ERROR", "error");
+
+/**
+ * A temporary log class.
+ */
+class Legacy_ModuleUtilsSimpleLog
+{
+	var $mFetalErrorFlag = false;
+	var $mMessages = array();
+
+	function add($msg)
+	{
+		$this->mMessages[] = array('type' => MODINSTALL_LOGTYPE_REPORT, 'message' => $msg);
+	}
+
+	function addReport($msg)
+	{
+		$this->add($msg);
+	}
+	
+	function addWarning($msg)
+	{
+		$this->mMessages[] = array('type' => MODINSTALL_LOGTYPE_WARNING, 'message' => $msg);
+	}
+
+	function addError($msg)
+	{
+		$this->mMessages[] = array('type' => MODINSTALL_LOGTYPE_ERROR, 'message' => $msg);
+		$this->mFetalErrorFlag = true;
+	}
+	
+	function hasError()
+	{
+		return $this->mFetalErrorFlag;
+	}
+}
+
+/**
+ * This provides static methods for the module installation. Methods of this
+ * class may move to base class of installers. 
+ */
+class Legacy_ModuleUtils
+{
+	/**
+	 */
+	function installTable(&$module, &$log)
+	{
+		$sqlfileInfo =& $module->getInfo('sqlfile');
+		$dirname = $module->getVar('dirname');
+
+		if (!isset($sqlfileInfo[XOOPS_DB_TYPE])) {
+			return;
+		}
+		
+		require_once XOOPS_MODULE_PATH . "/base/admin/class/Legacy_SQLScanner.class.php";
+		$scanner =& new Legacy_SQLScanner();
+		$scanner->setDB_PREFIX(XOOPS_DB_PREFIX);
+		
+		$sqlfile = $sqlfileInfo[XOOPS_DB_TYPE];
+		if (!$scanner->loadFile(XOOPS_MODULE_PATH . "/${dirname}/" . $sqlfile)) {
+			$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_SQL_FILE_NOT_FOUND, $sqlfile));
+			return false;
+		}
+
+		$scanner->parse();
+		$sqls = $scanner->getSQL();
+		
+		$root =& XCube_Root::getSingleton();
+		$db =& $root->mController->getDB();
+		
+		//
+		// TODO The following variable exists for rollback, but it is not implemented.
+		//
+		foreach ($sqls as $sql) {
+			if (!$db->query($sql)) {
+				$log->addError($db->error());
+				return;
+			}
+		}
+		
+		$log->addReport(_AD_BASE_MESSAGE_DATABASE_SETUP_FINISHED);
+	}
+
+	/**
+	 *  Insert template to DB.
+	 *  This function depends on the structure of Legacy_RenderSystem. We should
+	 * move this to another mechanism.
+	 *
+	 * @param $dirname string
+	 * @param $$template string[][]
+	 * @param $log Legacy_ModuleUtilsSimpleLog *
+	 * @param bool
+	 */
+	function installTemplate($module, $template, &$log)
+	{
+		$tplHandler =& xoops_gethandler('tplfile');
+
+		$fileName = trim($template['file']);
+
+		$tpldata = Legacy_ModuleUtils::readTemplateFile($module->getVar('dirname'), $fileName);
+		if ($tpldata == false)
+			return false;
+
+		//
+		// Create template file object, then store it.
+		//
+		$tplfile =& $tplHandler->create();
+		$tplfile->setVar('tpl_refid', $module->getVar('mid'));
+		$tplfile->setVar('tpl_lastimpoerted', 0);
+		$tplfile->setVar('tpl_lastmodified', time());
+
+		if (preg_match("/\.css$/i", $fileName)) {
+			$tplfile->setVar('tpl_type', 'css');
+		}
+		else {
+			$tplfile->setVar('tpl_type', 'module');
+		}
+
+		$tplfile->setVar('tpl_source', $tpldata, true);
+		$tplfile->setVar('tpl_module', $module->getVar('dirname'));
+		$tplfile->setVar('tpl_tplset', 'default');
+		$tplfile->setVar('tpl_file', $fileName, true);
+
+		$description = isset($tpl['description']) ? $tpl['description'] : '';
+		$tplfile->setVar('tpl_desc', $description, true);
+		
+		if ($tplHandler->insert($tplfile)) {
+			$log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_TEMPLATE_INSTALLED, $fileName));
+		}
+		else {
+			$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_INSTALL_TEMPLATE, $fileName));
+			return false;
+		}
+
+		return true;
+	}
+	
+	/**
+	 * Read template file, return it.
+	 *
+	 * @return string or false
+	 */
+	function readTemplateFile($dirname, $fileName, $isblock = false)
+	{
+		//
+		// Load template data
+		//
+		if ($isblock) {
+			$filePath = XOOPS_MODULE_PATH . "/" . $dirname . "/templates/blocks/" . $fileName;
+		}
+		else {
+			$filePath = XOOPS_MODULE_PATH . "/" . $dirname . "/templates/" . $fileName;
+		}
+
+		if (!file_exists($filePath)) {
+			return false;
+		}
+
+		$lines = file($filePath);
+		if ($lines == false) {
+			return false;
+		}
+
+		$tpldata = "";
+		foreach ($lines as $line) {
+			//
+			// Unify linefeed to "\r\n" 
+			//
+			$tpldata .= str_replace("\n", "\r\n", str_replace("\r\n", "\n", $line));
+		}
+		
+		return $tpldata;
+	}
+	
+	/**
+	 * Create XoopsBlock object by array that is defined in xoops_version, return it.
+	 * @param $module XoopsModule
+	 * @param $block array
+	 * @return XoopsBlock
+	 */
+	function &createBlockByInfo(&$module, $block)
+	{
+		$options = isset($block['options']) ? $block['options'] : null;
+		$edit_func = isset($block['edit_func']) ? $block['edit_func'] : null;
+		$template = isset($block['template']) ? $block['template'] : null;
+		$visible = isset($block['visible']) ? $block['visible'] : (isset($block['visible_any']) ? $block['visible_any']: 0);
+		$blockHandler =& xoops_gethandler('block');
+		$blockObj =& $blockHandler->create();
+
+		$blockObj->set('mid', $module->getVar('mid'));
+		$blockObj->set('options', $options);
+		$blockObj->set('name', $block['name']);
+		$blockObj->set('title', $block['name']);
+		$blockObj->set('block_type', 'M');
+		$blockObj->set('c_type', 1);
+		$blockObj->set('isactive', 1);
+		$blockObj->set('dirname', $module->getVar('dirname'));
+		$blockObj->set('func_file', $block['file']);
+		
+		//
+		// IMPORTANT CONVENTION
+		//
+		$show_func = "";
+		if (isset($block['class'])) {
+			$show_func = "cl::" . $block['class'];
+		}
+		else {
+			$show_func = $block['show_func'];
+		}
+		
+		$blockObj->set('show_func', $show_func);
+		$blockObj->set('edit_func', $edit_func);
+		$blockObj->set('template', $template);
+		$blockObj->set('last_modified', time());
+		$blockObj->set('visible', $visible);
+
+		return $blockObj;
+	}
+
+    /**
+     * Merge existing block XoopsBlock object and new XoopsBlock object from xoops_verion
+     * @param $oldBlock XoopsBlock
+     * @param $newBlock XoopsBlock
+     * @param $changedFlag bool
+     * @return XoopsBlock
+     */
+	function &mergeBlockObject(&$oldBlock, &$newBlock, &$changedFlag)
+    {
+        $blockObj =& $oldBlock->xoopsClone();
+        $blockObj->unsetNew();
+        
+		$changedFlag = false;
+		$checkValues = array('name', 'func_file', 'show_func', 'edit_func', 'template');
+		foreach($checkValues as $checkValue) {
+		    if ($newBlock->getVar($checkValue) != $oldBlock->getVar($checkValue)) {
+		        $blockObj->setVar($checkValue, $newBlock->getVar($checkValue));
+		        $changedFlag |= true;
+		    }
+		}
+
+		$old_options=explode("|",$oldBlock->getVar('options'));
+		$new_options=explode("|",$newBlock->getVar('options'));
+		if (count($new_options) > count($old_options)) {
+	        $changedFlag |= true;
+		    for ($i=count($old_options); $i<count($new_options); $i++) {
+		        $old_options[$i] = $old_options[$i];
+		    }
+		    $blockObj->setVar('options', implode("|", $old_options));
+		} else if (count($new_options) < count($old_options)) {
+	        $changedFlag |= true;
+		    $blockObj->setVar('options', $newBlock->getVar('options'));
+		}
+		
+		return $blockObj;
+    }
+
+	/**
+	 * This function can receive both new and update.
+	 * @param $module XoopsModule
+	 * @param $blockObj XoopsBlock
+	 * @param $block array
+	 * @return bool
+	 */
+	function installBlock(&$module, &$blockObj, &$block, &$log)
+	{
+		$isNew = $blockObj->isNew();
+		$blockHandler =& xoops_gethandler('block');
+
+        if (!empty($block['show_all_module'])) {
+            $autolink = false;
+        } else {
+            $autolink = true;
+        }
+		if (!$blockHandler->insert($blockObj, $autolink)) {
+			$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_INSTALL_BLOCK, $blockObj->getVar('name')));
+
+			return false;
+		}
+		else {
+			$log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_BLOCK_INSTALLED, $blockObj->getVar('name')));
+
+			$tplHandler =& xoops_gethandler('tplfile');
+
+			if (!Legacy_ModuleUtils::installBlockTemplate($module, $blockObj)) {
+				$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_BLOCK_TEMPLATE_INSTALL, $blockObj->getVar('name')));
+			}
+			
+			//
+			// Process of a permission.
+			//
+			if ($isNew) {
+                if (!empty($block['show_all_module'])) {
+        			$link_sql = "INSERT INTO " . $blockHandler->db->prefix('block_module_link') . " (block_id, module_id) VALUES (".$blockObj->getVar('bid').", 0)";
+		        	if (!$blockHandler->db->query($link_sql)) {
+       					$log->addWarn(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_SET_LINK, $blockObj->getVar('name')));
+		        	}
+    			}
+   				$gpermHandler =& xoops_gethandler('groupperm');
+   				$bperm =& $gpermHandler->create();
+				$bperm->setVar('gperm_itemid', $blockObj->getVar('bid'));
+				$bperm->setVar('gperm_name', 'block_read');
+				$bperm->setVar('gperm_modid', 1);
+				
+				if (!empty($block['visible_any'])) {
+    				$memberHandler =& xoops_gethandler('member');
+    				$groupObjects =& $memberHandler->getGroups();
+    				foreach($groupObjects as $group) {
+        				$bperm->setVar('gperm_groupid', $group->getVar('groupid'));
+        				$bperm->setNew();
+        				if (!$gpermHandler->insert($bperm)) {
+        					$log->addWarn(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_SET_BLOCK_PERMISSION, $blockObj->getVar('name')));
+        				}
+        			}
+				} else {
+				    $root =& XCube_Root::getSingleton();
+                    $groups = $root->mContext->mXoopsUser->getGroups();
+                    foreach ($groups as $mygroup) {
+        				$bperm->setVar('gperm_groupid', $mygroup);
+        				$bperm->setNew();
+        				if (!$gpermHandler->insert($bperm)) {
+        					$log->addWarn(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_SET_BLOCK_PERMISSION, $blockObj->getVar('name')));
+    				    }
+    				}
+				}
+			}
+
+			return true;
+		}
+	}
+	
+	function unInstallBlock(&$block, &$log) {
+		$blockHandler =& xoops_gethandler('block');
+		$blockHandler->delete($block);
+		$log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_UNINSTALLATION_BLOCK_SUCCESSFUL, $block->get('name')));
+		//
+		// delete permission
+		//
+		$gpermHandler =& xoops_gethandler('groupperm');
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('gperm_name', 'block_read'));
+		$criteria->add(new Criteria('gperm_itemid', $block->getVar('bid')));
+		$criteria->add(new Criteria('gperm_modid', 1));
+		$gpermHandler->deleteAll($criteria);
+    }
+    
+	/**
+	 * Save the information of block's template specified and the source code of it
+	 * to database.
+	 * @return bool
+	 */
+	function installBlockTemplate(&$module, &$block)
+	{
+		if ($block->get('template') == null) {
+			return true;
+		}
+		
+		$tplHandler =& xoops_gethandler('tplfile');
+
+		$criteria =& new CriteriaCompo();
+		$criteria->add(new Criteria('tpl_type', 'block'));
+		$criteria->add(new Criteria('tpl_tplset', 'default'));
+		$criteria->add(new Criteria('tpl_module', $module->getVar('dirname')));
+		$criteria->add(new Criteria('tpl_file', $block->getVar('template')));
+		$tplfiles =& $tplHandler->getObjects($criteria);
+
+		if (count($tplfiles) > 0) {
+			$tplfile =& $tplfiles[0];
+		}
+		else {
+			$tplfile =& $tplHandler->create();
+			$tplfile->setVar('tpl_refid', $block->getVar('bid'));
+			$tplfile->setVar('tpl_tplset', 'default');
+			$tplfile->setVar('tpl_file', $block->getVar('template'));
+			$tplfile->setVar('tpl_module', $module->getVar('dirname'));
+			$tplfile->setVar('tpl_type', 'block');
+			// $tplfile->setVar('tpl_desc', $tpl_desc);
+			$tplfile->setVar('tpl_lastimported', 0);
+		}
+		
+		$tplSource = Legacy_ModuleUtils::readTemplateFile($module->getVar('dirname'), $block->getVar('template'), true);
+		$tplfile->setVar('tpl_source', $tplSource);
+		$tplfile->setVar('tpl_lastmodified', time());
+
+		return $tplHandler->insert($tplfile);
+	}
+
+	function insertAllConfigs(&$module, &$log)
+	{
+		$configInfos = Legacy_ModuleUtils::getConfigInfosFromManifesto($module);
+
+		$count = 0;
+		if (is_array($configInfos)) {
+			$configHandler =& xoops_gethandler('config');
+			
+			foreach ($configInfos as $configInfo) {
+				$config =& $configHandler->createConfig();
+				
+				$config->loadFromConfigInfo($module->get('mid'), $configInfo, $count++);
+				
+				if ($configHandler->insertConfig($config)) {
+					$log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_INSERT_CONFIG, $configInfo['name']));
+				}
+				else {
+					$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_INSERT_CONFIG, $configInfo['name']));
+				}
+				
+				unset($config);
+			}
+		}
+	}
+
+	/**
+	 * Get & build config items from Manifesto by specific module object.
+	 */	
+	function &getConfigInfosFromManifesto(&$module)
+	{
+		$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
+			                   );
+		}
+
+		//
+		// Insert comment config by old style.
+		//
+		if ($module->get('hasnotification') != 0) {
+			require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
+			require_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
+			
+			$t_options = array();
+			$t_options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
+			$t_options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
+			$t_options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
+			$t_options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
+			
+			$configInfos[] = array(
+				'name' => 'notification_enabled',
+				'title' => '_NOT_CONFIG_ENABLE',
+				'description' => '_NOT_CONFIG_ENABLEDSC',
+				'formtype' => 'select',
+				'valuetype' => 'int',
+				'default' => XOOPS_NOTIFICATION_ENABLEBOTH,
+				'options' => $t_options
+			);
+			
+			//
+			// FIXME: doesn't work when update module... can't read back the
+			//        array of options properly...  " changing to &quot;
+			//
+			
+			unset ($t_options);
+			
+			$t_options = array();
+			$t_categoryArr =& notificationCategoryInfo('', $module->get('mid'));
+			foreach ($t_categoryArr as $t_category) {
+				$t_eventArr =& notificationEvents($t_category['name'], false, $module->get('mid'));
+				foreach ($t_eventArr as $t_event) {
+					if (!empty($event['invisible'])) {
+						continue;
+					}
+					$t_optionName = $t_category['title'] . ' : ' . $t_event['title'];
+					$t_options[$t_optionName] = $t_category['name'] . '-' . $t_event['name'];
+				}
+			}
+				
+			$configInfos[] = array(
+				'name' => 'notification_events',
+				'title' => '_NOT_CONFIG_EVENTS',
+				'description' => '_NOT_CONFIG_EVENTSDSC',
+				'formtype' => 'select_multi',
+				'valuetype' => 'array',
+				'default' => array_values($t_options),
+				'options' => $t_options
+			);
+		}
+		
+		return $configInfos;
+	}
+	
+
+	/**
+	 * Delete all configs of $module.
+	 *
+	 * @param $module XoopsModule
+	 */
+	function deleteAllConfigs(&$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
Index: xoops2jp/html/modules/legacy/admin/class/ModuleUninstaller.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/ModuleUninstaller.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/ModuleUninstaller.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,172 @@
+<?php
+
+if (!defined('XOOPS_ROOT_PATH')) exit();
+
+require_once XOOPS_BASE_PATH."/admin/class/AbstractModuleInstaller.class.php";
+
+class Legacy_ModuleUninstaller extends Legacy_AbstractModuleInstaller
+{
+	function Legacy_ModuleUninstaller($dirname)
+	{
+		parent::Legacy_AbstractModuleInstaller($dirname);
+		
+		$this->mProcessScript->register('Legacy_ModuleUninstaller.ProcessScript');
+		$this->mProcessScript->add('Legacy_ModuleUninstaller::_processScript');
+		
+		$this->mInstallTable->register('Legacy_ModuleInstaller.InstallTable');
+		$this->mInstallTable->add('Legacy_ModuleUninstaller::_uninstallTable');
+
+		$this->mInstallTemplate->register('Legacy_ModuleUninstaller.InstallTemplate');
+		$this->mInstallTemplate->add('Legacy_ModuleUninstaller::_uninstallTemplate');
+	}
+	
+	/**
+	 * Load xoops module object that isn't installed and return it.
+	 * @static
+	 * @access public
+	 * @param $dirname string
+	 * @return XoopsModule
+	 */
+	function &loadModuleObject($dirname)
+	{
+		$error = null;
+
+		$moduleHandler =& xoops_gethandler('module');
+		$module =& $moduleHandler->getByDirname($dirname);
+
+		if (!is_object($module)) {
+			$this->mLog->addError(_AD_BASE_ERROR_MODULE_NOT_FOUND);
+			return $error;
+		}
+		
+		if ($module->getVar('isactive') != 0) {
+			$this->mLog->addError(_AD_BASE_ERROR_CASE_OF_ACTIVE_MODULE);
+			return $error;
+		}
+
+		return $module;
+	}
+	
+	/**
+	 * Delete module information from XOOPS database because this class is uninstaller.
+	 */
+	function _installModule()
+	{
+		$moduleHandler =& xoops_gethandler('module');
+		if (!$moduleHandler->delete($this->mModule)) {
+			$this->mLog->addError(_AD_BASE_ERROR_DELETE_MODULEINFO_FROM_DB);
+		}
+		else {
+			$this->mLog->addReport(_AD_BASE_MESSAGE_DELETE_MODULEINFO_FROM_DB);
+		}
+	}
+
+	/**
+	 * Drop table because this class is uninstaller.
+	 */
+	function _uninstallTable(&$module, &$log)
+	{
+		$root =& XCube_Root::getSingleton();
+		$db =& $root->mController->getDB();
+
+		$tables = $module->getInfo('tables');
+		if ($tables != false && is_array($tables)) {
+			foreach($tables as $table) {
+				//
+				// TODO Do we need to check reserved core tables?
+				//
+				$sql = "DROP TABLE " . $db->prefix($table);
+				if ($db->query($sql)) {
+					$log->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_DROP_TABLE, $db->prefix($table)));
+				}
+				else {
+					$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_DROP_TABLE, $db->prefix($table)));
+				}
+			}
+		}
+	}
+
+	/**
+	 * Delete template because this class is uninstaller.
+	 */
+	function _uninstallTemplate(&$module, &$log)
+	{
+		$tplHandler =& xoops_gethandler('tplfile');
+
+		$deleteTemplates =& $tplHandler->find(null, 'module', $module->getVar('mid'));
+		
+		foreach($deleteTemplates as $tpl) {
+			if (!$tplHandler->delete($tpl)) {
+				$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_TEMPLATE_UNINSTALLED, $tpl->getVar('tpl_file')));
+			}
+		}
+	}
+
+	/**
+	 * Delete all of module's blocks.
+	 */
+	function _installBlock()
+	{
+		$blockHandler =& xoops_gethandler('block');
+		$criteria = new Criteria('mid', $this->mModule->getVar('mid'));
+
+		$blocks =& $blockHandler->getObjectsDirectly($criteria);
+		
+		$gpermHandler =& xoops_gethandler('groupperm');
+		foreach ($blocks as $block) {
+			$blockHandler->delete($block);
+			$this->mLog->addReport(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_BLOCK_HAS_BEEN_UNINSTALLED, $block->get('name')));
+
+			//
+			// delete permission
+			//
+			$criteria =& new CriteriaCompo();
+			$criteria->add(new Criteria('gperm_name', 'block_read'));
+			$criteria->add(new Criteria('gperm_itemid', $block->getVar('bid')));
+			$criteria->add(new Criteria('gperm_modid', 1));
+			$gpermHandler->deleteAll($criteria);
+		}
+
+		$tplHandler =& xoops_gethandler('tplfile');
+		$criteria =& new Criteria('tpl_module', $this->mModule->getVar('dirname'));
+		if(!$tplHandler->deleteAll($criteria)) {
+			$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_COULD_NOT_DELETE_BLOCK_TEMPLATES, $tplHandler->db->error()));
+		}
+	}
+
+	function _installPreference()
+	{
+		Legacy_ModuleUtils::deleteAllConfigs($this->mModule, $this->mLog);
+	}
+
+	function _processScript(&$module, &$log)
+	{
+		$installScript = trim($module->getInfo('onUninstall'));
+		if ($installScript != false) {
+			require_once XOOPS_MODULE_PATH . "/" . $module->getVar('dirname') . "/" . $installScript;
+			$funcName = 'xoops_module_uninstall_' . $module->getVar('dirname');
+			if (function_exists($funcName)) {
+				if (!call_user_func($funcName, $module)) {
+					$log->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_FAILED_TO_EXECUTE_CALLBACK, $funcName));
+				}
+			}
+		}
+	}
+	
+	function _processReport()
+	{
+		if (!$this->mLog->hasError()) {
+			$this->mLog->add(XCube_Utils::formatMessage(_AD_BASE_MESSAGE_UNINSTALLATION_MODULE_SUCCESSFUL, $this->mModule->get('name')));
+		}
+		else {
+			if (is_object($this->mModule)) {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_UNINSTALLATION_MODULE_FAILURE, $this->mModule->get('name')));
+			}
+			else {
+				$this->mLog->addError(XCube_Utils::formatMessage(_AD_BASE_ERROR_UNINSTALLATION_MODULE_FAILURE, $this->mDirname));
+			}
+		}
+	}
+}
+
+?>
\ No newline at end of file
Index: xoops2jp/html/modules/legacy/admin/class/EasyLex_SQLScanner.class.php
diff -u /dev/null xoops2jp/html/modules/legacy/admin/class/EasyLex_SQLScanner.class.php:1.1.2.1
--- /dev/null	Sat Oct 14 23:55:23 2006
+++ xoops2jp/html/modules/legacy/admin/class/EasyLex_SQLScanner.class.php	Sat Oct 14 23:55:23 2006
@@ -0,0 +1,415 @@
+<?php
+/**
+ * @package EasyLexSQL
+ * @varsion $Id$
+ * 
+ * In the original BSD license, both occurrences of the phrase "COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS" in the disclaimer read "REGENTS AND CONTRIBUTORS".
+ * 
+ * Copyright (c) 2006, XOOPS Cube Project team/minahito (minah****@users*****)
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * 
+ * a) Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * b) Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * c) Neither the name of the XOOPS Cube Project team nor the names of its
+ *    contributors may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *    
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+define('EASYLEX_SQL_UNKNOWN', 0);
+define('EASYLEX_SQL_DIGIT', 1);
+define('EASYLEX_SQL_LETTER', 2);
+define('EASYLEX_SQL_STRING_LITERAL', 3);
+define('EASYLEX_SQL_STRING_LITERAL_ESCAPE', 10);
+define('EASYLEX_SQL_OPEN_PARENTHESIS', 4);
+define('EASYLEX_SQL_CLOSE_PARENTHESIS', 5);
+define('EASYLEX_SQL_SEPARATER', 6);
+define('EASYLEX_SQL_SEMICOLON', 7);
+define('EASYLEX_SQL_MARK', 8);
+define('EASYLEX_SQL_COMMA', 9);
+
+/**
+ * This is BSD easy lexcal scanner for SQL.
+ * 
+ * @version 1.00
+ */
+class EasyLex_SQLScanner
+{
+	var $mTokens;
+	var $mStatus = EASYLEX_SQL_UNKNOWN;
+	
+	/**
+	 * @var Array of char
+	 */
+	var $mBuffer = array();
+	
+	var $mIndex = 0;
+	
+	var $mActiveToken = '';
+	
+	var $mActiveQuoteMark = null;
+	
+	function setBuffer($buffer)
+	{
+		$this->mBuffer = array();
+		for ($i = 0; $i < strlen($buffer); $i++) {
+			$this->mBuffer[$i] = $buffer{$i};
+		}
+		
+		$this->mIndex = 0;
+	}
+	
+	function parse()
+	{
+		while ($this->mIndex <= count($this->mBuffer)) {
+			if ($this->mIndex == count($this->mBuffer)) {
+				$ch = '';
+				$type = EASYLEX_SQL_UNKNOWN;
+			}
+			else {
+				$ch = $this->mBuffer[$this->mIndex];
+				$type = $this->_getChrType($ch);
+			}
+			
+			switch ($this->mStatus) {
+				case EASYLEX_SQL_UNKNOWN:
+					$this->_parseUnknown($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_DIGIT:
+					$this->_parseDigit($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_LETTER:
+					$this->_parseLetter($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_STRING_LITERAL:
+					$this->_parseStringLiteral($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_STRING_LITERAL_ESCAPE:
+					$this->_parseStringLiteralEscape($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_OPEN_PARENTHESIS:
+					$this->_parseOpenParenthesis($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_CLOSE_PARENTHESIS:
+					$this->_parseCloseParenthesis($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_SEPARATER:
+					$this->_parseSeparater($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_MARK:
+					$this->_parseMark($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_SEMICOLON:
+					$this->_parseSemicolon($ch, $type);
+					break;
+					
+				case EASYLEX_SQL_COMMA:
+					$this->_parseComma($ch, $type);
+					break;
+			}
+		}
+	}
+	
+	/**
+	 * Load file and set buffer. If $preprocess is true, scan commetns and
+	 * remove these.
+	 * 
+	 * @param  string $path file path
+	 * @param  bool   $preprocess
+	 * @return bool
+	 */
+	function loadFile($path, $preprocess = true)
+	{
+		if (!file_exists($path)) {
+			return false;
+		}
+
+		$fp = fopen($path, "rb");
+		if (!$fp) {
+			return false;
+		}
+		
+		$t_buff = "";
+		while ($str = fgets($fp)) {
+			if ($preprocess) {
+				$str = preg_replace("/^\s*\#.*/", "", $str);
+			}
+			$t_buff .= $str;
+		}
+		
+		$this->setBuffer($t_buff);
+		
+		fclose($fp);
+		return true;
+	}
+	
+	function _getChrType($ch)
+	{
+		if (preg_match("/\s/", $ch)) {
+			return EASYLEX_SQL_SEPARATER;
+		}
+		
+		if ($ch == '(') {
+			return EASYLEX_SQL_OPEN_PARENTHESIS;
+		}
+		
+		if ($ch == ')') {
+			return EASYLEX_SQL_CLOSE_PARENTHESIS;
+		}
+		
+		if ($ch == ';') {
+			return EASYLEX_SQL_SEMICOLON;
+		}
+		
+		if ($ch == ',') {
+			return EASYLEX_SQL_COMMA;
+		}
+		
+		if (preg_match("/[0-9]/", $ch)) {
+			return EASYLEX_SQL_DIGIT;
+		}
+		
+		if (preg_match("/[!=<>%\*]/", $ch)) {
+			return EASYLEX_SQL_MARK;
+		}
+		
+		return EASYLEX_SQL_LETTER;
+	}
+	
+	function _parseUnknown($ch, $type)
+	{
+		$this->mStatus = $type;
+		$this->mActiveToken .= $ch;
+		$this->mIndex++;
+		
+		if ($ch == "'" || $ch == '"' || $ch == '`') {
+			$this->mStatus = EASYLEX_SQL_STRING_LITERAL;
+			$this->mActiveQuoteMark = $ch;
+		}
+
+	}
+	
+	function _parseDigit($ch, $type)
+	{
+		if ($type == EASYLEX_SQL_DIGIT) {
+			$this->mActiveToken .= $ch;
+			$this->mIndex++;
+		}
+		elseif ($type == EASYLEX_SQL_LETTER) {
+			$this->mStatus = EASYLEX_SQL_LETTER;
+			$this->mActiveToken .= $ch;
+			$this->mIndex++;
+		}
+		else {
+			$this->_createToken();
+		}
+	}
+	
+	function _parseLetter($ch, $type)
+	{
+		if ($type == EASYLEX_SQL_LETTER || $type == EASYLEX_SQL_DIGIT) {
+			$this->mActiveToken .= $ch;
+			$this->mIndex++;
+		}
+		else {
+			$this->_createToken();
+		}
+	}
+	
+	function _parseStringLiteral($ch, $type)
+	{
+		$this->mActiveToken .= $ch;
+		$this->mIndex++;
+		
+		if ($ch == "\\") {
+			$this->mStatus = EASYLEX_SQL_STRING_LITERAL_ESCAPE;
+		}
+		elseif ($ch == $this->mActiveQuoteMark) {
+			$this->_createToken();
+		}
+	}
+	
+	function _parseStringLiteralEscape($ch, $type)
+	{
+		$this->mStatus = EASYLEX_SQL_STRING_LITERAL;
+	}
+	
+	function _parseOpenParenthesis($ch, $type)
+	{
+		$this->_createToken();
+	}
+	
+	function _parseCloseParenthesis($ch, $type)
+	{
+		$this->_createToken();
+	}
+	
+	function _parseSeparater($ch, $type)
+	{
+		if ($type == EASYLEX_SQL_SEPARATER) {
+			$this->mActiveToken .= $ch;
+			$this->mIndex++;
+		}
+		else {
+			// $this->_createToken();
+			$this->mStatus = EASYLEX_SQL_UNKNOWN;
+			$this->mActiveToken = "";
+		}
+	}
+	
+	function _parseSemicolon($ch, $type)
+	{
+		$this->_createToken();
+	}
+	
+	function _parseMark($ch, $type)
+	{
+		if ($type == EASYLEX_SQL_MARK) {
+			$this->mActiveToken .= $ch;
+			$this->mIndex++;
+		}
+		else {
+			$this->_createToken();
+		}
+	}
+	
+	function _parseComma($ch, $type)
+	{
+		$this->_createToken();
+	}
+	
+	function _createToken($type = null, $value = null)
+	{
+		if ($type === null) {
+			$type = $this->mStatus;
+		}
+		
+		if ($value === null) {
+			$value = $this->mActiveToken;
+		}
+		
+		$token =& new EasyLex_SQLToken($type, $value);
+		$this->mTokens[] =& $token;
+		
+		$this->mStatus = EASYLEX_SQL_UNKNOWN;
+		$this->mActiveToken = "";
+		
+		return $token;
+	}
+	
+	/**
+	 * Return Array of operations.
+	 * 
+	 * @return Array $ret[Index] = Array of tokens.
+	 */
+	function &getOperations()
+	{
+		$ret = array();
+		$t_tokens = array();
+		$depth = 0;
+		
+		foreach (array_keys($this->mTokens) as $key) {
+			if ($this->mTokens[$key]->mType == EASYLEX_SQL_OPEN_PARENTHESIS) {
+				$depth++;
+			}
+			elseif ($this->mTokens[$key]->mType == EASYLEX_SQL_CLOSE_PARENTHESIS) {
+				$depth--;
+			}
+			
+			$t_tokens[] =& $this->mTokens[$key];
+			
+			if ($this->mTokens[$key]->mType == EASYLEX_SQL_SEMICOLON && $depth == 0) {
+				$ret[] =& $t_tokens;
+				unset($t_tokens);
+				$t_tokens = array();
+			}
+		}
+		
+		if (count($t_tokens) > 0) {
+			$ret[] =& $t_tokens;
+			unset($t_tokens);
+		}
+		
+		return $ret;
+	}
+	
+	function getSQL()
+	{
+		$sqls = array();
+		$lines =& $this->getOperations();
+		
+		foreach ($lines as $line) {
+			$t_arr = array();
+			foreach ($line as $token) {
+				$t_arr[] = $token->getOutputValue();
+			}
+			$sqls[] = join(" ", $t_arr);
+		}
+		
+		return $sqls;
+	}
+}
+
+class EasyLex_SQLToken
+{
+	var $mType = EASYLEX_SQL_UNKNOWN;
+	var $mValue = "";
+	
+	function EasyLex_SQLToken($type, $value)
+	{
+		$this->mType = $type;
+		$this->mValue = $value;
+	}
+	
+	function getOutputValue()
+	{
+		if ($this->mType == EASYLEX_SQL_SEPARATER) {
+			return "";
+		}
+		else {
+			return $this->mValue;
+		}
+	}
+	
+	function getValue()
+	{
+		if ($this->mType == EASYLEX_SQL_SEPARATER) {
+			return "";
+		}
+		
+		if ($this->mType == EASYLEX_SQL_STRING_LITERAL) {
+			return substr($this->mValue, 1, strlen($this->mValue) - 2);
+		}
+		
+		return $this->mValue;
+	}
+}
+
+?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index