Post::showPost()   F
last analyzed

Complexity

Conditions 42
Paths > 20000

Size

Total Lines 242
Code Lines 180

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 42
eloc 180
c 1
b 0
f 0
nc 29196288
nop 1
dl 0
loc 242
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Newbb;
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @copyright    {@link https://xoops.org/ XOOPS Project}
17
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
18
 * @author       XOOPS Development Team, phppp (D.J., [email protected])
19
 */
20
21
use Xmf\Request;
22
use XoopsModules\Newbb;
23
24
\defined('NEWBB_FUNCTIONS_INI') || require XOOPS_ROOT_PATH . '/modules/newbb/include/functions.ini.php';
25
newbb_load_object();
0 ignored issues
show
Bug introduced by
The function newbb_load_object was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

25
/** @scrutinizer ignore-call */ 
26
newbb_load_object();
Loading history...
26
27
/**
28
 * Class Post
29
 */
30
class Post extends \XoopsObject
31
{
32
    private $post_id;
0 ignored issues
show
introduced by
The private property $post_id is not used, and could be removed.
Loading history...
33
    private $topic_id;
0 ignored issues
show
introduced by
The private property $topic_id is not used, and could be removed.
Loading history...
34
    private $forum_id;
0 ignored issues
show
introduced by
The private property $forum_id is not used, and could be removed.
Loading history...
35
    private $post_time;
0 ignored issues
show
introduced by
The private property $post_time is not used, and could be removed.
Loading history...
36
    private $poster_ip;
0 ignored issues
show
introduced by
The private property $poster_ip is not used, and could be removed.
Loading history...
37
    private $poster_name;
0 ignored issues
show
introduced by
The private property $poster_name is not used, and could be removed.
Loading history...
38
    private $subject;
0 ignored issues
show
introduced by
The private property $subject is not used, and could be removed.
Loading history...
39
    private $pid;
0 ignored issues
show
introduced by
The private property $pid is not used, and could be removed.
Loading history...
40
    private $dohtml;
0 ignored issues
show
introduced by
The private property $dohtml is not used, and could be removed.
Loading history...
41
    private $dosmiley;
0 ignored issues
show
introduced by
The private property $dosmiley is not used, and could be removed.
Loading history...
42
    private $doxcode;
0 ignored issues
show
introduced by
The private property $doxcode is not used, and could be removed.
Loading history...
43
    private $doimage;
0 ignored issues
show
introduced by
The private property $doimage is not used, and could be removed.
Loading history...
44
    private $dobr;
0 ignored issues
show
introduced by
The private property $dobr is not used, and could be removed.
Loading history...
45
    private $uid;
0 ignored issues
show
introduced by
The private property $uid is not used, and could be removed.
Loading history...
46
    private $icon;
0 ignored issues
show
introduced by
The private property $icon is not used, and could be removed.
Loading history...
47
    private $attachsig;
0 ignored issues
show
introduced by
The private property $attachsig is not used, and could be removed.
Loading history...
48
    private $approved;
0 ignored issues
show
introduced by
The private property $approved is not used, and could be removed.
Loading history...
49
    private $post_karma;
0 ignored issues
show
introduced by
The private property $post_karma is not used, and could be removed.
Loading history...
50
    private $require_reply;
0 ignored issues
show
introduced by
The private property $require_reply is not used, and could be removed.
Loading history...
51
    private $attachment;
0 ignored issues
show
introduced by
The private property $attachment is not used, and could be removed.
Loading history...
52
    private $post_text;
0 ignored issues
show
introduced by
The private property $post_text is not used, and could be removed.
Loading history...
53
    private $post_edit;
0 ignored issues
show
introduced by
The private property $post_edit is not used, and could be removed.
Loading history...
54
55
    //class Post extends \XoopsObject {
56
    public $attachment_array = [];
57
58
    /**
59
     * Post constructor.
60
     */
61
    public function __construct()
62
    {
63
        parent::__construct('bb_posts');
0 ignored issues
show
Unused Code introduced by
The call to XoopsObject::__construct() has too many arguments starting with 'bb_posts'. ( Ignorable by Annotation )

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

63
        parent::/** @scrutinizer ignore-call */ 
64
                __construct('bb_posts');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
64
        $this->initVar('post_id', \XOBJ_DTYPE_INT);
65
        $this->initVar('topic_id', \XOBJ_DTYPE_INT, 0, true);
66
        $this->initVar('forum_id', \XOBJ_DTYPE_INT, 0, true);
67
        $this->initVar('post_time', \XOBJ_DTYPE_INT, 0, true);
68
        $this->initVar('poster_ip', \XOBJ_DTYPE_INT, 0);
69
        $this->initVar('poster_name', \XOBJ_DTYPE_TXTBOX, '');
70
        $this->initVar('subject', \XOBJ_DTYPE_TXTBOX, '', true);
71
        $this->initVar('pid', \XOBJ_DTYPE_INT, 0);
72
        $this->initVar('dohtml', \XOBJ_DTYPE_INT, 0);
73
        $this->initVar('dosmiley', \XOBJ_DTYPE_INT, 1);
74
        $this->initVar('doxcode', \XOBJ_DTYPE_INT, 1);
75
        $this->initVar('doimage', \XOBJ_DTYPE_INT, 1);
76
        $this->initVar('dobr', \XOBJ_DTYPE_INT, 1);
77
        $this->initVar('uid', \XOBJ_DTYPE_INT, 1);
78
        $this->initVar('icon', \XOBJ_DTYPE_TXTBOX, '');
79
        $this->initVar('attachsig', \XOBJ_DTYPE_INT, 0);
80
        $this->initVar('approved', \XOBJ_DTYPE_INT, 1);
81
        $this->initVar('post_karma', \XOBJ_DTYPE_INT, 0);
82
        $this->initVar('require_reply', \XOBJ_DTYPE_INT, 0);
83
        $this->initVar('attachment', \XOBJ_DTYPE_TXTAREA, '');
84
        $this->initVar('post_text', \XOBJ_DTYPE_TXTAREA, '');
85
        $this->initVar('post_edit', \XOBJ_DTYPE_TXTAREA, '');
86
    }
87
88
    // ////////////////////////////////////////////////////////////////////////////////////
89
    // attachment functions    TODO: there should be a file/attachment management class
90
91
    /**
92
     * @return array|mixed|null
93
     */
94
    public function getAttachment()
95
    {
96
        if (\count($this->attachment_array)) {
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachment?
Loading history...
97
            return $this->attachment_array;
98
        }
99
        $attachment = $this->getVar('attachment');
100
        if (empty($attachment)) {
101
            $this->attachment_array = null;
102
        } else {
103
            $this->attachment_array = @\unserialize(\base64_decode($attachment, true));
104
        }
105
106
        return $this->attachment_array;
107
    }
108
109
    /**
110
     * @param $attach_key
111
     * @return bool
112
     */
113
    public function incrementDownload($attach_key)
114
    {
115
        if (!$attach_key) {
116
            return false;
117
        }
118
        $this->attachment_array[(string)$attach_key]['num_download']++;
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachment?
Loading history...
119
120
        return $this->attachment_array[(string)$attach_key]['num_download'];
121
    }
122
123
    /**
124
     * @return bool
125
     */
126
    public function saveAttachment()
127
    {
128
        $attachment_save = '';
129
        if ($this->attachment_array && \is_array($this->attachment_array)) {
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachment?
Loading history...
130
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
131
        }
132
        $this->setVar('attachment', $attachment_save);
133
        $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' SET attachment=' . $GLOBALS['xoopsDB']->quoteString($attachment_save) . ' WHERE post_id = ' . $this->getVar('post_id');
134
        if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
135
            //xoops_error($GLOBALS["xoopsDB"]->error());
136
            return false;
137
        }
138
139
        return true;
140
    }
141
142
    /**
143
     * @param null $attach_array
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $attach_array is correct as it would always require null to be passed?
Loading history...
144
     * @return bool
145
     */
146
    public function deleteAttachment($attach_array = null)
147
    {
148
        $attach_old = $this->getAttachment();
149
        if (!\is_array($attach_old) || \count($attach_old) < 1) {
0 ignored issues
show
introduced by
The condition is_array($attach_old) is always true.
Loading history...
150
            return true;
151
        }
152
        $this->attachment_array = [];
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachment?
Loading history...
153
154
        if (null === $attach_array) {
0 ignored issues
show
introduced by
The condition null === $attach_array is always true.
Loading history...
155
            $attach_array = \array_keys($attach_old);
156
        } // to delete all!
157
        if (!\is_array($attach_array)) {
0 ignored issues
show
introduced by
The condition is_array($attach_array) is always true.
Loading history...
158
            $attach_array = [$attach_array];
159
        }
160
161
        foreach ($attach_old as $key => $attach) {
162
            if (\in_array($key, $attach_array, true)) {
163
                @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for unlink(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

163
                /** @scrutinizer ignore-unhandled */ @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $attach['name_saved']);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
164
                @\unlink(XOOPS_ROOT_PATH . '/' . $GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/thumbs/' . $attach['name_saved']); // delete thumbnails
165
                continue;
166
            }
167
            $this->attachment_array[$key] = $attach;
168
        }
169
        $attachment_save = '';
170
        if ($this->attachment_array && \is_array($this->attachment_array)) {
171
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
172
        }
173
        $this->setVar('attachment', $attachment_save);
174
175
        return true;
176
    }
177
178
    /**
179
     * @param string $name_saved
180
     * @param string $name_display
181
     * @param string $mimetype
182
     * @param int    $num_download
183
     * @return bool
184
     */
185
    public function setAttachment($name_saved = '', $name_display = '', $mimetype = '', $num_download = 0)
186
    {
187
        static $counter = 0;
188
        $this->attachment_array = $this->getAttachment();
0 ignored issues
show
Bug introduced by
The property attachment_array does not exist on XoopsModules\Newbb\Post. Did you mean attachment?
Loading history...
189
        if ($name_saved) {
190
            $key                          = (string)(\time() + $counter++);
191
            $this->attachment_array[$key] = [
192
                'name_saved'   => $name_saved,
193
                'name_display' => $name_display ?? $name_saved,
194
                'mimetype'     => $mimetype,
195
                'num_download' => isset($num_download) ? (int)$num_download : 0,
196
            ];
197
        }
198
        $attachment_save = null;
199
        if (\is_array($this->attachment_array)) {
0 ignored issues
show
introduced by
The condition is_array($this->attachment_array) is always true.
Loading history...
200
            $attachment_save = \base64_encode(\serialize($this->attachment_array));
201
        }
202
        $this->setVar('attachment', $attachment_save);
203
204
        return true;
205
    }
206
207
    /**
208
     * TODO: refactor
209
     * @param bool $asSource
210
     * @return string
211
     */
212
    public function displayAttachment($asSource = false)
0 ignored issues
show
Unused Code introduced by
The parameter $asSource is not used and could be removed. ( Ignorable by Annotation )

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

212
    public function displayAttachment(/** @scrutinizer ignore-unused */ $asSource = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
213
    {
214
        $post_attachment = '';
215
        $attachments     = $this->getAttachment();
216
        if ($attachments && \is_array($attachments)) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $attachments of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
217
            $iconHandler = newbb_getIconHandler();
0 ignored issues
show
Bug introduced by
The function newbb_getIconHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

217
            $iconHandler = /** @scrutinizer ignore-call */ newbb_getIconHandler();
Loading history...
218
            $mime_path   = $iconHandler->getPath('mime');
219
            require_once $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . '/include/functions.image.php');
220
            $image_extensions = ['jpg', 'jpeg', 'gif', 'png', 'bmp']; // need improve !!!
221
            $post_attachment  .= '<br><strong>' . _MD_ATTACHMENT . '</strong>:';
222
            $post_attachment  .= "<div style='margin: 1em 0; border-top: 1px solid;'></div>\n";
223
            //            $post_attachment .= '<br><hr style="height: 1px;" noshade="noshade"><br>';
224
            foreach ($attachments as $key => $att) {
225
                $file_extension = \ltrim(mb_strrchr($att['name_saved'], '.'), '.');
226
                $filetype       = $file_extension;
227
                if (\file_exists($GLOBALS['xoops']->path("{$mime_path}/{$filetype}.gif"))) {
228
                    $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/{$filetype}.gif");
229
                } else {
230
                    $icon_filetype = $GLOBALS['xoops']->url("{$mime_path}/unknown.gif");
231
                }
232
                $file_size = @\filesize($GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/' . $att['name_saved']));
233
                $file_size = \number_format($file_size / 1024, 2) . ' KB';
234
                if ($GLOBALS['xoopsModuleConfig']['media_allowed']
235
                    && \in_array(mb_strtolower($file_extension), $image_extensions, true)) {
236
                    $post_attachment .= '<br><img src="' . $icon_filetype . '" alt="' . $filetype . '"><strong>&nbsp; ' . $att['name_display'] . '</strong> <small>(' . $file_size . ')</small>';
237
                    $post_attachment .= '<br>' . newbb_attachmentImage($att['name_saved']);
0 ignored issues
show
Bug introduced by
The function newbb_attachmentImage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

237
                    $post_attachment .= '<br>' . /** @scrutinizer ignore-call */ newbb_attachmentImage($att['name_saved']);
Loading history...
238
                    $isDisplayed     = true;
0 ignored issues
show
Unused Code introduced by
The assignment to $isDisplayed is dead and can be removed.
Loading history...
239
                } else {
240
                    if (empty($GLOBALS['xoopsModuleConfig']['show_userattach'])) {
241
                        $post_attachment .= "<a href='"
242
                                            . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&amp;post_id=" . $this->getVar('post_id'))
243
                                            . "'> <img src='{$icon_filetype}' alt='{$filetype}'> {$att['name_display']}</a> "
244
                                            . _MD_FILESIZE
245
                                            . ": {$file_size}; "
246
                                            . _MD_HITS
247
                                            . ": {$att['num_download']}";
248
                    } elseif (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->uid() > 0
249
                              && $GLOBALS['xoopsUser']->isActive()) {
250
                        $post_attachment .= "<a href='"
251
                                            . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname', 'n') . "/dl_attachment.php?attachid={$key}&amp;post_id=" . $this->getVar('post_id'))
252
                                            . "'> <img src='"
253
                                            . $icon_filetype
254
                                            . "' alt='{$filetype}'> {$att['name_display']}</a> "
255
                                            . _MD_FILESIZE
256
                                            . ": {$file_size}; "
257
                                            . _MD_HITS
258
                                            . ": {$att['num_download']}";
259
                    } else {
260
                        $post_attachment .= _MD_NEWBB_SEENOTGUEST;
261
                    }
262
                }
263
                $post_attachment .= '<br>';
264
            }
265
        }
266
267
        return $post_attachment;
268
    }
269
270
    // attachment functions
271
    // ////////////////////////////////////////////////////////////////////////////////////
272
273
    /**
274
     * @param string $poster_name
275
     * @param string $post_editmsg
276
     * @return bool
277
     */
278
    public function setPostEdit($poster_name = '', $post_editmsg = '')
0 ignored issues
show
Unused Code introduced by
The parameter $poster_name is not used and could be removed. ( Ignorable by Annotation )

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

278
    public function setPostEdit(/** @scrutinizer ignore-unused */ $poster_name = '', $post_editmsg = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
279
    {
280
        if ($this->getVar('approved') < 1
281
            || empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])
282
            || (\time() - $this->getVar('post_time')) < $GLOBALS['xoopsModuleConfig']['recordedit_timelimit'] * 60) {
283
            return true;
284
        }
285
        if (($GLOBALS['xoopsUser'] instanceof \XoopsUser) && $GLOBALS['xoopsUser']->isActive()) {
286
            if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $GLOBALS['xoopsUser']->getVar('name')) {
287
                $edit_user = $GLOBALS['xoopsUser']->getVar('name');
288
            } else {
289
                $edit_user = $GLOBALS['xoopsUser']->getVar('uname');
290
            }
291
        }
292
        $post_edit              = [];
293
        $post_edit['edit_user'] = $edit_user; // The proper way is to store uid instead of name. However, to save queries when displaying, the current way is ok.
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $edit_user does not seem to be defined for all execution paths leading up to this point.
Loading history...
294
        $post_edit['edit_time'] = \time();
295
        $post_edit['edit_msg']  = $post_editmsg;
296
297
        $post_edits = $this->getVar('post_edit');
298
        if (!empty($post_edits)) {
299
            $post_edits = \unserialize(\base64_decode($post_edits, true));
300
        }
301
        if (!\is_array($post_edits)) {
302
            $post_edits = [];
303
        }
304
        $post_edits[] = $post_edit;
305
        $post_edit    = \base64_encode(\serialize($post_edits));
306
        unset($post_edits);
307
        $this->setVar('post_edit', $post_edit);
308
309
        return true;
310
    }
