Passed
Push — master ( d15df8...324677 )
by
unknown
10:16
created

XoopsGuiCpadmin   C

Complexity

Total Complexity 55

Size/Duplication

Total Lines 438
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 296
c 1
b 0
f 0
dl 0
loc 438
rs 6
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 137 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 $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 server configuration
107
        $this->getServerConfig();
108
109
        // Add Composer packages versions
110
        ComposerInfo::getComposerInfo($tpl);
111
112
        // Add System menu items
113
        $this->getAdminMenu();
114
115
        // Get module list
116
        $this->getModules();
117
118
        // Get preferences
119
        $this->getPreferences();
120
121
        // add MODULES  Menu items
122
        /* @var XoopsModuleHandler $module_handler */
123
        $module_handler = xoops_getHandler('module');
124
        $criteria       = new CriteriaCompo();
125
        $criteria->add(new Criteria('hasadmin', 1));
126
        $criteria->add(new Criteria('isactive', 1));
127
        $criteria->setSort('mid');
128
        $mods = $module_handler->getObjects($criteria);
129
130
        $menu               = [];
131
        /* @var XoopsGroupPermHandler $moduleperm_handler */
132
        $moduleperm_handler = xoops_getHandler('groupperm');
133
        foreach ($mods as $mod) {
134
            $rtn        = [];
135
            $modOptions = [];                                                         //add for sub menus
136
            $sadmin     = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
137
138
            if ($sadmin) {
139
                $info = $mod->getInfo();
140
                if (!empty($info['adminindex'])) {
141
                    $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex'];
142
                } else {
143
                    $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
144
                }
145
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES);
146
                $rtn['absolute'] = 1;
147
                $rtn['url']      = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus
148
                $modOptions      = $mod->getAdminMenu();                                        //add for sub menus
149
                $rtn['options']  = $modOptions;                                             //add for sub menus
150
151
                if (isset($info['icon']) && $info['icon'] !== '') {
152
                    $rtn['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['icon'];
153
                }
154
                $menu[] = $rtn;
155
            }
156
        }
157
        $tpl->append('navitems', [
158
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin',
159
            'text' => '<span class="fa fa-puzzle-piece"></span> ' . _AM_SYSTEM_MODULES,
160
            '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 133. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
161
            'menu' => $menu]);
162
        
163
        //add OPTIONS/links for local support
164
        if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/transition/language/' . $xoopsConfig['language'] . '/localsupport.php')) {
165
            $links = include XOOPS_ADMINTHEME_PATH . '/transition/language/' . $xoopsConfig['language'] . '/localsupport.php';
166
            if (count($links) > 0) {
167
                $tpl->append('navitems', ['link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_LOCALSUPPORT, 'menu' => $links]);
168
            }
169
        }
170
171
        if (is_object($xoopsModule) || !empty($_GET['xoopsorgnews'])) {
172
            if (is_object($xoopsModule) && file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('adminmenu'))) {
173
                include $file;
174
            }
175
176
            return null;
177
        }
178
        
179
    }
180
181
    /**
182
     * Get all system menu item
183
     */
184
    public function getAdminMenu() {
185
        global $xoopsConfig, $xoopsUser, $xoopsModule, $xoTheme, $xoopsTpl, $xoopsDB;
186
187
        include_once $GLOBALS['xoops']->path('/modules/system/constants.php');
188
189
        $groups = $xoopsUser->getGroups();
190
        $all_ok = false;
191
        if (!in_array(XOOPS_GROUP_ADMIN, $groups)) {
192
            $sysperm_handler = xoops_getHandler('groupperm');
193
            $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

193
            /** @scrutinizer ignore-call */ 
194
            $ok_syscats      = $sysperm_handler->getItemIds('system_admin', $groups);
Loading history...
194
        } else {
195
            $all_ok = true;
196
        }
197
198
        xoops_load('xoopslists');
199
200
        $admin_dir        = XOOPS_ROOT_PATH . '/modules/system/admin';
201
        $dirlist          = XoopsLists::getDirListAsArray($admin_dir);
202
        $inactive_section = ['blocksadmin', 'groups', 'modulesadmin', 'preferences', 'tplsets'];
203
        foreach ($dirlist as $directory) {
204
            if (file_exists($admin_dir . '/' . $directory . '/xoops_version.php')) {
205
                require $admin_dir . '/' . $directory . '/xoops_version.php';
206
207
                if ($modversion['hasAdmin']) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $modversion seems to be never defined.
Loading history...
208
                    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

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