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 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000-2016 XOOPS.org // |
||
6 | // <https://xoops.org/> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | // Author: phppp (D.J., [email protected]) // |
||
28 | // URL: https://xoops.org // |
||
29 | // Project: Article Project // |
||
30 | // ------------------------------------------------------------------------ // |
||
31 | // irmtfan enhance include |
||
32 | |||
33 | use Xmf\Request; |
||
34 | use XoopsModules\Newbb; |
||
35 | use XoopsModules\Xoopspoll; |
||
36 | |||
37 | include_once __DIR__ . '/header.php'; |
||
38 | $xoopsLogger->startTime('newBB_viewtopic'); |
||
39 | include_once __DIR__ . '/include/functions.read.php'; |
||
40 | include_once __DIR__ . '/include/functions.render.php'; |
||
41 | xoops_loadLanguage('user'); |
||
42 | |||
43 | /*Build the page query*/ |
||
44 | $query_vars = ['post_id', 'topic_id', 'status', 'order', 'start', 'move', 'mode']; |
||
45 | $query_array = []; |
||
46 | foreach ($query_vars as $var) { |
||
47 | if (Request::getString($var, '', 'GET')) { |
||
48 | $query_array[$var] = "{$var}=" . Request::getString($var, '', 'GET'); |
||
49 | } |
||
50 | } |
||
51 | $page_query = htmlspecialchars(implode('&', array_values($query_array))); |
||
52 | unset($query_array); |
||
53 | |||
54 | $forum_id = Request::getInt('forum', 0, 'GET'); |
||
55 | $read = (Request::getString('read', '', 'GET') |
||
56 | && 'new' === Request::getString('read', '', 'GET')) ? Request::getString('read', '', 'GET') : ''; |
||
57 | $topic_id = Request::getInt('topic_id', 0, 'GET'); // isset($_GET['topic_id']) ? (int)($_GET['topic_id']) : 0; |
||
58 | $post_id = Request::getInt('post_id', 0, 'GET'); // !empty($_GET['post_id']) ? (int)($_GET['post_id']) : 0; |
||
59 | $move = strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move']) ? strtolower($_GET['move']) : ''; |
||
60 | $start = Request::getInt('start', 0, 'GET'); // !empty($_GET['start']) ? (int)($_GET['start']) : 0; |
||
61 | $status = (Request::getString('status', '', 'GET') |
||
62 | && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted'], true)) ? Request::getString('status', '', 'GET') : ''; |
||
63 | $mode = Request::getInt('mode', (!empty($status) ? 2 : 0), 'GET'); // !empty($_GET['mode']) ? (int)($_GET['mode']) : (!empty($status) ? 2 : 0); |
||
64 | $order = (Request::getString('order', '', 'GET') |
||
65 | && in_array(Request::getString('order', '', 'GET'), ['ASC', 'DESC'], true)) ? Request::getString('order', '', 'GET') : ''; |
||
66 | |||
67 | if ('' === $order) { |
||
68 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isActive()) { |
||
69 | $order = (1 == $GLOBALS['xoopsUser']->getVar('uorder')) ? 'DESC' : 'ASC'; |
||
70 | } else { |
||
71 | $order = (1 == $GLOBALS['xoopsConfig']['com_order']) ? 'DESC' : 'ASC'; |
||
72 | } |
||
73 | } |
||
74 | |||
75 | View Code Duplication | if (!$topic_id && !$post_id) { |
|
76 | $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; |
||
77 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
78 | } |
||
79 | |||
80 | ///** @var Newbb\TopicHandler $topicHandler */ |
||
81 | //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic'); |
||
82 | if (!empty($post_id)) { |
||
83 | $topicObject = $topicHandler->getByPost($post_id); |
||
84 | $topic_id = $topicObject->getVar('topic_id'); |
||
85 | } elseif (!empty($move)) { |
||
86 | $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id); |
||
87 | $topic_id = $topicObject->getVar('topic_id'); |
||
88 | } else { |
||
89 | $topicObject = $topicHandler->get($topic_id); |
||
90 | } |
||
91 | |||
92 | View Code Duplication | if (!is_object($topicObject) || !$topic_id = $topicObject->getVar('topic_id')) { |
|
93 | $redirect = empty($forum_id) ? XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php' : XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum={$forum_id}"; |
||
94 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
95 | } |
||
96 | $forum_id = $topicObject->getVar('forum_id'); |
||
97 | ///** @var Newbb\ForumHandler $forumHandler */ |
||
98 | //$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum'); |
||
99 | $forumObject = $forumHandler->get($forum_id); |
||
100 | |||
101 | $isAdmin = newbbIsAdmin($forumObject); |
||
102 | |||
103 | if ((!$isAdmin && $topicObject->getVar('approved') < 0) || (!$forumHandler->getPermission($forumObject)) |
||
104 | || (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view'))) { |
||
105 | redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW); |
||
106 | } |
||
107 | |||
108 | // START irmtfan - find if topic is read or unread - for all users (member and anon) |
||
109 | $topic_is_unread = true; |
||
110 | /* if $GLOBALS['xoopsModuleConfig']["read_mode"] === 0 || |
||
111 | * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1 || |
||
112 | * never read && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2 || |
||
113 | * => $topic_last_post_time_or_id_read = NULL |
||
114 | * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 2 |
||
115 | * => $topic_last_post_time_or_id_read = false |
||
116 | * if !$GLOBALS['xoopsUser'] && $GLOBALS['xoopsModuleConfig']["read_mode"] === 1 |
||
117 | * => $topic_last_post_time_or_id_read = lastview(newbb_IP{ip}LT) |
||
118 | */ |
||
119 | $topic_last_post_time_or_id_read = newbbGetRead('topic', $topic_id); |
||
120 | if (!empty($topic_last_post_time_or_id_read)) { |
||
121 | if (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
122 | // $postHandler = Newbb\Helper::getInstance()->getHandler('Post'); |
||
123 | $postObject = $postHandler->get($topicObject->getVar('topic_last_post_id')); |
||
124 | $topic_is_unread = ($topic_last_post_time_or_id_read < $postObject->getVar('post_time')); |
||
125 | } |
||
126 | if (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) { |
||
127 | $topic_is_unread = ($topic_last_post_time_or_id_read < $topicObject->getVar('topic_last_post_id')); |
||
128 | // hack jump to last post read if post_id is empty - is there any better way? |
||
129 | if (empty($post_id) && $topic_is_unread |
||
130 | && !empty($GLOBALS['xoopsModuleConfig']['jump_to_topic_last_post_read_enabled'])) { |
||
131 | header('Location: ' . Request::getString('REQUEST_URI', '', 'SERVER') . '&post_id=' . $topic_last_post_time_or_id_read); |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | // END irmtfan - find if topic is read or unread - for all users (member and anon) |
||
136 | |||
137 | /* Only admin has access to admin mode */ |
||
138 | if (!$isAdmin) { |
||
139 | $status = ''; |
||
140 | $mode = 0; |
||
141 | } |
||
142 | |||
143 | if (!empty($GLOBALS['xoopsModuleConfig']['enable_karma'])) { |
||
144 | // /** @var Newbb\KarmaHandler $karmaHandler */ |
||
145 | // $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma'); |
||
146 | $user_karma = $karmaHandler->getUserKarma(); |
||
147 | } |
||
148 | |||
149 | //$viewmode = "flat"; |
||
150 | |||
151 | $total_posts = $topicHandler->getPostCount($topicObject, $status); |
||
152 | $postsArray = []; |
||
153 | $postsArray = $topicHandler->getAllPosts($topicObject, $order, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, $post_id, $status); |
||
154 | |||
155 | //irmtfan - increment topic_views only if the topic is unread |
||
156 | if ($topic_is_unread) { |
||
157 | $topicObject->incrementCounter(); |
||
158 | } |
||
159 | newbbSetRead('topic', $topic_id, $topicObject->getVar('topic_last_post_id')); |
||
160 | |||
161 | $GLOBALS['xoopsOption']['template_main'] = 'newbb_viewtopic.tpl'; |
||
162 | // irmtfan remove and move to footer.php |
||
163 | //$xoopsOption['xoops_module_header']= $xoops_module_header; |
||
164 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
||
165 | include_once $GLOBALS['xoops']->path('header.php'); |
||
166 | //$xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
||
167 | // irmtfan new method |
||
168 | View Code Duplication | if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) { |
|
169 | $xoopsTpl->assign('xoops_module_header', ' |
||
170 | <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forumObject->getVar('forum_id') . '" /> |
||
171 | ' . @$xoopsTpl->get_template_vars('xoops_module_header')); |
||
172 | } |
||
173 | |||
174 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
175 | /** @var Newbb\OnlineHandler $onlineHandler */ |
||
176 | $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online'); |
||
177 | $onlineHandler->init($forumObject, $topicObject); |
||
178 | $xoopsTpl->assign('online', $onlineHandler->showOnline()); |
||
179 | } |
||
180 | $xoopsTpl->assign('parentforum', $forumHandler->getParents($forumObject)); |
||
181 | // irmtfan - remove icon_path and use newbbDisplayImage |
||
182 | $xoopsTpl->assign('anonym_avatar', newbbDisplayImage('anonym')); |
||
183 | |||
184 | // START irmtfan improve infobox |
||
185 | $infobox = []; |
||
186 | $infobox['show'] = (int)$GLOBALS['xoopsModuleConfig']['show_infobox']; //4.05 |
||
187 | // irmtfan removed then define after array |
||
188 | //$xoopsTpl->assign('infobox', $infobox); //4.05 |
||
189 | $iconHandler = newbbGetIconHandler(); // can be use in the follwing codes in this file |
||
190 | |||
191 | if ($infobox['show'] > 0) { |
||
192 | // irmtfan - remove icon_path and use newbbDisplayImage |
||
193 | $infobox['icon'] = [ |
||
194 | 'expand' => $iconHandler->getImageSource('less'), |
||
195 | 'collapse' => $iconHandler->getImageSource('more') |
||
196 | ]; |
||
197 | if (1 == $infobox['show']) { |
||
198 | $infobox['style'] = 'none'; //irmtfan move semicolon |
||
199 | $infobox['alt'] = _MD_NEWBB_SEEUSERDATA; |
||
200 | $infobox['src'] = 'more'; |
||
201 | } else { |
||
202 | $infobox['style'] = 'block'; //irmtfan move semicolon |
||
203 | $infobox['alt'] = _MD_NEWBB_HIDEUSERDATA; |
||
204 | $infobox['src'] = 'less'; |
||
205 | } |
||
206 | $infobox['displayImage'] = newbbDisplayImage($infobox['src'], $infobox['alt']); |
||
207 | } |
||
208 | $xoopsTpl->assign('infobox', $infobox); |
||
209 | // END irmtfan improve infobox |
||
210 | |||
211 | $xoopsTpl->assign([ |
||
212 | 'topic_title' => '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?topic_id=' . $topic_id . '">' . $topicObject->getFullTitle() . '</a>', |
||
213 | 'forum_name' => $forumObject->getVar('forum_name'), |
||
214 | 'lang_nexttopic' => _MD_NEWBB_NEXTTOPIC, |
||
215 | 'lang_prevtopic' => _MD_NEWBB_PREVTOPIC, |
||
216 | 'topic_status' => $topicObject->getVar('topic_status') |
||
217 | ]); |
||
218 | |||
219 | //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category'); |
||
220 | $categoryObject = $categoryHandler->get($forumObject->getVar('cat_id'), ['cat_title']); |
||
221 | $xoopsTpl->assign('category', ['id' => $forumObject->getVar('cat_id'), 'title' => $categoryObject->getVar('cat_title')]); |
||
222 | |||
223 | $xoopsTpl->assign('post_id', $post_id); |
||
224 | $xoopsTpl->assign('topic_id', $topic_id); |
||
225 | $xoopsTpl->assign('forum_id', $forum_id); |
||
226 | |||
227 | $order_current = ('DESC' === $order) ? 'DESC' : 'ASC'; |
||
228 | $xoopsTpl->assign('order_current', $order_current); |
||
229 | |||
230 | $t_new = newbbDisplayImage('t_new', _MD_NEWBB_POSTNEW); |
||
231 | $t_reply = newbbDisplayImage('t_reply', _MD_NEWBB_REPLY); |
||
232 | // irmtfan show topic status if show reg is 0 and revise forum_post_or_register |
||
233 | if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'post')) { |
||
234 | $xoopsTpl->assign('forum_post', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/newtopic.php?forum=' . $forum_id . '"> ' . $t_new . '</a>'); |
||
235 | } else { |
||
236 | if ($topicObject->getVar('topic_status')) { |
||
237 | $xoopsTpl->assign('topic_lock', _MD_NEWBB_TOPICLOCKED); |
||
238 | } |
||
239 | if (!is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsModuleConfig']['show_reg'])) { |
||
240 | $xoopsTpl->assign('forum_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri) . '">' . _MD_NEWBB_REGTOPOST . '</a>'); |
||
241 | } |
||
242 | } |
||
243 | // irmtfan for backward compatibility assign forum_post_or_register smarty again. |
||
244 | $xoopsTpl->assign('forum_post_or_register', @$xoopsTpl->get_template_vars('forum_post') . @$xoopsTpl->get_template_vars('forum_register') . @$xoopsTpl->get_template_vars('topic_lock')); |
||
245 | |||
246 | if ($topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply')) { |
||
247 | $xoopsTpl->assign('forum_reply', '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/reply.php?topic_id=' . $topic_id . '"> ' . $t_reply . '</a>'); |
||
248 | } |
||
249 | |||
250 | $poster_array = []; |
||
251 | $require_reply = false; |
||
252 | /** @var Post $eachpost */ |
||
253 | foreach ($postsArray as $eachpost) { |
||
254 | if ($eachpost->getVar('uid') > 0) { |
||
255 | $poster_array[$eachpost->getVar('uid')] = 1; |
||
256 | } |
||
257 | if ($eachpost->getVar('require_reply') > 0) { |
||
258 | $require_reply = true; |
||
259 | } |
||
260 | } |
||
261 | |||
262 | $userid_array = []; |
||
263 | $online = []; |
||
264 | View Code Duplication | if (is_array($poster_array) && count($poster_array) > 0) { |
|
265 | /** @var \XoopsMemberHandler $memberHandler */ |
||
266 | $memberHandler = xoops_getHandler('member'); |
||
267 | $userid_array = array_keys($poster_array); |
||
268 | $user_criteria = '(' . implode(',', $userid_array) . ')'; |
||
269 | $users = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true); |
||
270 | } else { |
||
271 | $users = []; |
||
272 | } |
||
273 | |||
274 | $viewtopic_users = []; |
||
275 | if (is_array($userid_array) && count($userid_array) > 0) { |
||
276 | require $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php'); |
||
277 | $userHandler = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']); |
||
278 | $userHandler->users = $users; |
||
279 | $userHandler->online = $online; |
||
280 | $viewtopic_users = $userHandler->getUsers(); |
||
281 | } |
||
282 | unset($users); |
||
283 | |||
284 | if ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $require_reply) { |
||
285 | if (!empty($GLOBALS['xoopsModuleConfig']['cache_enabled'])) { |
||
286 | $viewtopic_posters = newbbGetSession('t' . $topic_id, true); |
||
287 | if (!is_array($viewtopic_posters) || 0 === count($viewtopic_posters)) { |
||
288 | $viewtopic_posters = $topicHandler->getAllPosters($topicObject); |
||
289 | newbbSetSession('t' . $topic_id, $viewtopic_posters); |
||
290 | } |
||
291 | } else { |
||
292 | $viewtopic_posters = $topicHandler->getAllPosters($topicObject); |
||
293 | } |
||
294 | } else { |
||
295 | $viewtopic_posters = []; |
||
296 | } |
||
297 | |||
298 | if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { |
||
299 | $post_werbung = [ |
||
300 | 'post_id' => 0, |
||
301 | 'post_parent_id' => 0, |
||
302 | 'post_date' => 0, |
||
303 | 'post_image' => '', |
||
304 | 'post_title' => '', |
||
305 | 'post_text' => '<div style="text-align: center;vertical-align: middle;"><br>' . xoops_getbanner() . '</div>', |
||
306 | 'post_attachment' => '', |
||
307 | 'post_edit' => 0, |
||
308 | 'post_no' => 0, |
||
309 | 'post_signature' => _MD_NEWBB_ADVERTISING_BLOCK, |
||
310 | 'poster_ip' => '', |
||
311 | 'thread_action' => '', |
||
312 | 'thread_buttons' => '', |
||
313 | 'mod_buttons' => '', |
||
314 | 'poster' => [ |
||
315 | 'uid' => -1, |
||
316 | 'link' => _MD_NEWBB_ADVERTISING_USER, |
||
317 | 'avatar' => 'avatars/blank.gif', |
||
318 | 'regdate' => 0, |
||
319 | 'last_login' => 0, |
||
320 | 'rank' => ['title' => ''] |
||
321 | ], |
||
322 | // irmtfan add last_login |
||
323 | 'post_permalink' => '' |
||
324 | ]; |
||
325 | } |
||
326 | |||
327 | $i = 0; |
||
328 | /** @var Post $eachpost */ |
||
329 | foreach ($postsArray as $eachpost) { |
||
330 | if ($GLOBALS['xoopsModuleConfig']['show_advertising']) { |
||
331 | if (2 === $i) { |
||
332 | $xoopsTpl->append('topic_posts', $post_werbung); |
||
333 | } |
||
334 | ++$i; |
||
335 | } |
||
336 | $xoopsTpl->append('topic_posts', $eachpost->showPost($isAdmin)); |
||
337 | } |
||
338 | |||
339 | if ($total_posts > $GLOBALS['xoopsModuleConfig']['posts_per_page']) { |
||
340 | include $GLOBALS['xoops']->path('class/pagenav.php'); |
||
341 | |||
342 | $nav = new \XoopsPageNav($total_posts, $GLOBALS['xoopsModuleConfig']['posts_per_page'], $start, 'start', 'topic_id=' . $topic_id . '&order=' . $order . '&status=' . $status . '&mode=' . $mode); |
||
343 | //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite']) && $GLOBALS['xoopsModuleConfig']['do_rewrite'] === 1) $nav->url = XOOPS_URL . $nav->url; |
||
344 | View Code Duplication | if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
|
345 | $navi = $nav->renderSelect(); |
||
346 | } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) { |
||
347 | $navi = $nav->renderImageNav(4); |
||
348 | } else { |
||
349 | $navi = $nav->renderNav(4); |
||
350 | } |
||
351 | $xoopsTpl->assign('forum_page_nav', $navi); |
||
352 | } else { |
||
353 | $xoopsTpl->assign('forum_page_nav', ''); |
||
354 | } |
||
355 | |||
356 | if (empty($post_id)) { |
||
357 | $first = array_keys($postsArray); |
||
358 | $post_id = !empty($first[0]) ? $first[0] : 0; |
||
359 | } |
||
360 | |||
361 | if (!empty($postsArray[$post_id])) { |
||
362 | $xoops_pagetitle = $postsArray[$post_id]->getVar('subject') . ' [' . $forumObject->getVar('forum_name') . ']'; |
||
363 | $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle); |
||
364 | $xoopsOption['xoops_pagetitle'] = $xoops_pagetitle; |
||
365 | $kw = array_unique(explode(' ', strip_tags($postsArray[$post_id]->getVar('post_text')), 150)); |
||
366 | asort($kw); |
||
367 | $kwort = ''; |
||
368 | $z = 0; |
||
369 | foreach ($kw as $k) { |
||
370 | if ($z < 30 && strlen(trim($k)) > 5) { |
||
371 | $kwort .= trim($k) . ' '; |
||
372 | ++$z; |
||
373 | } |
||
374 | } |
||
375 | $xoTheme->addMeta('meta', 'keywords', $kwort); |
||
376 | $xoTheme->addMeta('meta', 'description', substr(strip_tags($postsArray[$post_id]->getVar('post_text')), 0, 120)); |
||
377 | } |
||
378 | unset($postsArray); |
||
379 | |||
380 | $xoopsTpl->assign('topic_print_link', "print.php?form=1&{$page_query}"); |
||
381 | |||
382 | $admin_actions = []; |
||
383 | $ad_merge = ''; |
||
384 | $ad_move = ''; |
||
385 | $ad_delete = ''; |
||
386 | // irmtfan add restore to viewtopic |
||
387 | $ad_restore = ''; |
||
388 | $ad_lock = ''; |
||
389 | $ad_unlock = ''; |
||
390 | $ad_sticky = ''; |
||
391 | $ad_unsticky = ''; |
||
392 | $ad_digest = ''; |
||
393 | $ad_undigest = ''; |
||
394 | |||
395 | // START irmtfan add restore to viewtopic |
||
396 | // if the topic is active |
||
397 | if ($topicObject->getVar('approved') > 0) { |
||
398 | $admin_actions['merge'] = [ |
||
399 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=merge&topic_id=' . $topic_id, |
||
400 | 'name' => _MD_NEWBB_MERGETOPIC, |
||
401 | 'image' => $ad_merge |
||
402 | ]; |
||
403 | $admin_actions['move'] = [ |
||
404 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=move&topic_id=' . $topic_id, |
||
405 | 'name' => _MD_NEWBB_MOVETOPIC, |
||
406 | 'image' => $ad_move |
||
407 | ]; |
||
408 | $admin_actions['delete'] = [ |
||
409 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=delete&topic_id=' . $topic_id, |
||
410 | 'name' => _MD_NEWBB_DELETETOPIC, |
||
411 | 'image' => $ad_delete |
||
412 | ]; |
||
413 | View Code Duplication | if (!$topicObject->getVar('topic_status')) { |
|
414 | $admin_actions['lock'] = [ |
||
415 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=lock&topic_id=' . $topic_id, |
||
416 | 'image' => $ad_lock, |
||
417 | 'name' => _MD_NEWBB_LOCKTOPIC |
||
418 | ]; |
||
419 | } else { |
||
420 | $admin_actions['unlock'] = [ |
||
421 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unlock&topic_id=' . $topic_id, |
||
422 | 'image' => $ad_unlock, |
||
423 | 'name' => _MD_NEWBB_UNLOCKTOPIC |
||
424 | ]; |
||
425 | } |
||
426 | View Code Duplication | if (!$topicObject->getVar('topic_sticky')) { |
|
427 | $admin_actions['sticky'] = [ |
||
428 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=sticky&topic_id=' . $topic_id, |
||
429 | 'image' => $ad_sticky, |
||
430 | 'name' => _MD_NEWBB_STICKYTOPIC |
||
431 | ]; |
||
432 | } else { |
||
433 | $admin_actions['unsticky'] = [ |
||
434 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=unsticky&topic_id=' . $topic_id, |
||
435 | 'image' => $ad_unsticky, |
||
436 | 'name' => _MD_NEWBB_UNSTICKYTOPIC |
||
437 | ]; |
||
438 | } |
||
439 | View Code Duplication | if (!$topicObject->getVar('topic_digest')) { |
|
440 | $admin_actions['digest'] = [ |
||
441 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=digest&topic_id=' . $topic_id, |
||
442 | 'image' => $ad_digest, |
||
443 | 'name' => _MD_NEWBB_DIGESTTOPIC |
||
444 | ]; |
||
445 | } else { |
||
446 | $admin_actions['undigest'] = [ |
||
447 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=undigest&topic_id=' . $topic_id, |
||
448 | 'image' => $ad_undigest, |
||
449 | 'name' => _MD_NEWBB_UNDIGESTTOPIC |
||
450 | ]; |
||
451 | } |
||
452 | // if the topic is pending/deleted then restore/approve |
||
453 | } else { |
||
454 | $admin_actions['restore'] = [ |
||
455 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/topicmanager.php?mode=restore&topic_id=' . $topic_id, |
||
456 | 'name' => _MD_NEWBB_RESTORETOPIC, |
||
457 | 'image' => $ad_restore |
||
458 | ]; |
||
459 | } |
||
460 | // END irmtfan add restore to viewtopic |
||
461 | |||
462 | $xoopsTpl->assign_by_ref('admin_actions', $admin_actions); |
||
463 | $xoopsTpl->assign('viewer_level', (int)($isAdmin ? 2 : is_object($GLOBALS['xoopsUser']))); |
||
464 | |||
465 | View Code Duplication | if ($GLOBALS['xoopsModuleConfig']['show_permissiontable']) { |
|
466 | // /** var Newbb\PermissionHandler $permHandler */ |
||
467 | // $permHandler = Newbb\Helper::getInstance()->getHandler('Permission'); |
||
468 | $permission_table = $permHandler->getPermissionTable($forumObject, $topicObject->getVar('topic_status'), $isAdmin); |
||
469 | $xoopsTpl->assign_by_ref('permission_table', $permission_table); |
||
470 | } |
||
471 | |||
472 | /////////////////////////////// |
||
473 | // show Poll |
||
474 | // START irmtfan poll_module |
||
475 | // irmtfan remove |
||
476 | /* |
||
477 | $pollmodul = false; |
||
478 | $moduleHandler = xoops_getHandler( 'module' ); |
||
479 | $PollModule = $moduleHandler->getByDirname('xoopspoll'); |
||
480 | if ($PollModule && $PollModule->getVar('isactive')) { |
||
481 | $pollmodul = 'xoopspoll'; |
||
482 | } else { |
||
483 | $PollModule = $moduleHandler->getByDirname('umfrage'); |
||
484 | if ($PollModule && $PollModule->getVar('isactive')) { |
||
485 | $pollmodul = 'umfrage'; |
||
486 | } |
||
487 | } |
||
488 | */ |
||
489 | //irmtfan remove |
||
490 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
||
491 | if (is_object($pollModuleHandler) && $pollModuleHandler->getVar('isactive')) { |
||
492 | $poll_id = $topicObject->getVar('poll_id'); |
||
493 | // can vote in poll |
||
494 | $pollVote = ($topicObject->getVar('topic_haspoll') && $poll_id > 0 |
||
495 | && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'vote')); |
||
496 | // can add poll |
||
497 | $pollAdd = $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'addpoll'); |
||
498 | if ($pollVote || $pollAdd) { |
||
499 | $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']); |
||
500 | // new xoopspoll module |
||
501 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
502 | // xoops_load('renderer', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
0 ignored issues
–
show
|
|||
503 | xoops_loadLanguage('main', $GLOBALS['xoopsModuleConfig']['poll_module']); |
||
504 | // old xoopspoll or umfrage or any clone from them |
||
505 | } else { |
||
506 | $classPoll = $topicObject->loadOldPoll(); |
||
507 | } |
||
508 | } |
||
509 | // START can vote in poll |
||
510 | if ($pollVote) { |
||
511 | $xoopsTpl->assign('topic_poll', 1); |
||
512 | $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0; |
||
513 | // new xoopspoll module |
||
514 | if ($pollModuleHandler->getVar('version') >= 140) { |
||
515 | $xpollHandler = Xoopspoll\Helper::getInstance()->getHandler('Poll'); |
||
516 | /** @var \XoopsPoll $pollObject */ |
||
517 | $pollObject = $xpollHandler->get($poll_id); |
||
518 | if (is_object($pollObject)) { |
||
519 | |||
520 | /* check to see if user has rights to view the results */ |
||
521 | $vis_return = $pollObject->isResultVisible(); |
||
522 | $isVisible = $vis_return; |
||
523 | $visibleMsg = $isVisible ? '' : $vis_return; |
||
524 | |||
525 | /* setup the module config handler */ |
||
526 | /** @var \XoopsConfigHandler $configHandler */ |
||
527 | $configHandler = xoops_getHandler('config'); |
||
528 | $xp_config = $configHandler->getConfigsByCat(0, $pollModuleHandler->getVar('mid')); |
||
529 | |||
530 | $GLOBALS['xoopsTpl']->assign([ |
||
531 | 'is_visible' => $isVisible, |
||
532 | 'visible_message' => $visibleMsg, |
||
533 | 'disp_votes' => $xp_config['disp_vote_nums'], |
||
534 | 'lang_vote' => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_VOTE'), |
||
535 | 'lang_results' => constant('_MD_' . strtoupper($GLOBALS['xoopsModuleConfig']['poll_module']) . '_RESULTS'), |
||
536 | 'back_link' => '' |
||
537 | ]); |
||
538 | $classRenderer = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Renderer'; |
||
539 | /** @var Xoopspoll\Renderer $renderer */ |
||
540 | $renderer = new $classRenderer($pollObject); |
||
541 | // check to see if user has voted, show form if not, otherwise get results for form |
||
542 | |||
543 | /** @var Xoopspoll\LogHandler $logHandler */ |
||
544 | $logHandler = Xoopspoll\Helper::getInstance()->getHandler('Log'); |
||
545 | if ($pollObject->isAllowedToVote() |
||
546 | && (!$logHandler->hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $uid))) { |
||
547 | $myTpl = new \XoopsTpl(); |
||
548 | $renderer->assignForm($myTpl); |
||
549 | $myTpl->assign('action', $GLOBALS['xoops']->url("modules/newbb/votepolls.php?topic_id={$topic_id}&poll_id={$poll_id}")); |
||
550 | $topic_pollform = $myTpl->fetch($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/templates/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '_view.tpl')); |
||
551 | $GLOBALS['xoopsTpl']->assign('topic_pollform', $topic_pollform); |
||
552 | } else { |
||
553 | $GLOBALS['xoopsTpl']->assign('can_vote', false); |
||
554 | $xoopsTpl->assign('topic_pollresult', 1); |
||
555 | $GLOBALS['xoopsTpl']->assign('topic_resultform', $renderer->renderResults()); |
||
556 | } |
||
557 | } |
||
558 | // old xoopspoll or umfrage or any clone from them |
||
559 | } else { |
||
560 | $pollObject = new $classPoll($poll_id); |
||
561 | $classRenderer = $classPoll . 'Renderer'; |
||
562 | $renderer = new $classRenderer($pollObject); |
||
563 | $xoopsTpl->assign('lang_alreadyvoted2', _PL_ALREADYVOTED2); |
||
564 | $xoopsTpl->assign('has_ended', $pollObject->getVar('end_time') < time() ? 1 : 0); |
||
565 | // umfrage has polltype |
||
566 | $polltype = $pollObject->getVar('polltype'); |
||
567 | if (!empty($polltype)) { |
||
568 | $xoopsTpl->assign('polltype', $polltype); |
||
569 | switch ($polltype) { |
||
570 | case 1: |
||
571 | $xoopsTpl->assign('polltypecomment', ''); |
||
572 | break; |
||
573 | case 2: |
||
574 | $xoopsTpl->assign('polltypecomment', _PL_FULLBLIND); |
||
575 | break; |
||
576 | case 3: |
||
577 | $xoopsTpl->assign('polltypecomment', _PL_HALFBLIND); |
||
578 | break; |
||
579 | |||
580 | } |
||
581 | } |
||
582 | $classLog = $classPoll . 'Log'; |
||
583 | $hasvoted = 0; |
||
584 | if ($GLOBALS['xoopsUser']) { |
||
585 | if ($classLog::hasVoted($poll_id, Request::getString('REMOTE_ADDR', '', 'SERVER'), $uid)) { |
||
586 | $hasvoted = 1; |
||
587 | } |
||
588 | } else { |
||
589 | $hasvoted = 1; |
||
590 | } |
||
591 | $xoopsTpl->assign('hasVoted', $hasvoted); |
||
592 | $xoopsTpl->assign('lang_vote', _PL_VOTE); |
||
593 | $xoopsTpl->assign('lang_results', $pollObject->getVar('end_time') < time() ? _PL_RESULTS : _PL_STANDINGS); |
||
594 | // irmtfan - if the poll is expired show the result |
||
595 | if ($hasvoted || $pollObject->hasExpired()) { |
||
596 | $renderer->assignResults($xoopsTpl); |
||
597 | $xoopsTpl->assign('topic_pollresult', 1); |
||
598 | setcookie('newbb_polls[' . $poll_id . ']', 1); |
||
599 | } else { |
||
600 | $renderer->assignForm($xoopsTpl); |
||
601 | $xoopsTpl->assign('lang_vote', _PL_VOTE); |
||
602 | $xoopsTpl->assign('lang_results', _PL_RESULTS); |
||
603 | setcookie('newbb_polls[' . $poll_id . ']', 1); |
||
604 | } |
||
605 | } |
||
606 | } |
||
607 | // END can vote in poll |
||
608 | // START can add poll |
||
609 | if ($pollAdd) { |
||
610 | if (!$topicObject->getVar('topic_haspoll')) { |
||
611 | if (is_object($GLOBALS['xoopsUser']) |
||
612 | && $GLOBALS['xoopsUser']->getVar('uid') == $topicObject->getVar('topic_poster')) { |
||
613 | $t_poll = newbbDisplayImage('t_poll', _MD_NEWBB_ADDPOLL); |
||
614 | $xoopsTpl->assign('forum_addpoll', '<a href=\'' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=add&topic_id=' . $topic_id . '\'>' . $t_poll . '</a>'); |
||
615 | } |
||
616 | } elseif ($isAdmin |
||
617 | || (is_object($pollObject) && is_object($GLOBALS['xoopsUser']) |
||
618 | && $GLOBALS['xoopsUser']->getVar('uid') == $pollObject->getVar('user_id'))) { |
||
619 | $poll_edit = ''; |
||
620 | $poll_delete = ''; |
||
621 | $poll_restart = ''; |
||
622 | $poll_log = ''; |
||
623 | |||
624 | $adminpoll_actions = []; |
||
625 | $adminpoll_actions['editpoll'] = [ |
||
626 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=edit&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id, |
||
627 | 'image' => $poll_edit, |
||
628 | 'name' => _MD_NEWBB_EDITPOLL |
||
629 | ]; |
||
630 | $adminpoll_actions['deletepoll'] = [ |
||
631 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=delete&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id, |
||
632 | 'image' => $poll_delete, |
||
633 | 'name' => _MD_NEWBB_DELETEPOLL |
||
634 | ]; |
||
635 | $adminpoll_actions['restartpoll'] = [ |
||
636 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=restart&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, |
||
637 | 'image' => $poll_restart, |
||
638 | 'name' => _MD_NEWBB_RESTARTPOLL |
||
639 | ]; |
||
640 | $adminpoll_actions['logpoll'] = [ |
||
641 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/polls.php?op=log&poll_id=' . $topicObject->getVar('poll_id') . '&topic_id=' . $topic_id . '&forum=' . $forum_id, |
||
642 | 'image' => $poll_log, |
||
643 | 'name' => _MD_NEWBB_POLL_VIEWLOG |
||
644 | ]; |
||
645 | |||
646 | $xoopsTpl->assign_by_ref('adminpoll_actions', $adminpoll_actions); |
||
647 | } |
||
648 | } |
||
649 | // END can add poll |
||
650 | } |
||
651 | if (isset($pollObject)) { |
||
652 | unset($pollObject); |
||
653 | } |
||
654 | // END irmtfan poll_module |
||
655 | |||
656 | $xoopsTpl->assign('p_up', newbbDisplayImage('up', _MD_NEWBB_TOP)); |
||
657 | $xoopsTpl->assign('rating_enable', $GLOBALS['xoopsModuleConfig']['rating_enabled']); |
||
658 | $xoopsTpl->assign('groupbar_enable', $GLOBALS['xoopsModuleConfig']['groupbar_enabled']); |
||
659 | $xoopsTpl->assign('anonymous_prefix', $GLOBALS['xoopsModuleConfig']['anonymous_prefix']); |
||
660 | // irmtfan add alt for prev next and down icons. |
||
661 | $xoopsTpl->assign('previous', newbbDisplayImage('previous', _MD_NEWBB_PREVTOPIC)); |
||
662 | $xoopsTpl->assign('next', newbbDisplayImage('next', _MD_NEWBB_NEXTTOPIC)); |
||
663 | $xoopsTpl->assign('down', newbbDisplayImage('down', _MD_NEWBB_BOTTOM)); |
||
664 | $xoopsTpl->assign('post_content', newbbDisplayImage('post')); |
||
665 | |||
666 | if (!empty($GLOBALS['xoopsModuleConfig']['rating_enabled'])) { |
||
667 | $xoopsTpl->assign('votes', $topicObject->getVar('votes')); |
||
668 | $rating = number_format($topicObject->getVar('rating') / 2, 0); |
||
669 | View Code Duplication | if ($rating < 1) { |
|
670 | $rating_img = newbbDisplayImage('blank'); |
||
671 | } else { |
||
672 | // irmtfan - add alt key for rating |
||
673 | $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating)); |
||
674 | } |
||
675 | $xoopsTpl->assign('rating_img', $rating_img); |
||
676 | $xoopsTpl->assign('rate1', newbbDisplayImage('rate1', _MD_NEWBB_RATE1)); |
||
677 | $xoopsTpl->assign('rate2', newbbDisplayImage('rate2', _MD_NEWBB_RATE2)); |
||
678 | $xoopsTpl->assign('rate3', newbbDisplayImage('rate3', _MD_NEWBB_RATE3)); |
||
679 | $xoopsTpl->assign('rate4', newbbDisplayImage('rate4', _MD_NEWBB_RATE4)); |
||
680 | $xoopsTpl->assign('rate5', newbbDisplayImage('rate5', _MD_NEWBB_RATE5)); |
||
681 | } |
||
682 | |||
683 | // create jump box |
||
684 | View Code Duplication | if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) { |
|
685 | include_once __DIR__ . '/include/functions.forum.php'; |
||
686 | $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id)); |
||
687 | } |
||
688 | |||
689 | $xoopsTpl->assign([ |
||
690 | 'lang_forum_index' => sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)), |
||
691 | 'lang_from' => _MD_NEWBB_FROM, |
||
692 | 'lang_joined' => _MD_NEWBB_JOINED, |
||
693 | 'lang_posts' => _MD_NEWBB_POSTS, |
||
694 | 'lang_poster' => _MD_NEWBB_POSTER, |
||
695 | 'lang_thread' => _MD_NEWBB_THREAD, |
||
696 | 'lang_edit' => _EDIT, |
||
697 | 'lang_delete' => _DELETE, |
||
698 | 'lang_reply' => _REPLY, |
||
699 | 'lang_postedon' => _MD_NEWBB_POSTEDON, |
||
700 | 'lang_groups' => _MD_NEWBB_GROUPS |
||
701 | ]); |
||
702 | |||
703 | $viewmode_options = []; |
||
704 | View Code Duplication | if ('DESC' === $order) { |
|
705 | $viewmode_options[] = [ |
||
706 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=ASC&status=$status&topic_id=' . $topic_id, |
||
707 | 'title' => _OLDESTFIRST |
||
708 | ]; |
||
709 | } else { |
||
710 | $viewmode_options[] = [ |
||
711 | 'link' => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewtopic.php?order=DESC&status=$status&topic_id=' . $topic_id, |
||
712 | 'title' => _NEWESTFIRST |
||
713 | ]; |
||
714 | } |
||
715 | |||
716 | switch ($status) { |
||
717 | case 'active': |
||
718 | $current_status = '[' . _MD_NEWBB_TYPE_ADMIN . ']'; |
||
719 | break; |
||
720 | case 'pending': |
||
721 | $current_status = '[' . _MD_NEWBB_TYPE_PENDING . ']'; |
||
722 | break; |
||
723 | case 'deleted': |
||
724 | $current_status = '[' . _MD_NEWBB_TYPE_DELETED . ']'; |
||
725 | break; |
||
726 | default: |
||
727 | $current_status = ''; |
||
728 | break; |
||
729 | } |
||
730 | $xoopsTpl->assign('topicstatus', $current_status); |
||
731 | |||
732 | $xoopsTpl->assign('mode', $mode); |
||
733 | $xoopsTpl->assign('status', $status); |
||
734 | //$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0); |
||
735 | $xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options); |
||
736 | unset($viewmode_options); |
||
737 | $xoopsTpl->assign('menumode', $menumode); |
||
738 | $xoopsTpl->assign('menumode_other', $menumode_other); |
||
739 | |||
740 | // START irmtfan add verifyUser to quick reply |
||
741 | //check banning |
||
742 | //$moderateHandler = Newbb\Helper::getInstance()->getHandler('Moderate'); |
||
743 | if (!empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled']) |
||
744 | && $topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'reply') |
||
745 | && $moderateHandler->verifyUser(-1, '', $forumObject->getVar('forum_id'))) { |
||
746 | // END irmtfan add verifyUser to quick reply |
||
747 | $forum_form = new \XoopsThemeForm(_MD_NEWBB_POSTREPLY, 'quick_reply', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/post.php', 'post', true); |
||
748 | if (!is_object($GLOBALS['xoopsUser'])) { |
||
749 | //$configHandler = xoops_getHandler('config'); |
||
750 | $user_tray = new \XoopsFormElementTray(_MD_NEWBB_ACCOUNT); |
||
751 | $user_tray->addElement(new \XoopsFormText(_MD_NEWBB_NAME, 'uname', 26, 255)); |
||
752 | $user_tray->addElement(new \XoopsFormPassword(_MD_NEWBB_PASSWORD, 'pass', 10, 32)); |
||
753 | $login_checkbox = new \XoopsFormCheckBox('', 'login', 1); |
||
754 | $login_checkbox->addOption(1, _MD_NEWBB_LOGIN); |
||
755 | $user_tray->addElement($login_checkbox); |
||
756 | $forum_form->addElement($user_tray); |
||
757 | $captcha = new \XoopsFormCaptcha('', "topic_{$topic_id}_{$start}"); |
||
758 | $captcha->setConfig('mode', 'text'); |
||
759 | $forum_form->addElement($captcha); |
||
760 | } |
||
761 | |||
762 | //$quickform = ( !empty($GLOBALS['xoopsModuleConfig']["editor_default"]) ) ? $GLOBALS['xoopsModuleConfig']["editor_default"] : "textarea"; |
||
763 | $quickform = !empty($GLOBALS['xoopsModuleConfig']['editor_quick_default']) ? $GLOBALS['xoopsModuleConfig']['editor_quick_default'] : 'textarea'; |
||
764 | $editor_configs = []; |
||
765 | $editor_configs ['name'] = 'message'; |
||
766 | //$editor_configs [ "value" ] = $message ; |
||
767 | $editor_configs ['rows'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_rows']) ? 10 : $GLOBALS['xoopsModuleConfig'] ['editor_rows']; |
||
768 | $editor_configs ['cols'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_cols']) ? 30 : $GLOBALS['xoopsModuleConfig'] ['editor_cols']; |
||
769 | $editor_configs ['width'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_width']) ? '100%' : $GLOBALS['xoopsModuleConfig'] ['editor_width']; |
||
770 | $editor_configs ['height'] = empty($GLOBALS['xoopsModuleConfig'] ['editor_height']) ? '400px' : $GLOBALS['xoopsModuleConfig'] ['editor_height']; |
||
771 | $_editor = new \XoopsFormEditor(_MD_NEWBB_MESSAGEC, $quickform, $editor_configs, true); |
||
772 | $forum_form->addElement($_editor, true); |
||
773 | |||
774 | $forum_form->addElement(new \XoopsFormHidden('dohtml', 0)); |
||
775 | $forum_form->addElement(new \XoopsFormHidden('dosmiley', 1)); |
||
776 | $forum_form->addElement(new \XoopsFormHidden('doxcode', 1)); |
||
777 | $forum_form->addElement(new \XoopsFormHidden('dobr', 1)); |
||
778 | $forum_form->addElement(new \XoopsFormHidden('attachsig', 1)); |
||
779 | |||
780 | $forum_form->addElement(new \XoopsFormHidden('isreply', 1)); |
||
781 | |||
782 | $forum_form->addElement(new \XoopsFormHidden('subject', _MD_NEWBB_RE . ': ' . $topicObject->getVar('topic_title', 'e'))); |
||
783 | $forum_form->addElement(new \XoopsFormHidden('pid', empty($post_id) ? $topicHandler->getTopPostId($topic_id) : $post_id)); |
||
784 | $forum_form->addElement(new \XoopsFormHidden('topic_id', $topic_id)); |
||
785 | $forum_form->addElement(new \XoopsFormHidden('forum', $forum_id)); |
||
786 | //$forum_form->addElement(new \XoopsFormHidden('viewmode', $viewmode)); |
||
787 | $forum_form->addElement(new \XoopsFormHidden('order', $order)); |
||
788 | $forum_form->addElement(new \XoopsFormHidden('start', $start)); |
||
789 | |||
790 | $forum_form->addElement(new \XoopsFormHidden('notify', -1)); |
||
791 | $forum_form->addElement(new \XoopsFormHidden('contents_submit', 1)); |
||
792 | |||
793 | $submit_button = new \XoopsFormButton('', 'quick_submit', _SUBMIT, 'submit'); |
||
794 | $submit_button->setExtra('onclick="if (document.forms.quick_reply.message.value === \'RE\' || document.forms.quick_reply.message.value === \'\') { alert(\'' . _MD_NEWBB_QUICKREPLY_EMPTY . '\'); return false;} else { return true;}"'); |
||
795 | $forum_form->addElement($submit_button); |
||
796 | |||
797 | $toggles = newbbGetCookie('G', true); |
||
798 | // START irmtfan improve quickreply smarty variable - add alt key to quick reply button - change $display to $style for more comprehension - add toggle $quickreply['expand'] |
||
799 | $quickreply = []; |
||
800 | $qr_collapse = 't_qr'; |
||
801 | $qr_expand = 't_qr_expand'; // change this |
||
802 | $quickreply['icon'] = [ |
||
803 | 'expand' => $iconHandler->getImageSource($qr_expand), |
||
804 | 'collapse' => $iconHandler->getImageSource($qr_collapse) |
||
805 | ]; |
||
806 | $quickreply['show'] = 1; // = !empty($GLOBALS['xoopsModuleConfig']['quickreply_enabled'] |
||
807 | $quickreply['expand'] = (count($toggles) > 0) ? (in_array('qr', $toggles, true) ? false : true) : true; |
||
808 | if ($quickreply['expand']) { |
||
809 | $quickreply['style'] = 'block'; //irmtfan move semicolon |
||
810 | $quickreply_icon_display = $qr_expand; |
||
811 | $quickreply_alt = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY; |
||
812 | } else { |
||
813 | $quickreply['style'] = 'none'; //irmtfan move semicolon |
||
814 | $quickreply_icon_display = $qr_collapse; |
||
815 | $quickreply_alt = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY; |
||
816 | } |
||
817 | $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt); |
||
818 | $quickreply['form'] = $forum_form->render(); |
||
819 | $xoopsTpl->assign('quickreply', $quickreply); |
||
820 | // END irmtfan improve quickreply smarty variable |
||
821 | unset($forum_form); |
||
822 | } else { |
||
823 | $xoopsTpl->assign('quickreply', ['show' => 0]); |
||
824 | } |
||
825 | |||
826 | if ($GLOBALS['xoopsModuleConfig']['do_tag'] |
||
827 | && @include_once $GLOBALS['xoops']->path('modules/tag/include/tagbar.php')) { |
||
828 | $xoopsTpl->assign('tagbar', tagBar($topicObject->getVar('topic_tags', 'n'))); |
||
829 | } |
||
830 | // irmtfan move to footer.php |
||
831 | include_once __DIR__ . '/footer.php'; |
||
832 | include $GLOBALS['xoops']->path('footer.php'); |
||
833 | $xoopsLogger->stopTime('newBB_viewtopic'); |
||
834 |
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.