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