Passed
Branch master (4e30dc)
by Michael
02:20
created

editcat()   C

Complexity

Conditions 8
Paths 72

Size

Total Lines 149
Code Lines 70

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 149
rs 5.2676
c 1
b 0
f 0
cc 8
eloc 70
nc 72
nop 2

How to fix   Long Method   

Long Method

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

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

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 */
8
9
use XoopsModules\Smartfaq;
10
11
require_once __DIR__ . '/admin_header.php';
12
13
// Creating the category handler object
14
/** @var \XoopsModules\Smartfaq\CategoryHandler $categoryHandler */
15
$categoryHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Category');
16
17
$op = '';
18
19
if (isset($_GET['op'])) {
20
    $op = $_GET['op'];
21
}
22
if (isset($_POST['op'])) {
23
    $op = $_POST['op'];
24
}
25
26
// Where do we start?
27
$startcategory = isset($_GET['startcategory']) ? (int)$_GET['startcategory'] : 0;
28
29
/**
30
 * @param XoopsObject $categoryObj
0 ignored issues
show
Bug introduced by
The type XoopsObject 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...
31
 * @param int         $level
32
 */
33
function displayCategory($categoryObj, $level = 0)
34
{
35
    global $xoopsModule, $categoryHandler, $pathIcon16;
36
    $description = $categoryObj->description();
37
    if (!XOOPS_USE_MULTIBYTES) {
0 ignored issues
show
Bug introduced by
The constant XOOPS_USE_MULTIBYTES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
38
        if (strlen($description) >= 100) {
39
            $description = substr($description, 0, 100 - 1) . '...';
40
        }
41
    }
42
    $modify = "<a href='category.php?op=mod&categoryid=" . $categoryObj->categoryid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_EDITCOL . "' alt='" . _AM_SF_EDITCOL . "'></a>";
43
    $delete = "<a href='category.php?op=del&categoryid=" . $categoryObj->categoryid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETECOL . "' alt='" . _AM_SF_DELETECOL . "'></a>";
44
45
    $spaces = '';
46
    for ($j = 0; $j < $level; ++$j) {
47
        $spaces .= '&nbsp;&nbsp;&nbsp;';
48
    }
49
50
    echo '<tr>';
51
    echo "<td class='even' align='lefet'>"
52
         . $spaces
53
         . "<a href='"
54
         . XOOPS_URL
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
         . '/modules/'
56
         . $xoopsModule->dirname()
57
         . '/category.php?categoryid='
58
         . $categoryObj->categoryid()
59
         . "'><img src='"
60
         . XOOPS_URL
61
         . "/modules/smartfaq/assets/images/icon/subcat.gif' alt=''>&nbsp;"
62
         . $categoryObj->name()
63
         . '</a></td>';
64
    echo "<td class='even' align='left'>" . $description . '</td>';
65
    echo "<td class='even' align='center'>" . $categoryObj->weight() . '</td>';
66
    echo "<td class='even' align='center'> $modify $delete </td>";
67
    echo '</tr>';
68
    $subCategoriesObj =& $categoryHandler->getCategories(0, 0, $categoryObj->categoryid());
69
    if (count($subCategoriesObj) > 0) {
70
        ++$level;
71
        foreach ($subCategoriesObj as $key => $thiscat) {
72
            displayCategory($thiscat, $level);
73
        }
74
    }
75
    unset($categoryObj);
76
}
77
78
/**
79
 * @param bool $showmenu
80
 * @param int  $categoryid
81
 */
82
function editcat($showmenu = false, $categoryid = 0)
0 ignored issues
show
Unused Code introduced by
The parameter $showmenu is not used and could be removed. ( Ignorable by Annotation )

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

