XoopsGuiCpadmin   C
last analyzed

Complexity

Total Complexity 55

Size/Duplication

Total Lines 444
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 299
dl 0
loc 444
rs 6
c 1
b 0
f 0
wmc 55

6 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
A getServerConfig() 0 17 4
B getPreferences() 0 84 6
F header() 0 143 15
B getModules() 0 54 6
F getAdminMenu() 0 109 23

How to fix   Complexity   

Complex Class

Complex classes like XoopsGuiCpadmin often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use XoopsGuiCpadmin, and based on these observations, apply Extract Interface, too.

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
xoops_load('gui', 'system');
13
14
/*
15
 * Xoops Cpanel default GUI class
16
 *
17
 * @copyright   (c) 2000-2021 XOOPS Project (www.xoops.org)
18
 * @license     GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package     system
20
 * @usbpackage  GUI
21
 * @since       2.5.11
22
 * @author      ForMuss     <[email protected]>
23
 */
24
25
 use Xmf\Request;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
26
27
 /**
28
 * Class XoopsGuiCpadmin
29
 */
30
class XoopsGuiCpadmin extends XoopsSystemGui
31
{
32
    /**
33
     * @return bool
34
     */
35
    public static function validate()
36
    {
37
        return true;
38
    }
39
40
    public function header()
41
    {
42
        parent::header();
43
44
        global $xoops, $xoopsConfig, $xoopsUser, $xoopsModule, $xoTheme, $xoopsTpl, $xoopsDB;
45
        $tpl =& $this->template;
46
47
        /*xoops_load('XoopsFormRendererBootstrap4');
48
        XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap4());*/
49
50
        include_once __DIR__ . '/class/XoopsFormRendererBootstrap4.php';
51
        XoopsFormRenderer::getInstance()->set(new XoopsFormRendererBootstrap4());
52
53
        include_once dirname(__DIR__) . '/ComposerInfo.php';
54
55
        // Determine if information box must be shown
56
        $currentScript = str_replace(XOOPS_ROOT_PATH . '/', '', $_SERVER['SCRIPT_FILENAME']);
57
58
        if('admin.php' == $currentScript){
59
            $show = $_GET['show'] ?? '';
60
            if('info' == $show){
61
                $tpl->assign('showCpadminInfo', true);
62
            }
63
        }
64
65
        $iconsSet = xoops_getModuleOption('typeicons', 'system');
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

65
        $iconsSet = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('typeicons', 'system');
Loading history...
66
67
        if ($iconsSet == '') {
68
            $icons = 'cpadmin';
69
        }
70
71
        $tpl->assign('theme_url', XOOPS_ADMINTHEME_URL . '/cpadmin' );
72
        $tpl->assign('theme_icons', XOOPS_URL . '/modules/system/images/icons/' . $iconsSet );
73
74
        // language
75
        $tpl->assign('xoops_language', $xoopsConfig['language']);
76
        $tpl->assign('xoops_sitename', $xoopsConfig['sitename']);
77
78
        $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
79
80
        $xoTheme->addStylesheet('https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback');
81
        $xoTheme->addStylesheet(XOOPS_URL . '/modules/system/css/admin.css');
82
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/cpadmin/css/adminlte.min.css');
83
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/cpadmin/css/color.css');
84
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/cpadmin/css/style.css');
85
86
        $tpl->assign('lang_cp', _CPHOME);
87
        
88
89
        // ADD MENU *****************************************
90
91
        //Add  CONTROL PANEL  Menu  items
92
        $menu                = [];
93
        $menu[0]['link']     = XOOPS_URL;
94
        $menu[0]['title']    = "<span class='fa fa-home'></span> " . _YOURHOME;
95
        $menu[0]['absolute'] = 1;
96
        $menu[1]['link']     = XOOPS_URL . '/admin.php?xoopsorgnews=1';
97
        $menu[1]['title']    = "<span class='fa fa-newspaper-o'></span> " . _CPADMIN_NEWS;
98
        $menu[1]['absolute'] = 1;
99
        $menu[1]['icon']     = XOOPS_ADMINTHEME_URL . '/transition/images/xoops.png';
100
        $menu[2]['link']     = XOOPS_URL . '/user.php?op=logout';
101
        $menu[2]['title']    = "<span class='fa fa-sign-out'></span> " . _LOGOUT;
102
        $menu[2]['absolute'] = 1;
103
        $menu[2]['icon']     = XOOPS_ADMINTHEME_URL . '/transition/images/logout.png';
104
        $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-cog"></span> ' . _CPADMIN_DASHBOARD, 'menu' => $menu]);
105
106
        // Add the system menu items
107
        // Load Language
108
        xoops_loadLanguage('menu', 'system');
109
        include_once XOOPS_ROOT_PATH . '/modules/system/admin/menu.php';
110
        $xoopsTpl->assign('adminMenuDomain', $adminMenuDomain);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $adminMenuDomain seems to be never defined.
Loading history...
111
112
        // Add server configuration
113
        $this->getServerConfig();
114
115
        // Add Composer packages versions
116
        ComposerInfo::getComposerInfo($tpl);
117
118
        // Add System menu items
119
        $this->getAdminMenu();
120
121
        // Get module list
122
        $this->getModules();
123
124
        // Get preferences
125
        $this->getPreferences();
126
127
        // add MODULES  Menu items
128
        /* @var XoopsModuleHandler $module_handler */
129
        $module_handler = xoops_getHandler('module');
130
        $criteria       = new CriteriaCompo();
131
        $criteria->add(new Criteria('hasadmin', 1));
132
        $criteria->add(new Criteria('isactive', 1));
133
        $criteria->setSort('mid');
134
        $mods = $module_handler->getObjects($criteria);
135
136
        $menu               = [];
137
        /* @var XoopsGroupPermHandler $moduleperm_handler */
138
        $moduleperm_handler = xoops_getHandler('groupperm');
139
        foreach ($mods as $mod) {
140
            $rtn        = [];
141
            $modOptions = [];                                                         //add for sub menus
142
            $sadmin     = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
143
144
            if ($sadmin) {
145
                $info = $mod->getInfo();
146
                if (!empty($info['adminindex'])) {
147
                    $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex'];
148
                } else {
149
                    $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
150
                }
151
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES);
152
                $rtn['absolute'] = 1;
153
                $rtn['url']      = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus
154
                $modOptions      = $mod->getAdminMenu();                                        //add for sub menus
155
                $rtn['options']  = $modOptions;                                             //add for sub menus
156
157
                if (isset($info['icon']) && $info['icon'] !== '') {
158
                    $rtn['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['icon'];
159
                }
160
                $menu[] = $rtn;
161
            }
162
        }
163
        $tpl->append('navitems', [
164
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin',
165
            'text' => '<span class="fa fa-puzzle-piece"></span> ' . _AM_SYSTEM_MODULES,
166
            'dir'  => $mod->getVar('dirname', 'n'),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mod seems to be defined by a foreach iteration on line 139. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
167
            'menu' => $menu]);
168
        
169
        //add OPTIONS/links for local support
170
        if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/transition/language/' . $xoopsConfig['language'] . '/localsupport.php')) {
171
            $links = include XOOPS_ADMINTHEME_PATH . '/transition/language/' . $xoopsConfig['language'] . '/localsupport.php';
172
            if (count($links) > 0) {
173
                $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_LOCALSUPPORT, 'menu' => $links]);
174
            }
