Completed
Push — master ( ded118...cf7347 )
by Michael
02:48
created

myblocksadmin.php ➔ list_blocks()   F

Complexity

Conditions 28
Paths 2881

Size

Total Lines 199
Code Lines 132

Duplication

Lines 12
Ratio 6.03 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 28
eloc 132
c 1
b 0
f 0
nc 2881
nop 0
dl 12
loc 199
rs 2

How to fix   Long Method    Complexity   

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 78 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( '../../../include/cp_header.php' ) ;
9
10
if (strstr(XOOPS_VERSION, "XOOPS 2.2")) {
11
    include 'myblocksadmin2.php' ;
12
    exit ;
13
}
14
15
include_once( 'mygrouppermform.php' ) ;
16
include_once( XOOPS_ROOT_PATH.'/class/xoopsblock.php' ) ;
17
include_once "../include/gtickets.php" ;// GIJ
18
19
20
$xoops_system_path = XOOPS_ROOT_PATH . '/modules/system' ;
21
22
// language files
23
$language = $xoopsConfig['language'] ;
24
if( ! file_exists( "$xoops_system_path/language/$language/admin/blocksadmin.php") ) $language = 'english' ;
25
26
// to prevent from notice that constants already defined
27
$error_reporting_level = error_reporting( 0 ) ;
28
include_once( "$xoops_system_path/constants.php" ) ;
29
include_once( "$xoops_system_path/language/$language/admin.php" ) ;
30
include_once( "$xoops_system_path/language/$language/admin/blocksadmin.php" ) ;
31
32
error_reporting( $error_reporting_level ) ;
33
34
$group_defs = file( "$xoops_system_path/language/$language/admin/groups.php" ) ;
35
foreach( $group_defs as $def ) {
36
    if( strstr( $def , '_AM_ACCESSRIGHTS' ) || strstr( $def , '_AM_ACTIVERIGHTS' ) ) eval( $def ) ;
37
}
38
// check $xoopsModule
39
if( ! is_object( $xoopsModule ) ) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ;
40
41
// set target_module if specified by $_GET['dirname']
42
$module_handler =& xoops_gethandler('module');
43
if( ! empty( $_GET['dirname'] ) ) {
44
    $target_module =& $module_handler->getByDirname($_GET['dirname']);
45
}/* 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...
46
    $target_module =& $module_handler->get( intval( $_GET['mid'] ) );
47
}*/
48
49 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...
50
    // specified by dirname
51
    $target_mid = $target_module->getVar( 'mid' ) ;
52
    $target_mname = $target_module->getVar( 'name' ) . "&nbsp;" . sprintf( "(%2.2f)" , $target_module->getVar('version') / 100.0 ) ;
53
    $query4redirect = '?dirname='.urlencode(strip_tags($_GET['dirname'])) ;
54
} else if( isset( $_GET['mid'] ) && $_GET['mid'] == 0 || $xoopsModule->getVar('dirname') == 'blocksadmin' ) {
55
    $target_mid = 0 ;
56
    $target_mname = '' ;
57
    $query4redirect = '?mid=0' ;
58
} else {
59
    $target_mid = $xoopsModule->getVar( 'mid' ) ;
60
    $target_mname = $xoopsModule->getVar( 'name' ) ;
61
    $query4redirect = '' ;
62
}
63
64
// check access right (needs system_admin of BLOCK)
65
$sysperm_handler =& xoops_gethandler('groupperm');
66 View Code Duplication
if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_BLOCK, $xoopsUser->getGroups())) redirect_header( XOOPS_URL.'/user.php' , 1 , _NOPERM ) ;
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...
67
68
// get blocks owned by the module (Imported from xoopsblock.php then modified)
69
//$block_arr =& XoopsBlock::getByModule( $target_mid ) ;
70
$db =& XoopsDatabaseFactory::getDatabaseConnection();
71
$sql = "SELECT * FROM ".$db->prefix("newblocks")." WHERE mid='$target_mid' ORDER BY visible DESC,side,weight";
72
$result = $db->query($sql);
73
$block_arr = array();
74
while( $myrow = $db->fetchArray($result) ) {
75
    $block_arr[] = new XoopsBlock($myrow);
76
}
77
78
function list_blocks() {
79
    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...
80
81
    // cachetime options
82
    $cachetimes = array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH);
