Passed
Pull Request — master (#70)
by Pierre-Henry
03:15
created

topicmanager.php (25 issues)

1
<?php
2
3
use Xmf\Request;
4
use XoopsModules\Newbb;
5
6
//
7
//  ------------------------------------------------------------------------ //
8
//                XOOPS - PHP Content Management System                      //
9
//                  Copyright (c) 2000-2016 XOOPS.org                        //
10
//                       <https://xoops.org/>                             //
11
//  ------------------------------------------------------------------------ //
12
//  This program is free software; you can redistribute it and/or modify     //
13
//  it under the terms of the GNU General Public License as published by     //
14
//  the Free Software Foundation; either version 2 of the License, or        //
15
//  (at your option) any later version.                                      //
16
//                                                                           //
17
//  You may not change or alter any portion of this comment or credits       //
18
//  of supporting developers from this source code or any supporting         //
19
//  source code which is considered copyrighted (c) material of the          //
20
//  original comment or credit authors.                                      //
21
//                                                                           //
22
//  This program is distributed in the hope that it will be useful,          //
23
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
24
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
25
//  GNU General Public License for more details.                             //
26
//                                                                           //
27
//  You should have received a copy of the GNU General Public License        //
28
//  along with this program; if not, write to the Free Software              //
29
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
30
//  ------------------------------------------------------------------------ //
31
//  Author: phppp (D.J., [email protected])                                  //
32
//  URL: https://xoops.org                                                    //
33
//  Project: Article Project                                                 //
34
//  ------------------------------------------------------------------------ //
35
require_once __DIR__ . '/header.php';
36
37
if (Request::getString('submit', '', 'POST')) {
38
    foreach (['forum', 'newforum', 'newtopic'] as $getint) {
39
        ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
    }
41
    foreach (['topic_id'] as $getint) {
42
        ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
    }
44
    if (!is_array($topic_id)) {
45
        $topic_id = [$topic_id];
46
    }
47
} else {
48
    foreach (['forum', 'topic_id'] as $getint) {
49
        ${$getint} = Request::getInt($getint, 0, 'GET');// (int)(@$_GET[$getint]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
50
    }
51
}
52
53
if (empty($topic_id)) {
54
    $redirect = empty($forum_id) ? 'index.php' : 'viewforum.php?forum={$forum}';
55
    $redirect = XOOPS_URL . '/modules/newbb/' . $redirect;
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
56
    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
0 ignored issues
show
The function redirect_header 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

56
    /** @scrutinizer ignore-call */ 
57
    redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
Loading history...
57
}
58
59
///** @var Newbb\TopicHandler $topicHandler */
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
60
//$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
61
///** @var Newbb\ForumHandler $forumHandler */
62
//$forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
63
64
if (!$forum) {
65
    /** @var Newbb\Topic $topicObject */
66
    $topicObject = $topicHandler->get((int)$topic_id);
67
    if (is_object($topicObject)) {
68
        $forum = $topicObject->getVar('forum_id');
69
    } else {
70
        $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id;
71
        redirect_header($redirect, 2, _MD_NEWBB_FORUMNOEXIST);
72
    }
73
    unset($topicObject);
74
}
75
76
if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) {
77
    //    /** @var Newbb\OnlineHandler $onlineHandler */
78
    //    $onlineHandler = Newbb\Helper::getInstance()->getHandler('Online');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
79
    $onlineHandler->init($forum);
80
}
81
// irmtfan add restore to viewtopic
82
$action_array = [
83
    'merge',
84
    'delete',
85
    'restore',
86
    'move',
87
    'lock',
88
    'unlock',
89
    'sticky',
90
    'unsticky',
91
    'digest',
92
    'undigest'
93
];
94
foreach ($action_array as $_action) {
95
    $action[$_action] = [
96
        'name'   => $_action,
97
        'desc'   => constant(strtoupper("_MD_NEWBB_DESC_{$_action}")),
98
        'submit' => constant(strtoupper("_MD_NEWBB_{$_action}")),
99
        'sql'    => "topic_{$_action}=1",
100
        'msg'    => constant(strtoupper("_MD_NEWBB_TOPIC{$_action}"))
101
    ];
102
}
103
$action['lock']['sql']     = 'topic_status = 1';
104
$action['unlock']['sql']   = 'topic_status = 0';
105
$action['unsticky']['sql'] = 'topic_sticky = 0';
106
$action['undigest']['sql'] = 'topic_digest = 0';
107
$action['digest']['sql']   = 'topic_digest = 1, digest_time = ' . time();
108
109
// Disable cache
110
$GLOBALS['xoopsConfig']['module_cache'][$xoopsModule->getVar('mid')] = 0;
111
// irmtfan include header.php after defining $xoopsOption['template_main']
112
require_once $GLOBALS['xoops']->path('header.php');
113
114
if (Request::getString('submit', '', 'POST')) {
115
    $mode = Request::getString('mode', '', 'POST');// $_POST['mode'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
116
117
    if ('delete' === $mode) {
118
        foreach ($topic_id as $tid) {
119
            $topicObject = $topicHandler->get($tid);
120
            $topicHandler->delete($topicObject, false);
121
            // irmtfan - sync topic after delete
122
            $topicHandler->synchronization($topicObject);
123
            $forumHandler->synchronization($forum);
124
            //$topicObject->loadFilters("delete");
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
125
            //sync($topic_id, "topic");
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
126
            //xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
127
        }
128
        // irmtfan full URL
129
        echo $action[$mode]['msg'] . "<p><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewforum.php?forum=$forum'>" . _MD_NEWBB_RETURNTOTHEFORUM . "</a></p><p><a href='index.php'>" . _MD_NEWBB_RETURNFORUMINDEX . '</a></p>';
130
    } elseif ('restore' === $mode) {
131
        //$topicHandler = Newbb\Helper::getInstance()->getHandler('Topic');
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
132
        $forums       = [];
133
        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
0 ignored issues
show
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
134
        foreach (array_keys($topicsObject) as $id) {
135
            $topicObject = $topicsObject[$id];
136
            $topicHandler->approve($topicObject);
137
            $topicHandler->synchronization($topicObject);
138
            $forums[$topicObject->getVar('forum_id')] = 1;
139
        }
140
        //irmtfan remove - no need to approve posts manually - see class/post.php approve function
141
        $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
142
        $forumsObject   = $forumHandler->getAll($criteria_forum);
143
        foreach (array_keys($forumsObject) as $id) {
144
            $forumHandler->synchronization($forumsObject[$id]);
145
        }
146
        unset($topicsObject, $forumsObject);
147
        // irmtfan add restore to viewtopic
148
        $restoretopic_id = $topicObject->getVar('topic_id');
149
        // irmtfan / missing in URL
150
        echo $action[$mode]['msg']
151
             . "<p><a href='"
152
             . XOOPS_URL
153
             . '/modules/'
154
             . $xoopsModule->getVar('dirname')
155
             . "/viewtopic.php?topic_id=$restoretopic_id'>"
156
             . _MD_NEWBB_VIEWTHETOPIC
157
             . '</a></p>'
158
             . "<p><a href='"
159
             . XOOPS_URL
160
             . '/modules/'
161
             . $xoopsModule->getVar('dirname')
162
             . "/viewforum.php?forum=$forum'>"
163
             . _MD_NEWBB_RETURNTOTHEFORUM
164
             . '</a></p>'
165
             . "<p><a href='index.php'>"
166
             . _MD_NEWBB_RETURNFORUMINDEX
167
             . '</a></p>';
168
    } elseif ('merge' === $mode) {
169
        //        /** @var PostHandler $postHandler */
170
        //        $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
171
        //        /** @var Newbb\RateHandler $rateHandler */
172
        //        $rateHandler = Newbb\Helper::getInstance()->getHandler('Rate');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
173
174
        foreach ($topic_id as $tid) {
175
            $topicObject    = $topicHandler->get($tid);
176
            $newtopicObject = $topicHandler->get($newtopic);
177
178
            /* return false if destination topic is not existing */
179
            // irmtfan bug fix: the old topic will be deleted if user input a not exist new topic
180
            if (!is_object($newtopicObject)) {
181
                $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $tid;
182
                redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC);
183
            }
184
            $criteria_topic = new \Criteria('topic_id', $tid);
185
            $criteria       = new \CriteriaCompo($criteria_topic);
0 ignored issues
show
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
186
            $criteria->add(new \Criteria('pid', 0));
187
            // irmtfan OR change to this for less query?:
188
            // $postHandler->updateAll("pid", $newtopicObject->getVar("topic_last_post_id"), $criteria, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
189
            $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true);
190
            $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true);
