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 | include_once(XOOPS_ROOT_PATH . '/header.php'); |
||
11 | |||
12 | global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
||
13 | |||
14 | // Creating the category handler object |
||
15 | $categoryHandler = sf_gethandler('category'); |
||
16 | |||
17 | // Creating the FAQ handler object |
||
18 | $faqHandler = sf_gethandler('faq'); |
||
19 | |||
20 | // Get the total number of categories |
||
21 | $totalCategories = count($categoryHandler->getCategories()); |
||
22 | |||
23 | if ($totalCategories == 0) { |
||
24 | redirect_header('index.php', 1, _AM_SF_NOCOLEXISTS); |
||
25 | } |
||
26 | |||
27 | // Find if the user is admin of the module |
||
28 | $isAdmin = sf_userIsAdmin(); |
||
29 | // If the user is not admin AND we don't allow user submission, exit |
||
30 | View Code Duplication | if (!($isAdmin || (isset($xoopsModuleConfig['allowrequest']) && $xoopsModuleConfig['allowrequest'] == 1 && (is_object($xoopsUser) || (isset($xoopsModuleConfig['anonpost']) && $xoopsModuleConfig['anonpost'] == 1))))) { |
|
31 | redirect_header('index.php', 1, _NOPERM); |
||
32 | } |
||
33 | |||
34 | $op = ''; |
||
35 | |||
36 | if (isset($_GET['op'])) { |
||
37 | $op = $_GET['op']; |
||
38 | } |
||
39 | if (isset($_POST['op'])) { |
||
40 | $op = $_POST['op']; |
||
41 | } |
||
42 | |||
43 | switch ($op) { |
||
44 | case 'post': |
||
45 | |||
46 | global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
||
47 | |||
48 | $newFaqObj = $faqHandler->create(); |
||
49 | |||
50 | View Code Duplication | if (!$xoopsUser) { |
|
51 | if ($xoopsModuleConfig['anonpost'] == 1) { |
||
52 | $uid = 0; |
||
53 | } else { |
||
54 | redirect_header('index.php', 3, _NOPERM); |
||
55 | } |
||
56 | } else { |
||
57 | $uid = $xoopsUser->uid(); |
||
58 | } |
||
59 | |||
60 | // Putting the values about the FAQ in the FAQ object |
||
61 | $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
||
62 | $newFaqObj->setVar('uid', $uid); |
||
63 | $newFaqObj->setVar('question', $_POST['question']); |
||
64 | $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
||
65 | $newFaqObj->setVar('notifypub', $notifypub); |
||
66 | |||
67 | // Setting the status of the FAQ |
||
68 | if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
||
69 | $newFaqObj->setVar('status', _SF_STATUS_OPENED); |
||
70 | } else { |
||
71 | $newFaqObj->setVar('status', _SF_STATUS_ASKED); |
||
72 | } |
||
73 | |||
74 | // Storing the FAQ object in the database |
||
75 | if (!$newFaqObj->store()) { |
||
76 | redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . sf_formatErrors($newFaqObj->getErrors())); |
||
77 | } |
||
78 | |||
79 | // Get the cateopry object related to that FAQ |
||
80 | // If autoapprove_requested |
||
81 | if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
||
82 | // We do not not subscribe user to notification on publish since we publish it right away |
||
83 | |||
84 | // Send notifications |
||
85 | $newFaqObj->sendNotifications(array(_SF_NOT_QUESTION_PUBLISHED)); |
||
86 | |||
87 | $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED; |
||
88 | View Code Duplication | } else { |
|
89 | // Subscribe the user to On Published notification, if requested |
||
90 | if ($notifypub == 1) { |
||
91 | include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
||
92 | $notificationHandler = xoops_getHandler('notification'); |
||
93 | $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
||
94 | } |
||
95 | // Send notifications |
||
96 | $newFaqObj->sendNotifications(array(_SF_NOT_QUESTION_SUBMITTED)); |
||
97 | |||
98 | $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL; |
||
99 | } |
||
100 | |||
101 | //redirect_header("javascript:history.go(-2)", 3, $redirect_msg); |
||
102 | redirect_header('index.php', 2, $redirect_msg); |
||
103 | break; |
||
104 | |||
105 | case 'form': |
||
106 | default: |
||
107 | |||
108 | global $xoopsUser, $myts; |
||
109 | |||
110 | $xoopsOption['template_main'] = 'smartfaq_submit.tpl'; |
||
111 | include_once(XOOPS_ROOT_PATH . '/header.php'); |
||
112 | include_once __DIR__ . '/footer.php'; |
||
113 | |||
114 | $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
||
0 ignored issues
–
show
|
|||
115 | |||
116 | $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
||
117 | $xoopsTpl->assign('whereInSection', $moduleName); |
||
118 | $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST); |
||
119 | |||
120 | $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST); |
||
121 | $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($xoopsModuleConfig['requestintromsg'])); |
||
122 | |||
123 | include_once 'include/request.inc.php'; |
||
124 | |||
125 | $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
||
0 ignored issues
–
show
|
|||
126 | |||
127 | $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name')); |
||
128 | |||
129 | include_once 'include/request.inc.php'; |
||
130 | |||
131 | include_once XOOPS_ROOT_PATH . '/footer.php'; |
||
132 | |||
133 | break; |
||
134 | } |
||
135 |
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.