175
        }
176
177
        if (is_object($xoopsModule) || !empty($_GET['xoopsorgnews'])) {
178
            if (is_object($xoopsModule) && file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('adminmenu'))) {
179
                include $file;
180
            }
181
182
            return null;
183
        }
184
        
185
    }
186
187
    /**
188
     * Get all system menu item
189
     */
190
    public function getAdminMenu() {
191
        global $xoopsConfig, $xoopsUser, $xoopsModule, $xoTheme, $xoopsTpl, $xoopsDB;
192
193
        include_once $GLOBALS['xoops']->path('/modules/system/constants.php');
194
195
        $groups = $xoopsUser->getGroups();
196
        $all_ok = false;
197
        if (!in_array(XOOPS_GROUP_ADMIN, $groups)) {
198
            $sysperm_handler = xoops_getHandler('groupperm');
199
            $ok_syscats      = $sysperm_handler->getItemIds('system_admin', $groups);
0 ignored issues
show
Bug introduced by
The method getItemIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

199
            /** @scrutinizer ignore-call */ 
200
            $ok_syscats      = $sysperm_handler->getItemIds('system_admin', $groups);
Loading history...
200
        } else {
201
            $all_ok = true;
202
        }
203
204
        xoops_load('xoopslists');
205
206
        $admin_dir        = XOOPS_ROOT_PATH . '/modules/system/admin';
207
        $dirlist          = XoopsLists::getDirListAsArray($admin_dir);
208
        $inactive_section = ['blocksadmin', 'groups', 'modulesadmin', 'preferences', 'tplsets'];
209
        foreach ($dirlist as $directory) {
210
            if (file_exists($admin_dir . '/' . $directory . '/xoops_version.php')) {
211
                require $admin_dir . '/' . $directory . '/xoops_version.php';
212
213
                if ($modversion['hasAdmin']) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $modversion seems to be never defined.
Loading history...
214
                    if (xoops_getModuleOption('active_' . $directory, 'system')) {
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

214
                    if (/** @scrutinizer ignore-deprecated */ xoops_getModuleOption('active_' . $directory, 'system')) {
Loading history...
215
                        $category = isset($modversion['category']) ? (int)$modversion['category'] : 0;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $modversion seems to never exist and therefore isset should always be false.
Loading history...
216
                        if (false !== $all_ok || in_array($modversion['category'], $ok_syscats)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ok_syscats does not seem to be defined for all execution paths leading up to this point.
Loading history...
217
                            $menu['file']   = $directory;
218
                            $menu['title']  = trim($modversion['name']);
219
                            $menu['desc']   = str_replace('<br>', ' ', $modversion['description']);
220
                            $menu['image']  = $modversion['image'];
221
                            $menu['icon']   = $modversion['icon'] ?? '';
222
                            $menu['link']   = XOOPS_URL . '/modules/system/admin.php?fct=' . $directory;
223
                            $menu['status'] = true;
224
                        }
225
                    } else {
226
                        $category = isset($modversion['category']) ? (int)$modversion['category'] : 0;
227
                        if (false !== $all_ok || in_array($modversion['category'], $ok_syscats)) {
228
                            $menu['file']   = $directory;
229
                            $menu['title']  = trim($modversion['name']);
230
                            $menu['desc']   = str_replace('<br>', ' ', $modversion['description']);
231
                            $menu['image']  = $modversion['image'];
232
                            $menu['icon']   = $modversion['icon'] ?? '';
233
                            $menu['link']   = XOOPS_URL . '/modules/system/admin.php?fct=' . $directory;
234
                            $menu['status'] = false;
235
                        }
236
                    }
237
                    if (!in_array($directory, $inactive_section)) {
238
                        $menu['used'] = true;
239
                    }
240
                    if (false !== $all_ok || in_array($modversion['category'], $ok_syscats)) {
241
                        switch ($directory) {
242
                            case 'avatars':
243
                                /* @var  SystemAvatarHandler $avatar_handler */
244
                                $avatar_handler = xoops_getHandler('avatar');
245
                                $avatar         = $avatar_handler->getCount();
246
                                $menu['infos']  = sprintf(_AM_SYSTEM_AVATAR_INFO, $avatar);
247
                                break;
248
                            case 'banners':
249
                                /* @var  SystemBannerHandler $banner_handler */
250
                                $banner_handler = xoops_getModuleHandler('banner', 'system');
251
                                $banner         = $banner_handler->getCount();
252
                                $menu['infos']  = sprintf(_AM_SYSTEM_BANNER_INFO, $banner);
253
                                break;
254
                            case 'comments':
255
                                /* @var  XoopsCommentHandler $comment_handler */
256
                                $comment_handler = xoops_getHandler('comment');
257
                                $comment         = $comment_handler->getCount();
258
                                $menu['infos']   = sprintf(_AM_SYSTEM_COMMENT_INFO, $comment);
259
                                break;
260
                            case 'groups':
261
                                /* @var  XoopsMembershipHandler $groups_Handler */
262
                                $groups_Handler = xoops_getModuleHandler('group', 'system');
263
                                $groups         = $groups_Handler->getCount();
264
                                $menu['infos']  = sprintf(_AM_SYSTEM_GROUP_INFO, $groups);
265
                                break;
266
                            case 'images':
267
                                /* @var  XoopsImageHandler $imgcat_handler */
268
                                $imgcat_handler = xoops_getHandler('image');
269
                                $img            = $imgcat_handler->getCount();
270
                                $menu['infos']  = sprintf(_AM_SYSTEM_IMG_INFO, $img);
271
                                break;
272
                            case 'smilies':
273
                                /* @var  SystemsmiliesHandler $smilies_Handler */
274
                                $smilies_Handler = xoops_getModuleHandler('smilies', 'system');
275
                                $smilies         = $smilies_Handler->getCount();
276
                                $menu['infos']   = sprintf(_AM_SYSTEM_SMILIES_INFO, $smilies);
277
                                break;
278
                            case 'userrank':
279
                                /* @var  SystemUserrankHandler $userrank_Handler */
280
                                $userrank_Handler = xoops_getModuleHandler('userrank', 'system');
281
                                $userrank         = $userrank_Handler->getCount();
282
                                $menu['infos']    = sprintf(_AM_SYSTEM_RANKS_INFO, $userrank);
283
                                break;
284
                            case 'users':
285
                                /* @var  SystemUsersHandler $member_handler */
286
                                $member_handler = xoops_getModuleHandler('users', 'system');
287
                                $member         = $member_handler->getCount();
288
                                $menu['infos']  = sprintf(_AM_SYSTEM_USERS_INFO, $member);
289
                                break;
290
                        }
291
                    }
292
                    $xoopsTpl->append('adminmenu', $menu);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $menu does not seem to be defined for all execution paths leading up to this point.
Loading history...
293
                    unset($menu);
294
                }
295
                unset($modversion);
296
            }
297
        }
298
        unset($dirlist);
299
    }