82
function editcat(/** @scrutinizer ignore-unused */ $showmenu = false, $categoryid = 0)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
83
{
84
    //$moderators = array(); // just to define the variable
85
    //$allmods = array();
86
    $startfaq = isset($_GET['startfaq']) ? (int)$_GET['startfaq'] : 0;
0 ignored issues
show
Unused Code introduced by
The assignment to $startfaq is dead and can be removed.
Loading history...
87
    global $categoryHandler, $xoopsUser, $xoopsUser, $myts, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $_GET;
88
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
89
90
    // Creating the faq handler object
91
    /** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
92
    $faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq');
0 ignored issues
show
Unused Code introduced by
The assignment to $faqHandler is dead and can be removed.
Loading history...
93
94
    echo '<script type="text/javascript" src="funcs.js"></script>';
95
    echo '<style>';
96
    echo '<!-- ';
97
    echo 'select { width: 130px; }';
98
    echo '-->';
99
    echo '</style>';
100
    // If there is a parameter, and the id exists, retrieve data: we're editing a category
101
    if (0 != $categoryid) {
102
103
        // Creating the category object for the selected category
104
        $categoryObj = new  \XoopsModules\Smartfaq\Category($categoryid);
105
106
        echo "<br>\n";
107
        if ($categoryObj->notLoaded()) {
108
            redirect_header('category.php', 1, _AM_SF_NOCOLTOEDIT);
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

108
            /** @scrutinizer ignore-call */ 
109
            redirect_header('category.php', 1, _AM_SF_NOCOLTOEDIT);
Loading history...
109
        }
110
        Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon');
111
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_EDITCOL . '</h3>';
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
112
        echo "<div id='bottomtable'>";
113
    } else {
114
        $categoryObj = $categoryHandler->create();
115
        echo "<br>\n";
116
        Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon');
117
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_CATEGORY_CREATE . '</h3>';
118
        echo "<div id='bottomtable'>";
119
    }
120
    // Start category form
121
    $sform = new \XoopsThemeForm(_AM_SF_CATEGORY, 'op', xoops_getenv('PHP_SELF'), 'post', true);
0 ignored issues
show
Bug introduced by
The function xoops_getenv 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

121
    $sform = new \XoopsThemeForm(_AM_SF_CATEGORY, 'op', /** @scrutinizer ignore-call */ xoops_getenv('PHP_SELF'), 'post', true);
Loading history...
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...
122
    $sform->setExtra('enctype="multipart/form-data"');
123
124
    // Name
125
    $sform->addElement(new \XoopsFormText(_AM_SF_CATEGORY, 'name', 50, 255, $categoryObj->name('e')), true);
0 ignored issues
show
Bug introduced by
The type XoopsFormText 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...
126
127
    // Parent Category
128
    $mytree = new Smartfaq\Tree($xoopsDB->prefix('smartfaq_categories'), 'categoryid', 'parentid');
129
    ob_start();
130
    $mytree->makeMySelBox('name', 'weight', $categoryObj->parentid(), 1, 'parentid');
131
132
    //makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="")
133
    $sform->addElement(new \XoopsFormLabel(_AM_SF_PARENT_CATEGORY_EXP, ob_get_contents()));
0 ignored issues
show
Bug introduced by
The type XoopsFormLabel 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...
134
    ob_end_clean();
135
136
    /*  $mytree = new Smartfaq\Tree($xoopsDB->prefix("smartfaq_categories"), "categoryid" , "parentid");
137
        ob_start();
138
        $sform->addElement(new \XoopsFormHidden('categoryid', $categoryObj->categoryid()));
139
        $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
140
        $sform->addElement(new \XoopsFormLabel(_AM_SF_CATEGORY_FAQ, ob_get_contents()));
141
        ob_end_clean();
142
        */
143
144
    // Decsription
145
    $sform->addElement(new \XoopsFormTextArea(_AM_SF_COLDESCRIPT, 'description', $categoryObj->description('e'), 7, 60));
0 ignored issues
show
Bug introduced by
The type XoopsFormTextArea 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...
146
147
    // Weight
