Passed
Push — master ( 882d2a...8f67b7 )
by Michael
03:09
created

NewbbXoopsGroupFormCheckBox   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 63
rs 10
c 1
b 0
f 0
wmc 10
1
<?php
2
//
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2016 XOOPS.org                        //
6
//                       <https://xoops.org/>                             //
7
//  ------------------------------------------------------------------------ //
8
//  This program is free software; you can redistribute it and/or modify     //
9
//  it under the terms of the GNU General Public License as published by     //
10
//  the Free Software Foundation; either version 2 of the License, or        //
11
//  (at your option) any later version.                                      //
12
//                                                                           //
13
//  You may not change or alter any portion of this comment or credits       //
14
//  of supporting developers from this source code or any supporting         //
15
//  source code which is considered copyrighted (c) material of the          //
16
//  original comment or credit authors.                                      //
17
//                                                                           //
18
//  This program is distributed in the hope that it will be useful,          //
19
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
//  GNU General Public License for more details.                             //
22
//                                                                           //
23
//  You should have received a copy of the GNU General Public License        //
24
//  along with this program; if not, write to the Free Software              //
25
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
//  ------------------------------------------------------------------------ //
27
// Author: XOOPS Foundation                                                  //
28
// URL: https://xoops.org/                                                //
29
// Project: XOOPS Project                                                    //
30
// ------------------------------------------------------------------------- //
31
32
use Xmf\Request;
0 ignored issues
show
Bug introduced by
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
use XoopsModules\Newbb;
34
35
require_once __DIR__ . '/admin_header.php';
36
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
37
if (!class_exists('XoopsGroupPermForm')) {
38
    require_once $GLOBALS['xoops']->path('class/xoopsform/grouppermform.php');
39
}
40
41
/**
42
 * TODO: synchronize cascade permissions for multi-level
43
 */
44
45
/**
46
 * Add category navigation to forum casscade structure
47
 * <ol>Special points:
48
 *    <li> Use negative values for category IDs to avoid conflict between category and forum
49
 *    <li> Disabled checkbox for categories to avoid unnecessary permission items for categories in forum permission table
50
 * </ol>
51
 *
52
 * Note: this is a __patchy__ solution. We should have a more extensible and flexible group permission management: not only for data architecture but also for management interface
53
 */
54
55
//$action = isset($_REQUEST['action']) ? strtolower($_REQUEST['action']) : "";
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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...
56
$action    = strtolower(Request::getCmd('action', ''));
57
$module_id = $xoopsModule->getVar('mid');
58
/** var Newbb\PermissionHandler $newbbpermHandler */
59
$newbbpermHandler = Newbb\Helper::getInstance()->getHandler('Permission');
60
$perms            = $newbbpermHandler->getValidForumPerms();
61
62
switch ($action) {
63
    case 'template':
64
        xoops_cp_header();
0 ignored issues
show
Bug introduced by
The function xoops_cp_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

64
        /** @scrutinizer ignore-call */ 
65
        xoops_cp_header();
Loading history...
65
        $adminObject->displayNavigation(basename(__FILE__));
66
        echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
67
        $opform    = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_TEMPLAT, 'actionform', 'admin_permissions.php', 'get');
0 ignored issues
show
Bug introduced by
The type XoopsSimpleForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
68
        $op_select = new \XoopsFormSelect('', 'action');
0 ignored issues
show
Bug introduced by
The type XoopsFormSelect was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
69
        $op_select->setExtra('onchange="document.forms.actionform.submit()"');
70
        $op_select->addOptionArray([
71
                                       'no'       => _SELECT,
0 ignored issues
show
Bug introduced by
The constant _SELECT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
72
                                       'template' => _AM_NEWBB_PERM_TEMPLATE,
73
                                       'apply'    => _AM_NEWBB_PERM_TEMPLATEAPP,
74
                                       'default'  => _AM_NEWBB_PERM_SETBYGROUP
75
                                   ]);
76
        $opform->addElement($op_select);
77
        $opform->display();
78
79
        $memberHandler = xoops_getHandler('member');
0 ignored issues
show
Bug introduced by
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

79
        $memberHandler = /** @scrutinizer ignore-call */ xoops_getHandler('member');
Loading history...
80
        $glist         = $memberHandler->getGroupList();
81
        $elements      = [];
