Passed
Push — master ( 2744eb...81ba93 )
by Michael
02:46
created

buildTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 35 and the first side effect is on line 12.

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

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

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

Loading history...
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 */
8
9
use XoopsModules\Smartfaq;
10
use XoopsModules\Smartfaq\Constants;
11
/** @var Smartfaq\Helper $helper */
12
$helper = Smartfaq\Helper::getInstance();
13
14
require_once __DIR__ . '/admin_header.php';
15
$myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Bug introduced by
The type MyTextSanitizer 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...
16
17
$faqid = \Xmf\Request::getInt('faqid', 0, 'POST');
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...
18
19
//$pick = isset($_GET['pick'])? (int)($_GET['pick']) : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
76% 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...
20
//$pick = isset($_POST['pick'])? (int)($_POST['pick']) : $_GET['pick'];
21
22
$statussel = \Xmf\Request::getInt('statussel', Constants::SF_STATUS_ALL, 'GET');
23
$statussel = \Xmf\Request::getInt('statussel', $statussel, 'POST');
24
25
$sortsel = isset($_GET['sortsel']) ? $_GET['sortsel'] : 'faqid';
26
$sortsel = isset($_POST['sortsel']) ? $_POST['sortsel'] : $sortsel;
27
28
$ordersel = isset($_GET['ordersel']) ? $_GET['ordersel'] : 'DESC';
29
$ordersel = isset($_POST['ordersel']) ? $_POST['ordersel'] : $ordersel;
30
31
$module_id    = $xoopsModule->getVar('mid');
32
$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

32
$gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
33
$groups       = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
Bug introduced by
The constant XOOPS_GROUP_ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
34
35
function buildTable()
36
{
37
    global $xoopsConfig,  $xoopsModule;
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...
38
    /** @var Smartfaq\Helper $helper */
39
    $helper = Smartfaq\Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
40
41
    echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>";
42
    echo '<tr>';
43
    echo "<th width='40' class='bg3' align='center'><b>" . _AM_SF_FAQID . '</b></td>';
44
    echo "<th width='20%' class='bg3' align='center'><b>" . _AM_SF_FAQCAT . '</b></td>';
45
    echo "<th class='bg3' align='center'><b>" . _AM_SF_QUESTION . '</b></td>';
46
47
    echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_ASKED . '</b></td>';
48
    echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_ANSWERED . '</b></td>';
49
50
    echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_CREATED . '</b></td>';
51
    echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_STATUS . '</b></td>';
52
    //echo "<td width='30' class='bg3' align='center'><b>" . _AM_SF_ANSWERS . "</b></td>";
53
    echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>';
54
    echo '</tr>';
55
}
56
57
// Code for the page
58
require_once XOOPS_ROOT_PATH . '/class/xoopslists.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...
59
require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
60
61
// Creating the category handler object
62
/** @var \XoopsModules\Smartfaq\CategoryHandler $categoryHandler */
63
$categoryHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Category');
64
65
// Creating the FAQ handler object
66
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
67
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq');
68
69
$startentry = \Xmf\Request::getInt('startentry', 0, 'GET');
70
71
$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...
72
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

