Passed
Push — master ( 81ba93...c6c854 )
by Michael
03:30
created

include/displayfaqs.php (1 issue)

Labels
Severity
1
<?php
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
12
/** @var Smartfaq\Helper $helper */
13
$helper = Smartfaq\Helper::getInstance();
14
$smartModuleConfig = $helper->getConfig();
15
$xoopsModule = $helper->getModule();
16
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
17
18
global $xoopsUser, $xoopsDB;
19
20
echo "<br>\n";
21
if (!isset($categoryid) || ($categoryid < 1)) {
22
    $faqs_title         = _AM_SF_PUBLISHEDFAQS;
23
    $faqs_info          = _AM_SF_PUBLISHED_DSC;
24
    $sel_cat            = -1;
25
    $pagenav_extra_args = '';
26
} else {
27
    $faqs_title         = _AM_SF_PUBLISHEDFAQS_CAT;
28
    $faqs_info          = _AM_SF_PUBLISHED_CAT_DSC;
29
    $sel_cat            = $categoryid;
30
    $pagenav_extra_args = "op=mod&categoryid=$categoryid";
31
}
32
33
Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
34
35
echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . $faqs_title . '</h3>';
36
echo "<div id='toptable'>";
37
echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . $faqs_info . '</span>';
38
39
// Get the total number of published FAQs
40
$totalfaqs = $faqHandler->getFaqsCount($sel_cat, [Constants::SF_STATUS_PUBLISHED, Constants::SF_STATUS_NEW_ANSWER]);
41
42
// creating the FAQ objects that are published
43
$faqsObj = $faqHandler->getAllPublished($helper->getConfig('perpage'), $startfaq, $sel_cat);
44
//$totalFaqsOnPage = count($faqsObj);
45
$allCats = $categoryHandler->getObjects(null, true);
46
echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
47
echo '<tr>';
48
echo "<th width='40' class='bg3' align='center'><b>" . _AM_SF_ARTID . '</b></td>';
49
echo "<th width='20%' class='bg3' align='left'><b>" . _AM_SF_ARTCOLNAME . '</b></td>';
50
echo "<th class='bg3' align='left'><b>" . _AM_SF_QUESTION . '</b></td>';
51
52
echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_ASKED . '</b></td>';
53
echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_ANSWERED . '</b></td>';
54
55
echo "<th width='90' class='bg3' align='center'><b>" . _AM_SF_CREATED . '</b></td>';
56
echo "<th width='60' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>';
57
echo '</tr>';
58
if ($totalfaqs > 0) {
59
    foreach ($faqsObj as $iValue) {
60
        $categoryObj = $allCats[$iValue->categoryid()];
61
        $modify      = "<a href='faq.php?op=mod&amp;faqid=" . $iValue->faqid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_EDITART . "' alt='" . _AM_SF_EDITART . "'></a>";
62
        $delete      = "<a href='faq.php?op=del&amp;faqid=" . $iValue->faqid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_EDITART . "' alt='" . _AM_SF_DELETEART . "'></a>";
63
64
        //adding name of the Question Submitter
65
        $requester = Smartfaq\Utility::getLinkedUnameFromId($iValue->uid(), $smartModuleConfig['userealname']);
66
67
        //adding name of the Answer Submitter
68
        /** @var \XoopsModules\Smartfaq\AnswerHandler $answerHandler */
69
        $answerHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Answer');
70
71
        $criteria = new \CriteriaCompo();
72
        $criteria->add(new \Criteria('faqid', $iValue->faqid()));
73
        $criteria->add(new \Criteria('status', true));
0 ignored issues
show
true of type true is incompatible with the type string expected by parameter $value of Criteria::__construct(). ( Ignorable by Annotation )

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

73
        $criteria->add(new \Criteria('status', /** @scrutinizer ignore-type */ true));
Loading history...
74
75
        $answerObjects = &$answerHandler->getObjects($criteria, true);
76
77
        foreach (array_keys($answerObjects) as $j) {
78
            $answerObj = $answerObjects[$j];
79
        }
80
81
        if (isset($answerObj->vars['uid']['value'])) {
82
            $answerSubmitterID = $answerObj->vars['uid']['value'];
83
84
            $answerSubmitter = Smartfaq\Utility::getLinkedUnameFromId($answerSubmitterID, $smartModuleConfig['userealname']);
85
        } else {
86
            $answerSubmitter = '--------';
87
        }
88
89
        echo '<tr>';
90
        echo "<td class='head' align='center'>" . $iValue->faqid() . '</td>';
91
        echo "<td class='even' align='left'>" . $categoryObj->name() . '</td>';
92
        echo "<td class='even' align='left'><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/faq.php?faqid=' . $iValue->faqid() . "'>" . $iValue->question(100) . '</a></td>';
93
94
        echo "<td class='even' align='center'>" . $requester . '</td>';
95
        echo "<td class='even' align='center'>" . $answerSubmitter . '</td>';
96
97
        echo "<td class='even' align='center'>" . $iValue->datesub('s') . '</td>';
98
        echo "<td class='even' align='center'> $modify $delete </td>";
99
        echo '</tr>';
100
    }
101
} else {
102
    $faqid = -1;
103
    echo '<tr>';
104
    echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOFAQS . '</td>';
105
    echo '</tr>';
106
}
107
echo "</table>\n";
108
echo "<br>\n";
109
110
$pagenav = new \XoopsPageNav($totalfaqs, $helper->getConfig('perpage'), $startfaq, 'startfaq', $pagenav_extra_args);
111
echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
112
echo '</div>';
113