Completed
Push — master ( deac0a...054aa6 )
by Michael
01:55
created

maps.php ➔ adslightMaps()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 55
Code Lines 37

Duplication

Lines 11
Ratio 20 %

Importance

Changes 0
Metric Value
cc 3
eloc 37
nc 3
nop 0
dl 11
loc 55
rs 9.7692
c 0
b 0
f 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 51 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
use Xmf\Request;
24
25
require_once __DIR__ . '/header.php';
26
//require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
28
$myts      = MyTextSanitizer::getInstance();
29
$module_id = $xoopsModule->getVar('mid');
30
31 View Code Duplication
if (is_object($GLOBALS['xoopsUser'])) {
32
    $groups = $GLOBALS['xoopsUser']->getGroups();
33
} else {
34
    $groups = XOOPS_GROUP_ANONYMOUS;
35
}
36
/** @var XoopsGroupPermHandler $gpermHandler */
37
$gpermHandler = xoops_getHandler('groupperm');
38
$perm_itemid  = Request::getInt('item_id', 0, 'POST');
39
//If no access
40 View Code Duplication
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
41
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
42
}
43
if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
44
    $prem_perm = '0';
45
} else {
46
    $prem_perm = '1';
47
}
48
49
#  function adslightMaps
50
#####################################################
51
function adslightMaps()
52
{
53
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $mytree, $meta, $mid, $moduleDirName, $main_lang, $prem_perm;
54
55
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
56
57
    include XOOPS_ROOT_PATH . '/header.php';
58
59
    $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid'));
60
    $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
61
    $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM);
62
    $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
63
    $xoopsTpl->assign('search_listings', _ADSLIGHT_SEARCH_LISTINGS);
64
    $xoopsTpl->assign('all_words', _ADSLIGHT_ALL_WORDS);
65
    $xoopsTpl->assign('any_words', _ADSLIGHT_ANY_WORDS);
66
    $xoopsTpl->assign('exact_match', _ADSLIGHT_EXACT_MATCH);
67
    $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX);
68
    $xoopsTpl->assign('search', _ADSLIGHT_SEARCH);
69
    $xoopsTpl->assign('permit', $prem_perm);
70
    $xoopsTpl->assign('imgscss', XOOPS_URL . '/modules/adslight/assets/css/adslight.css');
71
    $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
72
73
    $GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow');
74
75
    $header_cssadslight = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >';
76
77
    $xoopsTpl->assign('xoops_module_header', $header_cssadslight);
78
79
    $maps_name   = $GLOBALS['xoopsModuleConfig']['adslight_maps_set'];
80
    $maps_width  = $GLOBALS['xoopsModuleConfig']['adslight_maps_width'];
81
    $maps_height = $GLOBALS['xoopsModuleConfig']['adslight_maps_height'];
82
83
    $xoopsTpl->assign('maps_name', $maps_name);
84
    $xoopsTpl->assign('maps_width', $maps_width);
85
    $xoopsTpl->assign('maps_height', $maps_height);
86
87
    $xoopsTpl->assign('adlight_maps_title', _ADSLIGHT_MAPS_TITLE);
88
    $xoopsTpl->assign('bullinfotext', _ADSLIGHT_MAPS_TEXT);
89
90
    // adslight 2
91
    $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
92
    $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
93
94 View Code Duplication
    if ($GLOBALS['xoopsUser']) {
95
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
96
        if ($usid = $member_usid) {
0 ignored issues
show
Unused Code introduced by
$usid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
97
            $xoopsTpl->assign('istheirs', true);
98
99
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=$member_usid"));
100
101
            $xoopsTpl->assign('show_user', $show_user);
102
            $xoopsTpl->assign('show_user_link', "members.php?usid=$member_usid");
103
        }
104
    }
105
}
106
107
######################################################
108
109
$pa = Request::getInt('pa', null, 'GET');
110
111
switch ($pa) {
112
    default:
113
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_maps.tpl';
114
        adslightMaps();
115
        break;
116
}
117
include XOOPS_ROOT_PATH . '/footer.php';
118