311
312
    /**
313
     * @return bool|string
314
     */
315
    public function displayPostEdit()
316
    {
317
        global $myts;
318
319
        if (empty($GLOBALS['xoopsModuleConfig']['recordedit_timelimit'])) {
320
            return false;
321
        }
322
323
        $post_edit  = '';
324
        $post_edits = $this->getVar('post_edit');
325
        if (!empty($post_edits)) {
326
            $post_edits = \unserialize(\base64_decode($post_edits, true));
327
        }
328
        if (!isset($post_edits) || !\is_array($post_edits)) {
329
            $post_edits = [];
330
        }
331
        if ($post_edits && \is_array($post_edits)) {
332
            foreach ($post_edits as $postedit) {
333
                $edit_time = (int)$postedit['edit_time'];
334
                $edit_user = ($postedit['edit_user']);
335
                $edit_msg  = !empty($postedit['edit_msg']) ? ($postedit['edit_msg']) : '';
336
                // Start irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
337
                if (empty($GLOBALS['xoopsModuleConfig']['do_latestedit'])) {
338
                    $post_edit = '';
339
                }
340
                // End irmtfan add option to do only the latest edit when do_latestedit=0 (Alfred)
341
                // START hacked by irmtfan
342
                // display/save all edit records.
343
                $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . newbb_formatTimestamp($edit_time) . '<br>';
0 ignored issues
show
Bug introduced by
The function newbb_formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

343
                $post_edit .= _MD_EDITEDBY . ' ' . $edit_user . ' ' . _MD_ON . ' ' . /** @scrutinizer ignore-call */ newbb_formatTimestamp($edit_time) . '<br>';
Loading history...
344
                // if reason is not empty
345
                if ('' !== $edit_msg) {
346
                    $post_edit .= \_MD_EDITEDMSG . ' ' . $edit_msg . '<br>';
347
                }
348
                // START hacked by irmtfan
349
            }
350
        }
351
352
        return $post_edit;
353
    }