148
    $sform->addElement(new \XoopsFormText(_AM_SF_COLPOSIT, 'weight', 4, 4, $categoryObj->weight()));
149
150
    // READ PERMISSIONS
151
    $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

151
    $memberHandler = /** @scrutinizer ignore-call */ xoops_getHandler('member');
Loading history...
152
    $group_list    = $memberHandler->getGroupList();
153
154
    $groups_read_checkbox = new \XoopsFormCheckBox(_AM_SF_PERMISSIONS_CAT_READ, 'groups_read[]', $categoryObj->getGroups_read());
0 ignored issues
show
Bug introduced by
The type XoopsFormCheckBox 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...
155
    foreach ($group_list as $group_id => $group_name) {
156
        if (XOOPS_GROUP_ADMIN != $group_id) {
0 ignored issues
show
Bug introduced by
The constant XOOPS_GROUP_ADMIN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
157
            $groups_read_checkbox->addOption($group_id, $group_name);
158
        }
159
    }
160
    $sform->addElement($groups_read_checkbox);
161
    // Apply permissions on all faqs
162
    $addapplyall_radio = new \XoopsFormRadioYN(_AM_SF_PERMISSIONS_APPLY_ON_FAQS, 'applyall', 0, ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . '');
0 ignored issues
show
Bug introduced by
The type XoopsFormRadioYN 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...
163
    $sform->addElement($addapplyall_radio);
164
    // MODERATORS
165
    //$moderators_tray = new \XoopsFormElementTray(_AM_SF_MODERATORS_DEF, '');
166
167
    $module_id = $xoopsModule->getVar('mid');
0 ignored issues
show
Unused Code introduced by
The assignment to $module_id is dead and can be removed.
Loading history...
168
169
    /*$gpermHandler = xoops_getHandler('groupperm');
170
    $mod_perms = $gpermHandler->getGroupIds('category_moderation', $categoryid, $module_id);
171
172
    $moderators_select = new \XoopsFormSelect('', 'moderators', $moderators, 5, true);
173
    $moderators_tray->addElement($moderators_select);
174
175
    $butt_mngmods = new \XoopsFormButton('', '', 'Manage mods', 'button');
176
    $butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"');
177
    $moderators_tray->addElement($butt_mngmods);
178
179
    $butt_delmod = new \XoopsFormButton('', '', 'Delete mod', 'button');
180
    $butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"');
181
    $moderators_tray->addElement($butt_delmod);
182
183
    $sform->addElement($moderators_tray);
184
    */
185
    $sform->addElement(new \XoopsFormHidden('categoryid', $categoryid));
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...
186
187
    // Action buttons tray
188
    $button_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...
189
190
    /*for ($i = 0, $iMax = count($moderators); $i < $iMax; ++$i) {
191
    $allmods[] = $moderators[$i];
192
    }
193
194
    $hiddenmods = new \XoopsFormHidden('allmods', $allmods);
195
    $button_tray->addElement($hiddenmods);
196
    */
197
    $hidden = new \XoopsFormHidden('op', 'addcategory');
198
    $button_tray->addElement($hidden);
199
    // No ID for category -- then it's new category, button says 'Create'
200
    if (!$categoryid) {
201
        $butt_create = new \XoopsFormButton('', '', _AM_SF_CREATE, 'submit');
0 ignored issues
show
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...
202
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
203
        $button_tray->addElement($butt_create);
204
205
        $butt_clear = new \XoopsFormButton('', '', _AM_SF_CLEAR, 'reset');
206
        $button_tray->addElement($butt_clear);
207
208
        $butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button');
209
        $butt_cancel->setExtra('onclick="history.go(-1)"');
210
        $button_tray->addElement($butt_cancel);
211
    } else {
212
        // button says 'Update'
213
        $butt_create = new \XoopsFormButton('', '', _AM_SF_MODIFY, 'submit');
214
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
215
        $button_tray->addElement($butt_create);
216
217
        $butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button');
218
        $butt_cancel->setExtra('onclick="history.go(-1)"');
219
        $button_tray->addElement($butt_cancel);
220
    }
