Completed
Push — master ( 454ebd...de22fe )
by Michael
03:58
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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__ . '/header.php';
12
13
$faqid = isset($_GET['faqid']) ? (int)$_GET['faqid'] : 0;
14
15
if (0 == $faqid) {
16
    redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED);
17
}
18
19
// Creating the FAQ handler object
20
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */
21
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq');
22
23
// Creating the FAQ object for the selected FAQ
24
$faqObj = new Smartfaq\Faq($faqid);
25
26
// If the selected FAQ was not found, exit
27
if ($faqObj->notLoaded()) {
28
    redirect_header('javascript:history.go(-1)', 1, _MD_SF_NOFAQSELECTED);
29
}
30
31
// Creating the category object that holds the selected FAQ
32
$categoryObj = $faqObj->category();
33
34
// Creating the answer object
35
$answerObj = $faqObj->answer();
36
37
// Check user permissions to access that category of the selected FAQ
38
$faqAccessGrantedResult = Smartfaq\Utility::faqAccessGranted($faqObj);
39
if ($faqAccessGrantedResult < 0) {
40
    redirect_header('javascript:history.go(-1)', 1, _NOPERM);
41
}
42
43
// Update the read counter of the selected FAQ
44
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && 1 == $xoopsModuleConfig['adminhits'])
45
    || ($xoopsUser
46
        && !$xoopsUser->isAdmin($xoopsModule->mid()))) {
47
    $faqObj->updateCounter();
48
}
49
$GLOBALS['xoopsOption']['template_main'] = 'smartfaq_faq.tpl';
50
require_once XOOPS_ROOT_PATH . '/header.php';
51
require_once __DIR__ . '/footer.php';
52
53
$faq = $faqObj->toArray(null, $categoryObj, false);
54
55
// Populating the smarty variables with informations related to the selected FAQ
56
/*$faq['questionlink'] = $faqObj->question($xoopsModuleConfig['questionsize']);
57
$faq['question'] = $faqObj->question();
58
59
$faq['categoryid'] = $categoryObj->categoryid();
60
$faq['categoryname'] = $categoryObj->name();
61
62
$faq['categorydescription'] = $categoryObj->description();
63
$faq['counter'] = $faqObj->counter();
64
$faq['comments'] = $faqObj->comments();
65
$faq['cancomment'] = $faqObj->cancomment();
66
*/
67
$faq['categoryPath'] = $categoryObj->getCategoryPath(true);
68
$faq['answer']       = $answerObj->answer();
69
70
// Check to see if we need to display partial answer. This should probably be in a the FAQ class...
71
if (0 == $faqAccessGrantedResult) {
72
    $faq['answer'] = xoops_substr($faq['answer'], 0, 150);
73
}
74
75
$faq['who_when'] = $faqObj->getWhoAndWhen();
76
77
$faq['adminlink'] = Smartfaq\Utility::getAdminLinks($faqObj->faqid());
78
79
$faq['comments'] = $faqObj->comments();
80
81
// Language constants
82
$xoopsTpl->assign('faq', $faq);
83
$xoopsTpl->assign('display_categoryname', false);
84
85
$xoopsTpl->assign('xcodes', $faqObj->getVar('xcodes'));
86
$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'));
87
$xoopsTpl->assign('lang_printerpage', _MD_SF_PRINTERFRIENDLY);
88
$xoopsTpl->assign('lang_sendstory', _MD_SF_SENDSTORY);
89
$xoopsTpl->assign('faqid', $faqObj->getVar('faqid'));
90
$xoopsTpl->assign('lang_reads', _MD_SF_READS);
91
$xoopsTpl->assign('lang_home', _MD_SF_HOME);
92
$xoopsTpl->assign('lang_faq', _MD_SF_FAQ);
93
$xoopsTpl->assign('lang_postedby', _MD_SF_POSTEDBY);
94
$xoopsTpl->assign('lang_on', _MD_SF_ON);
95
$xoopsTpl->assign('lang_datesub', _MD_SF_DATESUB);
96
$xoopsTpl->assign('lang_hitsdetail', _MD_SF_HITSDETAIL);
97
$xoopsTpl->assign('lang_hits', _MD_SF_READS);
98
$xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS);
99
100
// Page Title Hack by marcan
101
$module_name = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
102
$xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $categoryObj->name() . ' - ' . $faq['question']);
103
// End Page Title Hack by marcan
104
105
// Include the comments if the selected FAQ supports comments
106
if (1 == $faqObj->cancomment()) {
107
    require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
108
}
109
110
//code to include smartie
111 View Code Duplication
if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
112
    require_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
113
    $xoopsTpl->assign('smarttie', 1);
114
}
115
//end code for smarttie
116
117
require_once XOOPS_ROOT_PATH . '/footer.php';
118