354
355
    /**
356
     * @return array
357
     */
358
    public function &getPostBody()
359
    {
360
        global $myts;
361
        $GLOBALS['xoopsModuleConfig'] = newbb_load_config(); // irmtfan  load all newbb configs - newbb config in blocks activated in some modules like profile
0 ignored issues
show
Bug introduced by
The function newbb_load_config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

361
        $GLOBALS['xoopsModuleConfig'] = /** @scrutinizer ignore-call */ newbb_load_config(); // irmtfan  load all newbb configs - newbb config in blocks activated in some modules like profile
Loading history...
362
        //        mod_loadFunctions('user', 'newbb');
363
        //        mod_loadFunctions('render', 'newbb');
364
        require_once \dirname(__DIR__) . '/include/functions.user.php';
365
        require_once \dirname(__DIR__) . '/include/functions.render.php';
366
367
        $uid          = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
368
        $karmaHandler = Newbb\Helper::getInstance()->getHandler('Karma');
369
        $user_karma   = $karmaHandler->getUserKarma();
0 ignored issues
show
Bug introduced by
The method getUserKarma() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

369
        /** @scrutinizer ignore-call */ 
370
        $user_karma   = $karmaHandler->getUserKarma();
Loading history...
370
371
        $post               = [];
372
        $post['attachment'] = false;
373
        $post_text          = &newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
0 ignored issues
show
Bug introduced by
The function newbb_displayTarea was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

373
        $post_text          = &/** @scrutinizer ignore-call */ newbb_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
Loading history...
374
        if (newbb_isAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
0 ignored issues
show
Bug introduced by
The function newbb_isAdmin was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

374
        if (/** @scrutinizer ignore-call */ newbb_isAdmin($this->getVar('forum_id')) || $this->checkIdentity()) {
Loading history...
375
            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
376
        } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
377
            $post['text'] = \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('post_karma') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, 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

377
            $post['text'] = \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, /** @scrutinizer ignore-type */ $this->getVar('post_karma'));
Loading history...
378
        } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