83
84
    // displaying TH
85
    lx_collapsableBar('default', 'defaultIcon');
86
    echo "<img  onclick=\"toggle('default'); toggleIcon('defaultIcon');\" id='defaultIcon' src='" . XOOPS_URL . "/modules/lexikon/images/close12.gif' alt='' /></a>&nbsp; "._AM_BADMIN."<br /><br />";
87
    echo "<div id='default' style='float:left; width:100%;'>";
88
    echo "
89
	<form action='admin.php' name='blockadmin' method='post'>
90
		<table width='95%' class='outer' cellpadding='4' cellspacing='1'>
91
		<tr valign='middle'>
92
			<th>"._AM_TITLE."</th>
93
			<th align='center' nowrap='nowrap'>"._AM_SIDE."<div style='font-size:smaller'>"._LEFT."-"._CENTER."-"._RIGHT."</div></th>
94
			<th align='center'>"._AM_WEIGHT."</th>
95
			<th align='center'>"._AM_VISIBLEIN."</th>
96
			<th align='center'>"._AM_BCACHETIME."</th>
97
			<th align='right'>"._AM_ACTION."</th>
98
		</tr>\n" ;
99
100
    // blocks displaying loop
101
    $class = 'even' ;
102
    $block_configs = get_block_configs() ;