191
            // irmtfan update vote data instead of deleting them
192
            $rateHandler->updateAll('topic_id', $newtopic, $criteria_topic, true);
193
194
            $topic_views = $topicObject->getVar('topic_views') + $newtopicObject->getVar('topic_views');
195
            // irmtfan better method to update topic_views in new topic
196
            //$criteria_newtopic = new \Criteria('topic_id', $newtopic);
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
197
            //$topicHandler->updateAll('topic_views', $topic_views, $criteria_newtopic, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
198
            $newtopicObject->setVar('topic_views', $topic_views);
199
            // START irmtfan poll_module and rewrite the method
200
            // irmtfan only move poll in old topic to new topic if new topic has not a poll
201
            $poll_id = $topicObject->getVar('poll_id');
202
            if ($poll_id > 0 && (0 == $newtopicObject->getVar('poll_id'))) {
203
                $newtopicObject->setVar('topic_haspoll', 1);
204
                $newtopicObject->setVar('poll_id', $poll_id);
205
                $poll_id = 0;// set to not delete the poll
206
                $topicObject->setVar('topic_haspoll', 0); // set to not delete the poll
207
                $topicObject->setVar('poll_id', 0);// set to not delete the poll
208
            }
209
            //update and sync newtopic after merge
210
            //$topicHandler->insert($newtopicObject, true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
