Completed
Push — master ( c1777d...d193e2 )
by Michael
13:22
created

myblocksadmin.php ➔ list_groups()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 22
Code Lines 16

Duplication

Lines 4
Ratio 18.18 %

Importance

Changes 0
Metric Value
cc 4
eloc 16
nc 8
nop 0
dl 4
loc 22
rs 8.9197
c 0
b 0
f 0
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 86 and the first side effect is on line 8.

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
//                            myblocksadmin.php                              //
4
//                - XOOPS block admin for each modules -                     //
5
//                          GIJOE <http://www.peak.ne.jp/>                   //
6
// ------------------------------------------------------------------------- //
7
8
include_once __DIR__ . '/../../../include/cp_header.php';
9
10
if (false !== strpos(XOOPS_VERSION, 'XOOPS 2.2')) {
11
    include __DIR__ . '/myblocksadmin2.php';
12
    exit;
13
}
14
15
include_once __DIR__ . '/mygrouppermform.php';
16
include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
17
include_once __DIR__ . '/../include/gtickets.php';// GIJ
18
19
$xoops_system_path = XOOPS_ROOT_PATH . '/modules/system';
20
21
// language files
22
$language = $xoopsConfig['language'];
23
if (!file_exists("$xoops_system_path/language/$language/admin/blocksadmin.php")) {
24
    $language = 'english';
25
}
26
27
// to prevent from notice that constants already defined
28
$error_reporting_level = error_reporting(0);
29
include_once "$xoops_system_path/constants.php";
30
include_once "$xoops_system_path/language/$language/admin.php";
31
include_once "$xoops_system_path/language/$language/admin/blocksadmin.php";
32
33
error_reporting($error_reporting_level);
34
35
$group_defs = file("$xoops_system_path/language/$language/admin/groups.php");
36 View Code Duplication
foreach ($group_defs as $def) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    if (true === strpos($def, '_AM_ACCESSRIGHTS') || true === strpos($def, '_AM_ACTIVERIGHTS')) {
38
        eval($def);
39
    }
