/** * Loads roles of the specific module with $module, and set loaded roles to * the current principal. * @static * @param XoopsModule $module */ function loadRolesByModule(&$module) { static $cache; $root =& XCube_Root::getSingleton(); $context =& $root->mContext; if ($module == null) { return; } if (isset($cache[$module->get('mid')])) { return; } $groups = is_object($context->mXoopsUser) ? $context->mXoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); $handler =& xoops_gethandler('groupperm'); if ($handler->checkRight('module_read', $module->get('mid'), $groups)) { $context->mUser->addRole('Module.' . $module->get('dirname') . '.Visitor'); } if (is_object($context->mXoopsUser) && $handler->checkRight('module_admin', $module->get('mid'), $groups)) { $context->mUser->addRole('Module.' . $module->get('dirname') . '.Admin'); } $handler =& xoops_getmodulehandler('group_permission', 'legacy'); $roleArr = $handler->getRolesByModule($module->get('mid'), $groups); foreach ($roleArr as $role) { $context->mUser->addRole('Module.' . $module->get('dirname') . '.' . $role); } $cache[$module->get('mid')] = true; }
/** * @todo no $renderer. It should be $render. */ function executeViewInput(&$controller, &$xoopsUser, &$renderer) { $renderer->setTemplateName("module_install.html"); $renderer->setAttribute('module', $this->mXoopsModule); $renderer->setAttribute('actionForm', $this->mActionForm); $renderer->setAttribute('currentVersion', round($this->mXoopsModule->get('version') / 100, 2)); }
/** * execute uninstall. * * @return bool */ public function executeUninstall() { $this->_uninstallTables(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } if ($this->_mXoopsModule->get('mid') != null) { $this->_uninstallModule(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } $this->_uninstallTemplates(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } $this->_uninstallBlocks(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } $this->_uninstallPreferences(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } } $this->_processReport(); return true; }
function _processReport() { if (!$this->mLog->hasError()) { $this->mLog->add(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_UPDATING_MODULE_SUCCESSFUL, $this->_mCurrentXoopsModule->get('name'))); } else { $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_UPDATING_MODULE_FAILURE, $this->_mCurrentXoopsModule->get('name'))); } }
function _processReport() { if (!$this->mLog->hasError()) { $this->mLog->add(XCube_Utils::formatString(_AD_LEGACY_MESSAGE_INSTALLATION_MODULE_SUCCESSFUL, $this->_mXoopsModule->get('name'))); } else { $this->mLog->addError(XCube_Utils::formatString(_AD_LEGACY_ERROR_INSTALLATION_MODULE_FAILURE, $this->_mXoopsModule->get('name'))); } }
/** * process report. */ private function _processReport() { $dirname = $this->_mCurrentXoopsModule->get('dirname'); $constpref = '_MI_' . strtoupper($dirname); if (!$this->mLog->hasError()) { $this->mLog->add(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_MODULE_UPDATED'), $this->_mCurrentXoopsModule->get('name'))); } else { $this->mLog->add(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_MODULE_UPDATED'), $this->_mCurrentXoopsModule->get('name'))); } }
/** * process report. */ private function _processReport() { $dirname = $this->_mXoopsModule->get('dirname'); $constpref = '_MI_' . strtoupper($dirname); if (!$this->mLog->hasError()) { $this->mLog->add(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_MODULE_INSTALLED'), $this->_mXoopsModule->getInfo('name'))); } elseif (is_object($this->_mXoopsModule)) { $this->mLog->addError(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_MODULE_INSTALLED'), $this->_mXoopsModule->getInfo('name'))); } else { $this->mLog->addError(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_MODULE_INSTALLED'), 'something')); } }
/** * Do execute porting. This member function is added to Delegate. * * @access public * @param XoopsModule $module * @param Legacy_ModuleInstallLog $log */ function execute(&$module, &$log) { if ($module->get('dirname') != 'XUpgrade') { return; } $this->mLog =& $log; $log->add(_MI_XUPGRADE_MESSAGE_START_PORTING); $this->_portConfigs(); if (XUPGRADE_ENABLE_TEMPLATEPORTING == true) { $this->_portTemplates(); } if ($this->mIsInstall) { $this->_adjustModules(); } }
/** * @private * Uninstalls the block template data specified by $block of $module. * @param XoopsBlock $block * @param XoopsModule $module This object is must the module which has $block. * @param string $tplset A name of the template set. If this is null, uninstalls * all templates of any template-sets. * @param $log * @remarks * This method users template handlers of the kernel. But, if they are hooked, * they may not do something. So, abstraction mechanism is possible enough. */ function _uninstallBlockTemplate(&$block, &$module, $tplset, &$log) { $handler =& xoops_gethandler('tplfile'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('tpl_refid', $block->get('bid'))); $criteria->add(new Criteria('tpl_file', $block->get('template'))); $criteria->add(new Criteria('tpl_module', $module->get('dirname'))); $criteria->add(new Criteria('tpl_type', 'block')); if ($tplset != null) { // See 'FIXME' $criteria->add(new Criteria('tpl_tplset', $tplset)); } $handler->deleteAll($criteria); }