300
301
    /**
302
     * Get All modules
303
     */
304
    public function getModules() {
305
        global $xoopsDB, $xoopsTpl, $xoopsUser, $xoopsModule;
306
307
        // add MODULES  Menu items
308
        /* @var XoopsModuleHandler $module_handler */
309
        $module_handler = xoops_getHandler('module');
310
        $criteria       = new CriteriaCompo();
311
        $criteria->add(new Criteria('hasadmin', 1));
312
        $criteria->add(new Criteria('isactive', 1));
313
        $criteria->setSort('mid');
314
        $mods = $module_handler->getObjects($criteria);
315
316
        $menu               = [];
317
        /* @var XoopsGroupPermHandler $moduleperm_handler */
318
        $moduleperm_handler = xoops_getHandler('groupperm');
319
        foreach ($mods as $mod) {
320
            $rtn        = [];
321
            $modOptions = [];                                                         //add for sub menus
322
            $sadmin     = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
323
            if ($sadmin) {
324
                $info = $mod->getInfo();
325
                if (!empty($info['adminindex'])) {
326
                    $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex'];
327
                } else {
328
                    $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
329
                }
330
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES);
331
                $rtn['dir']      = $mod->getVar('dirname', 'n');
332
                $rtn['absolute'] = 1;
333
                $rtn['url']      = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus
334
                $modOptions      = $mod->getAdminMenu();                                        //add for sub menus
335
                $rtn['options']  = $modOptions;                                             //add for sub menus
336
                $rtn['icon'] = '<i class="fas fa-cog"></i>';
337
338
                $menu[] = $rtn;
339
            }
340
        }