103
    foreach( array_keys( $block_arr ) as $i ) {
104
        $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...
105
        $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...
106
107
        $weight = $block_arr[$i]->getVar("weight") ;
108
        $title = $block_arr[$i]->getVar("title") ;
109
        $name = $block_arr[$i]->getVar("name") ;
110
        $bcachetime = $block_arr[$i]->getVar("bcachetime") ;
111
        $bid = $block_arr[$i]->getVar("bid") ;
112
113
        // visible and side
114
        if ( $block_arr[$i]->getVar("visible") != 1 ) {
115
            $sseln = " checked='checked'";
116
            $scoln = "#FF9966";
117
        } else switch( $block_arr[$i]->getVar("side") ) {
118
            default :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a DEFAULT statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement.

switch ($expr) {
    default : //wrong
        doSomething();
        break;
}

switch ($expr) {
    default: //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
119
            case XOOPS_SIDEBLOCK_LEFT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
120
                $ssel0 = " checked='checked'";
121
                $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...
122
                break ;
123
            case XOOPS_SIDEBLOCK_RIGHT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
124
                $ssel1 = " checked='checked'";
125
                $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...
126
                break ;
127
            case XOOPS_CENTERBLOCK_LEFT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
128
                $ssel2 = " checked='checked'";
129
                $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...
130
                break ;
131
            case XOOPS_CENTERBLOCK_RIGHT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
132
                $ssel4 = " checked='checked'";
133
                $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...
134
                break ;
135
            case XOOPS_CENTERBLOCK_CENTER :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
136
                $ssel3 = " checked='checked'";
137
                $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...
138
                break ;
139
            case XOOPS_CENTERBLOCK_BOTTOMLEFT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
140
                $ssel5 = " checked='checked'";
141
                $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...
142
                break ;
143
            case XOOPS_CENTERBLOCK_BOTTOMRIGHT :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
144
                $ssel6 = " checked='checked'";
145
                $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...
146
                break ;
147
            case XOOPS_CENTERBLOCK_BOTTOM :
0 ignored issues
show
Coding Style introduced by
There must be no space before the colon in a CASE statement

As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.

switch ($selector) {
    case "A": //right
        doSomething();
        break;
    case "B" : //wrong
        doSomethingElse();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
148
                $ssel7 = " checked='checked'";
149
                $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...
150
                break ;
151
        }
152
153
        // bcachetime
154
        $cachetime_options = '' ;
155 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...
156
            if( $bcachetime == $cachetime ) {
157
                $cachetime_options .= "<option value='$cachetime' selected='selected'>$cachetime_name</option>\n" ;
158
            } else {
159
                $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n" ;
160
            }
161
        }
162
163
        // target modules
164
        $db =& XoopsDatabaseFactory::getDatabaseConnection();
165
        $result = $db->query( "SELECT module_id FROM ".$db->prefix('block_module_link')." WHERE block_id='$bid'" ) ;
166
        $selected_mids = array();
167
        while ( list( $selected_mid ) = $db->fetchRow( $result ) ) {
168
            $selected_mids[] = intval( $selected_mid ) ;
169
        }
170
        $module_handler =& xoops_gethandler('module');
171
        $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
172
        $criteria->add(new Criteria('isactive', 1));
173
        $module_list =& $module_handler->getList($criteria);
174
        $module_list[-1] = _AM_TOPPAGE;
175
        $module_list[0] = _AM_ALLPAGES;
176
        ksort($module_list);
177
        $module_options = '' ;
178
        foreach( $module_list as $mid => $mname ) {
179
            if( in_array( $mid , $selected_mids ) ) {
180
                $module_options .= "<option value='$mid' selected='selected'>$mname</option>\n" ;
181
            } else {
182
                $module_options .= "<option value='$mid'>$mname</option>\n" ;
183
            }
184
        }
185
186
        // delete link if it is cloned block
187
        if( $block_arr[$i]->getVar("block_type") == 'D' || $block_arr[$i]->getVar("block_type") == 'C' ) {
188
            $delete_link = "<br /><a href='admin.php?fct=blocksadmin&amp;op=delete&amp;bid=$bid'>"._DELETE."</a>" ;
189
        } else {
190
            $delete_link = '' ;
191
        }
192
193
        // clone link if it is marked as cloneable block
194
        // $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...
195
        if( $block_arr[$i]->getVar("block_type") == 'D' || $block_arr[$i]->getVar("block_type") == 'C' ) {
196
            $can_clone = true ;
197
        } else {
198
            $can_clone = false ;
199 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...
200
                if( $block_arr[$i]->getVar("show_func") == $bconf['show_func'] && $block_arr[$i]->getVar("func_file") == $bconf['file'] && ( empty( $bconf['template'] ) || $block_arr[$i]->getVar("template") == $bconf['template'] ) ) {
201
                    if( ! empty( $bconf['can_clone'] ) ) $can_clone = true ;
202
                }
203
            }
204
        }
205
        if( $can_clone ) {
206
            $clone_link = "<br /><a href='admin.php?fct=blocksadmin&amp;op=clone&amp;bid=$bid'>"._CLONE."</a>" ;
207
        } else {
208
            $clone_link = '' ;
209
        }
210
211
        // displaying part
212
        echo "
213
		<tr valign='middle'>
214
			<td class='$class'>
215
				$name
216
				<br />
217
				<input type='text' name='title[$bid]' value='$title' size='20' />
218
			</td>
219
			<td class='$class' align='center' nowrap='nowrap' width='125px'>
220
      <div align='center' >
221
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_LEFT."'$ssel2 />
222
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_CENTER."'$ssel3 />
223
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_RIGHT."'$ssel4 />
224
      </div>
225
      <div>
226
        <span style='float:right'><input type='radio' name='side[$bid]' value='".XOOPS_SIDEBLOCK_RIGHT."'$ssel1 /></span>
227
        <div align='left'><input type='radio' name='side[$bid]' value='".XOOPS_SIDEBLOCK_LEFT."'$ssel0 /></div>
228
      </div>
229
      <div align='center'>
230
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_BOTTOMLEFT."'$ssel5 />
231
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_BOTTOM."'$ssel7 />
232
        <input type='radio' name='side[$bid]' value='".XOOPS_CENTERBLOCK_BOTTOMRIGHT."'$ssel6 />
233
      </div>
234
      <br />
235
        <div style='float:left;width:30%;'>&nbsp;</div>
236
				<div style='float:left;background-color:$scoln;'>
237
					<input type='radio' name='side[$bid]' value='-1'  $sseln />
238
				</div>
239
				<div style='float:left;'>"._NONE."</div>
240
			</td>
241
			<td class='$class' align='center'>
242
				<input type='text' name=weight[$bid] value='$weight' size='3' maxlength='5' style='text-align:right;' />
243
			</td>
244
			<td class='$class' align='center'>
245
				<select name='bmodule[$bid][]' size='5' multiple='multiple'>
246
					$module_options
247
				</select>
248
			</td>
249
			<td class='$class' align='center'>
250
				<select name='bcachetime[$bid]' size='1'>
251
					$cachetime_options
252
				</select>
253
			</td>
254
			<td class='$class' align='right'>
255
				<a href='admin.php?fct=blocksadmin&amp;op=edit&amp;bid=$bid'>"._EDIT."</a>{$delete_link}{$clone_link}
256
				<input type='hidden' name='bid[$bid]' value='$bid' />
257
			</td>
258
		</tr>\n" ;
259
260
        $class = ( $class == 'even' ) ? 'odd' : 'even' ;
261
    }
