30 public $mModules = [];
46 return _AD_BLOCK_MENU;
59 public function execute()
61 $root =& XCube_Root::getSingleton();
64 $langMgr =& $root->mLanguageManager;
65 $langMgr->loadModuleAdminMessageCatalog(
'legacy');
67 $langMgr->loadModinfoMessageCatalog(
'legacy');
70 $controller =& $root->mController;
71 $user =& $root->mContext->mXoopsUser;
72 $groups = implode(
',', $user->getGroups());
73 $cachePath = LEGACY_ADMIN_BLOCK_MENU_CACHEPREFIX . md5(XOOPS_SALT .
"($groups)". $langMgr->mLanguageName).
'.html';
75 $render =& $this->getRenderTarget();
76 if (file_exists($cachePath)) {
77 $render->mRenderBuffer = file_get_contents($cachePath);
80 $render->setAttribute(
'legacy_module',
'legacy');
82 $this->mCurrentModule =& $controller->mRoot->mContext->mXoopsModule;
84 if (($this->mCurrentModule->get(
'dirname') ===
'legacy') && xoops_getrequest(
'action') ===
'help') {
85 $moduleHandler =& xoops_gethandler(
'module');
86 $t_module =& $moduleHandler->getByDirname(xoops_gethandler(
'legacy'));
87 if (is_object($t_module)) {
88 $this->mCurrentModule =& $t_module;
93 $db=&$controller->getDB();
95 $mod = $db->prefix(
'modules');
96 $perm = $db->prefix(
'group_permission');
101 if ($root->mContext->mUser->isInRole(
'Site.Owner')) {
102 $sql =
"SELECT DISTINCT weight, mid FROM {$mod} WHERE isactive=1 AND hasadmin=1 ORDER BY weight, mid";
104 $sql =
"SELECT DISTINCT {$mod}.weight, {$mod}.mid FROM {$mod},{$perm} " .
105 "WHERE {$mod}.isactive=1 AND {$mod}.mid={$perm}.gperm_itemid AND {$perm}.gperm_name='module_admin' AND {$perm}.gperm_groupid IN ({$groups}) " .
106 "AND {$mod}.hasadmin=1 " .
107 "ORDER BY {$mod}.weight, {$mod}.mid";
111 $result=$db->query($sql);
113 $handler =& xoops_gethandler(
'module');
115 while ([$weight, $mid] = $db->fetchRow($result)) {
116 $xoopsModule = & $handler->get($mid);
117 $module =& Legacy_Utils::createModule($xoopsModule,
false);
119 $this->mModules[] =& $module;
123 $tpl = $db->prefix(
'tplfile');
125 $sql =
"SELECT DISTINCT tpl_module FROM {$tpl}";
126 $result = $db->query($sql);
127 while ($row = $db->fetchArray($result)) {
128 $tpl_modules[] = $row[
'tpl_module'];
130 $render->setAttribute(
'tplmodules', $tpl_modules);
133 $render->setTemplateName(
'legacy_admin_block_menu.html');
134 $render->setAttribute(
'modules', $this->mModules);
135 $render->setAttribute(
'currentModule', $this->mCurrentModule);
140 $renderSystem->renderBlock($render);
141 file_put_contents($cachePath, $render->mRenderBuffer);
144 public static function clearCache()
146 $adminDashboardMenucache = glob(LEGACY_ADMIN_BLOCK_MENU_CACHEPREFIX .
'*.html');
147 if ($adminDashboardMenucache) {
148 foreach ($adminDashboardMenucache as $file) {