40
}
41
// check $xoopsModule
42
if (!is_object($xoopsModule)) {
43
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
44
}
45
46
// set target_module if specified by $_GET['dirname']
47
/** @var XoopsModuleHandler $moduleHandler */
48
$moduleHandler = xoops_getHandler('module');
49
if (!empty($_GET['dirname'])) {
50
    $target_module = $moduleHandler->getByDirname($_GET['dirname']);
51
}/* else if ( ! empty( $_GET['mid'] ) ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
52
    $target_module = $moduleHandler->get( (int)( $_GET['mid'] ) );
53
}*/
54
55 View Code Duplication
if (!empty($target_module) && is_object($target_module)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    // specified by dirname
57
    $target_mid     = $target_module->getVar('mid');
58
    $target_mname   = $target_module->getVar('name') . '&nbsp;' . sprintf('(%2.2f)', $target_module->getVar('version') / 100.0);
59
    $query4redirect = '?dirname=' . urlencode(strip_tags($_GET['dirname']));
60
} elseif (isset($_GET['mid']) && $_GET['mid'] == 0 || $xoopsModule->getVar('dirname') === 'blocksadmin') {
61
    $target_mid     = 0;
62
    $target_mname   = '';
63
    $query4redirect = '?mid=0';
64
} else {
65
    $target_mid     = $xoopsModule->getVar('mid');
66
    $target_mname   = $xoopsModule->getVar('name');
67
    $query4redirect = '';
68
}
69
70
// check access right (needs system_admin of BLOCK)
71
$syspermHandler = xoops_getHandler('groupperm');
72 View Code Duplication
if (!$syspermHandler->checkRight('system_admin', XOOPS_SYSTEM_BLOCK, $xoopsUser->getGroups())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
74
}
75
76
// get blocks owned by the module (Imported from xoopsblock.php then modified)
77
//$block_arr = XoopsBlock::getByModule( $target_mid ) ;
78
$db        = XoopsDatabaseFactory::getDatabaseConnection();
79
$sql       = 'SELECT * FROM ' . $db->prefix('newblocks') . " WHERE mid='$target_mid' ORDER BY visible DESC,side,weight";
80
$result    = $db->query($sql);
81
$block_arr = array();
82
while ($myrow = $db->fetchArray($result)) {
83
    $block_arr[] = new XoopsBlock($myrow);
84
}
85
86
function list_blocks()
87
{
88
    global $query4redirect, $block_arr, $xoopsGTicket;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
89
90
    // cachetime options
91
    $cachetimes = array(
92
        '0'       => _NOCACHE,
93
        '30'      => sprintf(_SECONDS, 30),
94
        '60'      => _MINUTE,
95
        '300'     => sprintf(_MINUTES, 5),
96
        '1800'    => sprintf(_MINUTES, 30),
97
        '3600'    => _HOUR,
98
        '18000'   => sprintf(_HOURS, 5),
99
        '86400'   => _DAY,
100
        '259200'  => sprintf(_DAYS, 3),
101
        '604800'  => _WEEK,
102
        '2592000' => _MONTH
103
    );
104
105
    // displaying TH
106
    lx_collapsableBar('default', 'defaultIcon');
107
    echo "<img  onclick=\"toggle('default'); toggleIcon('defaultIcon');\" id='defaultIcon' src='"
108
         . XOOPS_URL
109
         . "/modules/lexikon/assets/images/close12.gif' alt='' /></a>&nbsp; "
110
         . _AM_BADMIN
111
         . '<br><br>';
112
    echo "<div id='default' style='float:left; width:100%;'>";
113
    echo "
114
    <form action='admin.php' name='blockadmin' method='post'>
115
        <table width='95%' class='outer' cellpadding='4' cellspacing='1'>
116
        <tr valign='middle'>
117
            <th>" . _AM_TITLE . "</th>
118
            <th align='center' nowrap='nowrap'>" . _AM_SIDE . "<div style='font-size:smaller;'>" . _LEFT . '-' . _CENTER . '-' . _RIGHT . "</div></th>
119
            <th align='center'>" . _AM_WEIGHT . "</th>
120
            <th align='center'>" . _AM_VISIBLEIN . "</th>
121
            <th align='center'>" . _AM_BCACHETIME . "</th>
122
            <th align='right'>" . _AM_ACTION . "</th>
123
        </tr>\n";
124
125
    // blocks displaying loop
126
    $class         = 'even';
127
    $block_configs = get_block_configs();
128
    foreach (array_keys($block_arr) as $i) {
129
        $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = '';
0 ignored issues
show
Unused Code introduced by
$ssel7 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...
Unused Code introduced by
$ssel6 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...
Unused Code introduced by
$ssel5 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...
130
        $scoln = $scol0 = $scol1 = $scol2 = $scol3 = $scol4 = $ssel5 = $ssel6 = $ssel7 = '';
0 ignored issues
show
Unused Code introduced by
$scol4 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...
Unused Code introduced by
$scol3 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...
Unused Code introduced by
$scol2 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...
Unused Code introduced by
$scol1 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...
Unused Code introduced by
$scol0 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...
131
132
        $weight     = $block_arr[$i]->getVar('weight');
133
        $title      = $block_arr[$i]->getVar('title');
134
        $name       = $block_arr[$i]->getVar('name');
135
        $bcachetime = $block_arr[$i]->getVar('bcachetime');
136
        $bid        = $block_arr[$i]->getVar('bid');
137
138
        // visible and side
139
        if ($block_arr[$i]->getVar('visible') != 1) {
140
            $sseln = ' checked';
141
            $scoln = '#FF9966';
142
        } else {
143
            switch ($block_arr[$i]->getVar('side')) {
144
                default:
145
                case XOOPS_SIDEBLOCK_LEFT:
146
                    $ssel0 = ' checked';
147
                    $scol0 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol0 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...
148
                    break;
149
                case XOOPS_SIDEBLOCK_RIGHT:
150
                    $ssel1 = ' checked';
151
                    $scol1 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol1 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...
152
                    break;
153
                case XOOPS_CENTERBLOCK_LEFT:
154
                    $ssel2 = ' checked';
155
                    $scol2 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol2 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...
156
                    break;
157
                case XOOPS_CENTERBLOCK_RIGHT:
158
                    $ssel4 = ' checked';
159
                    $scol4 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol4 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...
160
                    break;
161
                case XOOPS_CENTERBLOCK_CENTER:
162
                    $ssel3 = ' checked';
163
                    $scol3 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol3 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...
164
                    break;
165
                case XOOPS_CENTERBLOCK_BOTTOMLEFT:
166
                    $ssel5 = ' checked';
167
                    $scol5 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol5 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...
168
                    break;
169
                case XOOPS_CENTERBLOCK_BOTTOMRIGHT:
170
                    $ssel6 = ' checked';
171
                    $scol6 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol6 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...
172
                    break;
173
                case XOOPS_CENTERBLOCK_BOTTOM:
174
                    $ssel7 = ' checked';
175
                    $scol7 = '#00FF00';
0 ignored issues
show
Unused Code introduced by
$scol7 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...
176
                    break;
177
            }
178
        }
179
180
        // bcachetime
181
        $cachetime_options = '';
182 View Code Duplication
        foreach ($cachetimes as $cachetime => $cachetime_name) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
183
            if ($bcachetime == $cachetime) {
184
                $cachetime_options .= "<option value='$cachetime' selected>$cachetime_name</option>\n";
185
            } else {
186
                $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n";
187
            }
188
        }
189
190
        // target modules
191
        $db            = XoopsDatabaseFactory::getDatabaseConnection();
192
        $result        = $db->query('SELECT module_id FROM ' . $db->prefix('block_module_link') . " WHERE block_id='$bid'");
193
        $selected_mids = array();
194
        while (list($selected_mid) = $db->fetchRow($result)) {
195
            $selected_mids[] = (int)$selected_mid;
196
        }
197
        /** @var XoopsModuleHandler $moduleHandler */
198
        $moduleHandler = xoops_getHandler('module');
199
        $criteria      = new CriteriaCompo(new Criteria('hasmain', 1));
200
        $criteria->add(new Criteria('isactive', 1));
201
        $module_list     = $moduleHandler->getList($criteria);
202
        $module_list[-1] = _AM_TOPPAGE;
203
        $module_list[0]  = _AM_ALLPAGES;
204
        ksort($module_list);
205
        $module_options = '';
206
        foreach ($module_list as $mid => $mname) {
207
            if (in_array($mid, $selected_mids)) {
208
                $module_options .= "<option value='$mid' selected>$mname</option>\n";
209
            } else {
210
                $module_options .= "<option value='$mid'>$mname</option>\n";
211
            }
212
        }
213
214
        // delete link if it is cloned block
215
        if ($block_arr[$i]->getVar('block_type') === 'D' || $block_arr[$i]->getVar('block_type') === 'C') {
216
            $delete_link = "<br><a href='admin.php?fct=blocksadmin&amp;op=delete&amp;bid=$bid'>" . _DELETE . '</a>';
217
        } else {
218
            $delete_link = '';
219
        }
220
221
        // clone link if it is marked as cloneable block
222
        // $modversion['blocks'][n]['can_clone']
0 ignored issues
show
Unused Code Comprehensibility introduced by
82% 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...
223
        if ($block_arr[$i]->getVar('block_type') === 'D' || $block_arr[$i]->getVar('block_type') === 'C') {
224
            $can_clone = true;
225
        } else {
226
            $can_clone = false;
227 View Code Duplication
            foreach ($block_configs as $bconf) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
228
                if ($block_arr[$i]->getVar('show_func') == $bconf['show_func']
229
                    && $block_arr[$i]->getVar('func_file') == $bconf['file']
230
                    && (empty($bconf['template'])
231
                        || $block_arr[$i]->getVar('template') == $bconf['template'])
232
                ) {
233
                    if (!empty($bconf['can_clone'])) {
234
                        $can_clone = true;
235
                    }
236
                }
237
            }
238
        }