341
        //$xoopsTpl->append('modules', $menu);
342
        $fct = Request::getString('fct', '');
343
        if($fct != '') {
344
            $xoopsTpl->assign('dashboard', false);
345
        } else {
346
            $xoopsTpl->assign('dashboard', true);
347
        }
348
        if(is_object($xoopsModule)) {
349
            $xoopsTpl->assign('dashboard', false);
350
        }
351
352
        $xoopsTpl->append('modules', [
353
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin',
354
            'text' => _AM_SYSTEM_MODULES,
355
            'icon' => 'fa fa-puzzle-piece',
356
            'dir'  => $mod->getVar('dirname', 'n'),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mod seems to be defined by a foreach iteration on line 319. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
357
            'menu' => $menu]);
358
    }
359
360
    /**
361
     * Get System and module preferences link
362
     */
363
    public function getPreferences(){
364
        global $xoopsDB, $xoopsTpl, $xoopsUser;
365
366
        $pref = [];
367
368
        $opt   = [];
369
        $opt[] = [
370
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=1',
371
            'title'    => _CPADMIN_GENERAL,
372
            'absolute' => 1,
373
            'icon'     => 'fas fa-cog'];
374
        $opt[] = [
375
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=2',
376
            'title'    => _CPADMIN_USERSETTINGS,
377
            'absolute' => 1,
378
            'icon'     => 'fas fa-cog'];
379
        $opt[] = [
380
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=3',
381
            'title'    => _CPADMIN_METAFOOTER,
382
            'absolute' => 1,
383
            'icon'     => 'fas fa-cog'];
384
        $opt[] = [
385
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=4',
386
            'title'    => _CPADMIN_CENSOR,
387
            'absolute' => 1,
388
            'icon'     => 'fas fa-cog'];
389
        $opt[] = [
390
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=5',
391
            'title'    => _CPADMIN_SEARCH,
392
            'absolute' => 1,
393
            'icon'     => 'fas fa-cog'];
394
        $opt[] = [
395
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=6',
396
            'title'    => _CPADMIN_MAILER,
397
            'absolute' => 1,
398
            'icon'     => 'fas fa-cog'];
399
        $opt[] = [
400
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=show&amp;confcat_id=7',
401
            'title'    => _CPADMIN_AUTHENTICATION,
402
            'absolute' => 1,
403
            'icon'     => 'fas fa-cog'];
404
        $opt[] = [
405
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=1',
406
            'title'    => _CPADMIN_MODULESETTINGS,
407
            'absolute' => 1,
408
            'icon'     => 'fas fa-cog'];
409
410
        $pref[] = [
411
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
412
            'title'    => _CPADMIN_SYSOPTIONS,
413
            'icon'     => 'fas fa-cogs',
414
            'absolute' => 1,
415
            'url'      => XOOPS_URL . '/modules/system/',
416
            'options'  => $opt];
417
        
418
        // add MODULES  Menu items
419
        /* @var XoopsModuleHandler $module_handler */
420
        $module_handler = xoops_getHandler('module');
421
        $criteria       = new CriteriaCompo();
422
        $criteria->add(new Criteria('hasadmin', 1));
423
        $criteria->add(new Criteria('isactive', 1));
424
        $criteria->setSort('mid');
425
        $mods = $module_handler->getObjects($criteria);
426
427
        /* @var XoopsGroupPermHandler $moduleperm_handler */
428
        $moduleperm_handler = xoops_getHandler('groupperm');
429
        foreach ($mods as $mod) {
430
            $rtn    = [];
431
            
432
            $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
433
            if ($sadmin && ($mod->getVar('hasnotification') || is_array($mod->getInfo('config')) || is_array($mod->getInfo('comments')))) {
434
                $rtn['link']     = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
435
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES | ENT_HTML5);
436
                $rtn['absolute'] = 1;
437
                $rtn['icon']     = 'fas fa-cogs';
438
                $pref[]          = $rtn;
439
            }
440
        }