72
/** @scrutinizer ignore-call */ 
73
xoops_cp_header();
Loading history...
73
$adminObject->displayNavigation(basename(__FILE__));
74
global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $faqid;
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...
75
76
// Total FAQs -- includes everything on the table
77
$totalfaqs = $faqHandler->getFaqsCount();
78
79
// Total categories
80
$totalcategories = $categoryHandler->getCategoriesCount(-1);
81
82
// Total FAQ count by status
83
$totalfaqbystatus = $faqHandler->getFaqsCountByStatus();
84
85
// Total asked FAQs
86
$totalasked = isset($totalfaqbystatus[Constants::SF_STATUS_ASKED]) ? $totalfaqbystatus[Constants::SF_STATUS_ASKED] : 0;
87
88
// Total opened FAQs
89
$totalopened = isset($totalfaqbystatus[Constants::SF_STATUS_OPENED]) ? $totalfaqbystatus[Constants::SF_STATUS_OPENED] : 0;
90
91
// Total answered FAQs
92
$totalanswered = isset($totalfaqbystatus[Constants::SF_STATUS_ANSWERED]) ? $totalfaqbystatus[Constants::SF_STATUS_ANSWERED] : 0;
93
94
// Total submitted FAQs
95
$totalsubmitted = isset($totalfaqbystatus[Constants::SF_STATUS_SUBMITTED]) ? $totalfaqbystatus[Constants::SF_STATUS_SUBMITTED] : 0;
96
97
// Total published FAQs
98
$totalpublished = isset($totalfaqbystatus[Constants::SF_STATUS_PUBLISHED]) ? $totalfaqbystatus[Constants::SF_STATUS_PUBLISHED] : 0;
99
100
// Total offline FAQs
101
$totaloffline = isset($totalfaqbystatus[Constants::SF_STATUS_OFFLINE]) ? $totalfaqbystatus[Constants::SF_STATUS_OFFLINE] : 0;
102
103
// Total rejected question
104
$totalrejectedquestion = isset($totalfaqbystatus[Constants::SF_STATUS_REJECTED_QUESTION]) ? $totalfaqbystatus[Constants::SF_STATUS_REJECTED_QUESTION] : 0;
105
106
// Total rejected smartfaq
107
$totalrejectedsmartfaq = isset($totalfaqbystatus[Constants::SF_STATUS_REJECTED_SMARTFAQ]) ? $totalfaqbystatus[Constants::SF_STATUS_REJECTED_SMARTFAQ] : 0;
108
109
// Total Q&A with new answers
110
$totalnewanswers = isset($totalfaqbystatus[Constants::SF_STATUS_NEW_ANSWER]) ? $totalfaqbystatus[Constants::SF_STATUS_NEW_ANSWER] : 0;
111
112
// -- //
113
//Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
114
//echo "<img onclick='toggle('toptable'); toggleIcon('toptableicon');' id='toptableicon' name='toptableicon' src=" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_INVENTORY . "</h3>";
115
//echo "<div id='toptable'>";
116
//echo "<br>";
117
//echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>";
118
//echo "<td class='head'>" . _AM_SF_TOTALCAT . "</td><td align='center' class='even'>" . $totalcategories . "</td>";
119
//echo "<td class='head'>" . _AM_SF_TOTALASKED . "</td><td align='center' class='even'>" . $totalasked . "</td>";
120
//echo "<td class='head'>" . _AM_SF_TOTALOPENED . "</td><td align='center' class='even'>" . $totalopened . "</td>";
121
//echo "<td class='head'>" . _AM_SF_TOTALSUBMITTED . "</td><td align='center' class='even'>" . $totalsubmitted . "</td>";
122
//echo "<td class='head'>" . _AM_SF_TOTALPUBLISHED . "</td><td align='center' class='even'>" . $totalpublished . "</td>";
123
//echo "<td class='head'>" . _AM_SF_TOTALNEWANSWERS . "</td><td align='center' class='even'>" . $totalnewanswers . "</td>";
124
//echo "</tr></table>";
125
//echo "<br>";
126
127
//$adminObject  = \Xmf\Module\Admin::getInstance();
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
128
$adminObject->addItemButton(_AM_SF_CATEGORY_CREATE, 'category.php?op=mod', 'add', '');
129
$adminObject->addItemButton(_AM_SF_CREATEART, 'faq.php?op=mod', 'add', '');
130
$adminObject->addItemButton(_AM_SF_CREATEQUESTION, 'question.php?op=mod', 'add', '');
131
$adminObject->displayButton('left', '');
132
133
//echo "<form><div style=\"margin-bottom: 24px;\">";
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% 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...
134
//echo "<input type='button' name='button' onclick=\"location='category.php?op=mod'\" value='" . _AM_SF_CATEGORY_CREATE . "'>&nbsp;&nbsp;";
135
//echo "<input type='button' name='button' onclick=\"location='faq.php?op=mod'\" value='" . _AM_SF_CREATEART . "'>&nbsp;&nbsp;";
136
//echo "<input type='button' name='button' onclick=\"location='question.php?op=mod'\" value='" . _AM_SF_CREATEQUESTION . "'>&nbsp;&nbsp;";
137
//echo "</div></form>";
138
//echo "</div>";
139
140
// Construction of lower table
141
Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon');
142
echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_ALLFAQS . '</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...
143
echo "<div id='bottomtable'>";
144
echo '<span style="color: #567; margin: 3px 0 18px 0; font-size: small; display: block; ">' . _AM_SF_ALLFAQSMSG . '</span>';
145
146
$showingtxt    = '';
147
$selectedtxt   = '';
148
$cond          = '';
149
$selectedtxt0  = '';
150
$selectedtxt1  = '';
151
$selectedtxt2  = '';
152
$selectedtxt3  = '';
153
$selectedtxt4  = '';
154
$selectedtxt5  = '';
155
$selectedtxt6  = '';
156
$selectedtxt7  = '';
157
$selectedtxt8  = '';
158
$selectedtxt9  = '';
159
$selectedtxt10 = '';
160
161
$sorttxtquestion = '';
162
$sorttxtcategory = '';
163
$sorttxtcreated  = '';
164
$sorttxtweight   = '';
165
$sorttxtfaqid    = '';
166
167
$ordertxtasc  = '';
168
$ordertxtdesc = '';
169
170
switch ($sortsel) {
171
    case 'faq.question':
172
        $sorttxtquestion = 'selected';
173
        break;
174
175
    case 'category.name':
176
        $sorttxtcategory = 'selected';
177
        break;
178
179
    case 'faq.datesub':
180
        $sorttxtcreated = 'selected';
181
        break;
182
183
    case 'faq.weight':
184
        $sorttxtweight = 'selected';
185
        break;
186
187
    default:
188
        $sorttxtfaqid = 'selected';
189
        break;
190
}
191
192
switch ($ordersel) {
193
    case 'ASC':
194
        $ordertxtasc = 'selected';
195
        break;
196
197
    default:
198
        $ordertxtdesc = 'selected';
199
        break;
200
}
201
202
switch ($statussel) {
203
    case Constants::SF_STATUS_ALL:
204
        $selectedtxt0        = 'selected';
205
        $caption             = _AM_SF_ALL;
206
        $cond                = '';
207
        $status_explaination = _AM_SF_ALL_EXP;
208
        break;
209
210
    case Constants::SF_STATUS_ASKED:
211
        $selectedtxt1        = 'selected';
212
        $caption             = _AM_SF_ASKED;
213
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_ASKED . ' ';
214
        $status_explaination = _AM_SF_ASKED_EXP;
215
        break;
216
217
    case Constants::SF_STATUS_OPENED:
218
        $selectedtxt2        = 'selected';
219
        $caption             = _AM_SF_OPENED;
220
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_OPENED . ' ';
221
        $status_explaination = _AM_SF_OPENED_EXP;
222
        break;
223
224
    case Constants::SF_STATUS_ANSWERED:
225
        $selectedtxt3        = 'selected';
226
        $caption             = _AM_SF_ANSWERED;
227
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_ANSWERED . ' ';
228
        $status_explaination = _AM_SF_ANSWERED_EXP;
229
        break;
230
231
    case Constants::SF_STATUS_SUBMITTED:
232
        $selectedtxt4        = 'selected';
233
        $caption             = _AM_SF_SUBMITTED;
234
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_SUBMITTED . ' ';
235
        $status_explaination = _AM_SF_SUBMITTED_EXP;
236
        break;
237
238
    case Constants::SF_STATUS_PUBLISHED:
239
        $selectedtxt5        = 'selected';
240
        $caption             = _AM_SF_PUBLISHED;
241
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_PUBLISHED . ' ';
242
        $status_explaination = _AM_SF_PUBLISHED_EXP;
243
        break;
244
245
    case Constants::SF_STATUS_NEW_ANSWER:
246
        $selectedtxt6        = 'selected';
247
        $caption             = _AM_SF_NEW_ANSWER;
248
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_NEW_ANSWER . ' ';
249
        $status_explaination = _AM_SF_NEW_ANSWER_EXP;
250
        break;
251
252
    case Constants::SF_STATUS_OFFLINE:
253
        $selectedtxt7        = 'selected';
254
        $caption             = _AM_SF_OFFLINE;
255
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_OFFLINE . ' ';
256
        $status_explaination = _AM_SF_OFFLINE_EXP;
257
        break;
258
259
    case Constants::SF_STATUS_REJECTED_QUESTION:
260
        $selectedtxt8        = 'selected';
261
        $caption             = _AM_SF_REJECTED_QUESTION;
262
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_REJECTED_QUESTION . ' ';
263
        $status_explaination = _AM_SF_REJECTED_QUESTION_EXP;
264
        break;
265
266
    case Constants::SF_STATUS_REJECTED_SMARTFAQ:
267
        $selectedtxt9        = 'selected';
268
        $caption             = _AM_SF_REJECTED_SMARTFAQ;
269
        $cond                = ' WHERE status = ' . Constants::SF_STATUS_REJECTED_SMARTFAQ . ' ';
270
        $status_explaination = _AM_SF_REJECTED_SMARTFAQ_EXP;
271
        break;
272
}
273
274
/* -- Code to show selected terms -- */
275
echo "<form name='pick' id='pick' action='" . $_SERVER['PHP_SELF'] . "' method='POST' style='margin: 0;'>";
276
277
echo "
278
    <table width='100%' cellspacing='1' cellpadding='2' border='0' style='border-left: 1px solid silver; border-top: 1px solid silver; border-right: 1px solid silver;'>
