Minahito
minah****@users*****
2006年 10月 5日 (木) 18:08:00 JST
Index: xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php diff -u /dev/null xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php:1.1.2.1 --- /dev/null Thu Oct 5 18:08:00 2006 +++ xoops2jp/html/modules/base/kernel/Legacy_AdminControllerStrategy.class.php Thu Oct 5 18:08:00 2006 @@ -0,0 +1,164 @@ +<?php +/** + * @package Legacy + * @version $Id: Legacy_AdminControllerStrategy.class.php,v 1.1.2.1 2006/10/05 09:08:00 minahito Exp $ + */ + +if (!defined('XOOPS_ROOT_PATH')) exit(); + +class Legacy_AdminControllerStrategy extends Legacy_AbstractControllerStrategy +{ + var $mStatusFlag = LEGACY_CONTROLLER_STATE_ADMIN; + + /** + * @var XCube_Delegate + * @param XCube_Controller &$controller + */ + var $mSetupBlock = null; + + /** + * If this array includes current action, getVirtualCurrentModule() returns + * the module object that specified by dirname. + * + * @access private + */ + var $_mSpecialActions = array("Help", "CommentList"); + + function Legacy_AdminControllerStrategy(&$controller) + { + global $xoopsOption; + + parent::Legacy_AbstractControllerStrategy($controller); + + // + // TODO We have to develop complated-switching-controller-mechanizm. + // + if (!defined("LEGACY_DEPENDENCE_RENDERER")) { + define("LEGACY_DEPENDENCE_RENDERER", "Legacy_AdminRenderSystem"); + } + + $controller->mRoot->mContext->mBaseRenderSystemName = "Legacy_AdminRenderSystem"; + + // + // Cover the spec of admin.php of the system module, for the compatibility. + // + if (isset($_REQUEST['fct']) && $_REQUEST['fct'] == "users") { + $GLOBALS['xoopsOption']['pagetype'] = "user"; + } + + $this->mSetupBlock =& new XCube_Delegate(); + $this->mSetupBlock->register('Legacy_AdminControllerStrategy.SetupBlock'); + } + + function _setupFilterChain() + { + parent::_setupFilterChain(); + + // + // Auto pre-loading. + // + if($this->mController->mRoot->getSiteConfig('Legacy', 'AutoPreload') == 1) { + $this->mController->_processPreload(XOOPS_ROOT_PATH . "/preload/admin"); + } + } + + function setupModuleContext(&$context, $dirname) + { + if ($dirname == null) { + $dirname = 'base'; + } + + Legacy_PublicControllerStrategy::setupModuleContext($context, $dirname); + } + + function &_createModule() + { + $module =& new Legacy_AdminModule(); + return $module; + } + + function setupBlock() + { + require_once XOOPS_BASE_PATH . "/admin/blocks/AdminActionSearch.class.php"; + require_once XOOPS_BASE_PATH . "/admin/blocks/AdminSideMenu.class.php"; + $this->mController->_mBlockChain[] =& new Legacy_AdminActionSearch(); + $this->mController->_mBlockChain[] =& new Legacy_AdminSideMenu(); + + $this->mSetupBlock->call(new XCube_Ref($this->mController)); + } + + function _processPreBlockFilter() + { + parent::_processPreBlockFilter(); + $this->mController->_processModulePreload('/admin/preload'); + } + + function &getVirtualCurrentModule() + { + $module = null; + + if ($this->mController->mRoot->mContext->mModule != null) { + $module =& $this->mController->mRoot->mContext->mXoopsModule; + + if ($module->get('dirname') == "base" && isset($_REQUEST['dirname'])) { + if (in_array(xoops_getrequest('action'), $this->_mSpecialActions)) { + $handler =& xoops_gethandler('module'); + $module =& $handler->getByDirname(xoops_getrequest('dirname')); + } + } + elseif ($module->get('dirname') == "base" && xoops_getrequest('action') == 'PreferenceEdit' && isset($_REQUEST['confmod_id'])) { + $handler =& xoops_gethandler('module'); + $module =& $handler->get(intval(xoops_getrequest('confmod_id'))); + } + } + + return $module; + } + + function &getMainThemeObject() + { + $handler =& xoops_getmodulehandler('theme', 'base'); + $theme =& $handler->create(); + + // + // TODO Load manifesto here. + // + $theme->set('dirname', $this->mController->mRoot->mSiteConfig['Legacy']['Theme']); + $theme->set('render_system', 'Legacy_AdminRenderSystem'); + + return $theme; + } + + function isEnableCacheFeature() + { + return false; + } + + function enableAccess() + { + if (!is_object($this->mController->mRoot->mContext->mXoopsUser)) { + return false; + } + + if ($this->mController->mRoot->mContext->mModule != null) { + $dirname = $this->mController->mRoot->mContext->mXoopsModule->get('dirname'); + + if ($this->mController->mRoot->mContext->mUser->isInRole("Module.${dirname}.Admin")) { + return true; + } + + // + // Decide $mid as a argument for checkRight() by current module's dirname. + // + $dirname = $this->mController->mRoot->mContext->mXoopsModule->get('dirname'); + if ($dirname == 'base' || $dirname == 'system') { + $handler =& xoops_gethandler('groupperm'); + return $handler->checkRight('module_admin', -1, $this->mController->mRoot->mContext->mXoopsUser->getGroups()); + } + } + + return false; + } +} + +?> \ No newline at end of file