Passed
Push — master ( 81ba93...c6c854 )
by Michael
03:30
created
1
<?php
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 */
8
9
use XoopsModules\Smartfaq;
10
/** @var Smartfaq\Helper $helper */
11
$helper = Smartfaq\Helper::getInstance();
12
13
require_once __DIR__ . '/header.php';
14
15
$faqid = \Xmf\Request::getInt('faqid', 0, 'GET');
16
17
if (0 == $faqid) {
18
    redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED);
19
}
20
21
// Creating the FAQ handler object
22
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
23
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq');
24
25
// Creating the FAQ object for the selected FAQ
26
$faqObj = new Smartfaq\Faq($faqid);
27
28
// If the selected FAQ was not found, exit
29
if ($faqObj->notLoaded()) {
30
    redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED);
31
}
32
33
// Creating the category object that holds the selected FAQ
34
$categoryObj = $faqObj->category();
35
36
// Creating the answer object
37
$answerObj = $faqObj->answer();
38
39
// Check user permissions to access that category of the selected FAQ
40
$faqAccessGrantedResult = Smartfaq\Utility::faqAccessGranted($faqObj);
41
if ($faqAccessGrantedResult < 0) {
42
    redirect_header('javascript:history.go(-1)', 1, _NOPERM);
43
}
44
45
// Update the read counter of the selected FAQ
46
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && 1 == $helper->getConfig('adminhits'))
47
    || ($xoopsUser
48
        && !$xoopsUser->isAdmin($xoopsModule->mid()))) {
49
    $faqObj->updateCounter();
50
}
51
$GLOBALS['xoopsOption']['template_main'] = 'smartfaq_faq.tpl';
52
require_once XOOPS_ROOT_PATH . '/header.php';
53
require_once __DIR__ . '/footer.php';
54
55
$faq = $faqObj->toArray(null, $categoryObj, false);
56
57
// Populating the smarty variables with informations related to the selected FAQ
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
58
/*$faq['questionlink'] = $faqObj->question($helper->getConfig('questionsize'));
59
$faq['question'] = $faqObj->question();
60
61
$faq['categoryid'] = $categoryObj->categoryid();
62
$faq['categoryname'] = $categoryObj->name();
63
64
$faq['categorydescription'] = $categoryObj->description();
65
$faq['counter'] = $faqObj->counter();
66
$faq['comments'] = $faqObj->comments();
67
$faq['cancomment'] = $faqObj->cancomment();
68
*/
69
$faq['categoryPath'] = $categoryObj->getCategoryPath(true);
70
$faq['answer']       = $answerObj->answer();
71
72
// Check to see if we need to display partial answer. This should probably be in a the FAQ class...
73
if (0 == $faqAccessGrantedResult) {
74
    $faq['answer'] = xoops_substr($faq['answer'], 0, 150);
75
}
76
77
$faq['who_when'] = $faqObj->getWhoAndWhen();
78
79
$faq['adminlink'] = Smartfaq\Utility::getAdminLinks($faqObj->faqid());
80
81
$faq['comments'] = $faqObj->comments();
82
83
// Language constants
84
$xoopsTpl->assign('faq', $faq);
85
$xoopsTpl->assign('display_categoryname', false);
86
87
$xoopsTpl->assign('xcodes', $faqObj->getVar('xcodes'));
88
$xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_MD_SF_INTARTICLE, $xoopsConfig['sitename']) . '&amp;body=' . sprintf(_MD_SF_INTARTFOUND, $xoopsConfig['sitename']) . ':  ' . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/faq.php?faqid=' . $faqObj->getVar('faqid'));
89
$xoopsTpl->assign('lang_printerpage', _MD_SF_PRINTERFRIENDLY);
90
$xoopsTpl->assign('lang_sendstory', _MD_SF_SENDSTORY);
91
$xoopsTpl->assign('faqid', $faqObj->getVar('faqid'));
92
$xoopsTpl->assign('lang_reads', _MD_SF_READS);
93
$xoopsTpl->assign('lang_home', _MD_SF_HOME);
94
$xoopsTpl->assign('lang_faq', _MD_SF_FAQ);
95
$xoopsTpl->assign('lang_postedby', _MD_SF_POSTEDBY);
96
$xoopsTpl->assign('lang_on', _MD_SF_ON);
97
$xoopsTpl->assign('lang_datesub', _MD_SF_DATESUB);
98
$xoopsTpl->assign('lang_hitsdetail', _MD_SF_HITSDETAIL);
99
$xoopsTpl->assign('lang_hits', _MD_SF_READS);
100
$xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS);
101
102
// Page Title Hack by marcan
103
$module_name = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
104
$xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $categoryObj->name() . ' - ' . $faq['question']);
105
// End Page Title Hack by marcan
106
107
// Include the comments if the selected FAQ supports comments
108
if (1 == $faqObj->cancomment()) {
109
    require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
110
}
111
112
//code to include smartie
113
if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
114
    require_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
115
    $xoopsTpl->assign('smarttie', 1);
116
}
117
//end code for smarttie
118
119
require_once XOOPS_ROOT_PATH . '/footer.php';
120