Passed
Pull Request — master (#73)
by
unknown
05:59 queued 03:12
created

viewpost.php (2 issues)

Labels
Severity
1
<?php
2
//
3
//  ------------------------------------------------------------------------ //
4
//                XOOPS - PHP Content Management System                      //
5
//                  Copyright (c) 2000-2020 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
32
use Xmf\Request;
33
use XoopsModules\Newbb;
34
35
require_once __DIR__ . '/header.php';
36
37
$start    = Request::getInt('start', 0, 'GET');
38
$forum_id = Request::getInt('forum', 0, 'GET');
39
$order    = Request::getString('order', 'DESC', 'GET');
40
41
$uid = Request::getInt('uid', 0, 'GET');
42
43
$status = (Request::getString('status', '', 'GET')
44
           && in_array(Request::getString('status', '', 'GET'), ['active', 'pending', 'deleted', 'new', 'all', 'digest'])) ? Request::getString('status', '', 'GET') : '';
45
$mode   = Request::getInt('mode', 0, 'GET');
46
$mode   = (!empty($status) && in_array($status, ['active', 'pending', 'deleted'])) ? 2 : $mode;
47
48
///** @var Newbb\ForumHandler $forumHandler */
49
//$forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
50
///** @var Newbb\PostHandler $postHandler */
51
//$postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
52
53
if (empty($forum_id)) {
54
    $forums       = $forumHandler->getByPermission(0, 'view');
55
    $accessForums = array_keys($forums);
56
    $isAdmin      = $GLOBALS['xoopsUserIsAdmin'];
57
} else {
58
    $forumObject       = $forumHandler->get($forum_id);
59
    $forums[$forum_id] = $forumObject;
60
    $accessForums      = [$forum_id];
61
    $isAdmin           = newbbIsAdmin($forumObject);
62
}
63
64
/* Only admin has access to admin mode */
65
if (!$isAdmin && 2 === $mode) {
66
    $status = in_array($status, ['active', 'pending', 'deleted']) ? '' : $status;
67
    $mode   = 0;
68
}
69
if ($mode) {
70
    $_GET['viewmode'] = 'flat';
71
}
72
//echo $mode.' - '.$status;
73
$post_perpage = $GLOBALS['xoopsModuleConfig']['posts_per_page'];
74
75
$criteria_count = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(',', $accessForums) . ')', 'IN'));
76
$criteria_post  = new \CriteriaCompo(new \Criteria('p.forum_id', '(' . implode(',', $accessForums) . ')', 'IN'));
77
$criteria_post->setSort('p.post_id');
78
$criteria_post->setOrder($order);
79
80
if (!empty($uid)) {
81
    $criteria_count->add(new \Criteria('uid', $uid));
82
    $criteria_post->add(new \Criteria('p.uid', $uid));
83
}
84
85
$join = null;
86
// START irmtfan solve the status issues and specially status = new issue
87
switch ($status) {
88
    case 'pending':
89
        $criteria_count->add(new \Criteria('approved', 0)); // irmtfan add new \Criteria
90
        $criteria_post->add(new \Criteria('p.approved', 0)); // irmtfan add new \Criteria
91
        break;
92
    case 'deleted':
93
        $criteria_count->add(new \Criteria('approved', -1)); // irmtfan add new \Criteria
94
        $criteria_post->add(new \Criteria('p.approved', -1)); // irmtfan add new \Criteria
95
        break;
96
    case 'new':
97
        //$criteria_status_count = new \CriteriaCompo(new \Criteria("post_time", (int)($last_visit), ">"));// irmtfan commented and removed
98
        //$criteria_status_post = new \CriteriaCompo(new \Criteria("p.post_time", (int)($last_visit), ">"));// irmtfan commented and removed
99
        $criteria_count->add(new \Criteria('approved', 1)); // irmtfan uncomment
100
        $criteria_post->add(new \Criteria('p.approved', 1)); // irmtfan uncomment
101
        // following is for 'unread' -- not finished -- irmtfan Now it is finished!
102
        if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) {
103
            //$criteria_status_count->add(new \Criteria('approved', 1));// irmtfan commented and removed
104
            //$criteria_status_post->add(new \Criteria('p.approved', 1));// irmtfan commented and removed
105
        } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
