adslightMaps()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 58
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 41
c 0
b 0
f 0
dl 0
loc 58
rs 9.264
cc 4
nc 4
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project (https://xoops.org)
15
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       XOOPS Development Team
17
 * @author       Pascal Le Boustouller: original author ([email protected])
18
 * @author       Luc Bizet (www.frxoops.org)
19
 * @author       jlm69 (www.jlmzone.com)
20
 * @author       mamba (www.xoops.org)
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Adslight\{
25
    Helper
26
};
27
28
require_once __DIR__ . '/header.php';
29
//require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
30
global $xoopsModule;
31
32
$myts     = \MyTextSanitizer::getInstance();
33
$moduleId = $xoopsModule->getVar('mid');
34
35
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
36
/** @var \XoopsGroupPermHandler $grouppermHandler */
37
$grouppermHandler = xoops_getHandler('groupperm');
38
$perm_itemid      = Request::getInt('item_id', 0, 'POST');
39
//If no access
40
if (!$grouppermHandler->checkRight('adslight_view', $perm_itemid, $groups, $moduleId)) {
41
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
42
}
43
$prem_perm = $grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $moduleId) ? '1' : '0';
44
45
#  function adslightMaps
46
#####################################################
47
function adslightMaps(): void
48
{
49
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $prem_perm;
50
51
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
52
    $helper                                  = Helper::getInstance();
53
54
    require_once XOOPS_ROOT_PATH . '/header.php';
55
56
    $GLOBALS['xoopsTpl']->assign('xmid', $xoopsModule->getVar('mid'));
57
    $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
58
    $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
59
    $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
60
    $GLOBALS['xoopsTpl']->assign('search_listings', _ADSLIGHT_SEARCH_LISTINGS);
61
    $GLOBALS['xoopsTpl']->assign('all_words', _ADSLIGHT_ALL_WORDS);
62
    $GLOBALS['xoopsTpl']->assign('any_words', _ADSLIGHT_ANY_WORDS);
63
    $GLOBALS['xoopsTpl']->assign('exact_match', _ADSLIGHT_EXACT_MATCH);
64
    $GLOBALS['xoopsTpl']->assign('only_pix', _ADSLIGHT_ONLYPIX);
65
    $GLOBALS['xoopsTpl']->assign('search', _ADSLIGHT_SEARCH);
66
    $GLOBALS['xoopsTpl']->assign('permit', $prem_perm);
67
    $GLOBALS['xoopsTpl']->assign('imgscss', XOOPS_URL . '/modules/adslight/assets/css/adslight.css');
68
    $GLOBALS['xoopsTpl']->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
69
70
    $GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow');
71
72
    $header_cssadslight = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >';
73
74
    $GLOBALS['xoopsTpl']->assign('xoops_module_header', $header_cssadslight);
75
76
    $maps_name   = $helper->getConfig('adslight_maps_set');
77
    $maps_width  = $helper->getConfig('adslight_maps_width');
78
    $maps_height = $helper->getConfig('adslight_maps_height');
79
80
    $GLOBALS['xoopsTpl']->assign('maps_name', $maps_name);
81
    $GLOBALS['xoopsTpl']->assign('maps_width', $maps_width);
82
    $GLOBALS['xoopsTpl']->assign('maps_height', $maps_height);
83
84
    $GLOBALS['xoopsTpl']->assign('adlight_maps_title', _ADSLIGHT_MAPS_TITLE);
85
    $GLOBALS['xoopsTpl']->assign('bullinfotext', _ADSLIGHT_MAPS_TEXT);
86
87
    // adslight 2
88
    $GLOBALS['xoopsTpl']->assign('adslight_active_menu', $helper->getConfig('adslight_active_menu'));
89
    $GLOBALS['xoopsTpl']->assign('adslight_active_rss', $helper->getConfig('adslight_active_rss'));
90
91
    if ($GLOBALS['xoopsUser']) {
92
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
93
        if ($usid = $member_usid) {
0 ignored issues
show
Unused Code introduced by
The assignment to $usid is dead and can be removed.
Loading history...
94
            $GLOBALS['xoopsTpl']->assign('istheirs', true);
95
96
            $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid={$member_usid}";
97
            $result = $xoopsDB->query($sql);
98
            if (!$xoopsDB->isResultSet($result)) {
99
                \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
100
            }
101
            [$show_user] = $xoopsDB->fetchRow($result);
102
103
            $GLOBALS['xoopsTpl']->assign('show_user', $show_user);
104
            $GLOBALS['xoopsTpl']->assign('show_user_link', "members.php?usid={$member_usid}");
105
        }
106
    }
107
}
108
109
######################################################
110
111
$pa                                      = Request::getInt('pa', null, 'GET');
112
$GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
113
adslightMaps();
114
//break;
115
require_once XOOPS_ROOT_PATH . '/footer.php';
116