221
222
    $sform->addElement($button_tray);
223
    $sform->display();
224
    echo '</div>';
225
226
    if ($categoryid) {
227
        require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/displayfaqs.php';
228
    }
229
230
    unset($hidden);
231
}
232
233
switch ($op) {
234
    case 'mod':
235
        $categoryid  = isset($_GET['categoryid']) ? (int)$_GET['categoryid'] : 0;
236
        $destList    = isset($_POST['destList']) ? $_POST['destList'] : '';
237
        $adminObject = \Xmf\Module\Admin::getInstance();
0 ignored issues
show
Bug introduced by
The type Xmf\Module\Admin 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...
238
        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

238
        /** @scrutinizer ignore-call */ 
239
        xoops_cp_header();
Loading history...
239
240
        $adminObject->displayNavigation(basename(__FILE__));
241
        editcat(true, $categoryid);
242
        break;
243
244
    case 'addcategory':
245
        global $_POST, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $modify, $myts, $categoryid;
246
247
        $categoryid = isset($_POST['categoryid']) ? (int)$_POST['categoryid'] : 0;
248
249
        if (0 != $categoryid) {
250
            $categoryObj = new Smartfaq\Category($categoryid);
251
        } else {
252
            $categoryObj = $categoryHandler->create();
253
        }
254
255
        //if (isset($_POST['allmods'])) $allmods = $_POST['allmods'];
256
        //if (isset($_POST['moderators'])) $moderators = $_POST['moderators'];
257
258
        $categoryObj->setVar('parentid', isset($_POST['parentid']) ? (int)$_POST['parentid'] : 0);
259
        $applyall = isset($_POST['applyall']) ? (int)$_POST['applyall'] : 0;
260
        $categoryObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 1);
261
262
        // Groups and permissions
263
        if (isset($_POST['groups_read'])) {
264
            $categoryObj->setGroups_read($_POST['groups_read']);
265
        } else {
266
            $categoryObj->setGroups_read();
267
        }
268
        //  $groups_admin = isset($_POST['groups_admin'])? $_POST['groups_admin'] : array();
269
        //  $mod_perms = isset($_POST['mod_perms'])? $_POST['mod_perms'] : array();
270
271
        $categoryObj->setVar('name', $_POST['name']);
272
273
        $categoryObj->setVar('description', $_POST['description']);
274
        if ($categoryObj->isNew()) {
275
            $redirect_msg = _AM_SF_CATCREATED;
276
            $redirect_to  = 'category.php?op=mod';
277
        } else {
278
            $redirect_msg = _AM_SF_COLMODIFIED;
279
            $redirect_to  = 'category.php';
280
        }
281
282
        if (!$categoryObj->store()) {
283
            redirect_header('javascript:history.go(-1)', 3, _AM_SF_CATEGORY_SAVE_ERROR . Smartfaq\Utility::formatErrors($categoryObj->getErrors()));
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

283
            /** @scrutinizer ignore-call */ 
284
            redirect_header('javascript:history.go(-1)', 3, _AM_SF_CATEGORY_SAVE_ERROR . Smartfaq\Utility::formatErrors($categoryObj->getErrors()));
Loading history...
284
        }
285
        // TODO : put this function in the category class
286
        Smartfaq\Utility::saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
287
        //Smartfaq\Utility::saveCategoryPermissions($groups_admin, $categoriesObj->categoryid(), 'category_admin');
288
289
        if ($applyall) {
290
            // TODO : put this function in the category class
291
            Smartfaq\Utility::overrideFaqsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid());
292
        }
293
294
        redirect_header($redirect_to, 2, $redirect_msg);
295
        break;
296
297
    case 'del':
298
        global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET;
299
300
        $module_id    = $xoopsModule->getVar('mid');