211
            $topicHandler->synchronization($newtopicObject); // very important: only use object
212
            //sync newforum after merge
213
            $newforum = $newtopicObject->getVar('forum_id');
214
            $forumHandler->synchronization($newforum);
215
            //hardcode remove force to delete old topic from database
216
            //$topicHandler->delete($topicObject,true); // cannot use this
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
217
            $topicHandler->deleteAll($criteria_topic, true); // $force = true
218
            //delete poll if old topic had a poll
219
            $topicObject->deletePoll($poll_id);
220
            //sync forum after delete old topic
221
            $forumHandler->synchronization($forum);
222
            // END irmtfan poll_module and rewrite the method
223
        }
224
        echo $action[$mode]['msg']
225
             . // irmtfan full URL
226
             "<p><a href='"
227
             . XOOPS_URL
228
             . '/modules/'
229
             . $xoopsModule->getVar('dirname')
230
             . "/viewtopic.php?topic_id=$newtopic'>"
231
             . _MD_NEWBB_VIEWTHETOPIC
232
             . '</a></p>'
233
             . "<p><a href='"
234
             . XOOPS_URL
235
             . '/modules/'
236
             . $xoopsModule->getVar('dirname')
237
             . "/viewforum.php?forum=$forum'>"
238
             . _MD_NEWBB_RETURNTOTHEFORUM
239
             . '</a></p>'
240
             . "<p><a href='"
241
             . XOOPS_URL
242
             . '/modules/'
243
             . $xoopsModule->getVar('dirname')
244
             . "/index.php'>"
245
             . _MD_NEWBB_RETURNFORUMINDEX
246
             . '</a></p>';