239
        if ($can_clone) {
240
            $clone_link = "<br><a href='admin.php?fct=blocksadmin&amp;op=clone&amp;bid=$bid'>" . _CLONE . '</a>';
241
        } else {
242
            $clone_link = '';
243
        }
244
245
        // displaying part
246
        echo "
247
        <tr valign='middle'>
248
            <td class='$class'>
249
                $name
250
                <br>
251
                <input type='text' name='title[$bid]' value='$title' size='20' />
252
            </td>
253
            <td class='$class' align='center' nowrap='nowrap' width='125px'>
254
      <div align='center' >
255
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_LEFT . "'$ssel2 />
256
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_CENTER . "'$ssel3 />
257
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_RIGHT . "'$ssel4 />
258
      </div>
259
      <div>
260
        <span style='float:right;'><input type='radio' name='side[$bid]' value='" . XOOPS_SIDEBLOCK_RIGHT . "'$ssel1 /></span>
261
        <div align='left'><input type='radio' name='side[$bid]' value='" . XOOPS_SIDEBLOCK_LEFT . "'$ssel0 /></div>
262
      </div>
263
      <div align='center'>
264
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5 />
265
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7 />
266
        <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6 />
267
      </div>
268
      <br>
269
        <div style='float:left;width:30%;'>&nbsp;</div>
270
                <div style='float:left;background-color:$scoln;'>
271
                    <input type='radio' name='side[$bid]' value='-1'  $sseln />