379
                  && (!$uid || !isset($viewtopic_users[$uid]))) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $viewtopic_users seems to never exist and therefore isset should always be false.
Loading history...
380
            $post['text'] = _MD_REPLY_REQUIREMENT;
381
        } else {
382
            $post['text'] = $post_text . '<br>' . $this->displayAttachment();
383
        }
384
        $memberHandler = \xoops_getHandler('member');
385
        $eachposter    = $memberHandler->getUser($this->getVar('uid'));
0 ignored issues
show
Bug introduced by
The method getUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsAvatarHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

385
        /** @scrutinizer ignore-call */ 
386
        $eachposter    = $memberHandler->getUser($this->getVar('uid'));
Loading history...
386
        if (\is_object($eachposter) && $eachposter->isActive()) {
387
            if ($GLOBALS['xoopsModuleConfig']['show_realname'] && $eachposter->getVar('name')) {
388
                $post['author'] = $eachposter->getVar('name');
389
            } else {
390
                $post['author'] = $eachposter->getVar('uname');
391
            }
392
            unset($eachposter);
393
        } else {
394
            $post['author'] = $this->getVar('poster_name') ?: $GLOBALS['xoopsConfig']['anonymous'];
395
        }
396
397
        $post['subject'] = newbb_htmlspecialchars($this->vars['subject']['value']);
