function updatemain() { Legacy_ModuleInstallUtils::clearAllOfModuleTemplatesForUpdate($this->_mTargetXoopsModule, $this->mLog); Legacy_ModuleInstallUtils::installAllOfModuleTemplates($this->_mTargetXoopsModule, $this->mLog); $this->saveXoopsModule($this->_mTargetXoopsModule); $this->mLog->add('Version' . $this->_mTargetVersion / 100 . ' for update.'); $this->_mCurrentVersion = $this->_mTargetVersion; }
/** * Creates a instance of the upgrade installer to mInstaller. And returns * it. * * The precondition is the existence of mXoopsModule. */ function &_getInstaller() { $dirname = $this->mXoopsModule->get('dirname'); $installer =& Legacy_ModuleInstallUtils::createUpdater($dirname); return $installer; }
/** * installAllOfConfigs * * @param XoopsModule &$module * @param Legacy_ModuleInstallLog &$log * * @return bool **/ public static function installAllOfConfigs(&$module, &$log) { $dirname = $module->get('dirname'); $fileReader = new Legacy_ModinfoX2FileReader($dirname); $preferences =& $fileReader->loadPreferenceInformations(); // // Preferences // foreach (array_keys($preferences->mPreferences) as $idx) { Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mPreferences[$idx], $module, $log); } // // Comments // foreach (array_keys($preferences->mComments) as $idx) { Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mComments[$idx], $module, $log); } // // Notifications // foreach (array_keys($preferences->mNotifications) as $idx) { Legacy_ModuleInstallUtils::installPreferenceByInfo($preferences->mNotifications[$idx], $module, $log); } }
/** * Updates all of preferences & notifications. * * @access protected * @note You may do custom */ function _updatePreferences() { Legacy_ModuleInstallUtils::smartUpdateAllOfPreferences($this->_mTargetXoopsModule, $this->mLog); }
function execute(&$controller, &$xoopsUser) { if (isset($_REQUEST['_form_control_cancel'])) { return LEGACY_FRAME_VIEW_CANCEL; } $this->mActionForm->fetch(); $this->mActionForm->validate(); if ($this->mActionForm->hasError()) { return $this->getDefaultView($controller, $xoopsUser); } $this->mInstaller->setForceMode($this->mActionForm->get('force')); if (!$this->mInstaller->executeInstall()) { $this->mInstaller->mLog->addReport('Force Uninstallation is started.'); $dirname = $this->mXoopsModule->get('dirname'); $uninstaller =& Legacy_ModuleInstallUtils::createUninstaller($dirname); $uninstaller->setForceMode(true); $uninstaller->setCurrentXoopsModule($this->mXoopsModule); $uninstaller->executeUninstall(); } return LEGACY_FRAME_VIEW_SUCCESS; }
/** * Checks whether the site is closed now, and whether all of must modules * have been installed. This function is called through delegates. * @var XoopsUser &$xoopsUser * @see preBlockFilter() */ function callbackSetupUser(&$principal, &$controller, &$context) { $retArray = Legacy_Utils::checkSystemModules(); $accessAllowFlag = false; $xoopsConfig = $controller->mRoot->mContext->getXoopsConfig(); if (!empty($_POST['xoops_login'])) { define('XOOPS_CPFUNC_LOADED', 1); $controller->checkLogin(); return; } elseif (is_object($context->mXoopsUser)) { if (in_array(XOOPS_GROUP_ADMIN, $context->mXoopsUser->getGroups())) { $accessAllowFlag = true; } } // @todo Devide following lines to another preload file if ($accessAllowFlag) { $GLOBALS['xoopsUser'] = $context->mXoopsUser; if (!empty($_POST['cube_module_install'])) { //@todo use Ticket require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstaller.class.php"; require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php"; if (isset($_POST['uninstalled_modules']) && is_array($_POST['uninstalled_modules'])) { foreach ($_POST['uninstalled_modules'] as $module) { $module = basename($module); if (in_array($module, $retArray['uninstalled'])) { $controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy'); $handler =& xoops_gethandler('module'); $xoopsModule =& $handler->create(); $xoopsModule->set('weight', 1); $xoopsModule->loadInfoAsVar($module); $installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname')); $installer->setForceMode(true); $installer->setCurrentXoopsModule($xoopsModule); $installer->executeInstall(); } } } if (isset($_POST['disabled_modules']) && is_array($_POST['disabled_modules'])) { $moduleHandler =& xoops_gethandler('module'); foreach ($_POST['disabled_modules'] as $module) { $module = basename($module); if (in_array($module, $retArray['disabled'])) { if ($moduleObject =& $moduleHandler->getByDirname($module)) { $moduleObject->setVar('isactive', 1); $moduleHandler->insert($moduleObject); $blockHandler =& xoops_gethandler('block'); $blockHandler->syncIsActive($moduleObject->get('mid'), $moduleObject->get('isactive')); } } } } if (isset($_POST['option_modules']) && is_array($_POST['option_modules'])) { $handler =& xoops_getmodulehandler('non_installation_module', 'legacy'); $objects = $handler->getObjects(); $optionModules = array(); foreach ($objects as $module) { if (!in_array($module->get('dirname'), $retArray['uninstalled'])) { $optionModules[] = $module->get('dirname'); } } foreach ($_POST['option_modules'] as $module) { $module = basename($module); if (in_array($module, $optionModules)) { $controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy'); $handler =& xoops_gethandler('module'); $xoopsModule =& $handler->create(); $xoopsModule->set('weight', 1); $xoopsModule->loadInfoAsVar($module); $installer =& Legacy_ModuleInstallUtils::createInstaller($xoopsModule->get('dirname')); $installer->setForceMode(true); $installer->setCurrentXoopsModule($xoopsModule); $installer->executeInstall(); } } } $controller->executeRedirect(XOOPS_URL . '/', 1); } elseif (!empty($_GET['cube_module_uninstall'])) { require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->assign('cube_module_uninstall', htmlspecialchars($_GET['cube_module_uninstall'], ENT_QUOTES)); $xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']), 'xoops_themecss' => xoops_getcss(), 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/')); ///< @todo filebase template with absolute file path $xoopsTpl->compile_check = true; $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_uninstall_modules.html'); exit; } elseif (!empty($_POST['cube_module_uninstallok'])) { //@todo use Ticket require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleUninstaller.class.php"; require_once XOOPS_LEGACY_PATH . "/admin/class/ModuleInstallUtils.class.php"; $module = basename($_POST['cube_module_uninstallok']); if (in_array($module, $retArray['disabled'])) { $controller->mRoot->mLanguageManager->loadModuleAdminMessageCatalog('legacy'); $handler =& xoops_gethandler('module'); $xoopsModule =& $handler->getByDirname($module); $uninstaller =& Legacy_ModuleInstallUtils::createUninstaller($xoopsModule->get('dirname')); $uninstaller->setForceMode(true); $uninstaller->setCurrentXoopsModule($xoopsModule); $uninstaller->executeUninstall(); } $controller->executeRedirect(XOOPS_URL . '/', 1); } else { $handler =& xoops_getmodulehandler('non_installation_module', 'legacy'); $objects = $handler->getObjectsFor2ndInstaller(); $optionModules = array(); foreach ($objects as $module) { $dirname = $module->getVar('dirname'); if (!in_array($dirname, $retArray['uninstalled'])) { $optionModule['dirname'] = $dirname; if (in_array($dirname, $retArray['recommended'])) { $optionModule['checked'] = 'checked="checked"'; $optionModule['desc'] = _SYS_RECOMMENDED_MODULES; $optionModules[' ' . $dirname] = $optionModule; } else { $optionModule['checked'] = ''; $optionModule['desc'] = _SYS_OPTION_MODULES; $optionModules[$dirname] = $optionModule; } } } ksort($optionModules); $optionModules = array_values($optionModules); require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->assign('uninstalled', $retArray['uninstalled']); $xoopsTpl->assign('disabled', $retArray['disabled']); $xoopsTpl->assign('option', $optionModules); $xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']), 'xoops_themecss' => xoops_getcss(), 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/')); ///< @todo filebase template with absolute file path $xoopsTpl->compile_check = true; $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_modules.html'); exit; } } if (!$accessAllowFlag) { require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); $xoopsTpl->assign(array('xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']), 'xoops_themecss' => xoops_getcss(), 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/', 'lang_login' => _LOGIN, 'lang_username' => _USERNAME, 'lang_password' => _PASSWORD, 'lang_siteclosemsg' => $xoopsConfig['closesite_text'])); $xoopsTpl->compile_check = true; // @todo filebase template with absolute file path $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_site_closed.html'); exit; } }
/** * @public * Removes a template data from only default group of some render-system. */ function clearBlockTemplateForUpdate(&$block, &$module, &$log) { Legacy_ModuleInstallUtils::_uninstallBlockTemplate($block, $module, 'default', $log); }
function _installPreferences() { Legacy_ModuleInstallUtils::installAllOfConfigs($this->_mXoopsModule, $this->mLog); }
function _uninstallPreferences() { Legacy_ModuleInstallUtils::uninstallAllOfConfigs($this->_mXoopsModule, $this->mLog); Legacy_ModuleInstallUtils::deleteAllOfNotifications($this->_mXoopsModule, $this->mLog); Legacy_ModuleInstallUtils::deleteAllOfComments($this->_mXoopsModule, $this->mLog); }
function update() { $updateSuccess = new XCube_Delegate(); $updateSuccess->register('Legacy_ModuleUpdateAction.UpdateSuccess'); $updateFail = new XCube_Delegate(); $updateFail->register('Legacy_ModuleUpdateAction.UpdateFail'); $module = get_module($this->name); $dirname = $module->get('dirname'); $installer = Legacy_ModuleInstallUtils::createUpdater($dirname); $installer->setCurrentXoopsModule($module); // Load the manifesto, and set it as the target object. $module->loadInfoAsVar($dirname); $module->set('name', $module->get('name')); $installer->setTargetXoopsModule($module); $installer->executeUpgrade(); if ($installer->mLog->hasError() === false) { $updateSuccess->call(new XCube_Ref($module), new XCube_Ref($installer->mLog)); XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Success'), new XCube_Ref($module), new XCube_Ref($installer->mLog)); $success = true; } else { $updateFail->call(new XCube_Ref($module), new XCube_Ref($installer->mLog)); XCube_DelegateUtils::call('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($dirname . '.Fail'), new XCube_Ref($module), new XCube_Ref($installer->mLog)); $success = false; } /* foreach ($installer->mLog->mMessages as $message) { echo sprintf('[%s] update: %s', date('Y-m-d H:i:s'), $message['message']), PHP_EOL; // TODO >> observer } */ return $success; }