106
            // START irmtfan use read_uid to find the unread posts when the user is logged in
107
            $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
108
            if (!empty($read_uid)) {
109
                $join                 = ' LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('newbb_reads_topic') . ' AS r ON r.read_item = p.topic_id AND r.uid = ' . $read_uid . ' '; // irmtfan corrected add AS
110
                $criteria_status_post = new \CriteriaCompo(); // irmtfan new \Criteria
111
                $criteria_status_post->add(new \Criteria('p.post_id', 'r.`post_id`', '>')); // irmtfan corrected - should use $value='r.``' to render in XOOPS/class/criteria.php
112
                $criteria_status_post->add(new \Criteria('r.read_id', null, 'IS NULL'), 'OR'); // irmtfan corrected - should use "IS NULL" to render in XOOPS/class/criteria.php
113
                $criteria_post->add($criteria_status_post); // irmtfan add the status criteria to post criteria - move here
114
                $criteria_count = $criteria_post; // irmtfan criteria count is equal to criteria post - move here
115
            }
116
117
            // END irmtfan use read_uid to find the unread posts when the user is logged in
118
            //$criteria_status_post->add(new \Criteria("p.approved", 1)); // irmtfan commented and removed
119
            //$criteria_status_count =& $criteria_status_post;
120
        } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
121
            $criteria_count->add(new \Criteria('post_time', (int)$last_visit, '>')); // irmtfan add new \Criteria
122
            $criteria_post->add(new \Criteria('p.post_time', (int)$last_visit, '>')); // irmtfan add new \Criteria
123
            // START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
124
            $topics         = [];
125
            $topic_lastread = newbbGetCookie('LT', true);
126
            if (count($topic_lastread) > 0) {
127
                foreach ($topic_lastread as $id => $time) {
128
                    if ($time > (int)$last_visit) {
129
                        $topics[] = $id;
130
                    }
131
                }
132
            }
133
            if (count($topics) > 0) {
134
                $criteria_count->add(new \Criteria('topic_id', '(' . implode(',', $topics) . ')', 'NOT IN'));
135
                $criteria_post->add(new \Criteria('p.topic_id', '(' . implode(',', $topics) . ')', 'NOT IN'));
136
            }
137
            // END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
138
            //$criteria_status_count->add(new \Criteria("approved", 1));// irmtfan commented and removed
139
            //$criteria_status_post->add(new \Criteria("p.approved", 1));// irmtfan commented and removed
140
        }
141
        break;
142
    default:
143
        $criteria_count->add(new \Criteria('approved', 1)); // irmtfan add new \Criteria
144
        $criteria_post->add(new \Criteria('p.approved', 1)); // irmtfan add new \Criteria
145
        break;