0 ignored issues
show
Bug introduced by
The function newbb_htmlspecialchars was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

397
        $post['subject'] = /** @scrutinizer ignore-call */ newbb_htmlspecialchars($this->vars['subject']['value']);
Loading history...
398
        $post['date']    = $this->getVar('post_time');
399
400
        return $post;
401
    }
402
403
    /**
404
     * @return bool
405
     */
406
    public function isTopic()
407
    {
408
        return !$this->getVar('pid');
409
    }
410
411
    /**
412
     * @param string $action_tag
413
     * @return bool
414
     */
415
    public function checkTimelimit($action_tag = 'edit_timelimit')
416
    {
417
        $newbb_config = newbb_load_config();
0 ignored issues
show
Bug introduced by
The function newbb_load_config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

417
        $newbb_config = /** @scrutinizer ignore-call */ newbb_load_config();
Loading history...
418
        if (empty($newbb_config['edit_timelimit'])) {
419
            return true;
420
        }
421
422
        return ($this->getVar('post_time') > \time() - $newbb_config[$action_tag] * 60);
423
    }
424
425
    /**
426
     * @param int $uid
427
     * @return bool
428
     */
429
    public function checkIdentity($uid = -1)
430
    {
431
        //        $uid = ($uid > -1) ? $uid : (($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0);
432
        if ($uid < 0 && $GLOBALS['xoopsUser'] instanceof \XoopsUser) {
433
            $uid = $GLOBALS['xoopsUser']->getVar('uid');
434
        } else {
435
            $uid = 0;
436
        }
437
        if ($this->getVar('uid') > 0) {
438
            $user_ok = $uid === $this->getVar('uid');
439
        } else {
440
            static $user_ip;
441
            if (!isset($user_ip)) {
442
                $user_ip = \XoopsUserUtility::getIP();
443
            }
444
            $user_ok = $user_ip === $this->getVar('poster_ip');
445
        }
446
447
        return $user_ok;
448
    }
449
450
    // TODO: cleaning up and merge with post hanldings in viewpost.php
451
452
    /**
453
     * @param $isadmin
454
     * @return array
455
     */
456
    public function showPost($isadmin)
