These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | use Xmf\Request; |
||
4 | |||
5 | // |
||
6 | // ------------------------------------------------------------------------ // |
||
7 | // XOOPS - PHP Content Management System // |
||
8 | // Copyright (c) 2000-2016 XOOPS.org // |
||
9 | // <https://xoops.org/> // |
||
10 | // ------------------------------------------------------------------------ // |
||
11 | // This program is free software; you can redistribute it and/or modify // |
||
12 | // it under the terms of the GNU General Public License as published by // |
||
13 | // the Free Software Foundation; either version 2 of the License, or // |
||
14 | // (at your option) any later version. // |
||
15 | // // |
||
16 | // You may not change or alter any portion of this comment or credits // |
||
17 | // of supporting developers from this source code or any supporting // |
||
18 | // source code which is considered copyrighted (c) material of the // |
||
19 | // original comment or credit authors. // |
||
20 | // // |
||
21 | // This program is distributed in the hope that it will be useful, // |
||
22 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
23 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
24 | // GNU General Public License for more details. // |
||
25 | // // |
||
26 | // You should have received a copy of the GNU General Public License // |
||
27 | // along with this program; if not, write to the Free Software // |
||
28 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
29 | // ------------------------------------------------------------------------ // |
||
30 | // Author: phppp (D.J., [email protected]) // |
||
31 | // URL: https://xoops.org // |
||
32 | // Project: Article Project // |
||
33 | // ------------------------------------------------------------------------ // |
||
34 | include_once __DIR__ . '/header.php'; |
||
35 | |||
36 | if (Request::getString('submit', '', 'POST')) { |
||
37 | foreach (['forum', 'newforum', 'newtopic'] as $getint) { |
||
38 | ${$getint} = Request::getInt($getint, 0, 'POST');// (int)(@$_POST[$getint]); |
||
0 ignored issues
–
show
|
|||
39 | } |
||
40 | foreach (['topic_id'] as $getint) { |
||
41 | ${$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. ![]() |
|||
42 | } |
||
43 | if (!is_array($topic_id)) { |
||
44 | $topic_id = [$topic_id]; |
||
45 | } |
||
46 | } else { |
||
47 | foreach (['forum', 'topic_id'] as $getint) { |
||
48 | ${$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. ![]() |
|||
49 | } |
||
50 | } |
||
51 | |||
52 | View Code Duplication | if (empty($topic_id)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
53 | $redirect = empty($forum_id) ? 'index.php' : 'viewforum.php?forum={$forum}'; |
||
54 | $redirect = XOOPS_URL . '/modules/newbb/' . $redirect; |
||
55 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
56 | } |
||
57 | |||
58 | /** @var \NewbbTopicHandler $topicHandler */ |
||
59 | $topicHandler = xoops_getModuleHandler('topic', 'newbb'); |
||
60 | /** @var \NewbbForumHandler $forumHandler */ |
||
61 | $forumHandler = xoops_getModuleHandler('forum', 'newbb'); |
||
62 | |||
63 | if (!$forum) { |
||
64 | /** @var \Topic $topicObject */ |
||
65 | $topicObject = $topicHandler->get((int)$topic_id); |
||
66 | if (is_object($topicObject)) { |
||
67 | $forum = $topicObject->getVar('forum_id'); |
||
68 | } else { |
||
69 | $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $topic_id; |
||
70 | redirect_header($redirect, 2, _MD_NEWBB_FORUMNOEXIST); |
||
71 | } |
||
72 | unset($topicObject); |
||
73 | } |
||
74 | |||
75 | if ($GLOBALS['xoopsModuleConfig']['wol_enabled']) { |
||
76 | /** @var \NewbbOnlineHandler $onlineHandler */ |
||
77 | $onlineHandler = xoops_getModuleHandler('online', 'newbb'); |
||
78 | $onlineHandler->init($forum); |
||
79 | } |
||
80 | // irmtfan add restore to viewtopic |
||
81 | $action_array = [ |
||
82 | 'merge', |
||
83 | 'delete', |
||
84 | 'restore', |
||
85 | 'move', |
||
86 | 'lock', |
||
87 | 'unlock', |
||
88 | 'sticky', |
||
89 | 'unsticky', |
||
90 | 'digest', |
||
91 | 'undigest' |
||
92 | ]; |
||
93 | foreach ($action_array as $_action) { |
||
94 | $action[$_action] = [ |
||
95 | 'name' => $_action, |
||
96 | 'desc' => constant(strtoupper("_MD_NEWBB_DESC_{$_action}")), |
||
97 | 'submit' => constant(strtoupper("_MD_NEWBB_{$_action}")), |
||
98 | 'sql' => "topic_{$_action}=1", |
||
99 | 'msg' => constant(strtoupper("_MD_NEWBB_TOPIC{$_action}")) |
||
100 | ]; |
||
101 | } |
||
102 | $action['lock']['sql'] = 'topic_status = 1'; |
||
103 | $action['unlock']['sql'] = 'topic_status = 0'; |
||
104 | $action['unsticky']['sql'] = 'topic_sticky = 0'; |
||
105 | $action['undigest']['sql'] = 'topic_digest = 0'; |
||
106 | $action['digest']['sql'] = 'topic_digest = 1, digest_time = ' . time(); |
||
107 | |||
108 | // Disable cache |
||
109 | $GLOBALS['xoopsConfig']['module_cache'][$xoopsModule->getVar('mid')] = 0; |
||
110 | // irmtfan include header.php after defining $xoopsOption['template_main'] |
||
111 | include_once $GLOBALS['xoops']->path('header.php'); |
||
112 | |||
113 | if (Request::getString('submit', '', 'POST')) { |
||
114 | $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. ![]() |
|||
115 | |||
116 | if ('delete' === $mode) { |
||
117 | foreach ($topic_id as $tid) { |
||
118 | $topicObject = $topicHandler->get($tid); |
||
119 | $topicHandler->delete($topicObject, false); |
||
120 | // irmtfan - sync topic after delete |
||
121 | $topicHandler->synchronization($topicObject); |
||
122 | $forumHandler->synchronization($forum); |
||
123 | //$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. ![]() |
|||
124 | //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. ![]() |
|||
125 | //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. ![]() |
|||
126 | } |
||
127 | // irmtfan full URL |
||
128 | 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>'; |
||
129 | } elseif ('restore' === $mode) { |
||
130 | //$topicHandler = xoops_getModuleHandler('topic', 'newbb'); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% 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. ![]() |
|||
131 | $forums = []; |
||
132 | $topicsObject = $topicHandler->getAll(new Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN')); |
||
133 | foreach (array_keys($topicsObject) as $id) { |
||
134 | $topicObject = $topicsObject[$id]; |
||
135 | $topicHandler->approve($topicObject); |
||
136 | $topicHandler->synchronization($topicObject); |
||
137 | $forums[$topicObject->getVar('forum_id')] = 1; |
||
138 | } |
||
139 | //irmtfan remove - no need to approve posts manually - see class/post.php approve function |
||
140 | $criteria_forum = new Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN'); |
||
141 | $forumsObject = $forumHandler->getAll($criteria_forum); |
||
142 | foreach (array_keys($forumsObject) as $id) { |
||
143 | $forumHandler->synchronization($forumsObject[$id]); |
||
144 | } |
||
145 | unset($topicsObject, $forumsObject); |
||
146 | // irmtfan add restore to viewtopic |
||
147 | $restoretopic_id = $topicObject->getVar('topic_id'); |
||
148 | // irmtfan / missing in URL |
||
149 | echo $action[$mode]['msg'] |
||
150 | . "<p><a href='" |
||
151 | . XOOPS_URL |
||
152 | . '/modules/' |
||
153 | . $xoopsModule->getVar('dirname') |
||
154 | . "/viewtopic.php?topic_id=$restoretopic_id'>" |
||
155 | . _MD_NEWBB_VIEWTHETOPIC |
||
156 | . '</a></p>' |
||
157 | . "<p><a href='" |
||
158 | . XOOPS_URL |
||
159 | . '/modules/' |
||
160 | . $xoopsModule->getVar('dirname') |
||
161 | . "/viewforum.php?forum=$forum'>" |
||
162 | . _MD_NEWBB_RETURNTOTHEFORUM |
||
163 | . '</a></p>' |
||
164 | . "<p><a href='index.php'>" |
||
165 | . _MD_NEWBB_RETURNFORUMINDEX |
||
166 | . '</a></p>'; |
||
167 | } elseif ('merge' === $mode) { |
||
168 | /** @var NewbbPostHandler $postHandler */ |
||
169 | $postHandler = xoops_getModuleHandler('post', 'newbb'); |
||
170 | /** @var \NewbbRateHandler $rateHandler */ |
||
171 | $rateHandler = xoops_getModuleHandler('rate', 'newbb'); |
||
172 | |||
173 | foreach ($topic_id as $tid) { |
||
174 | $topicObject = $topicHandler->get($tid); |
||
175 | $newtopicObject = $topicHandler->get($newtopic); |
||
176 | |||
177 | /* return false if destination topic is not existing */ |
||
178 | // irmtfan bug fix: the old topic will be deleted if user input a not exist new topic |
||
179 | if (!is_object($newtopicObject)) { |
||
180 | $redirect = XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $tid; |
||
181 | redirect_header($redirect, 2, _MD_NEWBB_ERRORTOPIC); |
||
182 | } |
||
183 | $criteria_topic = new Criteria('topic_id', $tid); |
||
184 | $criteria = new CriteriaCompo($criteria_topic); |
||
185 | $criteria->add(new Criteria('pid', 0)); |
||
186 | // irmtfan OR change to this for less query?: |
||
187 | // $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. ![]() |
|||
188 | $postHandler->updateAll('pid', $topicHandler->getTopPostId($newtopic), $criteria, true); |
||
189 | $postHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
||
190 | // irmtfan update vote data instead of deleting them |
||
191 | $rateHandler->updateAll('topic_id', $newtopic, $criteria_topic, true); |
||
192 | |||
193 | $topic_views = $topicObject->getVar('topic_views') + $newtopicObject->getVar('topic_views'); |
||
194 | // irmtfan better method to update topic_views in new topic |
||
195 | //$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. ![]() |
|||
196 | //$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. ![]() |
|||
197 | $newtopicObject->setVar('topic_views', $topic_views); |
||
198 | // START irmtfan poll_module and rewrite the method |
||
199 | // irmtfan only move poll in old topic to new topic if new topic has not a poll |
||
200 | $poll_id = $topicObject->getVar('poll_id'); |
||
201 | if ($poll_id > 0 && (0 == $newtopicObject->getVar('poll_id'))) { |
||
202 | $newtopicObject->setVar('topic_haspoll', 1); |
||
203 | $newtopicObject->setVar('poll_id', $poll_id); |
||
204 | $poll_id = 0;// set to not delete the poll |
||
205 | $topicObject->setVar('topic_haspoll', 0); // set to not delete the poll |
||
206 | $topicObject->setVar('poll_id', 0);// set to not delete the poll |
||
207 | } |
||
208 | //update and sync newtopic after merge |
||
209 | //$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. ![]() |
|||
210 | $topicHandler->synchronization($newtopicObject); // very important: only use object |
||
211 | //sync newforum after merge |
||
212 | $newforum = $newtopicObject->getVar('forum_id'); |
||
213 | $forumHandler->synchronization($newforum); |
||
214 | //hardcode remove force to delete old topic from database |
||
215 | //$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. ![]() |
|||
216 | $topicHandler->deleteAll($criteria_topic, true); // $force = true |
||
217 | //delete poll if old topic had a poll |
||
218 | $topicObject->deletePoll($poll_id); |
||
219 | //sync forum after delete old topic |
||
220 | $forumHandler->synchronization($forum); |
||
221 | // END irmtfan poll_module and rewrite the method |
||
222 | } |
||
223 | echo $action[$mode]['msg'] |
||
224 | . // irmtfan full URL |
||
225 | "<p><a href='" |
||
226 | . XOOPS_URL |
||
227 | . '/modules/' |
||
228 | . $xoopsModule->getVar('dirname') |
||
229 | . "/viewtopic.php?topic_id=$newtopic'>" |
||
230 | . _MD_NEWBB_VIEWTHETOPIC |
||
231 | . '</a></p>' |
||
232 | . "<p><a href='" |
||
233 | . XOOPS_URL |
||
234 | . '/modules/' |
||
235 | . $xoopsModule->getVar('dirname') |
||
236 | . "/viewforum.php?forum=$forum'>" |
||
237 | . _MD_NEWBB_RETURNTOTHEFORUM |
||
238 | . '</a></p>' |
||
239 | . "<p><a href='" |
||
240 | . XOOPS_URL |
||
241 | . '/modules/' |
||
242 | . $xoopsModule->getVar('dirname') |
||
243 | . "/index.php'>" |
||
244 | . _MD_NEWBB_RETURNFORUMINDEX |
||
245 | . '</a></p>'; |
||
246 | } elseif ('move' === $mode) { |
||
247 | if ($newforum > 0) { |
||
248 | $topic_id = $topic_id[0]; |
||
249 | $topicObject = $topicHandler->get($topic_id); |
||
250 | $topicObject->loadFilters('update'); |
||
251 | $topicObject->setVar('forum_id', $newforum, true); |
||
252 | $topicHandler->insert($topicObject, true); |
||
253 | $topicObject->loadFilters('update'); |
||
254 | |||
255 | $sql = sprintf('UPDATE "%s" SET forum_id = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_posts'), $newforum, $topic_id); |
||
256 | if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
||
257 | return false; |
||
258 | } |
||
259 | $forumHandler->synchronization($forum); |
||
260 | $forumHandler->synchronization($newforum); |
||
261 | // irmtfan full URL |
||
262 | echo $action[$mode]['msg'] . "<p><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewtopic.php?topic_id=$topic_id&forum=$newforum'>" . _MD_NEWBB_GOTONEWFORUM . "</a></p><p><a href='" . XOOPS_URL . "/modules/newbb/index.php'>" . _MD_NEWBB_RETURNFORUMINDEX . '</a></p>'; |
||
263 | } else { |
||
264 | // irmtfan - issue with javascript:history.go(-1) |
||
265 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERRORFORUM); |
||
266 | } |
||
267 | } else { |
||
268 | $topic_id = $topic_id[0]; |
||
269 | $forum = $topicHandler->get($topic_id, 'forum_id'); |
||
270 | $forum_new = !empty($newtopic) ? $topicHandler->get($newtopic, 'forum_id') : 0; |
||
271 | |||
272 | if (!$forumHandler->getPermission($forum, 'moderate') |
||
273 | || (!empty($forum_new) |
||
274 | && !$forumHandler->getPermission($forum_new, 'reply')) // The forum for the topic to be merged to |
||
275 | || (!empty($newforum) && !$forumHandler->getPermission($newforum, 'post')) // The forum to be moved to |
||
276 | ) { |
||
277 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _NOPERM); |
||
278 | } |
||
279 | |||
280 | if (!empty($action[$mode]['sql'])) { |
||
281 | $sql = sprintf('UPDATE %s SET ' . $action[$mode]['sql'] . ' WHERE topic_id = %u', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $topic_id); |
||
282 | if (!$r = $GLOBALS['xoopsDB']->query($sql)) { |
||
283 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id&order=$order&viewmode=$viewmode", 2, _MD_NEWBB_ERROR_BACK . '<br>sql:' . $sql); |
||
284 | } |
||
285 | } else { |
||
286 | redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?forum=$forum&topic_id=$topic_id", 2, _MD_NEWBB_ERROR_BACK); |
||
287 | } |
||
288 | if ('digest' === $mode && $GLOBALS['xoopsDB']->getAffectedRows()) { |
||
289 | $topicObject = $topicHandler->get($topic_id); |
||
290 | /** @var \NewbbStatsHandler $statsHandler */ |
||
291 | $statsHandler = xoops_getModuleHandler('stats', 'newbb'); |
||
292 | $statsHandler->update($topicObject->getVar('forum_id'), 'digest'); |
||
293 | $userstatsHandler = xoops_getModuleHandler('userstats', 'newbb'); |
||
294 | if ($user_stat = $userstatsHandler->get($topicObject->getVar('topic_poster'))) { |
||
295 | $z = $user_stat->getVar('user_digests') + 1; |
||
296 | $user_stat->setVar('user_digests', (int)$z); |
||
297 | $userstatsHandler->insert($user_stat); |
||
298 | } |
||
299 | } |
||
300 | // irmtfan full URL |
||
301 | echo $action[$mode]['msg'] |
||
302 | . "<p><a href='" |
||
303 | . XOOPS_URL |
||
304 | . '/modules/' |
||
305 | . $xoopsModule->getVar('dirname') |
||
306 | . "/viewtopic.php?topic_id=$topic_id&forum=$forum'>" |
||
307 | . _MD_NEWBB_VIEWTHETOPIC |
||
308 | . "</a></p><p><a href='" |
||
309 | . XOOPS_URL |
||
310 | . "/modules/newbb/viewforum.php?forum=$forum'>" |
||
311 | . _MD_NEWBB_RETURNFORUMINDEX |
||
312 | . '</a></p>'; |
||
313 | } |
||
314 | } else { // No submit |
||
315 | $mode = Request::getString('mode', '', 'GET'); //$_GET['mode']; |
||
316 | echo "<form action='" . Request::getString('PHP_SELF', '', 'SERVER') . "' method='post'>"; |
||
317 | echo "<table border='0' cellpadding='1' cellspacing='0' align='center' width='95%'>"; |
||
318 | echo "<tr><td class='bg2'>"; |
||
319 | echo "<table border='0' cellpadding='1' cellspacing='1' width='100%'>"; |
||
320 | echo "<tr class='bg3' align='left'>"; |
||
321 | echo "<td colspan='2' align='center'>" . $action[$mode]['desc'] . '</td></tr>'; |
||
322 | |||
323 | if ('move' === $mode) { |
||
324 | echo '<tr><td class="bg3">' . _MD_NEWBB_MOVETOPICTO . '</td><td class="bg1">'; |
||
325 | $box = '<select name="newforum" size="1">'; |
||
326 | |||
327 | /** @var \NewbbCategoryHandler $categoryHandler */ |
||
328 | $categoryHandler = xoops_getModuleHandler('category', 'newbb'); |
||
329 | $categories = $categoryHandler->getByPermission('access'); |
||
330 | $forums = $forumHandler->getForumsByCategory(array_keys($categories), 'post', false); |
||
331 | |||
332 | View Code Duplication | if (count($categories) > 0 && count($forums) > 0) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
333 | foreach (array_keys($forums) as $key) { |
||
334 | /** @var \NewbbCategory[] $categories */ |
||
335 | $box .= "<option value='-1'>[" . $categories[$key]->getVar('cat_title') . ']</option>'; |
||
336 | foreach ($forums[$key] as $forumid => $_forum) { |
||
337 | $box .= "<option value='" . $forumid . "'>-- " . $_forum['title'] . '</option>'; |
||
338 | if (!isset($_forum['sub'])) { |
||
339 | continue; |
||
340 | } |
||
341 | foreach (array_keys($_forum['sub']) as $fid) { |
||
342 | $box .= "<option value='" . $fid . "'>---- " . $_forum['sub'][$fid]['title'] . '</option>'; |
||
343 | } |
||
344 | } |
||
345 | } |
||
346 | } else { |
||
347 | $box .= "<option value='-1'>" . _MD_NEWBB_NOFORUMINDB . '</option>'; |
||
348 | } |
||
349 | unset($forums, $categories); |
||
350 | |||
351 | echo $box; |
||
352 | echo '</select></td></tr>'; |
||
353 | } |
||
354 | if ('merge' === $mode) { |
||
355 | echo '<tr><td class="bg3">' . _MD_NEWBB_MERGETOPICTO . '</td><td class="bg1">'; |
||
356 | echo _MD_NEWBB_TOPIC . " ID-$topic_id -> ID: <input name='newtopic' value='' />"; |
||
357 | echo '</td></tr>'; |
||
358 | } |
||
359 | echo '<tr class="bg3"><td colspan="2" align="center">'; |
||
360 | echo "<input type='hidden' name='mode' value='" . $action[$mode]['name'] . "' />"; |
||
361 | echo "<input type='hidden' name='topic_id' value='" . $topic_id . "' />"; |
||
362 | echo "<input type='hidden' name='forum' value='" . $forum . "' />"; |
||
363 | echo "<input type='submit' name='submit' value='" . $action[$mode]['submit'] . "' />"; |
||
364 | echo '</td></tr></form></table></td></tr></table>'; |
||
365 | } |
||
366 | // irmtfan move to footer.php |
||
367 | include_once __DIR__ . '/footer.php'; |
||
368 | include $GLOBALS['xoops']->path('footer.php'); |
||
369 |
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.