279
        <tr>
280
            <td><span style='font-weight: bold; font-size: 12px; font-variant: small-caps;'>" . _AM_SF_SHOWING . ' ' . $caption . "</span></td>
281
            <td align='right'>" . _AM_SF_SELECT_SORT . "
282
                <select name='sortsel' onchange='submit()'>
283
                    <option value='faq.faqid' $sorttxtfaqid>" . _AM_SF_ID . "</option>
284
                    <option value='category.name' $sorttxtcategory>" . _AM_SF_CATEGORY . "</option>
285
                    <option value='faq.question' $sorttxtquestion>" . _AM_SF_QUESTION . "</option>
286
                    <option value='faq.datesub' $sorttxtcreated>" . _AM_SF_CREATED . "</option>
287
                    <option value='faq.weight' $sorttxtweight>" . _AM_SF_WEIGHT . "</option>
288
                </select>
289
                <select name='ordersel' onchange='submit()'>
290
                    <option value='ASC' $ordertxtasc>" . _AM_SF_ASC . "</option>
291
                    <option value='DESC' $ordertxtdesc>" . _AM_SF_DESC . '</option>
292
                </select>
293
            ' . _AM_SF_SELECT_STATUS . " :
294
                <select name='statussel' onchange='submit()'>
295
                    <option value='0' $selectedtxt0>" . _AM_SF_ALL . " [$totalfaqs]</option>