82
        $perm_template = $newbbpermHandler->getTemplate();
83
        foreach (array_keys($glist) as $i) {
84
            $selected   = !empty($perm_template[$i]) ? array_keys($perm_template[$i]) : [];
85
            $ret_ele    = '<tr align="left" valign="top"><td class="head">' . $glist[$i] . '</td>';
86
            $ret_ele    .= '<td class="even">';
87
            $ret_ele    .= '<table class="outer"><tr><td class="odd"><table><tr>';
88
            $ii         = 0;
89
            $option_ids = [];
90
            foreach ($perms as $perm) {
91
                ++$ii;
92
                if (0 == $ii % 5) {
93
                    $ret_ele .= '</tr><tr>';
94
                }
95
                $checked      = in_array('forum_' . $perm, $selected) ? ' checked' : '';
96
                $option_id    = $perm . '_' . $i;
97
                $option_ids[] = $option_id;
98
                $ret_ele      .= '<td><input name="perms[' . $i . '][' . 'forum_' . $perm . ']" id="' . $option_id . '" onclick="" value="1" type="checkbox"' . $checked . '>' . constant('_AM_NEWBB_CAN_' . strtoupper($perm)) . '<br></td>';
99
            }
100
            $ret_ele    .= '</tr></table></td><td class="even">';
101
            $ret_ele    .= _ALL . ' <input id="checkall[' . $i . ']" type="checkbox" value="" onclick="var optionids = new Array(' . implode(', ', $option_ids) . '); xoopsCheckAllElements(optionids, \'checkall[' . $i . ']\')" />';
0 ignored issues
show
Bug introduced by
The constant _ALL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
102
            $ret_ele    .= '</td></tr></table>';
103
            $ret_ele    .= '</td></tr>';
104
            $elements[] = $ret_ele;
105
        }
106
        $tray = new \XoopsFormElementTray('');
0 ignored issues
show
Bug introduced by
The type XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
107
        $tray->addElement(new \XoopsFormHidden('action', 'template_save'));
0 ignored issues
show
Bug introduced by
The type XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
108
        $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
0 ignored issues
show
Bug introduced by
The constant _SUBMIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
109
        $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
0 ignored issues
show
Bug introduced by
The constant _CANCEL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
110
        $ret = '<br><strong>' . _AM_NEWBB_PERM_TEMPLATE . '</strong><br>' . _AM_NEWBB_PERM_TEMPLATE_DESC . '<br>';
111
        $ret .= "<form name='template' id='template' method='post'>\n<table width='100%' class='outer' cellspacing='1'>\n";
112
        $ret .= implode("\n", $elements);
113
        $ret .= '<tr align="left" valign="top"><td class="head"></td><td class="even" style="text-align:center;">';
114
        $ret .= $tray->render();
115
        $ret .= '</td></tr>';
116
        $ret .= '</table></form>';
117
        echo $ret;
118
        require_once __DIR__ . '/admin_footer.php';
119
        break;
120
121
    case 'template_save':
122
        //        $res = $newbbpermHandler->setTemplate($_POST['perms'], $groupid = 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
123
        $res = $newbbpermHandler->setTemplate(Request::getArray('perms', '', 'POST'), $groupid = 0);
124
        if ($res) {
125
            redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_CREATED);
0 ignored issues
show
Bug introduced by
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

125
            /** @scrutinizer ignore-call */ 
126
            redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_CREATED);
Loading history...
126
        } else {
127
            redirect_header('admin_permissions.php?action=template', 2, _AM_NEWBB_PERM_TEMPLATE_ERROR);
128
        }
129
        break;
130
    //        exit();
131
132
    case 'apply':
133
        $perm_template = $newbbpermHandler->getTemplate();
134
        if (null === $perm_template) {
135
            redirect_header('admin_permissions.php?action=template', 2, _AM_NEWBB_PERM_TEMPLATE);
136
        }
137
        xoops_cp_header();
138
        $adminObject->displayNavigation(basename(__FILE__));
139
        echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
140
        $opform    = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP_APPLY, 'actionform', 'admin_permissions.php', 'get');
141
        $op_select = new \XoopsFormSelect('', 'action');
142
        $op_select->setExtra('onchange="document.forms.actionform.submit()"');
