XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Legacy_AdminControllerStrategy.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
20{
21 public $mStatusFlag = LEGACY_CONTROLLER_STATE_ADMIN;
22
27 public $mSetupBlock = null;
28
35 public $_mSpecialActions = ['Help', 'CommentList'];
36
37 public function __construct(&$controller)
38 {
39 global $xoopsOption;
40
41 parent::__construct($controller);
42
43 //
44 // TODO We have to develop completed-switching-controller-mechanism.
45 //
46 if (!defined('LEGACY_DEPENDENCE_RENDERER')) {
47 define('LEGACY_DEPENDENCE_RENDERER', 'Legacy_AdminRenderSystem');
48 }
49
50 $controller->mRoot->mContext->mBaseRenderSystemName = 'Legacy_AdminRenderSystem';
51
52 //
53 // Cover the spec of admin.php of the system module, for compatibility.
54 //
55 if (isset($_REQUEST['fct']) && 'users' == $_REQUEST['fct']) {
56 $GLOBALS['xoopsOption']['pagetype'] = 'user';
57 }
58
59 $this->mSetupBlock =new XCube_Delegate();
60 $this->mSetupBlock->register('Legacy_AdminControllerStrategy.SetupBlock');
61 }
62
63 public function _setupFilterChain()
64 {
65 parent::_setupFilterChain();
66
67 //
68 // Auto pre-loading.
69 //
70 if (1 == $this->mController->mRoot->getSiteConfig('Legacy', 'AutoPreload')) {
71 $this->mController->_processPreload(XOOPS_ROOT_PATH . '/preload/admin');
72 }
73 }
74
75 public function setupModuleContext(&$context, $dirname)
76 {
77 if (null == $dirname) {
78 $dirname = 'legacy';
79 }
80
81 parent::setupModuleContext($context, $dirname);
82 }
83
88 public function setupBlock()
89 {
90 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminActionSearch.class.php';
91 require_once XOOPS_LEGACY_PATH . '/admin/blocks/AdminSideMenu.class.php';
92 $this->mController->_mBlockChain[] =new Legacy_AdminActionSearch();
93 $this->mController->_mBlockChain[] =new Legacy_AdminSideMenu();
94
95 $this->mSetupBlock->call(new XCube_Ref($this->mController));
96 }
97
98 public function _processPreBlockFilter()
99 {
100 parent::_processPreBlockFilter();
101 $this->mController->_processModulePreload('/admin/preload');
102 }
103
104 public function &getVirtualCurrentModule()
105 {
106 static $ret_module;
107 if (is_object($ret_module)) {
108 return $ret_module;
109 }
110
111 if (null != $this->mController->mRoot->mContext->mModule) {
112 $module =& $this->mController->mRoot->mContext->mXoopsModule;
113
114 if ('legacy' == $module->get('dirname') && isset($_REQUEST['dirname'])) {
115 if (in_array(xoops_getrequest('action'), $this->_mSpecialActions)) {
116 $handler =& xoops_gethandler('module');
117 $t_xoopsModule =& $handler->getByDirname(xoops_getrequest('dirname'));
118 $ret_module =& Legacy_Utils::createModule($t_xoopsModule);
119 }
120 } elseif ('legacy' == $module->get('dirname') && 'PreferenceEdit' == xoops_getrequest('action') && isset($_REQUEST['confmod_id'])) {
121 $handler =& xoops_gethandler('module');
122 $t_xoopsModule =& $handler->get((int)xoops_getrequest('confmod_id'));
123 $ret_module =& Legacy_Utils::createModule($t_xoopsModule);
124 }
125
126 if (!is_object($ret_module)) {
127 $ret_module =& Legacy_Utils::createModule($module);
128 }
129 }
130
131 return $ret_module;
132 }
133
134 public function &getMainThemeObject()
135 {
136 $handler =& xoops_getmodulehandler('theme', 'legacy');
137 $theme =& $handler->create();
138
139 //
140 // TODO Load manifesto here.
141 //
142 $theme->set('dirname', $this->mController->mRoot->mSiteConfig['Legacy']['Theme']);
143 $theme->set('render_system', 'Legacy_AdminRenderSystem');
144
145 return $theme;
146 }
147
148 public function isEnableCacheFeature()
149 {
150 return false;
151 }
152
153 public function enableAccess()
154 {
155 $principal =& $this->mController->mRoot->mContext->mUser;
156
157 if (!$principal->mIdentity->isAuthenticated()) {
158 return false;
159 }
160
161 if (null != $this->mController->mRoot->mContext->mModule) {
162 $dirname = $this->mController->mRoot->mContext->mXoopsModule->get('dirname');
163
164 if ('legacy' == $dirname) {
165 return $principal->isInRole('Site.Administrator');
166 } elseif (defined('_LEGACY_ALLOW_ACCESS_FROM_ANY_ADMINS_')) {
167 return $this->mController->mRoot->mContext->mXoopsUser->isAdmin(0);
168 }
169
170 return $principal->isInRole("Module.{$dirname}.Admin");
171 } else {
172 return $principal->isInRole('Site.Administrator');
173 }
174
175 return false;
176 }
177
178 // TODO TRUST PATH lang catalog
179 public function setupModuleLanguage()
180 {
181 $root =& XCube_Root::getSingleton();
182
183 $root->mContext->mXoopsModule->loadInfo($root->mContext->mXoopsModule->get('dirname'));
184
185 if (isset($root->mContext->mXoopsModule->modinfo['cube_style']) && false != $root->mContext->mXoopsModule->modinfo['cube_style']) {
186 $root->mLanguageManager->loadModuleMessageCatalog($root->mContext->mXoopsModule->get('dirname'));
187 }
188 $root->mLanguageManager->loadModuleAdminMessageCatalog($root->mContext->mXoopsModule->get('dirname'));
189 $root->mLanguageManager->loadModinfoMessageCatalog($root->mContext->mXoopsModule->get('dirname'));
190 }
191}
[Final] Used for the simple mechanism for common delegation in XCube.