247
    } elseif ('move' === $mode) {
248
        if ($newforum > 0) {
249
            $topic_id    = $topic_id[0];
250
            $topicObject = $topicHandler->get($topic_id);
251
            $topicObject->loadFilters('update');
252
            $topicObject->setVar('forum_id', $newforum, true);
253
            $topicHandler->insert($topicObject, true);
254
            $topicObject->loadFilters('update');
255
256
            $sql = sprintf('UPDATE "%s" SET forum_id = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id);
257
            if (!$r = $GLOBALS['xoopsDB']->query($sql)) {
258
                return false;
259
            }
260
            $forumHandler->synchronization($forum);
261
            $forumHandler->synchronization($newforum);
262
            // irmtfan full URL
263
            echo $action[$mode]['msg']
264
                 . "<p><a href='"
265
                 . XOOPS_URL
266
                 . '/modules/'
267
                 . $xoopsModule->getVar('dirname')
268
                 . "/viewtopic.php?topic_id=$topic_id&amp;forum=$newforum'>"
269
                 . _MD_NEWBB_GOTONEWFORUM
270
                 . "</a></p><p><a href='"
271
                 . XOOPS_URL
272
                 . "/modules/newbb/index.php'>"
273
                 . _MD_NEWBB_RETURNFORUMINDEX
274
                 . '</a></p>';
275
        } else {
276
            // irmtfan - issue with javascript:history.go(-1)
277
            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERRORFORUM);
278
        }
279
    } else {
280
        $topic_id  = $topic_id[0];
281
        $forum     = $topicHandler->get($topic_id, 'forum_id');
282
        $forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0;
283
284
        if (!$forumHandler->getPermission($forum, 'moderate')
285
            || (!empty($forum_new)
286
                && !$forumHandler->getPermission($forum_new, 'reply'))        // The forum for the topic to be merged to
287
            || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to
288
        ) {
289
            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
290
        }
291
292
        if (!empty($action[$mode]['sql'])) {
293
            $sql = sprintf('UPDATE `%s` SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $topic_id);
294
            if (!$r = $GLOBALS['xoopsDB']->query($sql)) {
295
                redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id&amp;order=$order&amp;viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql: ' . $sql);
296
            }
297
        } else {
298
            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&amp;topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK);
299
        }
300
        if ('digest' === $mode && $GLOBALS['xoopsDB']->getAffectedRows()) {
301
            $topicObject = $topicHandler->get($topic_id);
302
            //            /** @var Newbb\StatsHandler $statsHandler */
303
            //            $statsHandler = Newbb\Helper::getInstance()->getHandler('Stats');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
304
            $statsHandler->update($topicObject->getVar('forum_id'), 'digest');
305
            //            /** @var Newbb\UserstatsHandler $userstatsHandler */
306
            //            $userstatsHandler = Newbb\Helper::getInstance()->getHandler('Userstats');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
307
            if ($user_stat = $userstatsHandler->get($topicObject->getVar('topic_poster'))) {
308
                $z = $user_stat->getVar('user_digests') + 1;
309
                $user_stat->setVar('user_digests', (int)$z);
310
                $userstatsHandler->insert($user_stat);
311
            }
312
        }
313
        // irmtfan full URL
314
        echo $action[$mode]['msg']
315
             . "<p><a href='"
316
             . XOOPS_URL
317
             . '/modules/'
318
             . $xoopsModule->getVar('dirname')
319
             . "/viewtopic.php?topic_id=$topic_id&amp;forum=$forum'>"
320
             . _MD_NEWBB_VIEWTHETOPIC
321
             . "</a></p><p><a href='"
322
             . XOOPS_URL
323
             . "/modules/newbb/viewforum.php?forum=$forum'>"
324
             . _MD_NEWBB_RETURNFORUMINDEX
325
             . '</a></p>';
326
    }
327
} else {  // No submit
328
    $mode = Request::getString('mode', '', 'GET'); //$_GET['mode'];
329
    echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>";
330
    echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>";
331
    echo "<tr><td class='bg2'>";
332
    echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>";
333
    echo "<tr class='bg3' align='left'>";
334
    echo "<td colspan='2' align='center'>" . $action[$mode]['desc'] . '</td></tr>';
335
336
    if ('move' === $mode) {
337
        echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">';
338
        $box = '<select name="newforum" size="1">';
339
340
        //        /** @var Newbb\CategoryHandler $categoryHandler */
341
        //        $categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
342
        $categories = $categoryHandler->getByPermission('access');
343
        $forums     = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false);
344
345
        if (count($categories) > 0 && count($forums) > 0) {
346
            foreach (array_keys($forums) as $key) {
347
                /** @var Newbb\Category[] $categories */
348
                $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>';
349
                foreach ($forums[$key] as $forumid => $_forum) {
350
                    $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>';
351
                    if (!isset($_forum['sub'])) {
352
                        continue;
353
                    }
354
                    foreach (array_keys($_forum['sub']) as $fid) {
355
                        $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>';
356
                    }
357
                }
358
            }
359
        } else {
360
            $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>';
361
        }
362
        unset($forums, $categories);
363
364
        echo $box;
365
        echo '</select></td></tr>';
366
    }
367
    if ('merge' === $mode) {
368
        echo '<tr><td class="bg3">' . _MD_NEWBB_MERGETOPICTO . '</td><td class="bg1">';
369
        echo _MD_NEWBB_TOPIC . "&nbsp;ID-$topic_id -> ID: <input name='newtopic' value='' />";
370
        echo '</td></tr>';
371
    }
372
    echo '<tr class="bg3"><td colspan="2" align="center">';
373
    echo "<input type='hidden' name='mode' value='" . $action[$mode]['name'] . "' />";
374
    echo "<input type='hidden' name='topic_id' value='" . $topic_id . "' />";
375
    echo "<input type='hidden' name='forum' value='" . $forum . "' />";
376
    echo "<input type='submit' name='submit' value='" . $action[$mode]['submit'] . "' />";
377
    echo '</td></tr></form></table></td></tr></table>';
378
}
379
// irmtfan move to footer.php
380
require_once __DIR__ . '/footer.php';
381
include $GLOBALS['xoops']->path('footer.php');
382