Completed
Branch master (1b2f30)
by Michael
06:29 queued 03:22
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
* $Id: faq.php,v 1.31 2006/09/29 18:49:10 malanciault Exp $
5
* Module: SmartFAQ
6
* Author: The SmartFactory <www.smartfactory.ca>
7
* Licence: GNU
8
*/
9
10
include_once __DIR__ . '/header.php';
11
12
$faqid = isset($_GET['faqid']) ? intval($_GET['faqid']) : 0;
13
14
if ($faqid == 0) {
15
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
16
    exit();
17
}
18
19
// Creating the FAQ handler object
20
$faq_handler =& sf_gethandler('faq');
21
22
// Creating the FAQ object for the selected FAQ
23
$faqObj = new sfFaq($faqid);
24
25
// If the selected FAQ was not found, exit
26
if ($faqObj->notLoaded()) {
27
    redirect_header("javascript:history.go(-1)", 1, _MD_SF_NOFAQSELECTED);
28
    exit();
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 = faqAccessGranted($faqObj);
39
if ($faqAccessGrantedResult < 0) {
40
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
41
    exit;
42
}
43
44
// Update the read counter of the selected FAQ
45
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && $xoopsModuleConfig['adminhits'] == 1) || ($xoopsUser && !$xoopsUser->isAdmin($xoopsModule->mid()))) {
46
    $faqObj->updateCounter();
47
}
48
$xoopsOption['template_main'] = 'smartfaq_faq.tpl';
49
include_once(XOOPS_ROOT_PATH . "/header.php");
50
include_once __DIR__ . '/footer.php';
51
52
$faq = $faqObj->toArray(null, $categoryObj, false);
53
54
// 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...
55
/*$faq['questionlink'] = $faqObj->question($xoopsModuleConfig['questionsize']);
56
$faq['question'] = $faqObj->question();
57
58
$faq['categoryid'] = $categoryObj->categoryid();
59
$faq['categoryname'] = $categoryObj->name();
60
61
$faq['categorydescription'] = $categoryObj->description();
62
$faq['counter'] = $faqObj->counter();
63
$faq['comments'] = $faqObj->comments();
64
$faq['cancomment'] = $faqObj->cancomment();
65
*/
66
$faq['categoryPath'] = $categoryObj->getCategoryPath(true);
67
$faq['answer'] = $answerObj->answer();
68
69
// Check to see if we need to display partial answer. This should probably be in a the FAQ class...
70
if ($faqAccessGrantedResult == 0) {
71
    $faq['answer'] = xoops_substr($faq['answer'], 0, 150);
72
}
73
74
$faq['who_when'] = $faqObj->getWhoAndWhen();
75
76
$faq['adminlink'] = sf_getAdminLinks($faqObj->faqid());
77
78
$faq['comments'] = $faqObj->comments();
79
80
// Language constants
81
$xoopsTpl->assign('faq', $faq);
82
$xoopsTpl->assign('display_categoryname', false);
83
84
$xoopsTpl->assign('xcodes', $faqObj->getVar('xcodes'));
85
$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'));
86
$xoopsTpl->assign('lang_printerpage', _MD_SF_PRINTERFRIENDLY);
87
$xoopsTpl->assign('lang_sendstory', _MD_SF_SENDSTORY);
88
$xoopsTpl->assign('faqid', $faqObj->getVar('faqid'));
89
$xoopsTpl->assign('lang_reads', _MD_SF_READS);
90
$xoopsTpl->assign('lang_home', _MD_SF_HOME);
91
$xoopsTpl->assign('lang_faq', _MD_SF_FAQ);
92
$xoopsTpl->assign('lang_postedby', _MD_SF_POSTEDBY);
93
$xoopsTpl->assign('lang_on', _MD_SF_ON);
94
$xoopsTpl->assign('lang_datesub', _MD_SF_DATESUB);
95
$xoopsTpl->assign('lang_hitsdetail', _MD_SF_HITSDETAIL);
96
$xoopsTpl->assign('lang_hits', _MD_SF_READS);
97
$xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS);
98
99
// Page Title Hack by marcan
100
$module_name = $myts->htmlSpecialChars($xoopsModule->getVar('name'));
101
$xoopsTpl->assign('xoops_pagetitle', $module_name . ' - ' . $categoryObj->name() . ' - ' . $faq['question']);
102
// End Page Title Hack by marcan
103
104
// Include the comments if the selected FAQ supports comments
105
if ($faqObj->cancomment() == 1) {
106
    include_once XOOPS_ROOT_PATH . "/include/comment_view.php";
107
}
108
109
//code to include smartie
110 View Code Duplication
if (file_exists(XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php')) {
111
    include_once XOOPS_ROOT_PATH . '/modules/smarttie/smarttie_links.php';
112
        $xoopsTpl->assign('smarttie',1);
113
}
114
//end code for smarttie
115
116
include_once XOOPS_ROOT_PATH . '/footer.php';
117