146
}
147
//$criteria_count->add($criteria_status_count); // irmtfan commented and removed
148
//$criteria_post->add($criteria_status_post); // irmtfan commented and removed
149
// END irmtfan solve the status issues and specially status = new issue
150
///** @var Newbb\KarmaHandler $karmaHandler */
151
//$karmaHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Karma');
152
$user_karma = $karmaHandler->getUserKarma();
153
154
$valid_modes     = ['flat', 'compact'];
155
$viewmode_cookie = newbbGetCookie('V');
156
157
if ('compact' === Request::getString('viewmode', '', 'GET')) {
158
    newbbSetCookie('V', 'compact', $forumCookie['expire']);
159
}
160
161
$viewmode = Request::getString('viewmode', (!empty($viewmode_cookie) ? $viewmode_cookie : (@$valid_modes[$GLOBALS['xoopsModuleConfig']['view_mode'] - 1])), 'GET');
162
$viewmode = in_array($viewmode, $valid_modes) ? $viewmode : $valid_modes[0];
163
164
$postCount = $postHandler->getPostCount($criteria_count, $join); // irmtfan add join for read_mode = 2
165
$posts     = $postHandler->getPostsByLimit($criteria_post, $post_perpage, $start, $join); // irmtfan add join for read_mode = 2
166
167
$poster_array = [];
168
if (count($posts) > 0) {
169
    foreach (array_keys($posts) as $id) {
170
        /** @var Newbb\Post[] $posts */
171
        $poster_array[$posts[$id]->getVar('uid')] = 1;
172
    }
173
}
174
175
$xoops_pagetitle                = $xoopsModule->getVar('name') . ' - ' . _MD_NEWBB_VIEWALLPOSTS;
176
$xoopsOption['xoops_pagetitle'] = $xoops_pagetitle;
177
$xoopsOption['template_main']   = 'newbb_viewpost.tpl';
178
179
require_once $GLOBALS['xoops']->path('header.php');
180
require_once __DIR__ . '/include/functions.time.php';
181
require_once __DIR__ . '/include/functions.render.php';
182
183
//global $xoTheme;
184
//$xoTheme->addScript('/Frameworks/textsanitizer/xoops.js');
185
186
if (!empty($forum_id)) {
187
    if (!$forumHandler->getPermission($forumObject, 'view')) {
188
        redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
189
    }
190
    if ($forumObject->getVar('parent_forum')) {
191
        $parent_forumObject = $forumHandler->get($forumObject->getVar('parent_forum'), ['forum_name']);
192
        $parentforum        = [
193
            'id'   => $forumObject->getVar('parent_forum'),
194
            'name' => $parent_forumObject->getVar('forum_name'),
195
        ];
196
        unset($parent_forumObject);
197
        $xoopsTpl->assign_by_ref('parentforum', $parentforum);
198
    }
199
    $xoopsTpl->assign('forum_name', $forumObject->getVar('forum_name'));
200
    $xoopsTpl->assign('forum_moderators', $forumObject->dispForumModerators());
201
202
    $xoops_pagetitle = $forumObject->getVar('forum_name') . ' - ' . _MD_NEWBB_VIEWALLPOSTS . ' [' . $xoopsModule->getVar('name') . ']';
203
    $xoopsTpl->assign('forum_id', $forumObject->getVar('forum_id'));
204
    // irmtfan new method
205
    if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
206
        $xoopsTpl->assign(
207
            'xoops_module_header',
208
            '
209
            <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '-' . $forumObject->getVar('forum_name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php?f=' . $forum_id . '" >
210
            ' . @$xoopsTpl->get_template_vars('xoops_module_header')
211
        );
212
    }
213
} elseif (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
214
    $xoopsTpl->assign(
215
        'xoops_module_header',
216
        '
217
        <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/rss.php" >
218
    ' . @$xoopsTpl->get_template_vars('xoops_module_header')
219
    );
220
}
221
// irmtfan remove and move to footer.php
222
//$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
223
$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
224
// irmtfan - remove icon_path and use newbbDisplayImage
225
$xoopsTpl->assign('anonym_avatar', newbbDisplayImage('anonym'));
226
$userid_array = [];
227
if (count($poster_array) > 0) {
228
    /** @var \XoopsMembershipHandler $memberHandler */
229
    $memberHandler = xoops_getHandler('member');
230
    $userid_array  = array_keys($poster_array);
231
    $user_criteria = '(' . implode(',', $userid_array) . ')';
232
    $users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);
0 ignored issues
show
The method getUsers() does not exist on XoopsMembershipHandler. Did you maybe mean getUsersByGroup()? ( Ignorable by Annotation )

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

232
    /** @scrutinizer ignore-call */ 