143
        $op_select->addOptionArray([
144
                                       'no'       => _SELECT,
145
                                       'template' => _AM_NEWBB_PERM_TEMPLATE,
146
                                       'apply'    => _AM_NEWBB_PERM_TEMPLATEAPP
147
                                   ]);
148
        $opform->addElement($op_select);
149
        $opform->display();
150
151
        /** @var Newbb\CategoryHandler $categoryHandler */
152
        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
153
        $criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
0 ignored issues
show
Bug introduced by
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
154
        $criteriaCategory->setSort('cat_order');
155
        $categories = $categoryHandler->getList($criteriaCategory);
156
157
        /** @var Newbb\ForumHandler $forumHandler */
158
        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
159
        $forums       = $forumHandler->getTree(array_keys($categories), 0, 'all');
160
        foreach (array_keys($forums) as $c) {
161
            $fm_options[-1 * $c - 1000] = ' ';
162
            $fm_options[-1 * $c]        = '[' . $categories[$c] . ']';
163
            foreach (array_keys($forums[$c]) as $f) {
164
                $fm_options[$f] = $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'];
165
            }
166
        }
167
        unset($forums, $categories);
168
169
        $fmform    = new \XoopsThemeForm(_AM_NEWBB_PERM_TEMPLATEAPP, 'fmform', 'admin_permissions.php', 'post', true);
0 ignored issues
show
Bug introduced by
The type XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
170
        $fm_select = new \XoopsFormSelect(_AM_NEWBB_PERM_FORUMS, 'forums', null, 10, true);
171
        $fm_select->addOptionArray($fm_options);
172
        $fmform->addElement($fm_select);
173
        $tray = new \XoopsFormElementTray('');
174
        $tray->addElement(new \XoopsFormHidden('action', 'apply_save'));
175
        $tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
176
        $tray->addElement(new \XoopsFormButton('', 'reset', _CANCEL, 'reset'));
177
        $fmform->addElement($tray);
178
        $fmform->display();
179
        require_once __DIR__ . '/admin_footer.php';
180
        break;
181
182
    case 'apply_save':
183
        if (!Request::getArray('forums', '', 'POST')) {
184
            break;
185
        }
186
        foreach (Request::getArray('forums', '', 'POST') as $forum) {
187
            if ($forum < 1) {
188
                continue;
189
            }
190
            $newbbpermHandler->applyTemplate($forum, $module_id);
191
        }
192
        $cacheHelper = Newbb\Utility::cleanCache();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $cacheHelper is correct as XoopsModules\Newbb\Utility::cleanCache() targeting XoopsModules\Newbb\Utility::cleanCache() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
193
        //$cacheHelper->delete('permission');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
194
        redirect_header('admin_permissions.php', 2, _AM_NEWBB_PERM_TEMPLATE_APPLIED);
195
        break;
196
197
    default:
198
        xoops_cp_header();
199
200
        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
201
        $criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
202
        $criteriaCategory->setSort('cat_order');
203
        $categories = $categoryHandler->getList($criteriaCategory);
204
205
        if (0 === count($categories)) {
206
            redirect_header('admin_cat_manager.php', 2, _AM_NEWBB_CREATENEWCATEGORY);
207
        }
208
209
        $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
210
        $forums       = $forumHandler->getTree(array_keys($categories), 0, 'all');
211
212
        if (0 === count($forums)) {
213
            redirect_header('admin_forum_manager.php', 2, _AM_NEWBB_CREATENEWFORUM);
214
        }
215
216
        $adminObject->displayNavigation(basename(__FILE__));
217
        echo "<legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_PERM_ACTION . '</legend>';
218
        $opform    = new \XoopsSimpleForm(_AM_NEWBB_PERM_ACTION_HELP, 'actionform', 'admin_permissions.php', 'get');
219
        $op_select = new \XoopsFormSelect('', 'action');
220
        $op_select->setExtra('onchange="document.forms.actionform.submit()"');
221
        $op_select->addOptionArray([
222
                                       'no'       => _SELECT,
223
                                       'template' => _AM_NEWBB_PERM_TEMPLATE,
224
                                       'apply'    => _AM_NEWBB_PERM_TEMPLATEAPP,
225
                                       'default'  => _AM_NEWBB_PERM_SETBYGROUP
226
                                   ]);
227
        $opform->addElement($op_select);
228
        $opform->display();
229
230
        $op_options = ['category' => _AM_NEWBB_CAT_ACCESS];