296
                    <option value='1' $selectedtxt1>" . _AM_SF_ASKED . " [$totalasked]</option>
297
                    <option value='2' $selectedtxt2>" . _AM_SF_OPENED . " [$totalopened]</option>
298
                    <option value='3' $selectedtxt3>" . _AM_SF_ANSWERED . " [$totalanswered]</option>
299
                    <option value='4' $selectedtxt4>" . _AM_SF_SUBMITTED . " [$totalsubmitted]</option>
300
                    <option value='5' $selectedtxt5>" . _AM_SF_PUBLISHED . " [$totalpublished]</option>
301
                    <option value='6' $selectedtxt6>" . _AM_SF_NEWANSWER . " [$totalnewanswers]</option>
302
                    <option value='7' $selectedtxt7>" . _AM_SF_OFFLINE . " [$totaloffline]</option>
303
                    <option value='8' $selectedtxt8>" . _AM_SF_REJECTED_QUESTION . " [$totalrejectedquestion]</option>
304
                    <option value='9' $selectedtxt9>" . _AM_SF_REJECTED_SMARTFAQ . " [$totalrejectedsmartfaq]</option>
305
                </select>
306
            </td>
307
        </tr>
308
    </table>
309
    </form>";
310
311
// Get number of entries in the selected state
312
$numrows        = (0 == $statussel) ? $totalfaqs : $totalfaqbystatus[$statussel];
313
$statusSelected = (0 == $statussel) ? Constants::SF_STATUS_ALL : $statussel;
314
315
// creating the Q&As objects
316
$faqsObj = $faqHandler->getFaqsAdminSide($helper->getConfig('perpage'), $startentry, $statusSelected, -1, $sortsel, $ordersel);
317
318
// fetching all categories
319
$allCats          = $categoryHandler->getObjects(null, true);
320
//$totalItemsOnPage = count($faqsObj);
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
321
buildTable();
322
323
if ($numrows > 0) {
324
325
    //$answer_criteria = new \Criteria('faqid', "(".implode(',', array_keys($faqsObj)).")", 'IN');
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...
326
    //$answer_criteria->setGroupby("faqid");
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...
327
    //$answerHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Answer');
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...
328
    //$answer_arr = $answerHandler->getCountByFAQ($answer_criteria);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
329
330
    foreach (array_keys($faqsObj) as $i) {
0 ignored issues
show
Bug introduced by
It seems like $faqsObj can also be of type boolean; however, parameter $input of array_keys() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

330
    foreach (array_keys(/** @scrutinizer ignore-type */ $faqsObj) as $i) {
Loading history...
331
        // Creating the category object to which this faq is linked
332
        $categoryObj = $allCats[$faqsObj[$i]->categoryid()];
333
        global $pathIcon16, $smartModuleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

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

1. Pass all data via parameters

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

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

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

    public function myFunction() {
        // Do something
    }
}
Loading history...
334
335
        //$answers = $answer_arr[$i];
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
336
337
        $approve = '';
338
339
        switch ($faqsObj[$i]->status()) {
340
            case Constants::SF_STATUS_ASKED:
341
                $statustxt = _AM_SF_ASKED;
342
                $approve   = "<a href='question.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/on.png' . "'  title='" . _AM_SF_QUESTION_MODERATE . "'  alt='" . _AM_SF_QUESTION_MODERATE . "'></a>&nbsp;";
343
                $modify    = '';
344
                $delete    = "<a href='question.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEQUESTION . "' alt='" . _AM_SF_DELETEQUESTION . "'></a>";
345
                break;
346
347
            case Constants::SF_STATUS_OPENED:
348
                $statustxt = _AM_SF_OPENED;
349
                $approve   = '';
350
                $modify    = "<a href='question.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_QUESTION_EDIT . "' alt='" . _AM_SF_QUESTION_EDIT . "'></a>&nbsp;";
351
                $delete    = "<a href='question.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEQUESTION . "' alt='" . _AM_SF_DELETEQUESTION . "'></a>";
352
                break;
353
354
            case Constants::SF_STATUS_ANSWERED:
355
                $statustxt = _AM_SF_ANSWERED;
356
                $approve   = "<a href='answer.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/approve.gif' title='" . _AM_SF_ANSWERED_MODERATE . "' alt='" . _AM_SF_ANSWERED_MODERATE . "'></a>&nbsp;";
357
                $modify    = '';
358
                $delete    = "<a href='question.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/delete.gif' title='" . _AM_SF_DELETEQUESTION . "' alt='" . _AM_SF_DELETEQUESTION . "'></a>";
359
                break;
360
361
            case Constants::SF_STATUS_SUBMITTED:
362
                $statustxt = _AM_SF_SUBMITTED;
363
                $approve   = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/approve.gif' title='" . _AM_SF_SUBMISSION_MODERATE . "' alt='" . _AM_SF_SUBMISSION_MODERATE . "'></a>&nbsp;";
364
                $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/delete.gif' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
365
                $modify    = '';
366
                break;
367
368
            case Constants::SF_STATUS_PUBLISHED:
369
                $statustxt = _AM_SF_PUBLISHED;
370
                $approve   = '';
371
                $modify    = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_FAQ_EDIT . "' alt='" . _AM_SF_FAQ_EDIT . "'></a>&nbsp;";
372
                $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
373
                break;
374
375
            case Constants::SF_STATUS_NEW_ANSWER:
376
                $statustxt = _AM_SF_NEWANSWER;
377
                $approve   = "<a href='answer.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/approve.gif' title='" . _AM_SF_FAQ_EDIT . "' alt='" . _AM_SF_FAQ_EDIT . "'></a>&nbsp;";
378
                $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/delete.gif' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
379
                $modify    = '';
380
                break;
381
382
            case Constants::SF_STATUS_OFFLINE:
383
                $statustxt = _AM_SF_OFFLINE;
384
                $approve   = '';
385
                $modify    = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_FAQ_EDIT . "' alt='" . _AM_SF_FAQ_EDIT . "'></a>&nbsp;";
386
                $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
387
                break;
388
389
            case Constants::SF_STATUS_REJECTED_QUESTION:
390
                $statustxt = _AM_SF_REJECTED_QUESTION;
391
                $approve   = '';
392
                $modify    = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_REJECTED_EDIT . "' alt='" . _AM_SF_REJECTED_EDIT . "'></a>&nbsp;";
393
                $delete    = "<a href='question.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEQUESTION . "' alt='" . _AM_SF_DELETEQUESTION . "'></a>";
394
                break;
395
396
            case Constants::SF_STATUS_REJECTED_SMARTFAQ:
397
                $statustxt = _AM_SF_REJECTED_SMARTFAQ;
398
                $approve   = '';
399
                $modify    = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_REJECTED_EDIT . "' alt='" . _AM_SF_REJECTED_EDIT . "'></a>&nbsp;";
400
                $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
401
                break;
402
403
            case 'default':
404
            default:
405
                $statustxt = _AM_SF_STATUS0;
406
                $approve   = '';
407
                $modify    = '';
408
                break;
409
        }
410
411
        //$modify = "<a href='faq.php?op=mod&amp;faqid=" . $faqid . "'><img src='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/assets/images/icon/edit.gif' alt='" . _AM_SF_EDITART . "'></a>&nbsp;";
412
413
        echo '<tr>';
414
        echo "<td class='head' align='center'>" . $faqsObj[$i]->faqid() . '</td>';
415
        echo "<td class='even' align='left'>" . $categoryObj->name() . '</td>';
416
        echo "<td class='even' align='left'>" . $faqsObj[$i]->question(100) . '</td>';
417
418
        //mb---------------------------------------
419
        //adding name of the Question Submitter
420
        $requester = Smartfaq\Utility::getLinkedUnameFromId($faqsObj[$i]->uid(), $smartModuleConfig['userealname']);
421
        echo "<td class='even' align='center'>" . $requester . '</td>';
422
423
        //adding name of the Answer Submitter
424
        /** @var \XoopsModules\Smartfaq\AnswerHandler $answerHandler */
425
        $answerHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Answer');
426
427
        $criteria = new \CriteriaCompo();
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...
428
        $criteria->add(new \Criteria('faqid', $faqsObj[$i]->faqid()));
0 ignored issues
show
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...
429
        $criteria->add(new \Criteria('status', true));
430
431
        $answerObjects =& $answerHandler->getObjects($criteria, true);
432
433
        foreach (array_keys($answerObjects) as $j) {
434
            $answerObj = $answerObjects[$j];
435
        }
436
437
        if (isset($answerObj->vars['uid']['value'])) {
438
            $answerSubmitterID = $answerObj->vars['uid']['value'];
439
440
            $answerSubmitter = Smartfaq\Utility::getLinkedUnameFromId($answerSubmitterID, $smartModuleConfig['userealname']);
441
        } else {
442
            $answerSubmitter = '--------';
443
        }
444
        echo "<td class='even' align='center'>" . $answerSubmitter . '</td>';
445
446
        //mb---------------------------------------
447
448
        echo "<td class='even' align='center'>" . $faqsObj[$i]->datesub('s') . '</td>';
449
        echo "<td class='even' align='center'>" . $statustxt . '</td>';
450
        //echo "<td class='even' align='center'>" . $answers . "</td>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% 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...
451
        echo "<td class='even' align='center'> " . $approve . $modify . $delete . '</td>';
452
        echo '</tr>';
453
    }
454
} else {
455
    // that is, $numrows = 0, there's no entries yet
456
    echo '<tr>';
457
    echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOFAQSSEL . '</td>';
458
    echo '</tr>';
459
}
460
echo "</table>\n";
461
echo "<span style=\"color: #567; margin: 3px 0 18px 0; font-size: small; display: block; \">$status_explaination</span>";
462
$pagenav = new \XoopsPageNav($numrows, $helper->getConfig('perpage'), $startentry, 'startentry', "statussel=$statussel&amp;sortsel=$sortsel&amp;ordersel=$ordersel");
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...
463
464
if (1 == $helper->getConfig('useimagenavpage')) {
465
    echo '<div style="text-align:right; background-color: white; margin: 10px 0;">' . $pagenav->renderImageNav() . '</div>';
466
} else {
467
    echo '<div style="text-align:right; background-color: white; margin: 10px 0;">' . $pagenav->renderNav() . '</div>';
468
}
469
// ENDs code to show active entries
470
echo '</div>';
471
// Close the collapsable div
472
echo '</div>';
473
echo '</div>';
474
475
require_once __DIR__ . '/admin_footer.php';
476