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