231
        $fm_options = [
232
            'category' => [
233
                'title'     => _AM_NEWBB_CAT_ACCESS,
234
                'item'      => 'category_access',
235
                'desc'      => '',
236
                'anonymous' => true
237
            ]
238
        ];
239
        foreach ($perms as $perm) {
240
            $op_options[$perm] = constant('_AM_NEWBB_CAN_' . strtoupper($perm));
241
            $fm_options[$perm] = [
242
                'title'     => constant('_AM_NEWBB_CAN_' . strtoupper($perm)),
243
                'item'      => 'forum_' . $perm,
244
                'desc'      => '',
245
                'anonymous' => true
246
            ];
247
        }
248
249
        $op_keys = array_keys($op_options);
250
        $op      = strtolower(Request::getCmd('op', Request::getCmd('op', '', 'COOKIE'), 'GET'));
251
        if (empty($op)) {
252
            $op = $op_keys[0];
253
            setcookie('op', isset($op_keys[1]) ? $op_keys[1] : '');
254
        } elseif (false !== ($key = array_search($op, $op_keys))) {
255
            setcookie('op', isset($op_keys[$key + 1]) ? $op_keys[$key + 1] : '');
256
        }
257
258
        $opform    = new \XoopsSimpleForm('', 'opform', 'admin_permissions.php', 'get');
259
        $op_select = new \XoopsFormSelect('', 'op', $op);
260
        $op_select->setExtra('onchange="document.forms.opform.submit()"');
261
        $op_select->addOptionArray($op_options);
262
        $opform->addElement($op_select);
263
        $opform->display();
264
265
        $perm_desc = '';
266
267
        $form = new Newbb\GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']);
0 ignored issues
show
Unused Code introduced by
The call to XoopsModules\Newbb\GroupPermForm::__construct() has too many arguments starting with $fm_options[$op]['anonymous']. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

267
        $form = /** @scrutinizer ignore-call */ new Newbb\GroupPermForm($fm_options[$op]['title'], $module_id, $fm_options[$op]['item'], $fm_options[$op]['desc'], 'admin/admin_permissions.php', $fm_options[$op]['anonymous']);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
268
269
        $categoryHandler  = Newbb\Helper::getInstance()->getHandler('Category');
270
        $criteriaCategory = new \CriteriaCompo(new \Criteria('1', 1));
271
        $criteriaCategory->setSort('cat_order');
272
        $categories = $categoryHandler->getList($criteriaCategory);
273
        if ('category' === $op) {
274
            foreach (array_keys($categories) as $key) {
275
                $form->addItem($key, $categories[$key]);
276
            }
277
            unset($categories);
278
        } else {
279
            $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
280
            $forums       = $forumHandler->getTree(array_keys($categories), 0, 'all');
281
            if (count($forums) > 0) {
282
                foreach (array_keys($forums) as $c) {
283
                    $key_c = -1 * $c;
284
                    $form->addItem($key_c, '<strong>[' . $categories[$c] . ']</strong>');
285
                    foreach (array_keys($forums[$c]) as $f) {
286
                        $pid = $forums[$c][$f]['parent_forum'] ?: $key_c;
287
                        $form->addItem($f, $forums[$c][$f]['prefix'] . $forums[$c][$f]['forum_name'], $pid);
288
                    }
289
                }
290
            }
291
            unset($forums, $categories);
292
        }
293
        $form->display();
294
        echo '<fieldset>';
295
        echo '<legend>&nbsp;' . _MI_NEWBB_ADMENU_PERMISSION . '&nbsp;</legend>';
296
        echo _AM_NEWBB_HELP_PERMISSION_TAB;
297
        echo '</fieldset>';
298
        // Since we can not control the permission update, a trick is used here
299
        /** var Newbb\PermissionHandler $permissionHandler */
300
        $permissionHandler = Newbb\Helper::getInstance()->getHandler('Permission');
301
        $permissionHandler->createPermData();
302
        $cacheHelper = Newbb\Utility::cleanCache();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $cacheHelper is correct as XoopsModules\Newbb\Utility::cleanCache() targeting XoopsModules\Newbb\Utility::cleanCache() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
303
        //$cacheHelper->delete('permission');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
304
        require_once __DIR__ . '/admin_footer.php';
305
        break;
306
}
307