31 public $mModules = [];
47 return _AD_BLOCK_ASIDE;
60 public function execute()
62 $root =& XCube_Root::getSingleton();
65 $langMgr =& $root->mLanguageManager;
66 $langMgr->loadModuleAdminMessageCatalog(
'legacy');
68 $langMgr->loadModinfoMessageCatalog(
'legacy');
71 $controller =& $root->mController;
72 $user =& $root->mContext->mXoopsUser;
73 $groups = implode(
',', $user->getGroups());
74 $cachePath = LEGACY_ADMINMENU_CACHEPREFIX . md5(XOOPS_SALT .
"($groups)". $langMgr->mLanguageName).
'.html';
77 $render =& $this->getRenderTarget();
78 if (file_exists($cachePath)) {
79 $render->mRenderBuffer = file_get_contents($cachePath);
82 $render->setAttribute(
'legacy_module',
'legacy');
84 $this->mCurrentModule =& $controller->mRoot->mContext->mXoopsModule;
86 if (($this->mCurrentModule->get(
'dirname') ===
'legacy') && xoops_getrequest(
'action') ===
'help') {
87 $moduleHandler =& xoops_gethandler(
'module');
88 $t_module =& $moduleHandler->getByDirname(xoops_gethandler(
'legacy'));
89 if (is_object($t_module)) {
90 $this->mCurrentModule =& $t_module;
95 $db = &$controller->getDB();
97 $mod = $db->prefix(
'modules');
98 $perm = $db->prefix(
'group_permission');
103 if ($root->mContext->mUser->isInRole(
'Site.Owner')) {
104 $sql =
"SELECT DISTINCT weight, mid FROM {$mod} WHERE isactive=1 AND hasadmin=1 ORDER BY weight, mid";
106 $sql =
"SELECT DISTINCT {$mod}.weight, {$mod}.mid FROM {$mod},{$perm} " .
107 "WHERE {$mod}.isactive=1 AND {$mod}.mid={$perm}.gperm_itemid AND {$perm}.gperm_name='module_admin' AND {$perm}.gperm_groupid IN ({$groups}) " .
108 "AND {$mod}.hasadmin=1 " .
109 "ORDER BY {$mod}.weight, {$mod}.mid";
112 $result=$db->query($sql);
114 $handler =& xoops_gethandler(
'module');
116 while ([$weight, $mid] = $db->fetchRow($result)) {
117 $xoopsModule = & $handler->get($mid);
118 $module =& Legacy_Utils::createModule($xoopsModule,
false);
120 $this->mModules[] =& $module;
124 $tpl = $db->prefix(
'tplfile');
126 $sql =
"SELECT DISTINCT tpl_module FROM {$tpl}";
127 $result = $db->query($sql);
128 while ($row = $db->fetchArray($result)) {
129 $tpl_modules[] = $row[
'tpl_module'];
131 $render->setAttribute(
'tplmodules', $tpl_modules);
134 $render->setTemplateName(
'legacy_admin_block_sidemenu.html');
135 $render->setAttribute(
'modules', $this->mModules);
136 $render->setAttribute(
'currentModule', $this->mCurrentModule);
141 $renderSystem->renderBlock($render);
142 file_put_contents($cachePath, $render->mRenderBuffer);
145 public static function clearCache()
147 $adminMenucache = glob(LEGACY_ADMINMENU_CACHEPREFIX .
'*.html');
148 if ($adminMenucache) {
149 foreach ($adminMenucache as $file) {