441
        $xoopsTpl->append('prefs', [
442
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
443
            'text' => _CPADMIN_SITEPREF,
444
            'icon' => 'fa fa-wrench',
445
            'dir'  => $mod->getVar('dirname', 'n'),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $mod seems to be defined by a foreach iteration on line 429. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
446
            'menu' => $pref]);
447
        /*$xoopsTpl->append('preferences', array(
448
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
449
            'text' => '<span class="fa fa-wrench"></span> ' . _CPADMIN_SITEPREF,
450
            //'dir'  => $mod->getVar('dirname', 'n'),
451
            'menu' => $pref));*/
452
    }
453
454
    /**
455
     * Get the server configuration
456
     */
457
    public function getServerConfig() {
458
        global $xoopsDB, $xoopsTpl;
459
460
        $xoopsTpl->assign('lang_php_version', PHP_VERSION);
461
        $xoopsTpl->assign('lang_smarty_version', $xoopsTpl::SMARTY_VERSION);
462
        $xoopsTpl->assign('lang_mysql_version', mysqli_get_server_info($xoopsDB->conn));
463
        $xoopsTpl->assign('lang_server_api', PHP_SAPI);
464
        $xoopsTpl->assign('lang_os_name', PHP_OS);
465
        $xoopsTpl->assign('allow_url_fopen', ini_get('allow_url_fopen') ? 'On' : 'Off');
466
        $xoopsTpl->assign('fsockopen', function_exists('fsockopen') ? 'On' : 'Off');
467
        $xoopsTpl->assign('post_max_size', ini_get('post_max_size'));
468
        $xoopsTpl->assign('max_input_time', ini_get('max_input_time'));
469
        $xoopsTpl->assign('output_buffering', ini_get('output_buffering'));
470
        $xoopsTpl->assign('max_execution_time', ini_get('max_execution_time'));
471
        $xoopsTpl->assign('memory_limit', ini_get('memory_limit'));
472
        $xoopsTpl->assign('file_uploads', ini_get('file_uploads') ? 'On' : 'Off');
473
        $xoopsTpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
474
    }
475
476
477
478
}
479