Passed
Push — master ( c46329...5f3a00 )
by Richard
06:51 queued 10s
created

XoopsGuiDark::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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-2016 XOOPS Project (www.xoops.org)
18
 * @license     GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @package     system
20
 * @usbpackage  GUI
21
 * @since       2.4
22
 * @author      Mamba       <[email protected]>
23
 * @author      Mojtabajml  <[email protected]>
24
 * @author      Voltan      <[email protected]>
25
 * @author      BitC3R0     <[email protected]>
26
 * @author      trabis      <[email protected]>
27
 */
28
29
/**
30
 * Class XoopsGuiDark
31
 */
32
class XoopsGuiDark extends XoopsSystemGui
33
{
34
    /**
35
     *
36
     */
37
    /*
38
    public function __construct()
39
    {
40
        // Check cookie
41
        $used = isset($_COOKIE['transition_theme']) ? $_COOKIE['transition_theme'] : 0;
42
43
        if(0 == $used){
44
45
            setcookie('transition_theme', 1, time() + (86400*365), '/', null, null, true);
46
47
            header('location: ' . XOOPS_URL . '/admin.php?show=info');
48
            die();
49
        }
50
    }
51
    */
52
    /**
53
     * @return bool
54
     */
55
    public static function validate()
56
    {
57
        return true;
58
    }
59
60
    public function header()
61
    {
62
        parent::header();
63
64
        global $xoopsConfig, $xoopsUser, $xoopsModule, $xoTheme, $xoopsTpl, $xoopsDB;
65
        $tpl =& $this->template;
66
67
        // Determine if information box must be shown
68
        $currentScript = str_replace(XOOPS_ROOT_PATH . '/', '', $_SERVER['SCRIPT_FILENAME']);
69
70
        if('admin.php' == $currentScript){
71
            $show = isset($_GET['show']) ? $_GET['show'] : '';
72
            if('info' == $show){
73
                $tpl->assign('showTransitionInfo', true);
74
            }
75
        }
76
77
        $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

77
        $iconsSet = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('typeicons', 'system');
Loading history...
78
79
        if ($iconsSet == '') {
80
            $icons = 'transition';
81
        }
82
83
        $tpl->assign('theme_icons', XOOPS_URL . '/modules/system/images/icons/' . $iconsSet);
84
85
        // language
86
        $tpl->assign('xoops_language', $xoopsConfig['language']);
87
88
        $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
89
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/styleswitch.js');
90
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/formenu.js');
91
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/menu.js');
92
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tooltip.js');
93
//        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.jquery.tools.min.js');
94
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.js');
95
        $xoTheme->addScript(XOOPS_ADMINTHEME_URL . '/dark/js/tabs.slideshow.js');
96
97
        $xoTheme->addStylesheet('https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i|Roboto:300,300i,400,400i,700,700i');
98
//        $xoTheme->addStylesheet('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
99
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/style.css');
100
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/dark.css', array('title' => 'dark', 'media' => 'screen'));
101
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/silver.css', array('title' => 'silver', 'media' => 'screen'));
102
        $xoTheme->addStylesheet(XOOPS_ADMINTHEME_URL . '/dark/css/orange.css', array('title' => 'orange', 'media' => 'screen'));
103
104
        $tpl->assign('lang_cp', _CPHOME);
105
        //start system overview
106
        //$tpl->assign('lang_xoops_version', XOOPS_VERSION);
107
        $tpl->assign('lang_php_vesion', PHP_VERSION);
108
        $tpl->assign('lang_mysql_version', mysqli_get_server_info($xoopsDB->conn));
109
        $tpl->assign('lang_server_api', PHP_SAPI);
110
        $tpl->assign('lang_os_name', PHP_OS);
111
//        $tpl->assign('safe_mode', ini_get('safe_mode') ? 'On' : 'Off');
112
//        $tpl->assign('register_globals', ini_get('register_globals') ? 'On' : 'Off');
113
//        $tpl->assign('magic_quotes_gpc', ini_get('magic_quotes_gpc') ? 'On' : 'Off');
114
        $tpl->assign('allow_url_fopen', ini_get('allow_url_fopen') ? 'On' : 'Off');
115
        $tpl->assign('fsockopen', function_exists('fsockopen') ? 'On' : 'Off');
116
//        $tpl->assign('allow_call_time_pass_reference', ini_get('allow_call_time_pass_reference') ? 'On' : 'Off');
117
        $tpl->assign('post_max_size', ini_get('post_max_size'));
118
        $tpl->assign('max_input_time', ini_get('max_input_time'));
119
        $tpl->assign('output_buffering', ini_get('output_buffering'));
120
        $tpl->assign('max_execution_time', ini_get('max_execution_time'));
121
        $tpl->assign('memory_limit', ini_get('memory_limit'));
122
        $tpl->assign('file_uploads', ini_get('file_uploads') ? 'On' : 'Off');
123
        $tpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
124
        $tpl->assign('xoops_sitename', $xoopsConfig['sitename']);
125
126
        // ADD MENU *****************************************
127
128
        //Add  CONTROL PANEL  Menu  items
129
        $menu                = array();
130
        $menu[0]['link']     = XOOPS_URL;
131
        $menu[0]['title']    = "<span class='fa fa-home'></span> " . _YOURHOME;
132
        $menu[0]['absolute'] = 1;
133
        $menu[1]['link']     = XOOPS_URL . '/admin.php?xoopsorgnews=1';
134
        $menu[1]['title']    = "<span class='fa fa-newspaper-o'></span> " . _OXYGEN_NEWS;
135
        $menu[1]['absolute'] = 1;
136
        $menu[1]['icon']     = XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png';
137
        $menu[2]['link']     = XOOPS_URL . '/user.php?op=logout';
138
        $menu[2]['title']    = "<span class='fa fa-sign-out'></span> " . _LOGOUT;
139
        $menu[2]['absolute'] = 1;
140
        $menu[2]['icon']     = XOOPS_ADMINTHEME_URL . '/dark/images/logout.png';
141
        $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-cog"></span> ' . _CPHOME, 'menu' => $menu));
142
143
        //add SYSTEM  Menu items
144
        include __DIR__ . '/menu.php';
145
        if (empty($xoopsModule) || 'system' === $xoopsModule->getVar('dirname', 'n')) {
146
            $modpath = XOOPS_URL . '/admin.php';
147
            $modname = _OXYGEN_SYSOPTIONS;
148
            $modid   = 1;
149
            $moddir  = 'system';
150
151
            $mod_options = $adminmenu;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $adminmenu seems to be never defined.
Loading history...
152
            foreach (array_keys($mod_options) as $item) {
153
                $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . '/modules/' . $moddir . '/' . $mod_options[$item]['link'] : $mod_options[$item]['link'];
154
                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . '/modules/system/images/' . $mod_options[$item]['icon'];
155
                unset($mod_options[$item]['icon_small']);
156
            }
157
        } else {
158
            $moddir  = $xoopsModule->getVar('dirname', 'n');
159
            $modpath = XOOPS_URL . '/modules/' . $moddir;
160
            $modname = $xoopsModule->getVar('name');
161
            $modid   = $xoopsModule->getVar('mid');
162
163
            $mod_options = $xoopsModule->getAdminMenu();
164
            foreach (array_keys($mod_options) as $item) {
165
                $mod_options[$item]['link'] = empty($mod_options[$item]['absolute']) ? XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['link'] : $mod_options[$item]['link'];
166
                //                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['icon'];
167
                //mb for direct URL access to icons in modules Admin
168
                $mod_options[$item]['icon'] = empty($mod_options[$item]['icon']) ? '' : (filter_var($mod_options[$item]['icon'], FILTER_VALIDATE_URL) ? $mod_options[$item]['icon'] : (XOOPS_URL . "/modules/{$moddir}/" . $mod_options[$item]['icon']));
169
            }
170
        }
171
172
        $tpl->assign('mod_options', $mod_options);
173
        $tpl->assign('modpath', $modpath);
174
        $tpl->assign('modname', $modname);
175
        $tpl->assign('modid', $modid);
176
        $tpl->assign('moddir', $moddir);
177
178
        // add MODULES  Menu items
179
        /* @var XoopsModuleHandler $module_handler */
180
        $module_handler = xoops_getHandler('module');
181
        $criteria       = new CriteriaCompo();
182
        $criteria->add(new Criteria('hasadmin', 1));
183
        $criteria->add(new Criteria('isactive', 1));
184
        $criteria->setSort('mid');
185
        $mods = $module_handler->getObjects($criteria);
186
187
        $menu               = array();
188
        /* @var XoopsGroupPermHandler $moduleperm_handler */
189
        $moduleperm_handler = xoops_getHandler('groupperm');
190
        foreach ($mods as $mod) {
191
            $rtn        = array();
192
            $modOptions = array();                                                         //add for sub menus
193
            $sadmin     = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
194
            if ($sadmin) {
195
                $info = $mod->getInfo();
196
                if (!empty($info['adminindex'])) {
197
                    $rtn['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['adminindex'];
198
                } else {
199
                    $rtn['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
200
                }
201
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES);
202
                $rtn['absolute'] = 1;
203
                $rtn['url']      = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/'; //add for sub menus
204
                $modOptions      = $mod->getAdminMenu();                                        //add for sub menus
205
                $rtn['options']  = $modOptions;                                             //add for sub menus
206
207
                if (isset($info['icon']) && $info['icon'] !== '') {
208
                    $rtn['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info['icon'];
209
                }
210
                $menu[] = $rtn;
211
            }
212
        }
213
        $tpl->append('navitems', array(
214
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin',
215
            'text' => '<span class="fa fa-puzzle-piece"></span> ' . _AM_SYSTEM_MODULES,
216
            '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 190. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
217
            'menu' => $menu));
218
219
        // add preferences menu
220
        $menu = array();
221
222
        $OPT   = array();
223
        $OPT[] = array(
224
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=1',
225
            'title'    => _OXYGEN_GENERAL,
226
            'absolute' => 1,
227
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
228
        $OPT[] = array(
229
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=2',
230
            'title'    => _OXYGEN_USERSETTINGS,
231
            'absolute' => 1,
232
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
233
        $OPT[] = array(
234
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=3',
235
            'title'    => _OXYGEN_METAFOOTER,
236
            'absolute' => 1,
237
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
238
        $OPT[] = array(
239
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=4',
240
            'title'    => _OXYGEN_CENSOR,
241
            'absolute' => 1,
242
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
243
        $OPT[] = array(
244
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=5',
245
            'title'    => _OXYGEN_SEARCH,
246
            'absolute' => 1,
247
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
248
        $OPT[] = array(
249
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=6',
250
            'title'    => _OXYGEN_MAILER,
251
            'absolute' => 1,
252
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
253
        $OPT[] = array(
254
            'link'     => 'admin.php?fct=preferences&amp;op=show&amp;confcat_id=7',
255
            'title'    => _OXYGEN_AUTHENTICATION,
256
            'absolute' => 1,
257
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
258
        $OPT[] = array(
259
            'link'     => 'admin.php?fct=preferences&amp;op=showmod&amp;mod=1',
260
            'title'    => _OXYGEN_MODULESETTINGS,
261
            'absolute' => 1,
262
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/icons/prefs_small.png');
263
264
        $menu[] = array(
265
            'link'     => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
266
            'title'    => _OXYGEN_SYSOPTIONS,
267
            'absolute' => 1,
268
            'url'      => XOOPS_URL . '/modules/system/',
269
            'options'  => $OPT);
270
271
        foreach ($mods as $mod) {
272
            $rtn    = array();
273
            $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
274
            if ($sadmin && ($mod->getVar('hasnotification') || is_array($mod->getInfo('config')) || is_array($mod->getInfo('comments')))) {
275
                $rtn['link']     = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
276
                $rtn['title']    = htmlspecialchars($mod->name(), ENT_QUOTES);
277
                $rtn['absolute'] = 1;
278
                $rtn['icon']     = XOOPS_ADMINTHEME_URL . '/gui/oxygen/icons/prefs_small.png';
279
                $menu[]          = $rtn;
280
            }
281
        }
282
        $tpl->append('navitems', array(
283
            'link' => XOOPS_URL . '/modules/system/admin.php?fct=preferences',
284
            'text' => '<span class="fa fa-wrench"></span> ' . _OXYGEN_SITEPREF,
285
            'dir'  => $mod->getVar('dirname', 'n'),
286
            'menu' => $menu));
287
288
        //add OPTIONS/Links Menu Items
289
        $menu   = array();
290
        $menu[] = array(
291
            'link'     => 'http://xoops.org',
292
            'title'    => _OXYGEN_XOOPSPROJECT,
293
            'absolute' => 1);
294
        $menu[] = array(
295
            'link'     => 'http://xoops.org',
296
            'title'    => _OXYGEN_WEBSITE,
297
            'absolute' => 1,
298
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png');
299
        $menu[] = array(
300
            'link'     => 'http://www.xoops.org/modules/repository/',
301
            'title'    => _OXYGEN_XOOPSMODULES,
302
            'absolute' => 1,
303
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/xoops.png');
304
        $menu[] = array(
305
            'link'     => 'http://www.xoops.org/modules/extgallery/',
306
            'title'    => _OXYGEN_XOOPSTHEMES,
307
            'absolute' => 1,
308
            'icon'     => XOOPS_ADMINTHEME_URL . '/dark/images/tweb.png');
309
310
        $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_INTERESTSITES, 'menu' => $menu));
311
312
        //add OPTIONS/links for local support
313
        if (file_exists($file = XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php')) {
314
            $links = include XOOPS_ADMINTHEME_PATH . '/dark/language/' . $xoopsConfig['language'] . '/localsupport.php';
315
            if (count($links) > 0) {
316
                $tpl->append('navitems', array('link' => XOOPS_URL . '/admin.php', 'text' => '<span class="fa fa-link"></span> ' . _OXYGEN_LOCALSUPPORT, 'menu' => $links));
317
            }
318
        }
319
320
        if (is_object($xoopsModule) || !empty($_GET['xoopsorgnews'])) {
321
            if (is_object($xoopsModule) && file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('adminmenu'))) {
322
                include $file;
323
            }
324
325
            return null;
326
        }
327
328
        foreach ($mods as $mod) {
329
            $sadmin = $moduleperm_handler->checkRight('module_admin', $mod->getVar('mid'), $xoopsUser->getGroups());
330
            if ($sadmin) {
331
                $rtn  = array();
332
                $info = $mod->getInfo();
333
                if (!empty($info ['adminindex'])) {
334
                    $rtn ['link'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['adminindex'];
335
                } else {
336
                    $rtn ['link'] = XOOPS_URL . '/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mod->getVar('mid');
337
                }
338
                $rtn ['title']       = htmlspecialchars($mod->getVar('name'), ENT_QUOTES);
339
                $rtn ['description'] = $mod->getInfo('description');
340
                $rtn ['absolute']    = 1;
341
                if (isset($info ['icon_big'])) {
342
                    $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['icon_big'];
343
                } elseif (isset($info ['image'])) {
344
                    $rtn ['icon'] = XOOPS_URL . '/modules/' . $mod->getVar('dirname', 'n') . '/' . $info ['image'];
345
                }
346
347
                $tpl->append('modules', $rtn);
348
            }
349
        }
350
    }
351
}
352