Issues (340)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

viewtopic.php (2 issues)

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

838
    $quickreply['expand'] = !((is_countable($toggles) ? count(/** @scrutinizer ignore-type */ $toggles) : 0) > 0) || !in_array('qr', $toggles, true);
Loading history...
It seems like $toggles can also be of type string; however, parameter $haystack of in_array() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

838
    $quickreply['expand'] = !((is_countable($toggles) ? count($toggles) : 0) > 0) || !in_array('qr', /** @scrutinizer ignore-type */ $toggles, true);
Loading history...
839
    if ($quickreply['expand']) {
840
        $quickreply['style']     = 'block';        //irmtfan move semicolon
841
        $quickreply_icon_display = $qr_expand;
842
        $quickreply_alt          = _MD_NEWBB_HIDE . ' ' . _MD_NEWBB_QUICKREPLY;
843
    } else {
844
        $quickreply['style']     = 'none';        //irmtfan move semicolon
845
        $quickreply_icon_display = $qr_collapse;
846
        $quickreply_alt          = _MD_NEWBB_SEE . ' ' . _MD_NEWBB_QUICKREPLY;
847
    }
848
    $quickreply['displayImage'] = newbbDisplayImage($quickreply_icon_display, $quickreply_alt);
849
    $quickreply['form']         = $forum_form->render();
850
    $xoopsTpl->assign('quickreply', $quickreply);
851
    // END irmtfan improve quickreply smarty variable
852
    unset($forum_form);
853
} else {
854
    $xoopsTpl->assign('quickreply', ['show' => 0]);
855
}
856
857
if (1 == $helper->getConfig('do_tag') && \class_exists(\XoopsModules\Tag\Tagbar::class) && \xoops_isActiveModule('tag')) {
858
    $tagbarObj = new \XoopsModules\Tag\Tagbar();
859
    $xoopsTpl->assign('tagbar', $tagbarObj->getTagbar($topicObject->getVar('topic_tags', 'n')));
860
}
861
862
// irmtfan move to footer.php
863
require_once __DIR__ . '/footer.php';
864
require_once $GLOBALS['xoops']->path('footer.php');
865
$xoopsLogger->stopTime('newBB_viewtopic');
866