233
    $users         = $memberHandler->getUsers(new \Criteria('uid', $user_criteria, 'IN'), true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
233
} else {
234
    $user_criteria = '';
235
    $users         = null;
236
}
237
238
$online = [];
239
240
if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
241
    if (!empty($user_criteria)) {
242
        //        /** @var Newbb\OnlineHandler $onlineHandler */
243
        //        $onlineHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Online');
244
        $onlineHandler->init($forum_id);
245
    }
246
}
247
248
$viewtopic_users = [];
249
250
if (count($userid_array) > 0) {
251
    //    require_once $GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname', 'n') . '/class/user.php');
252
    $userHandler         = new Newbb\UserHandler($GLOBALS['xoopsModuleConfig']['groupbar_enabled'], $GLOBALS['xoopsModuleConfig']['wol_enabled']);
253
    $userHandler->users  = $users;
254
    $userHandler->online = $online;
0 ignored issues
show
The property online does not seem to exist on XoopsModules\Newbb\UserHandler.
Loading history...
255
    $viewtopic_users     = $userHandler->getUsers();
256
}
257
258
$pn = 0;
259
//$topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
260
static $suspension = [];
261
foreach (array_keys($posts) as $id) {
262
    ++$pn;
263
264
    /** @var Newbb\Post $post */
265
    $post       = $posts[$id];
266
    $post_title = $post->getVar('subject');
267
268
    $posticon = $post->getVar('icon');
269
    if ($posticon) {
270
        $post_image = '<a name="' . $post->getVar('post_id') . '"><img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($posticon, ENT_QUOTES | ENT_HTML5) . '" alt="" ></a>';
271
    } else {
272
        $post_image = '<a name="' . $post->getVar('post_id') . '"><img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" ></a>';
273
    }
274
    $poster = [
275
        'uid'  => 0,
276
        'name' => $post->getVar('poster_name') ?: $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']),
277
        'link' => $post->getVar('poster_name') ?: $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']),
278
    ];
279
    if ($post->getVar('uid') > 0 && isset($viewtopic_users[$post->getVar('uid')])) {
280
        $poster = $viewtopic_users[$post->getVar('uid')];
281
    }
282
    if ($isAdmin || $post->checkIdentity()) {
283
        $post_text       = $post->getVar('post_text');
284
        $post_attachment = $post->displayAttachment();
285
    } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $post->getVar('post_karma') > $user_karma) {
286
        $post_text       = "<div class='karma'>" . sprintf(_MD_NEWBB_KARMA_REQUIREMENT, $user_karma, $post->getVar('post_karma')) . '</div>';
287
        $post_attachment = '';
288
    } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $post->getVar('require_reply')) {
289
        $post_text       = "<div class='karma'>" . _MD_NEWBB_REPLY_REQUIREMENT . '</div>';
290
        $post_attachment = '';
291
    } else {
292
        $post_text       = $post->getVar('post_text');
293
        $post_attachment = $post->displayAttachment();
294
    }
295
296
    $thread_buttons = [];
297
298
    if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
299
        if (!isset($suspension[$post->getVar('forum_id')])) {
300
            //            /** @var Newbb\ModerateHandler $moderateHandler */
301
            //            $moderateHandler                       = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Moderate');
302
            $suspension[$post->getVar('forum_id')] = !$moderateHandler->verifyUser(-1, '', $post->getVar('forum_id'));
303
        }
304
305
        if ($isAdmin
306
            || (!$suspension[$post->getVar('forum_id')] && $post->checkIdentity()
307
                && $post->checkTimelimit('delete_timelimit'))) {
308
            $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
309
            $thread_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/delete.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
310
            $thread_buttons['delete']['name']  = _DELETE;
311
        }
312
        if ($isAdmin
313
            || !$suspension[$post->getVar('forum_id')] && $post->checkIdentity()
314
               && $post->checkTimelimit('edit_timelimit')) {
315
            $thread_buttons['edit']['image'] = newbbDisplayImage('p_edit', _EDIT);
316
            $thread_buttons['edit']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/edit.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
317
            $thread_buttons['edit']['name']  = _EDIT;
318
        }
