@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | define('_MD_SF_MAINHEAD', 'Welcome to the'); |
77 | 77 | define( |
78 | 78 | '_MD_SF_MAININTRO', |
79 | - "In this area of the site, you will find the answers to the frequently asked questions. Each Q&A is placed in a category for easier finding. This is the section from where the random Q&As in the right column of the site come from. Should you not find the answer to a particular question, don't hesitate to <a href='" |
|
80 | - . XOOPS_URL |
|
81 | - . "/forms/askus/form.php'>Ask us a Question!</a>" |
|
79 | + "In this area of the site, you will find the answers to the frequently asked questions. Each Q&A is placed in a category for easier finding. This is the section from where the random Q&As in the right column of the site come from. Should you not find the answer to a particular question, don't hesitate to <a href='" |
|
80 | + . XOOPS_URL |
|
81 | + . "/forms/askus/form.php'>Ask us a Question!</a>" |
|
82 | 82 | ); |
83 | 83 | define('_MD_SF_MAINNOSELECTCAT', 'You did not select a valid category'); |
84 | 84 | define('_MD_SF_MAINNOFAQS', 'There are no Q&As in this category'); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | define('_MD_SF_REQUEST_ERROR', 'An error occured. Your request was not sent.'); |
121 | 121 | define( |
122 | 122 | '_MD_SF_REQUEST_INTRO', |
123 | - 'You did not find the answer to the question you were looking for? No problem! Simply fill the following form in order to request the answer for a new question. The site administrator will review your request and publish this new question in the Open Questions section for someone to answer it!' |
|
123 | + 'You did not find the answer to the question you were looking for? No problem! Simply fill the following form in order to request the answer for a new question. The site administrator will review your request and publish this new question in the Open Questions section for someone to answer it!' |
|
124 | 124 | ); |
125 | 125 | define('_MD_SF_REQUEST_RECEIVED_NEED_APPROVAL', 'Your request has been sent and will be published in the Open Questions section upon approval by a moderator.<br>Thank you for your contribution!'); |
126 | 126 | define('_MD_SF_REQUEST_RECEIVED_AND_PUBLISHED', 'Your request has been sent and automatically published in the Open Questions section. Thank you for your contribution!'); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | define('_AM_SF_CONTEXTMODULELINK', 'Contextually linked to this module'); |
79 | 79 | define( |
80 | 80 | '_AM_SF_CONTEXTMODULELINK_FAQ', |
81 | - "Contextually linked to this module<span style='font-size: xx-small; font-weight: normal; display: block;'>Select the module to which this Q&A will be<br>linked. If the Contextual FAQ block is visible<br>on that module, the 'How do I' statement of<br>this Q&A will be displayed.</span>" |
|
81 | + "Contextually linked to this module<span style='font-size: xx-small; font-weight: normal; display: block;'>Select the module to which this Q&A will be<br>linked. If the Contextual FAQ block is visible<br>on that module, the 'How do I' statement of<br>this Q&A will be displayed.</span>" |
|
82 | 82 | ); |
83 | 83 | define('_AM_SF_CONTEXTOPTIONS', 'Contextual options'); |
84 | 84 | define('_AM_SF_CONTEXTPAGE', 'Contextually linked to this URL'); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | define('_AM_SF_ERROR_FAQ_NOT_SAVED', 'An error occured. The Q&A was not saved in the database.'); |
122 | 122 | define( |
123 | 123 | '_AM_SF_EXACTURL', |
124 | - "Exact URL?<span style='font-size: xx-small; font-weight: normal; display: block;'>If set to 'Yes', the Q&A will only display in the'Specific URL set above'. If set to 'No', the Q&A will be displayed in all pages that match a part of the root of the specific URL. ie; modules/newbb/*.php</span>" |
|
124 | + "Exact URL?<span style='font-size: xx-small; font-weight: normal; display: block;'>If set to 'Yes', the Q&A will only display in the'Specific URL set above'. If set to 'No', the Q&A will be displayed in all pages that match a part of the root of the specific URL. ie; modules/newbb/*.php</span>" |
|
125 | 125 | ); |
126 | 126 | define('_AM_SF_FAQ_EDIT', 'Edit this Q&A'); |
127 | 127 | define('_AM_SF_FAQ_NEW_ANSWER_PUBLISHED', 'The original answer was replaced by this answer.'); |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | * Author: The SmartFactory <www.smartfactory.ca> |
6 | 6 | * Licence: GNU |
7 | 7 | */ |
8 | -require_once __DIR__ . '/header.php'; |
|
8 | +require_once __DIR__.'/header.php'; |
|
9 | 9 | |
10 | 10 | // At which record shall we start for the Categories |
11 | -$catstart = isset($_GET['catstart']) ? (int)$_GET['catstart'] : 0; |
|
11 | +$catstart = isset($_GET['catstart']) ? (int) $_GET['catstart'] : 0; |
|
12 | 12 | |
13 | 13 | // At which record shall we start for the FAQ |
14 | -$start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
|
14 | +$start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
15 | 15 | |
16 | 16 | // Creating the category handler object |
17 | 17 | $categoryHandler = sf_gethandler('category'); |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | |
37 | 37 | $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_index.tpl'; |
38 | 38 | |
39 | -require_once XOOPS_ROOT_PATH . '/header.php'; |
|
40 | -require_once __DIR__ . '/footer.php'; |
|
39 | +require_once XOOPS_ROOT_PATH.'/header.php'; |
|
40 | +require_once __DIR__.'/footer.php'; |
|
41 | 41 | |
42 | 42 | // Creating the categories objects |
43 | 43 | $categoriesObj = $categoryHandler->getCategories($xoopsModuleConfig['catperpage'], $catstart); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | // Get the last smartfaq in each category |
61 | 61 | $last_qnaObj = $faqHandler->getLastPublishedByCat(); |
62 | 62 | } |
63 | -$lastfaqsize = (int)$xoopsModuleConfig['lastfaqsize']; |
|
63 | +$lastfaqsize = (int) $xoopsModuleConfig['lastfaqsize']; |
|
64 | 64 | $categories = []; |
65 | 65 | foreach ($categoriesObj as $cat_id => $category) { |
66 | 66 | $total = 0; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (isset($totalQnas[$subcat_id]) && $totalQnas[$subcat_id] > 0) { |
71 | 71 | if (isset($last_qnaObj[$subcat_id])) { |
72 | 72 | $subcat->setVar('last_faqid', $last_qnaObj[$subcat_id]->getVar('faqid')); |
73 | - $subcat->setVar('last_question_link', "<a href='faq.php?faqid=" . $last_qnaObj[$subcat_id]->getVar('faqid') . "'>" . $last_qnaObj[$subcat_id]->question($lastfaqsize) . '</a>'); |
|
73 | + $subcat->setVar('last_question_link', "<a href='faq.php?faqid=".$last_qnaObj[$subcat_id]->getVar('faqid')."'>".$last_qnaObj[$subcat_id]->question($lastfaqsize).'</a>'); |
|
74 | 74 | } |
75 | 75 | $subcat->setVar('faqcount', $totalQnas[$subcat_id]); |
76 | 76 | if ($xoopsModuleConfig['displaysubcatonindex']) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | if ($total > 0) { |
89 | 89 | if (isset($last_qnaObj[$cat_id])) { |
90 | 90 | $category->setVar('last_faqid', $last_qnaObj[$cat_id]->getVar('faqid')); |
91 | - $category->setVar('last_question_link', "<a href='faq.php?faqid=" . $last_qnaObj[$cat_id]->getVar('faqid') . "'>" . $last_qnaObj[$cat_id]->question($lastfaqsize) . '</a>'); |
|
91 | + $category->setVar('last_question_link', "<a href='faq.php?faqid=".$last_qnaObj[$cat_id]->getVar('faqid')."'>".$last_qnaObj[$cat_id]->question($lastfaqsize).'</a>'); |
|
92 | 92 | } |
93 | 93 | $category->setVar('faqcount', $total); |
94 | 94 | if (!isset($categories[$cat_id])) { |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | $memberHandler = xoops_getHandler('member'); |
129 | - $users = $memberHandler->getUsers(new Criteria('uid', '(' . implode(',', array_keys($userids)) . ')', 'IN'), true); |
|
129 | + $users = $memberHandler->getUsers(new Criteria('uid', '('.implode(',', array_keys($userids)).')', 'IN'), true); |
|
130 | 130 | for ($i = 0; $i < $totalQnasOnPage; ++$i) { |
131 | 131 | $faq = $faqsObj[$i]->toArray(null, $allcategories); |
132 | 132 | |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | // Language constants |
155 | -$moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
155 | +$moduleName = & $myts->displayTarea($xoopsModule->getVar('name')); |
|
156 | 156 | $xoopsTpl->assign('whereInSection', $moduleName); |
157 | 157 | $xoopsTpl->assign('displaysubcatonindex', $xoopsModuleConfig['displaysubcatonindex']); |
158 | 158 | $xoopsTpl->assign('displaylastfaqs', $xoopsModuleConfig['displaylastfaqs']); |
159 | 159 | $xoopsTpl->assign('display_categoryname', true); |
160 | 160 | $xoopsTpl->assign('displayFull', $xoopsModuleConfig['displaytype'] === 'full'); |
161 | 161 | |
162 | -$xoopsTpl->assign('lang_mainhead', _MD_SF_MAINHEAD . ' ' . $moduleName); |
|
162 | +$xoopsTpl->assign('lang_mainhead', _MD_SF_MAINHEAD.' '.$moduleName); |
|
163 | 163 | $xoopsTpl->assign('lang_mainintro', $myts->displayTarea($xoopsModuleConfig['indexwelcomemsg'], 1)); |
164 | 164 | $xoopsTpl->assign('lang_total', _MD_SF_TOTAL_SMARTFAQS); |
165 | 165 | $xoopsTpl->assign('lang_home', _MD_SF_HOME); |
@@ -178,20 +178,20 @@ discard block |
||
178 | 178 | $xoopsTpl->assign('lang_comments', _MD_SF_COMMENTS); |
179 | 179 | |
180 | 180 | // Category Navigation Bar |
181 | -require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
181 | +require_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
182 | 182 | $pagenav = new XoopsPageNav($totalCategories, $xoopsModuleConfig['catperpage'], $catstart, 'catstart', ''); |
183 | 183 | if ($xoopsModuleConfig['useimagenavpage'] == 1) { |
184 | - $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">' . $pagenav->renderImageNav() . '</div>'); |
|
184 | + $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">'.$pagenav->renderImageNav().'</div>'); |
|
185 | 185 | } else { |
186 | - $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'); |
|
186 | + $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">'.$pagenav->renderNav().'</div>'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // FAQ Navigation Bar |
190 | 190 | $pagenav = new XoopsPageNav($totalFaqs, $xoopsModuleConfig['indexperpage'], $start, 'start', ''); |
191 | 191 | if ($xoopsModuleConfig['useimagenavpage'] == 1) { |
192 | - $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderImageNav() . '</div>'); |
|
192 | + $xoopsTpl->assign('navbar', '<div style="text-align:right;">'.$pagenav->renderImageNav().'</div>'); |
|
193 | 193 | } else { |
194 | - $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'); |
|
194 | + $xoopsTpl->assign('navbar', '<div style="text-align:right;">'.$pagenav->renderNav().'</div>'); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | // Page Title Hack by marcan |
@@ -199,4 +199,4 @@ discard block |
||
199 | 199 | $xoopsTpl->assign('xoops_pagetitle', $module_name); |
200 | 200 | // End Page Title Hack by marcan |
201 | 201 | |
202 | -require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
202 | +require_once XOOPS_ROOT_PATH.'/footer.php'; |
@@ -44,94 +44,94 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | switch ($op) { |
47 | - case 'post': |
|
47 | + case 'post': |
|
48 | 48 | |
49 | - global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
49 | + global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
50 | 50 | |
51 | - $newFaqObj = $faqHandler->create(); |
|
51 | + $newFaqObj = $faqHandler->create(); |
|
52 | 52 | |
53 | - if (!$xoopsUser) { |
|
54 | - if ($xoopsModuleConfig['anonpost'] == 1) { |
|
55 | - $uid = 0; |
|
53 | + if (!$xoopsUser) { |
|
54 | + if ($xoopsModuleConfig['anonpost'] == 1) { |
|
55 | + $uid = 0; |
|
56 | + } else { |
|
57 | + redirect_header('index.php', 3, _NOPERM); |
|
58 | + } |
|
56 | 59 | } else { |
57 | - redirect_header('index.php', 3, _NOPERM); |
|
60 | + $uid = $xoopsUser->uid(); |
|
58 | 61 | } |
59 | - } else { |
|
60 | - $uid = $xoopsUser->uid(); |
|
61 | - } |
|
62 | - |
|
63 | - // Putting the values about the FAQ in the FAQ object |
|
64 | - $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
|
65 | - $newFaqObj->setVar('uid', $uid); |
|
66 | - $newFaqObj->setVar('question', $_POST['question']); |
|
67 | - $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
68 | - $newFaqObj->setVar('notifypub', $notifypub); |
|
69 | - |
|
70 | - // Setting the status of the FAQ |
|
71 | - if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
|
72 | - $newFaqObj->setVar('status', _SF_STATUS_OPENED); |
|
73 | - } else { |
|
74 | - $newFaqObj->setVar('status', _SF_STATUS_ASKED); |
|
75 | - } |
|
76 | - |
|
77 | - // Storing the FAQ object in the database |
|
78 | - if (!$newFaqObj->store()) { |
|
79 | - redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . sf_formatErrors($newFaqObj->getErrors())); |
|
80 | - } |
|
81 | - |
|
82 | - // Get the cateopry object related to that FAQ |
|
83 | - // If autoapprove_requested |
|
84 | - if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
|
85 | - // We do not not subscribe user to notification on publish since we publish it right away |
|
86 | - |
|
87 | - // Send notifications |
|
88 | - $newFaqObj->sendNotifications([_SF_NOT_QUESTION_PUBLISHED]); |
|
89 | - |
|
90 | - $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED; |
|
91 | - } else { |
|
92 | - // Subscribe the user to On Published notification, if requested |
|
93 | - if ($notifypub == 1) { |
|
94 | - require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
|
95 | - $notificationHandler = xoops_getHandler('notification'); |
|
96 | - $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
|
62 | + |
|
63 | + // Putting the values about the FAQ in the FAQ object |
|
64 | + $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
|
65 | + $newFaqObj->setVar('uid', $uid); |
|
66 | + $newFaqObj->setVar('question', $_POST['question']); |
|
67 | + $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
68 | + $newFaqObj->setVar('notifypub', $notifypub); |
|
69 | + |
|
70 | + // Setting the status of the FAQ |
|
71 | + if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
|
72 | + $newFaqObj->setVar('status', _SF_STATUS_OPENED); |
|
73 | + } else { |
|
74 | + $newFaqObj->setVar('status', _SF_STATUS_ASKED); |
|
75 | + } |
|
76 | + |
|
77 | + // Storing the FAQ object in the database |
|
78 | + if (!$newFaqObj->store()) { |
|
79 | + redirect_header('javascript:history.go(-1)', 3, _MD_SF_REQUEST_ERROR . sf_formatErrors($newFaqObj->getErrors())); |
|
97 | 80 | } |
98 | - // Send notifications |
|
99 | - $newFaqObj->sendNotifications([_SF_NOT_QUESTION_SUBMITTED]); |
|
100 | 81 | |
101 | - $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL; |
|
102 | - } |
|
82 | + // Get the cateopry object related to that FAQ |
|
83 | + // If autoapprove_requested |
|
84 | + if ($xoopsModuleConfig['autoapprove_request'] == 1) { |
|
85 | + // We do not not subscribe user to notification on publish since we publish it right away |
|
86 | + |
|
87 | + // Send notifications |
|
88 | + $newFaqObj->sendNotifications([_SF_NOT_QUESTION_PUBLISHED]); |
|
89 | + |
|
90 | + $redirect_msg = _MD_SF_REQUEST_RECEIVED_AND_PUBLISHED; |
|
91 | + } else { |
|
92 | + // Subscribe the user to On Published notification, if requested |
|
93 | + if ($notifypub == 1) { |
|
94 | + require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; |
|
95 | + $notificationHandler = xoops_getHandler('notification'); |
|
96 | + $notificationHandler->subscribe('question', $newFaqObj->faqid(), 'approved', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE); |
|
97 | + } |
|
98 | + // Send notifications |
|
99 | + $newFaqObj->sendNotifications([_SF_NOT_QUESTION_SUBMITTED]); |
|
100 | + |
|
101 | + $redirect_msg = _MD_SF_REQUEST_RECEIVED_NEED_APPROVAL; |
|
102 | + } |
|
103 | 103 | |
104 | - //redirect_header("javascript:history.go(-2)", 3, $redirect_msg); |
|
105 | - redirect_header('index.php', 2, $redirect_msg); |
|
106 | - break; |
|
104 | + //redirect_header("javascript:history.go(-2)", 3, $redirect_msg); |
|
105 | + redirect_header('index.php', 2, $redirect_msg); |
|
106 | + break; |
|
107 | 107 | |
108 | - case 'form': |
|
109 | - default: |
|
108 | + case 'form': |
|
109 | + default: |
|
110 | 110 | |
111 | - global $xoopsUser, $myts; |
|
111 | + global $xoopsUser, $myts; |
|
112 | 112 | |
113 | - $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl'; |
|
114 | - require_once XOOPS_ROOT_PATH . '/header.php'; |
|
115 | - require_once __DIR__ . '/footer.php'; |
|
113 | + $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl'; |
|
114 | + require_once XOOPS_ROOT_PATH . '/header.php'; |
|
115 | + require_once __DIR__ . '/footer.php'; |
|
116 | 116 | |
117 | - $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
117 | + $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
118 | 118 | |
119 | - $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
120 | - $xoopsTpl->assign('whereInSection', $moduleName); |
|
121 | - $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST); |
|
119 | + $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
120 | + $xoopsTpl->assign('whereInSection', $moduleName); |
|
121 | + $xoopsTpl->assign('lang_submit', _MD_SF_REQUEST); |
|
122 | 122 | |
123 | - $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST); |
|
124 | - $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($xoopsModuleConfig['requestintromsg'])); |
|
123 | + $xoopsTpl->assign('lang_intro_title', _MD_SF_REQUEST); |
|
124 | + $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . $myts->displayTarea($xoopsModuleConfig['requestintromsg'])); |
|
125 | 125 | |
126 | - require_once __DIR__ . '/include/request.inc.php'; |
|
126 | + require_once __DIR__ . '/include/request.inc.php'; |
|
127 | 127 | |
128 | - $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
128 | + $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
129 | 129 | |
130 | - $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name')); |
|
130 | + $sectionname = $myts->htmlSpecialChars($xoopsModule->getVar('name')); |
|
131 | 131 | |
132 | - require_once __DIR__ . '/include/request.inc.php'; |
|
132 | + require_once __DIR__ . '/include/request.inc.php'; |
|
133 | 133 | |
134 | - require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
134 | + require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
135 | 135 | |
136 | - break; |
|
136 | + break; |
|
137 | 137 | } |
@@ -46,153 +46,153 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | switch ($op) { |
49 | - case 'preview': |
|
49 | + case 'preview': |
|
50 | 50 | |
51 | - global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
51 | + global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
52 | 52 | |
53 | - $faqObj = $faqHandler->create(); |
|
54 | - $answerObj = $answerHandler->create(); |
|
55 | - $categoryObj = $categoryHandler->get($_POST['categoryid']); |
|
53 | + $faqObj = $faqHandler->create(); |
|
54 | + $answerObj = $answerHandler->create(); |
|
55 | + $categoryObj = $categoryHandler->get($_POST['categoryid']); |
|
56 | 56 | |
57 | - if (!$xoopsUser) { |
|
58 | - if ($xoopsModuleConfig['anonpost'] == 1) { |
|
59 | - $uid = 0; |
|
57 | + if (!$xoopsUser) { |
|
58 | + if ($xoopsModuleConfig['anonpost'] == 1) { |
|
59 | + $uid = 0; |
|
60 | + } else { |
|
61 | + redirect_header('index.php', 3, _NOPERM); |
|
62 | + } |
|
60 | 63 | } else { |
61 | - redirect_header('index.php', 3, _NOPERM); |
|
64 | + $uid = $xoopsUser->uid(); |
|
62 | 65 | } |
63 | - } else { |
|
64 | - $uid = $xoopsUser->uid(); |
|
65 | - } |
|
66 | 66 | |
67 | - $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
67 | + $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
68 | 68 | |
69 | - // Putting the values about the FAQ in the FAQ object |
|
70 | - $faqObj->setVar('categoryid', $_POST['categoryid']); |
|
71 | - $faqObj->setVar('uid', $uid); |
|
72 | - $faqObj->setVar('question', $_POST['question']); |
|
73 | - $faqObj->setVar('howdoi', $_POST['howdoi']); |
|
74 | - $faqObj->setVar('diduno', $_POST['diduno']); |
|
75 | - $faqObj->setVar('datesub', time()); |
|
69 | + // Putting the values about the FAQ in the FAQ object |
|
70 | + $faqObj->setVar('categoryid', $_POST['categoryid']); |
|
71 | + $faqObj->setVar('uid', $uid); |
|
72 | + $faqObj->setVar('question', $_POST['question']); |
|
73 | + $faqObj->setVar('howdoi', $_POST['howdoi']); |
|
74 | + $faqObj->setVar('diduno', $_POST['diduno']); |
|
75 | + $faqObj->setVar('datesub', time()); |
|
76 | 76 | |
77 | - // Putting the values in the answer object |
|
78 | - $answerObj->setVar('status', _SF_AN_STATUS_APPROVED); |
|
79 | - $answerObj->setVar('faqid', $faqObj->faqid()); |
|
80 | - $answerObj->setVar('answer', $_POST['answer']); |
|
81 | - $answerObj->setVar('uid', $uid); |
|
77 | + // Putting the values in the answer object |
|
78 | + $answerObj->setVar('status', _SF_AN_STATUS_APPROVED); |
|
79 | + $answerObj->setVar('faqid', $faqObj->faqid()); |
|
80 | + $answerObj->setVar('answer', $_POST['answer']); |
|
81 | + $answerObj->setVar('uid', $uid); |
|
82 | 82 | |
83 | - global $xoopsUser, $myts; |
|
83 | + global $xoopsUser, $myts; |
|
84 | 84 | |
85 | - $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl'; |
|
86 | - require_once XOOPS_ROOT_PATH . '/header.php'; |
|
87 | - require_once __DIR__ . '/footer.php'; |
|
85 | + $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.tpl'; |
|
86 | + require_once XOOPS_ROOT_PATH . '/header.php'; |
|
87 | + require_once __DIR__ . '/footer.php'; |
|
88 | 88 | |
89 | - $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
89 | + $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
90 | 90 | |
91 | - $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
92 | - $faq = $faqObj->toArray(null, $categoryObj, false); |
|
93 | - $faq['categoryPath'] = $categoryObj->getCategoryPath(true); |
|
94 | - $faq['answer'] = $answerObj->answer(); |
|
95 | - $faq['who_when'] = $faqObj->getWhoAndWhen(); |
|
91 | + $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
92 | + $faq = $faqObj->toArray(null, $categoryObj, false); |
|
93 | + $faq['categoryPath'] = $categoryObj->getCategoryPath(true); |
|
94 | + $faq['answer'] = $answerObj->answer(); |
|
95 | + $faq['who_when'] = $faqObj->getWhoAndWhen(); |
|
96 | 96 | |
97 | - $faq['comments'] = -1; |
|
98 | - $xoopsTpl->assign('faq', $faq); |
|
99 | - $xoopsTpl->assign('op', 'preview'); |
|
100 | - $xoopsTpl->assign('whereInSection', $moduleName); |
|
101 | - $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME); |
|
97 | + $faq['comments'] = -1; |
|
98 | + $xoopsTpl->assign('faq', $faq); |
|
99 | + $xoopsTpl->assign('op', 'preview'); |
|
100 | + $xoopsTpl->assign('whereInSection', $moduleName); |
|
101 | + $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME); |
|
102 | 102 | |
103 | - $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name()))); |
|
104 | - $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO); |
|
103 | + $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name()))); |
|
104 | + $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO); |
|
105 | 105 | |
106 | - require_once __DIR__ . '/include/submit.inc.php'; |
|
106 | + require_once __DIR__ . '/include/submit.inc.php'; |
|
107 | 107 | |
108 | - require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
108 | + require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
109 | 109 | |
110 | - exit(); |
|
111 | - break; |
|
110 | + exit(); |
|
111 | + break; |
|
112 | 112 | |
113 | - case 'post': |
|
113 | + case 'post': |
|
114 | 114 | |
115 | - global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
115 | + global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
116 | 116 | |
117 | - $newFaqObj = $faqHandler->create(); |
|
118 | - $newAnswerObj = $answerHandler->create(); |
|
117 | + $newFaqObj = $faqHandler->create(); |
|
118 | + $newAnswerObj = $answerHandler->create(); |
|
119 | 119 | |
120 | - if (!$xoopsUser) { |
|
121 | - if ($xoopsModuleConfig['anonpost'] == 1) { |
|
122 | - $uid = 0; |
|
120 | + if (!$xoopsUser) { |
|
121 | + if ($xoopsModuleConfig['anonpost'] == 1) { |
|
122 | + $uid = 0; |
|
123 | + } else { |
|
124 | + redirect_header('index.php', 3, _NOPERM); |
|
125 | + } |
|
123 | 126 | } else { |
124 | - redirect_header('index.php', 3, _NOPERM); |
|
127 | + $uid = $xoopsUser->uid(); |
|
125 | 128 | } |
126 | - } else { |
|
127 | - $uid = $xoopsUser->uid(); |
|
128 | - } |
|
129 | - |
|
130 | - $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
131 | - |
|
132 | - // Putting the values about the FAQ in the FAQ object |
|
133 | - $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
|
134 | - $newFaqObj->setVar('uid', $uid); |
|
135 | - $newFaqObj->setVar('question', $_POST['question']); |
|
136 | - $newFaqObj->setVar('howdoi', $_POST['howdoi']); |
|
137 | - $newFaqObj->setVar('diduno', $_POST['diduno']); |
|
138 | - $newFaqObj->setVar('notifypub', $notifypub); |
|
139 | - //$newFaqObj->setVar('modulelink', $_POST['modulelink']); |
|
140 | - //$newFaqObj->setVar('contextpage', $_POST['contextpage']); |
|
141 | 129 | |
142 | - // Setting the status of the FAQ |
|
143 | - |
|
144 | - // if user is admin, FAQ are automatically published |
|
145 | - $isAdmin = sf_userIsAdmin(); |
|
146 | - if ($isAdmin) { |
|
147 | - $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED); |
|
148 | - } elseif ($xoopsModuleConfig['autoapprove_submitted_faq'] == 1) { |
|
149 | - $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED); |
|
150 | - } else { |
|
151 | - $newFaqObj->setVar('status', _SF_STATUS_SUBMITTED); |
|
152 | - } |
|
130 | + $notifypub = isset($_POST['notifypub']) ? $_POST['notifypub'] : 0; |
|
131 | + |
|
132 | + // Putting the values about the FAQ in the FAQ object |
|
133 | + $newFaqObj->setVar('categoryid', $_POST['categoryid']); |
|
134 | + $newFaqObj->setVar('uid', $uid); |
|
135 | + $newFaqObj->setVar('question', $_POST['question']); |
|
136 | + $newFaqObj->setVar('howdoi', $_POST['howdoi']); |
|
137 | + $newFaqObj->setVar('diduno', $_POST['diduno']); |
|
138 | + $newFaqObj->setVar('notifypub', $notifypub); |
|
139 | + //$newFaqObj->setVar('modulelink', $_POST['modulelink']); |
|
140 | + //$newFaqObj->setVar('contextpage', $_POST['contextpage']); |
|
141 | + |
|
142 | + // Setting the status of the FAQ |
|
143 | + |
|
144 | + // if user is admin, FAQ are automatically published |
|
145 | + $isAdmin = sf_userIsAdmin(); |
|
146 | + if ($isAdmin) { |
|
147 | + $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED); |
|
148 | + } elseif ($xoopsModuleConfig['autoapprove_submitted_faq'] == 1) { |
|
149 | + $newFaqObj->setVar('status', _SF_STATUS_PUBLISHED); |
|
150 | + } else { |
|
151 | + $newFaqObj->setVar('status', _SF_STATUS_SUBMITTED); |
|
152 | + } |
|
153 | 153 | |
154 | - // Storing the FAQ object in the database |
|
155 | - if (!$newFaqObj->store()) { |
|
156 | - redirect_header('javascript:history.go(-1)', 2, _MD_SF_SUBMIT_ERROR); |
|
157 | - } |
|
154 | + // Storing the FAQ object in the database |
|
155 | + if (!$newFaqObj->store()) { |
|
156 | + redirect_header('javascript:history.go(-1)', 2, _MD_SF_SUBMIT_ERROR); |
|
157 | + } |
|
158 | 158 | |
159 | - // Putting the values in the answer object |
|
160 | - $newAnswerObj->setVar('status', _SF_AN_STATUS_APPROVED); |
|
161 | - $newAnswerObj->setVar('faqid', $newFaqObj->faqid()); |
|
162 | - $newAnswerObj->setVar('answer', $_POST['answer']); |
|
163 | - $newAnswerObj->setVar('uid', $uid); |
|
164 | - |
|
165 | - //==================================================================================== |
|
166 | - //TODO post Attachment |
|
167 | - $attachments_tmp = []; |
|
168 | - if (!empty($_POST['attachments_tmp'])) { |
|
169 | - $attachments_tmp = unserialize(base64_decode($_POST['attachments_tmp'])); |
|
170 | - if (isset($_POST['delete_tmp']) && count($_POST['delete_tmp'])) { |
|
171 | - foreach ($_POST['delete_tmp'] as $key) { |
|
172 | - unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attachments_tmp[$key][0]); |
|
173 | - unset($attachments_tmp[$key]); |
|
159 | + // Putting the values in the answer object |
|
160 | + $newAnswerObj->setVar('status', _SF_AN_STATUS_APPROVED); |
|
161 | + $newAnswerObj->setVar('faqid', $newFaqObj->faqid()); |
|
162 | + $newAnswerObj->setVar('answer', $_POST['answer']); |
|
163 | + $newAnswerObj->setVar('uid', $uid); |
|
164 | + |
|
165 | + //==================================================================================== |
|
166 | + //TODO post Attachment |
|
167 | + $attachments_tmp = []; |
|
168 | + if (!empty($_POST['attachments_tmp'])) { |
|
169 | + $attachments_tmp = unserialize(base64_decode($_POST['attachments_tmp'])); |
|
170 | + if (isset($_POST['delete_tmp']) && count($_POST['delete_tmp'])) { |
|
171 | + foreach ($_POST['delete_tmp'] as $key) { |
|
172 | + unlink(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attachments_tmp[$key][0]); |
|
173 | + unset($attachments_tmp[$key]); |
|
174 | + } |
|
174 | 175 | } |
175 | 176 | } |
176 | - } |
|
177 | - if (count($attachments_tmp)) { |
|
178 | - foreach ($attachments_tmp as $key => $attach) { |
|
179 | - if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attachments_tmp[$key][0])) { |
|
180 | - $post_obj->setAttachment($attach[0], $attach[1], $attach[2]); |
|
177 | + if (count($attachments_tmp)) { |
|
178 | + foreach ($attachments_tmp as $key => $attach) { |
|
179 | + if (rename(XOOPS_CACHE_PATH . '/' . $attachments_tmp[$key][0], XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['dir_attachments'] . '/' . $attachments_tmp[$key][0])) { |
|
180 | + $post_obj->setAttachment($attach[0], $attach[1], $attach[2]); |
|
181 | + } |
|
181 | 182 | } |
182 | 183 | } |
183 | - } |
|
184 | - $error_upload = ''; |
|
184 | + $error_upload = ''; |
|
185 | 185 | |
186 | - if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != '' |
|
187 | - && $topicHandler->getPermission($forum_obj, $topic_status, 'attach')) { |
|
188 | - require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php'; |
|
189 | - $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024; |
|
190 | - $uploaddir = XOOPS_CACHE_PATH; |
|
186 | + if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != '' |
|
187 | + && $topicHandler->getPermission($forum_obj, $topic_status, 'attach')) { |
|
188 | + require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/uploader.php'; |
|
189 | + $maxfilesize = $forum_obj->getVar('attach_maxkb') * 1024; |
|
190 | + $uploaddir = XOOPS_CACHE_PATH; |
|
191 | 191 | |
192 | - $uploader = new sfUploader($uploaddir, $newAnswerObj->getVar('attach_ext'), (int)$maxfilesize, (int)$xoopsModuleConfig['max_img_width'], (int)$xoopsModuleConfig['max_img_height']); |
|
192 | + $uploader = new sfUploader($uploaddir, $newAnswerObj->getVar('attach_ext'), (int)$maxfilesize, (int)$xoopsModuleConfig['max_img_width'], (int)$xoopsModuleConfig['max_img_height']); |
|
193 | 193 | |
194 | - if ($_FILES['userfile']['error'] > 0) { |
|
195 | - switch ($_FILES['userfile']['error']) { |
|
194 | + if ($_FILES['userfile']['error'] > 0) { |
|
195 | + switch ($_FILES['userfile']['error']) { |
|
196 | 196 | case 1: |
197 | 197 | $error_message[] = _MD_NEWBB_MAXUPLOADFILEINI; |
198 | 198 | break; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | default: |
203 | 203 | $error_message[] = _MD_NEWBB_UPLOAD_ERRNODEF; |
204 | 204 | break; |
205 | - } |
|
205 | + } |
|
206 | 206 | } else { |
207 | 207 | $uploader->setCheckMediaTypeByExt(); |
208 | 208 | |
@@ -265,30 +265,30 @@ discard block |
||
265 | 265 | redirect_header('index.php', 2, $redirect_msg); |
266 | 266 | break; |
267 | 267 | |
268 | - case 'form': |
|
269 | - default: |
|
268 | + case 'form': |
|
269 | + default: |
|
270 | 270 | |
271 | - global $xoopsUser, $myts; |
|
271 | + global $xoopsUser, $myts; |
|
272 | 272 | |
273 | - $faqObj = $faqHandler->create(); |
|
274 | - $answerObj = $answerHandler->create(); |
|
275 | - $categoryObj = $categoryHandler->create(); |
|
273 | + $faqObj = $faqHandler->create(); |
|
274 | + $answerObj = $answerHandler->create(); |
|
275 | + $categoryObj = $categoryHandler->create(); |
|
276 | 276 | |
277 | - $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.html'; |
|
278 | - require_once XOOPS_ROOT_PATH . '/header.php'; |
|
279 | - require_once __DIR__ . '/footer.php'; |
|
277 | + $GLOBALS['xoopsOption']['template_main'] = 'smartfaq_submit.html'; |
|
278 | + require_once XOOPS_ROOT_PATH . '/header.php'; |
|
279 | + require_once __DIR__ . '/footer.php'; |
|
280 | 280 | |
281 | - $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
282 | - $notifypub = 1; |
|
283 | - $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
284 | - $xoopsTpl->assign('whereInSection', $moduleName); |
|
285 | - $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME); |
|
281 | + $name = $xoopsUser ? ucwords($xoopsUser->getVar('uname')) : 'Anonymous'; |
|
282 | + $notifypub = 1; |
|
283 | + $moduleName =& $myts->displayTarea($xoopsModule->getVar('name')); |
|
284 | + $xoopsTpl->assign('whereInSection', $moduleName); |
|
285 | + $xoopsTpl->assign('lang_submit', _MD_SF_SUB_SNEWNAME); |
|
286 | 286 | |
287 | - $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name()))); |
|
288 | - $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO); |
|
287 | + $xoopsTpl->assign('lang_intro_title', sprintf(_MD_SF_SUB_SNEWNAME, ucwords($xoopsModule->name()))); |
|
288 | + $xoopsTpl->assign('lang_intro_text', _MD_SF_GOODDAY . "<b>$name</b>, " . _MD_SF_SUB_INTRO); |
|
289 | 289 | |
290 | - require_once __DIR__ . '/include/submit.inc.php'; |
|
290 | + require_once __DIR__ . '/include/submit.inc.php'; |
|
291 | 291 | |
292 | - require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
293 | - break; |
|
292 | + require_once XOOPS_ROOT_PATH . '/footer.php'; |
|
293 | + break; |
|
294 | 294 | } |