457
    {
458
        global $myts;
459
        global $forumUrl, $forumImage;
460
        global $viewtopic_users, $viewtopic_posters, $forum_obj, $topic_obj, $online, $user_karma, $viewmode, $order, $start, $total_posts, $topic_status;
461
        static $post_NO = 0;
462
        static $name_anonymous;
463
464
        if (!isset($name_anonymous)) {
465
            $name_anonymous = htmlspecialchars($GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5);
466
        }
467
468
        //        mod_loadFunctions('time', 'newbb');
469
        //        mod_loadFunctions('render', 'newbb');
470
        //        mod_loadFunctions('text', 'newbb'); // irmtfan add text functions
471
        require_once \dirname(__DIR__) . '/include/functions.time.php';
472
        require_once \dirname(__DIR__) . '/include/functions.render.php';
473
        require_once \dirname(__DIR__) . '/include/functions.text.php';
474
475
        $post_id  = $this->getVar('post_id');
476
        $topic_id = $this->getVar('topic_id');
477
        $forum_id = $this->getVar('forum_id');
478
479
        $query_vars              = ['status', 'order', 'start', 'mode', 'viewmode'];
480
        $query_array             = [];
481
        $query_array['topic_id'] = "topic_id={$topic_id}";
482
        foreach ($query_vars as $var) {
483
            if (!empty($_GET[$var])) {
484
                $query_array[$var] = "{$var}={$_GET[$var]}";
485
            }
486
        }
487
        $page_query = \htmlspecialchars(\implode('&', \array_values($query_array)), \ENT_QUOTES | \ENT_HTML5);
488
489
        $uid = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
490
491
        ++$post_NO;
492
        if ('desc' === mb_strtolower($order)) {
493
            $post_no = $total_posts - ($start + $post_NO) + 1;
494
        } else {
495
            $post_no = $start + $post_NO;
496
        }
497
498
        if ($isadmin || $this->checkIdentity()) {
499
            $post_text       = $this->getVar('post_text');
500
            $post_attachment = $this->displayAttachment();
501
        } elseif ($GLOBALS['xoopsModuleConfig']['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
502
            $post_text       = "<div class='karma'>" . \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma')) . '</div>';
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('post_karma') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, 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

502
            $post_text       = "<div class='karma'>" . \sprintf(_MD_KARMA_REQUIREMENT, $user_karma, /** @scrutinizer ignore-type */ $this->getVar('post_karma')) . '</div>';
Loading history...
503
            $post_attachment = '';
504
        } elseif ($GLOBALS['xoopsModuleConfig']['allow_require_reply'] && $this->getVar('require_reply')
505
                  && (!$uid
506
                      || !\in_array($uid, $viewtopic_posters, true))) {
507
            $post_text       = "<div class='karma'>" . _MD_REPLY_REQUIREMENT . "</div>\n";
508
            $post_attachment = '';
509
        } else {
510
            $post_text       = $this->getVar('post_text');
511
            $post_attachment = $this->displayAttachment();
512
        }
513
        // START irmtfan add highlight feature
514
        // Hightlighting searched words
515
        $post_title = $this->getVar('subject');
516
        if (!empty($_GET['keywords']) && Request::hasVar('keywords', 'GET')) {
517
            $keywords   = htmlspecialchars(\trim(\urldecode($_GET['keywords'])), ENT_QUOTES | ENT_HTML5);
518
            $post_text  = \newbb_highlightText($post_text, $keywords);
519
            $post_title = \newbb_highlightText($post_title, $keywords);
520
        }
521
        // END irmtfan add highlight feature
522
        if (isset($viewtopic_users[$this->getVar('uid')])) {
523
            $poster = $viewtopic_users[$this->getVar('uid')];
524
        } else {
525
            $name   = ($post_name = $this->getVar('poster_name')) ? $post_name : $name_anonymous;
526
            $poster = [
527
                'poster_uid' => 0,
528
                'name'       => $name,
529
                'link'       => $name,
530
            ];
531
        }
532
533
        $posticon = $this->getVar('icon');
534
        if ($posticon) {
535
            $post_image = "<a name='{$post_id}'><img src='" . $GLOBALS['xoops']->url("images/subject/{$posticon}") . "' alt=''></a>";
536
        } else {
537
            $post_image = "<a name='{$post_id}'><img src='" . $GLOBALS['xoops']->url('images/icons/posticon.gif') . "' alt=''></a>";
538
        }
539
540
        $thread_buttons = [];
541
        $mod_buttons    = [];
542
543
        if (($this->getVar('uid') > 0)
544
            && $isadmin
545
            && (($GLOBALS['xoopsUser'] instanceof \XoopsUser)
546
                && $GLOBALS['xoopsUser']->getVar('uid') !== $this->getVar('uid'))) {
547
            $mod_buttons['bann']['image']    = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
0 ignored issues
show
Bug introduced by
The function newbb_displayImage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

547
            $mod_buttons['bann']['image']    = /** @scrutinizer ignore-call */ newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
Loading history...
548
            $mod_buttons['bann']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&amp;fuid=" . $this->getVar('uid'));
549
            $mod_buttons['bann']['name']     = _MD_SUSPEND_MANAGEMENT;
550
            $thread_buttons['bann']['image'] = newbb_displayImage('p_bann', _MD_SUSPEND_MANAGEMENT);
551
            $thread_buttons['bann']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/moderate.php?forum={$forum_id}&amp;fuid=" . $this->getVar('uid'));
552
            $thread_buttons['bann']['name']  = _MD_SUSPEND_MANAGEMENT;
553
        }
554
555
        if ($GLOBALS['xoopsModuleConfig']['enable_permcheck']) {
556
            /** @var Newbb\TopicHandler $topicHandler */
557
            $topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
558
            $topic_status = $topic_obj->getVar('topic_status');
559
            if ($topicHandler->getPermission($forum_id, $topic_status, 'edit')) {
560
                $edit_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('edit_timelimit')));
561
                if ($edit_ok) {
562
                    $thread_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT);
563
                    $thread_buttons['edit']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
564
                    $thread_buttons['edit']['name']  = _EDIT;
565
                    $mod_buttons['edit']['image']    = newbb_displayImage('p_edit', _EDIT);
566
                    $mod_buttons['edit']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
567
                    $mod_buttons['edit']['name']     = _EDIT;
568
                }
569
            }