262
263
    echo "
264
		<tr>
265
			<td class='foot' align='center' colspan='6'>
266
				<input type='hidden' name='query4redirect' value='$query4redirect' />
267
				<input type='hidden' name='fct' value='blocksadmin' />
268
				<input type='hidden' name='op' value='order' />
269
				".$xoopsGTicket->getTicketHtml( __LINE__ , 1800 , 'myblocksadmin' )."
270
				<input type='submit' name='submit' value='"._SUBMIT."' />
271
			</td>
272
		</tr>
273
		</table>
274
	</form>\n" ;
275
    echo "</div>";
276
}
277
278
function get_block_configs() {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
279
    $error_reporting_level = error_reporting( 0 ) ;
280
    if( preg_match( '/^[.0-9a-zA-Z_-]+$/' , @$_GET['dirname'] ) ) {
281
        include dirname(dirname(dirname(__FILE__))).'/'.$_GET['dirname'].'/xoops_version.php' ;
282
    } else {
283
        include '../xoops_version.php' ;
284
    }
285
    error_reporting( $error_reporting_level ) ;
286
    if( empty( $modversion['blocks'] ) ) return array() ;
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...
287
    else return $modversion['blocks'] ;
288
}
289
290
function list_groups() {
291
    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...
292
    lx_collapsableBar('groups', 'groupIcon');
293
  echo "<img  onclick=\"toggle('groups'); toggleIcon('groupsIcon');\" id='groupsIcon' src='" . XOOPS_URL . "/modules/lexikon/images/close12.gif' alt='' /></a>&nbsp; "._MD_AM_ADGS ." <br>";
294
    echo "<div id='groups' style='float:left; width:100%;'>";
295
    $item_list = array() ;
296
    foreach( array_keys( $block_arr ) as $i ) {
297
        $item_list[ $block_arr[$i]->getVar("bid") ] = $block_arr[$i]->getVar("title") ;
298
    }
299
300
    $form = new MyXoopsGroupPermForm( _MD_AM_ADGS , 1 , 'block_read' , '' ) ;
301 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...
302
        $form->addAppendix( 'module_admin' , $target_mid , $target_mname . ' ' . _AM_ACTIVERIGHTS ) ;
303
        $form->addAppendix( 'module_read' , $target_mid , $target_mname .' ' . _AM_ACCESSRIGHTS ) ;
304
    }
305
    foreach( $item_list as $item_id => $item_name) {
306
            $form->addItem( $item_id , $item_name ) ;
307
    }
308
    echo $form->render() ;
309
    echo "</div>";
310
}
311
312 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...
313
    if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) {
314
        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
315
    }
316
317
    include( "mygroupperm.php" ) ;
318
    redirect_header( XOOPS_URL."/modules/".$xoopsModule->dirname()."/admin/myblocksadmin.php$query4redirect" , 1 , _MD_AM_DBUPDATED );
319
}
320
321
xoops_cp_header() ;
322
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/admin/functions.php";
323
//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...
324
325
if( ! empty( $block_arr ) ) {
326
    echo "<h4 style='text-align:left;'>$target_mname : "._AM_BADMIN."</h4>\n" ;
327
    list_blocks() ;
328
}
329
330
list_groups() ;
331
xoops_cp_footer() ;
332