NobuNobu
nobun****@users*****
2006年 4月 11日 (火) 17:39:07 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.10 xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.11 --- xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php:1.1.2.10 Sun Apr 2 23:42:44 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleInstaller.class.php Tue Apr 11 17:39:07 2006 @@ -10,162 +10,182 @@ */ class Legacy_ModuleInstaller extends Legacy_AbstractModuleInstaller { - var $mAgree = false; + var $mAgree = false; - /** - * 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 (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. - // - $adminPerm =& $this->_createPermission(XOOPS_GROUP_ADMIN); - $adminPerm->setVar('gperm_name', 'module_admin'); - - if (!$gpermHandler->insert($adminPerm)) { - $log->addError("Could not set admin permission " . $this->mModule->getVar('mid')); - } - $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("Could not set read permission " . $this->mModule->getVar('mid')); - } - } - } else { - // - // Add a permission which administrators can read. - // - $root = $root=&XCube_Root::getSingleton(); - $groups = $root->mController->mXoopsUser->getGroups(); - foreach($groups as $mygroup) { - $readPerm =& $this->_createPermission($mygroup); - $readPerm->setVar('gperm_name', 'module_read'); - - if (!$gpermHandler->insert($readPerm)) { - $log->addError("Could not set read permission " . $this->mModule->getVar('mid')); - } - } - } - } - } - - /** - * 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; - } - - function _installTable() - { - Legacy_ModuleUtils::installTable($this->mModule, $this->mLog); - } - - function _installTemplate() - { - $templates = $this->mModule->getInfo('templates'); - if ($templates != false) { - foreach ($templates as $template) { - Legacy_ModuleUtils::installTemplate($this->mModule, $template, $this->mLog); - } - } - } - - 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 _installPreference() - { - Legacy_ModuleUtils::insertAllConfigs($this->mModule, $this->mLog); - } - - function _processScript() - { - $installScript = trim($this->mModule->getInfo('onInstall')); - if ($installScript != false) { - require_once XOOPS_MODULE_PATH . "/" . $this->mModule->getVar('dirname') . "/" . $installScript; - $funcName = 'xoops_module_install_' . $this->mModule->getVar('dirname'); - if (function_exists($funcName)) { - if (!call_user_func($funcName, $this->mModule)) { - $this->mLog->addError("Failed to execute " . $funcName); - } - } - } - } - - function hasAgree() - { - return $this->mAgree; - } + /** + * 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 (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("Could not set admin permission " . $this->mModule->getVar('mid')); + } + } + + // + // Add a permission which administrators can manage. (Special for Legacy System Module) + // + if ($this->mModule->getVar('dirname') == 'system') { + for ($i=1; $i<16; $i++) { + $sysAdminPerm =& $this->_createPermission(XOOPS_GROUP_ADMIN); + $adminPerm->setVar('gperm_itemid', $i); + $adminPerm->setVar('gperm_name', 'system_admin'); + if (!$gpermHandler->insert($adminPerm)) { + $log->addError("Could not set system admin permission " . $this->mModule->getVar('mid')); + } + unset($sysAdminPerm); + } + } + + 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("Could not set read permission " . $this->mModule->getVar('mid')); + } + } + } else { + // + // Add a permission which administrators can read. + // + $root = $root=&XCube_Root::getSingleton(); + $groups = $root->mController->mXoopsUser->getGroups(); + foreach($groups as $mygroup) { + $readPerm =& $this->_createPermission($mygroup); + $readPerm->setVar('gperm_name', 'module_read'); + + if (!$gpermHandler->insert($readPerm)) { + $log->addError("Could not set read permission " . $this->mModule->getVar('mid')); + } + } + } + } + } + } + + /** + * 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; + } + + function _installTable() + { + Legacy_ModuleUtils::installTable($this->mModule, $this->mLog); + } + + function _installTemplate() + { + $templates = $this->mModule->getInfo('templates'); + if ($templates != false) { + foreach ($templates as $template) { + Legacy_ModuleUtils::installTemplate($this->mModule, $template, $this->mLog); + } + } + } + + 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 _installPreference() + { + Legacy_ModuleUtils::insertAllConfigs($this->mModule, $this->mLog); + } + + function _processScript() + { + $installScript = trim($this->mModule->getInfo('onInstall')); + if ($installScript != false) { + require_once XOOPS_MODULE_PATH . "/" . $this->mModule->getVar('dirname') . "/" . $installScript; + $funcName = 'xoops_module_install_' . $this->mModule->getVar('dirname'); + if (function_exists($funcName)) { + if (!call_user_func($funcName, $this->mModule)) { + $this->mLog->addError("Failed to execute " . $funcName); + } + } + } + } + + function hasAgree() + { + return $this->mAgree; + } } ?> \ No newline at end of file Index: xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php diff -u xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.14 xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.15 --- xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php:1.1.2.14 Tue Apr 11 00:10:23 2006 +++ xoops2jp/html/modules/base/admin/class/ModuleUtils.class.php Tue Apr 11 17:39:07 2006 @@ -401,7 +401,9 @@ $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); + if (isset($configInfo['description'])) { + $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);