570
571
            if ($topicHandler->getPermission($forum_id, $topic_status, 'delete')) {
572
                $delete_ok = ($isadmin || ($this->checkIdentity() && $this->checkTimelimit('delete_timelimit')));
573
574
                if ($delete_ok) {
575
                    $thread_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE);
576
                    $thread_buttons['delete']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
577
                    $thread_buttons['delete']['name']  = _DELETE;
578
                    $mod_buttons['delete']['image']    = newbb_displayImage('p_delete', _DELETE);
579
                    $mod_buttons['delete']['link']     = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
580
                    $mod_buttons['delete']['name']     = _DELETE;
581
                }
582
            }
583
            if ($topicHandler->getPermission($forum_id, $topic_status, 'reply')) {
584
                $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY);
585
                $thread_buttons['reply']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}");
586
                $thread_buttons['reply']['name']  = _MD_REPLY;
587
588
                $thread_buttons['quote']['image'] = newbb_displayImage('p_quote', _MD_QUOTE);
589
                $thread_buttons['quote']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}&amp;quotedac=1");
590
                $thread_buttons['quote']['name']  = _MD_QUOTE;
591
            }
592
        } else {
593
            $mod_buttons['edit']['image'] = newbb_displayImage('p_edit', _EDIT);
594
            $mod_buttons['edit']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/edit.php?{$page_query}");
595
            $mod_buttons['edit']['name']  = _EDIT;
596
597
            $mod_buttons['delete']['image'] = newbb_displayImage('p_delete', _DELETE);
598
            $mod_buttons['delete']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/delete.php?{$page_query}");
599
            $mod_buttons['delete']['name']  = _DELETE;
600
601
            $thread_buttons['reply']['image'] = newbb_displayImage('p_reply', _MD_REPLY);
602
            $thread_buttons['reply']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/reply.php?{$page_query}");
603
            $thread_buttons['reply']['name']  = _MD_REPLY;
604
        }
605
606
        if (!$isadmin && $GLOBALS['xoopsModuleConfig']['reportmod_enabled']) {
607
            $thread_buttons['report']['image'] = newbb_displayImage('p_report', _MD_REPORT);
608
            $thread_buttons['report']['link']  = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/report.php?{$page_query}");
609
            $thread_buttons['report']['name']  = _MD_REPORT;
610
        }
611
612
        $thread_action = [];
613
        // irmtfan add pdf permission
614
        if ($topicHandler->getPermission($forum_id, $topic_status, 'pdf')
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $topicHandler does not seem to be defined for all execution paths leading up to this point.
Loading history...
615
            && \file_exists($GLOBALS['xoops']->path('Frameworks/tcpdf/tcpdf.php'))) {
616
            $thread_action['pdf']['image']  = newbb_displayImage('pdf', _MD_PDF);
617
            $thread_action['pdf']['link']   = $GLOBALS['xoops']->url('modules/newbb/makepdf.php?type=post&amp;pageid=0');
618
            $thread_action['pdf']['name']   = _MD_PDF;
619
            $thread_action['pdf']['target'] = '_blank';
620
        }
621
        // irmtfan add print permission
622
        if ($topicHandler->getPermission($forum_id, $topic_status, 'print')) {
623
            $thread_action['print']['image']  = newbb_displayImage('printer', _MD_PRINT);
624
            $thread_action['print']['link']   = $GLOBALS['xoops']->url("modules/newbb/print.php?form=2&amp;forum={$forum_id}&amp;topic_id={$topic_id}");
625
            $thread_action['print']['name']   = _MD_PRINT;
626
            $thread_action['print']['target'] = '_blank';
627
        }