301
        $gpermHandler = xoops_getHandler('groupperm');
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

301
        $gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
302
303
        $categoryid = isset($_POST['categoryid']) ? (int)$_POST['categoryid'] : 0;
304
        $categoryid = isset($_GET['categoryid']) ? (int)$_GET['categoryid'] : $categoryid;
305
306
        $categoryObj = new Smartfaq\Category($categoryid);
307
308
        $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
309
        $name    = isset($_POST['name']) ? $_POST['name'] : '';
310
311
        if ($confirm) {
312
            if (!$categoryHandler->delete($categoryObj)) {
313
                redirect_header('category.php', 1, _AM_SF_DELETE_CAT_ERROR);
314
            }
315
            redirect_header('category.php', 1, sprintf(_AM_SF_COLISDELETED, $name));
316
        } else {
317
            // no confirm: show deletion condition
318
            $categoryid = isset($_GET['categoryid']) ? (int)$_GET['categoryid'] : 0;
319
            xoops_cp_header();
320
            xoops_confirm([
0 ignored issues
show
Bug introduced by
The function xoops_confirm 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

320
            /** @scrutinizer ignore-call */ 
321
            xoops_confirm([
Loading history...
321
                              'op'         => 'del',
322
                              'categoryid' => $categoryObj->categoryid(),
323
                              'confirm'    => 1,
324
                              'name'       => $categoryObj->name()
325
                          ], 'category.php', _AM_SF_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_SF_DELETE_CAT_CONFIRM, _AM_SF_DELETE);
326
            xoops_cp_footer();
0 ignored issues
show
Bug introduced by
The function xoops_cp_footer 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

326
            /** @scrutinizer ignore-call */ 
327
            xoops_cp_footer();
Loading history...
327
        }
328
        exit();
329
        break;
330
331
    case 'cancel':
332
        redirect_header('category.php', 1, sprintf(_AM_SF_BACK2IDX, ''));
333
        break;
334
    case 'default':
335
    default:
336
        $adminObject = \Xmf\Module\Admin::getInstance();
337
        xoops_cp_header();
338
339
        $adminObject->displayNavigation(basename(__FILE__));
340
        echo "<br>\n";
341
342
        // Creating the objects for top categories
343
        $categoriesObj =& $categoryHandler->getCategories($xoopsModuleConfig['perpage'], $startcategory, 0);
344
345
        Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
346
        echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_CATEGORIES_TITLE . '</h3>';
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
347
        echo "<div id='toptable'>";
348
        echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_SF_CATEGORIES_DSC . '</span>';
349
350
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
351
        echo '<tr>';
352
        echo "<th width='35%' class='bg3' align='left'><b>" . _AM_SF_ARTCOLNAME . '</b></td>';
353
        echo "<th class='bg3' align='left'><b>" . _AM_SF_DESCRIP . '</b></td>';
354
        echo "<th class='bg3' width='65' align='center'><b>" . _AM_SF_WEIGHT . '</b></td>';
355
        echo "<th width='60' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>';
356
        echo '</tr>';
357
        $totalCategories = $categoryHandler->getCategoriesCount(0);
358
        if (count($categoriesObj) > 0) {
359
            foreach ($categoriesObj as $key => $thiscat) {
360
                displayCategory($thiscat);
361
            }
362
        } else {
363
            echo '<tr>';
364
            echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOCAT . '</td>';
365
            echo '</tr>';
366
            $categoryid = '0';
367
        }
368
        echo "</table>\n";
369
        require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
370
        $pagenav = new \XoopsPageNav($totalCategories, $xoopsModuleConfig['perpage'], $startcategory, 'startcategory');
0 ignored issues
show
Bug introduced by
The type XoopsPageNav 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...
371
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
372
        echo '</div>';
373
374
        editcat(false);
375
376
        break;
377
}
378
379
require_once __DIR__ . '/admin_footer.php';
380