272
                </div>
273
                <div style='float:left;'>" . _NONE . "</div>
274
            </td>
275
            <td class='$class' align='center'>
276
                <input type='text' name=weight[$bid] value='$weight' size='3' maxlength='5' style='text-align:right;' />
277
            </td>
278
            <td class='$class' align='center'>
279
                <select name='bmodule[$bid][]' size='5' multiple='multiple'>
280
                    $module_options
281
                </select>
282
            </td>
283
            <td class='$class' align='center'>
284
                <select name='bcachetime[$bid]' size='1'>
285
                    $cachetime_options
286
                </select>
287
            </td>
288
            <td class='$class' align='right'>
289
                <a href='admin.php?fct=blocksadmin&amp;op=edit&amp;bid=$bid'>" . _EDIT . "</a>{$delete_link}{$clone_link}
290
                <input type='hidden' name='bid[$bid]' value='$bid' />
291
            </td>
292
        </tr>\n";
293
294
        $class = ($class === 'even') ? 'odd' : 'even';
295
    }
296
297
    echo "
298
        <tr>
299
            <td class='foot' align='center' colspan='6'>
300
                <input type='hidden' name='query4redirect' value='$query4redirect' />
301
                <input type='hidden' name='fct' value='blocksadmin' />
302
                <input type='hidden' name='op' value='order' />
303
                " . $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'myblocksadmin') . "
304
                <input type='submit' name='submit' value='" . _SUBMIT . "' />
305
            </td>
306
        </tr>
307
        </table>
308
    </form>\n";
309
    echo '</div>';
310
}
311
312
/**
313
 * @return array
314
 */
315
function get_block_configs()
0 ignored issues
show
Coding Style introduced by
get_block_configs uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
316
{
317
    $error_reporting_level = error_reporting(0);
318
    if (preg_match('/^[.0-9a-zA-Z_-]+$/', @$_GET['dirname'])) {
319
        include __DIR__ . '/../../' . $_GET['dirname'] . '/xoops_version.php';
320
    } else {
321
        include __DIR__ . '/../xoops_version.php';
322
    }
323
    error_reporting($error_reporting_level);
324
    if (empty($modversion['blocks'])) {
0 ignored issues
show
Bug introduced by
The variable $modversion seems to never exist, and therefore empty should always return true. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
325
        return array();
326
    } else {
327
        return $modversion['blocks'];
328
    }
329
}
330
331
function list_groups()
332
{
333
    global $target_mid, $target_mname, $block_arr;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
334
    lx_collapsableBar('groups', 'groupIcon');
335
    echo "<img  onclick=\"toggle('groups'); toggleIcon('groupsIcon');\" id='groupsIcon' src='" . XOOPS_URL . "/modules/lexikon/assets/images/close12.gif' alt='' /></a>&nbsp; " . _MD_AM_ADGS . ' <br>';
336
    echo "<div id='groups' style='float:left; width:100%;'>";
337
    $item_list = array();
338
    foreach (array_keys($block_arr) as $i) {
339
        $item_list[$block_arr[$i]->getVar('bid')] = $block_arr[$i]->getVar('title');
340
    }
341
342
    $form = new MyXoopsGroupPermForm(_MD_AM_ADGS, 1, 'block_read', '');
343 View Code Duplication
    if ($target_mid > 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
344
        $form->addAppendix('module_admin', $target_mid, $target_mname . ' ' . _AM_ACTIVERIGHTS);
345
        $form->addAppendix('module_read', $target_mid, $target_mname . ' ' . _AM_ACCESSRIGHTS);
346
    }
347
    foreach ($item_list as $item_id => $item_name) {
348
        $form->addItem($item_id, $item_name);
349
    }
350
    echo $form->render();
351
    echo '</div>';
352
}
353
354 View Code Duplication
if (!empty($_POST['submit'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
355
    if (!$xoopsGTicket->check(true, 'myblocksadmin')) {
356
        redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
357
    }
358
359
    include __DIR__ . '/mygroupperm.php';
360
    redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/admin/myblocksadmin.php$query4redirect", 1, _MD_AM_DBUPDATED);
361
}
362
363
xoops_cp_header();
364
include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/admin/functions.php';
365
//lx_adminMenu(3, _AM_LEXIKON_BLOCKS);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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...
366
367
if (!empty($block_arr)) {
368
    echo "<h4 style='text-align:left;'>$target_mname : " . _AM_BADMIN . "</h4>\n";
369
    list_blocks();
370
}
371
372
list_groups();
373
xoops_cp_footer();
374