319
        if (is_object($GLOBALS['xoopsUser']) && !$suspension[$post->getVar('forum_id')]) {
320
            $thread_buttons['reply']['image'] = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
321
            $thread_buttons['reply']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
322
            $thread_buttons['reply']['name']  = _MD_NEWBB_REPLY;
323
324
            $thread_buttons['quote']['image'] = newbbDisplayImage('p_quote', _MD_NEWBB_QUOTE);
325
            $thread_buttons['quote']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id') . '&amp;quotedac=1';
326
            $thread_buttons['quote']['name']  = _MD_NEWBB_QUOTE;
327
        }
328
    } else {
329
        $thread_buttons['delete']['image'] = newbbDisplayImage('p_delete', _DELETE);
330
        $thread_buttons['delete']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/delete.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
331
        $thread_buttons['delete']['name']  = _DELETE;
332
        $thread_buttons['edit']['image']   = newbbDisplayImage('p_edit', _EDIT);
333
        $thread_buttons['edit']['link']    = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/edit.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
334
        $thread_buttons['edit']['name']    = _EDIT;
335
        $thread_buttons['reply']['image']  = newbbDisplayImage('p_reply', _MD_NEWBB_REPLY);
336
        $thread_buttons['reply']['link']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/reply.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
337
        $thread_buttons['reply']['name']   = _MD_NEWBB_REPLY;
338
    }
339
340
    if (!$isAdmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
341
        $thread_buttons['report']['image'] = newbbDisplayImage('p_report', _MD_NEWBB_REPORT);
342
        $thread_buttons['report']['link']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/report.php?forum=' . $post->getVar('forum_id') . '&amp;topic_id=' . $post->getVar('topic_id');
343
        $thread_buttons['report']['name']  = _MD_NEWBB_REPORT;
344
    }
345
    $thread_action = [];
346
347
    $xoopsTpl->append(
348
        'posts',
349
        [
350
            'post_id'         => $post->getVar('post_id'),
351
            'topic_id'        => $post->getVar('topic_id'),
352
            'forum_id'        => $post->getVar('forum_id'),
353
            'post_date'       => newbbFormatTimestamp($post->getVar('post_time')),
354
            'post_image'      => $post_image,
355
            'post_title'      => $post_title,
356
            'post_text'       => $post_text,
357
            'post_attachment' => $post_attachment,
358
            'post_edit'       => $post->displayPostEdit(),
359
            'post_no'         => $start + $pn,
360
            'post_signature'  => $post->getVar('attachsig') ? @$poster['signature'] : '',
361
            //                                 'poster_ip'       => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? long2ip($post->getVar('poster_ip')) : '',
362
            'poster_ip'       => ($isAdmin && $GLOBALS['xoopsModuleConfig']['show_ip']) ? $post->getVar('poster_ip') : '',
363
            'thread_action'   => $thread_action,
364
            'thread_buttons'  => $thread_buttons,
365
            'poster'          => $poster,
366
        ]
367
    );
368
369
    unset($thread_buttons, $poster);