628
629
        if ($GLOBALS['xoopsModuleConfig']['show_sociallinks']) {
630
            $full_title  = $this->getVar('subject');
631
            $clean_title = \preg_replace('/[^A-Za-z0-9-]+/', '+', $this->getVar('subject'));
632
            $full_link   = $GLOBALS['xoops']->url("modules/newbb/viewtopic.php?post_id={$post_id}");
633
634
            $thread_action['social_twitter']['image']  = newbb_displayImage('twitter', \_MD_SHARE_TWITTER);
635
            $thread_action['social_twitter']['link']   = "https://twitter.com/share?text={$clean_title}&amp;url={$full_link}";
636
            $thread_action['social_twitter']['name']   = \_MD_SHARE_TWITTER;
637
            $thread_action['social_twitter']['target'] = '_blank';
638
639
            $thread_action['social_facebook']['image']  = newbb_displayImage('facebook', \_MD_SHARE_FACEBOOK);
640
            $thread_action['social_facebook']['link']   = "https://www.facebook.com/sharer.php?u={$full_link}";
641
            $thread_action['social_facebook']['name']   = \_MD_SHARE_FACEBOOK;
642
            $thread_action['social_facebook']['target'] = '_blank';
643
644
            $thread_action['social_gplus']['image']  = newbb_displayImage('googleplus', \_MD_SHARE_GOOGLEPLUS);
645
            $thread_action['social_gplus']['link']   = "https://plusone.google.com/_/+1/confirm?hl=en&url={$full_link}";
646
            $thread_action['social_gplus']['name']   = \_MD_SHARE_GOOGLEPLUS;
647
            $thread_action['social_gplus']['target'] = '_blank';
648
649
            $thread_action['social_linkedin']['image']  = newbb_displayImage('linkedin', \_MD_SHARE_LINKEDIN);
650
            $thread_action['social_linkedin']['link']   = "https://www.linkedin.com/shareArticle?mini=true&amp;title={$full_title}&amp;url={$full_link}";
651
            $thread_action['social_linkedin']['name']   = \_MD_SHARE_LINKEDIN;
652
            $thread_action['social_linkedin']['target'] = '_blank';
653
654
            $thread_action['social_delicious']['image']  = newbb_displayImage('delicious', \_MD_SHARE_DELICIOUS);
655
            $thread_action['social_delicious']['link']   = "https://del.icio.us/post?title={$full_title}&amp;url={$full_link}";
656
            $thread_action['social_delicious']['name']   = \_MD_SHARE_DELICIOUS;
657
            $thread_action['social_delicious']['target'] = '_blank';
658
659
            $thread_action['social_digg']['image']  = newbb_displayImage('digg', \_MD_SHARE_DIGG);
660
            $thread_action['social_digg']['link']   = "https://digg.com/submit?phase=2&amp;title={$full_title}&amp;url={$full_link}";
661
            $thread_action['social_digg']['name']   = \_MD_SHARE_DIGG;
662
            $thread_action['social_digg']['target'] = '_blank';
663
664
            $thread_action['social_reddit']['image']  = newbb_displayImage('reddit', \_MD_SHARE_REDDIT);
665
            $thread_action['social_reddit']['link']   = "https://reddit.com/submit?title={$full_title}&amp;url={$full_link}";
666
            $thread_action['social_reddit']['name']   = \_MD_SHARE_REDDIT;
667
            $thread_action['social_reddit']['target'] = '_blank';
668
669
            $thread_action['social_wong']['image']  = newbb_displayImage('wong', \_MD_SHARE_MRWONG);
670
            $thread_action['social_wong']['link']   = "https://www.mister-wong.de/index.php?action=addurl&bm_url=$full_link}";
671
            $thread_action['social_wong']['name']   = \_MD_SHARE_MRWONG;
672
            $thread_action['social_wong']['target'] = '_blank';
673
        }
674
675
        $post = [
676
            'post_id'         => $post_id,
677
            'post_parent_id'  => $this->getVar('pid'),
678
            'post_date'       => newbb_formatTimestamp($this->getVar('post_time')),
0 ignored issues
show
Bug introduced by
The function newbb_formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

678
            'post_date'       => /** @scrutinizer ignore-call */ newbb_formatTimestamp($this->getVar('post_time')),
Loading history...
679
            'post_image'      => $post_image,
680
            'post_title'      => $post_title,        // irmtfan $post_title to add highlight keywords
681
            'post_text'       => $post_text,
682
            'post_attachment' => $post_attachment,
683
            'post_edit'       => $this->displayPostEdit(),
684
            'post_no'         => $post_no,
685
            'post_signature'  => $this->getVar('attachsig') ? @$poster['signature'] : '',
686
            'poster_ip'       => ($isadmin
687
                                  && $GLOBALS['xoopsModuleConfig']['show_ip']) ? \long2ip($this->getVar('poster_ip')) : '',
688
            'thread_action'   => $thread_action,
689
            'thread_buttons'  => $thread_buttons,
690
            'mod_buttons'     => $mod_buttons,
691
            'poster'          => $poster,
692
            'post_permalink'  => "<a href='" . $GLOBALS['xoops']->url('/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/viewtopic.php?post_id={$post_id}") . "'></a>",
693
        ];
694
695
        unset($thread_buttons, $mod_buttons, $eachposter);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $eachposter does not exist. Did you maybe mean $poster?
Loading history...
696
697
        return $post;
698
    }
699
}
700