370
}
371
unset($viewtopic_users, $forums);
372
373
if (!empty($GLOBALS['xoopsModuleConfig']['show_jump'])) {
374
    require_once __DIR__ . '/include/functions.forum.php';
375
    $xoopsTpl->assign('forum_jumpbox', newbbMakeJumpbox($forum_id));
376
}
377
378
if ($postCount > $post_perpage) {
379
    require_once $GLOBALS['xoops']->path('class/pagenav.php');
380
    $nav = new \XoopsPageNav($postCount, $post_perpage, $start, 'start', 'forum=' . $forum_id . '&amp;viewmode=' . $viewmode . '&amp;status=' . $status . '&amp;uid=' . $uid . '&amp;order=' . $order . '&amp;mode=' . $mode);
381
    //if (isset($GLOBALS['xoopsModuleConfig']['do_rewrite'])) $nav->url = formatURL(Request::getString('SERVER_NAME', '', 'SERVER')) . $nav->url;
382
    if ('select' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
383
        $navi = $nav->renderSelect();
384
    } elseif ('image' === $GLOBALS['xoopsModuleConfig']['pagenav_display']) {
385
        $navi = $nav->renderImageNav(4);
386
    } else {
387
        $navi = $nav->renderNav(4);
388
    }
389
390
    $xoopsTpl->assign('pagenav', $navi);
391
} else {
392
    $xoopsTpl->assign('pagenav', '');
393
}
394
395
$xoopsTpl->assign('lang_forum_index', sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)));
396
397
switch ($status) {
398
    case 'active':
399
        $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_ADMIN . ']';
400
        break;
401
    case 'pending':
402
        $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_PENDING . ']';
403
        break;
404
    case 'deleted':
405
        $lang_title = _MD_NEWBB_VIEWALLPOSTS . ' [' . _MD_NEWBB_TYPE_DELETED . ']';
406
        break;
407
    case 'new':
408
        $lang_title = _MD_NEWBB_NEWPOSTS;
409
        break;
410
    default:
411
        $lang_title = _MD_NEWBB_VIEWALLPOSTS;
412
        break;
413
}
414
if ($uid > 0) {
415
    $lang_title .= ' (' . \XoopsUser::getUnameFromId($uid) . ')';
416
}
417
$xoopsTpl->assign('lang_title', $lang_title);
418
// irmtfan up to p_up
419
$xoopsTpl->assign('p_up', newbbDisplayImage('up', _MD_NEWBB_TOP));
420
$xoopsTpl->assign('groupbar_enable', $GLOBALS['xoopsModuleConfig']['groupbar_enabled']);
421
$xoopsTpl->assign('anonymous_prefix', $GLOBALS['xoopsModuleConfig']['anonymous_prefix']);
422
$xoopsTpl->assign('down', newbbDisplayImage('down', _MD_NEWBB_BOTTOM));
423
424
$all_link       = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&amp;start=$start";
425
$post_link      = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id;
426
$newpost_link   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . '&amp;status=new';
427
$digest_link    = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&amp;start=$start&amp;status=digest";
428
$unreplied_link = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&amp;start=$start&amp;status=unreplied";
429
$unread_link    = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?forum=' . $forum_id . "&amp;start=$start&amp;status=unread";
430
431
$xoopsTpl->assign('all_link', $all_link);
432
$xoopsTpl->assign('post_link', $post_link);
433
$xoopsTpl->assign('newpost_link', $newpost_link);
434
$xoopsTpl->assign('digest_link', $digest_link);
435
$xoopsTpl->assign('unreplied_link', $unreplied_link);
436
$xoopsTpl->assign('unread_link', $unread_link);
437
438
$viewmode_options = [];
439
if ('DESC' === $order) {
440
    $viewmode_options[] = [
441
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?viewmode=flat&amp;order=ASC&amp;forum=' . $forum_id,
442
        'title' => _OLDESTFIRST,
443
    ];
444
} else {
445
    $viewmode_options[] = [
446
        'link'  => XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewpost.php?viewmode=flat&amp;order=DESC&amp;forum=' . $forum_id,
447
        'title' => _NEWESTFIRST,
448
    ];
449
}
450
451
//$xoopsTpl->assign('viewmode_compact', ($viewmode=="compact")?1:0);
452
$xoopsTpl->assign_by_ref('viewmode_options', $viewmode_options);
453
$xoopsTpl->assign('menumode', $menumode);
454
$xoopsTpl->assign('menumode_other', $menumode_other);
455
456
$xoopsTpl->assign('viewer_level', $isAdmin ? 2 : is_object($GLOBALS['xoopsUser']));
457
$xoopsTpl->assign('uid', $uid);
458
$xoopsTpl->assign('mode', $mode);
459
$xoopsTpl->assign('status', $status);
460
// irmtfan move to footer.php
461
require_once __DIR__ . '/footer.php';
462
require_once $GLOBALS['xoops']->path('footer.php');
463