Passed
Push — master ( 4990f6...882d2a )
by Michael
03:01
created
class/ForumHandler.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
             return $_cachedForums;
101 101
         }
102 102
 
103
-        $criteria = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $valid_ids) . ')', 'IN'));
103
+        $criteria = new \CriteriaCompo(new \Criteria('forum_id', '('.implode(', ', $valid_ids).')', 'IN'));
104 104
         if (is_numeric($cat) && $cat > 0) {
105 105
             $criteria->add(new \Criteria('cat_id', (int)$cat));
106 106
         } elseif (is_array($cat) && count($cat) > 0) {
107
-            $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat) . ')', 'IN'));
107
+            $criteria->add(new \Criteria('cat_id', '('.implode(', ', $cat).')', 'IN'));
108 108
         }
109 109
         $criteria->setSort('forum_order');
110 110
         $criteria->setOrder('ASC');
@@ -181,23 +181,23 @@  discard block
 block discarded – undo
181 181
         $topic_lastread = newbbGetCookie('LT', true);
182 182
         $criteria_forum = '';
183 183
         if (is_object($forum)) {
184
-            $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id');
184
+            $criteria_forum = ' AND t.forum_id = '.$forum->getVar('forum_id');
185 185
             $hot_threshold  = $forum->getVar('hot_threshold');
186 186
         } else {
187 187
             $hot_threshold = 10;
188 188
             if (is_array($forum) && count($forum) > 0) {
189
-                $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')';
189
+                $criteria_forum = ' AND t.forum_id IN ('.implode(',', array_keys($forum)).')';
190 190
             } elseif (!empty($forum)) {
191
-                $criteria_forum = ' AND t.forum_id =' . (int)$forum;
191
+                $criteria_forum = ' AND t.forum_id ='.(int)$forum;
192 192
             }
193 193
         }
194 194
 
195
-        $criteria_post    = $startdate ? ' p.post_time > ' . $startdate : ' 1 = 1 ';
195
+        $criteria_post    = $startdate ? ' p.post_time > '.$startdate : ' 1 = 1 ';
196 196
         $criteria_topic   = empty($type) ? '' : " AND t.type_id={$type}";
197 197
         $criteria_extra   = '';
198 198
         $criteria_approve = ' AND t.approved = 1';
199 199
         $post_on          = ' p.post_id = t.topic_last_post_id';
200
-        $leftjoin         = ' LEFT JOIN ' . $this->db->prefix('newbb_posts') . ' p ON p.post_id = t.topic_last_post_id';
200
+        $leftjoin         = ' LEFT JOIN '.$this->db->prefix('newbb_posts').' p ON p.post_id = t.topic_last_post_id';
201 201
         $sort_array       = [];
202 202
         switch ($status) {
203 203
             case 'digest':
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                     // START irmtfan use read_uid to find the unread posts when the user is logged in
215 215
                     $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
216 216
                     if (!empty($read_uid)) {
217
-                        $leftjoin      .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' ';
217
+                        $leftjoin      .= ' LEFT JOIN '.$this->db->prefix('newbb_reads_topic').' r ON r.read_item = t.topic_id AND r.uid = '.$read_uid.' ';
218 218
                         $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
219 219
                     } else {
220 220
                     }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                 } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
223 223
                     // START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
224 224
                     if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
225
-                        $criteria_post  = ' p.post_time > ' . $time_criterion; // for all users
225
+                        $criteria_post  = ' p.post_time > '.$time_criterion; // for all users
226 226
                         $topics         = [];
227 227
                         $topic_lastread = newbbGetCookie('LT', true);
228 228
                         if (count($topic_lastread) > 0) {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                             }
234 234
                         }
235 235
                         if (count($topics) > 0) {
236
-                            $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
236
+                            $criteria_extra = ' AND t.topic_id NOT IN ('.implode(',', $topics).')';
237 237
                         }
238 238
                     }
239 239
                     // END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 break;
242 242
             case 'pending':
243 243
                 $post_on          = ' p.topic_id = t.topic_id';
244
-                $criteria_post    .= ' AND p.pid = 0';
244
+                $criteria_post .= ' AND p.pid = 0';
245 245
                 $criteria_approve = ' AND t.approved = 0';
246 246
                 break;
247 247
 
@@ -255,31 +255,31 @@  discard block
 block discarded – undo
255 255
 
256 256
             default:
257 257
                 if ($startdate > 0) {
258
-                    $criteria_post = ' (p.post_time > ' . $startdate . ' OR t.topic_sticky=1)';
258
+                    $criteria_post = ' (p.post_time > '.$startdate.' OR t.topic_sticky=1)';
259 259
                 }
260 260
                 $sort_array[] = 't.topic_sticky DESC';
261 261
                 break;
262 262
         }
263 263
 
264
-        $select = 't.*, ' . ' p.post_time as last_post_time, p.poster_name as last_poster_name, p.icon, p.post_id, p.uid';
265
-        $from   = $this->db->prefix('newbb_topics') . ' t ' . $leftjoin;
266
-        $where  = $criteria_post . $criteria_topic . $criteria_forum . $criteria_extra . $criteria_approve;
264
+        $select = 't.*, '.' p.post_time as last_post_time, p.poster_name as last_poster_name, p.icon, p.post_id, p.uid';
265
+        $from   = $this->db->prefix('newbb_topics').' t '.$leftjoin;
266
+        $where  = $criteria_post.$criteria_topic.$criteria_forum.$criteria_extra.$criteria_approve;
267 267
 
268 268
         if ($excerpt) {
269 269
             $select .= ', p.post_karma, p.require_reply, pt.post_text';
270
-            $from   .= ' LEFT JOIN ' . $this->db->prefix('newbb_posts_text') . ' pt ON pt.post_id = t.topic_last_post_id';
270
+            $from   .= ' LEFT JOIN '.$this->db->prefix('newbb_posts_text').' pt ON pt.post_id = t.topic_last_post_id';
271 271
         }
272 272
         if ('u.uname' === $sort) {
273 273
             $sort = 't.topic_poster';
274 274
         }
275 275
 
276
-        $sort_array[] = trim($sort . ' ' . $order);
276
+        $sort_array[] = trim($sort.' '.$order);
277 277
         $sortby       = implode(', ', array_filter($sort_array));
278 278
         if (empty($sortby)) {
279 279
             $sortby = 't.topic_last_post_id DESC';
280 280
         }
281 281
 
282
-        $sql = 'SELECT ' . $select . ' FROM ' . $from . ' WHERE ' . $where . ' ORDER BY ' . $sortby;
282
+        $sql = 'SELECT '.$select.' FROM '.$from.' WHERE '.$where.' ORDER BY '.$sortby;
283 283
 
284 284
         if (!$result = $this->db->query($sql, $GLOBALS['xoopsModuleConfig']['topics_per_page'], $start)) {
285 285
             redirect_header('index.php', 2, _MD_NEWBB_ERROROCCURED);
@@ -304,16 +304,16 @@  discard block
 block discarded – undo
304 304
 
305 305
             if ($myrow['topic_haspoll']) {
306 306
                 if ($myrow['topic_sticky']) {
307
-                    $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY) . '<br>' . newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL);
307
+                    $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY).'<br>'.newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL);
308 308
                 } else {
309 309
                     $topic_icon = newbbDisplayImage('poll', _MD_NEWBB_TOPICHASPOLL);
310 310
                 }
311 311
             } elseif ($myrow['topic_sticky']) {
312 312
                 $topic_icon = newbbDisplayImage('topic_sticky', _MD_NEWBB_TOPICSTICKY);
313 313
             } elseif (!empty($myrow['icon'])) {
314
-                $topic_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($myrow['icon']) . '" alt="" />';
314
+                $topic_icon = '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($myrow['icon']).'" alt="" />';
315 315
             } else {
316
-                $topic_icon = '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />';
316
+                $topic_icon = '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
317 317
             }
318 318
 
319 319
             // ------------------------------------------------------
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
             if ($rating < 1) {
324 324
                 $rating_img = newbbDisplayImage('blank');
325 325
             } else {
326
-                $rating_img = newbbDisplayImage('rate' . $rating, constant('_MD_NEWBB_RATE' . $rating));
326
+                $rating_img = newbbDisplayImage('rate'.$rating, constant('_MD_NEWBB_RATE'.$rating));
327 327
             }
328 328
             // ------------------------------------------------------
329 329
             // topic_page_jump
@@ -332,28 +332,28 @@  discard block
 block discarded – undo
332 332
             $totalpages           = ceil(($myrow['topic_replies'] + 1) / $GLOBALS['xoopsModuleConfig']['posts_per_page']);
333 333
             if ($totalpages > 1) {
334 334
                 $topic_page_jump .= '&nbsp;&nbsp;';
335
-                $append          = false;
335
+                $append = false;
336 336
                 for ($i = 1; $i <= $totalpages; ++$i) {
337 337
                     if ($i > 3 && $i < $totalpages) {
338 338
                         if (!$append) {
339 339
                             $topic_page_jump .= '...';
340
-                            $append          = true;
340
+                            $append = true;
341 341
                         }
342 342
                     } else {
343
-                        $topic_page_jump .= '[<a href="' . XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;start=' . (($i - 1) * $GLOBALS['xoopsModuleConfig']['posts_per_page']) . '">' . $i . '</a>]';
343
+                        $topic_page_jump .= '[<a href="'.XOOPS_URL.'/modules/newbb/viewtopic.php?topic_id='.$myrow['topic_id'].'&amp;start='.(($i - 1) * $GLOBALS['xoopsModuleConfig']['posts_per_page']).'">'.$i.'</a>]';
344 344
                         // irmtfan remove here and move
345 345
                         //$topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/newbb/viewtopic.php?post_id=" . $myrow['post_id'] . "&amp;start=" . (($i - 1) * $GLOBALS['xoopsModuleConfig']['posts_per_page']) . "'>" . newbbDisplayImage('lastposticon',_MD_NEWBB_GOTOLASTPOST) . '</a>';
346 346
                     }
347 347
                 }
348 348
             }
349 349
             // irmtfan - move here for both topics with and without pages
350
-            $topic_page_jump_icon = "<a href='" . XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $myrow['post_id'] . "'>" . newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST) . '</a>';
350
+            $topic_page_jump_icon = "<a href='".XOOPS_URL.'/modules/newbb/viewtopic.php?post_id='.$myrow['post_id']."'>".newbbDisplayImage('lastposticon', _MD_NEWBB_GOTOLASTPOST).'</a>';
351 351
 
352 352
             // ------------------------------------------------------
353 353
             // => topic array
354 354
             $forum_link = '';
355 355
             if (!empty($viewAllForums[$myrow['forum_id']])) {
356
-                $forum_link = '<a href="' . XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $myrow['forum_id'] . '">' . $viewAllForums[$myrow['forum_id']]['forum_name'] . '</a>';
356
+                $forum_link = '<a href="'.XOOPS_URL.'/modules/newbb/viewforum.php?forum='.$myrow['forum_id'].'">'.$viewAllForums[$myrow['forum_id']]['forum_name'].'</a>';
357 357
             }
358 358
 
359 359
             $topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
             //$topic_title = '<span style="color:'.$typen[$myrow["type_id"]]["type_color"].'">['.$typen[$myrow["type_id"]]["type_name"].']</span> '.$topic_title.'';
363 363
             //}
364 364
             if ($myrow['topic_digest']) {
365
-                $topic_title = "<span class='digest'>" . $topic_title . '</span>';
365
+                $topic_title = "<span class='digest'>".$topic_title.'</span>';
366 366
             }
367 367
 
368 368
             if (0 == $excerpt) {
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
                 //'type_text'                 => $topic_prefix,/*irmtfan remove here and move to for loop*/
382 382
                 'topic_title'          => $topic_title,
383 383
                 //'topic_link'                => XOOPS_URL . '/modules/newbb/viewtopic.php?topic_id=' . $myrow['topic_id'],
384
-                'topic_link'           => 'viewtopic.php?topic_id=' . $myrow['topic_id'],
384
+                'topic_link'           => 'viewtopic.php?topic_id='.$myrow['topic_id'],
385 385
                 'rating_img'           => $rating_img,
386 386
                 'topic_page_jump'      => $topic_page_jump,
387 387
                 'topic_page_jump_icon' => $topic_page_jump_icon,
@@ -456,10 +456,10 @@  discard block
 block discarded – undo
456 456
         } // irmtfan end for loop
457 457
         // END irmtfan move to a for loop
458 458
         if (count($topics) > 0) {
459
-            $sql = ' SELECT DISTINCT topic_id FROM ' . $this->db->prefix('newbb_posts') . " WHERE attachment != ''" . ' AND topic_id IN (' . implode(',', array_keys($topics)) . ')';
459
+            $sql = ' SELECT DISTINCT topic_id FROM '.$this->db->prefix('newbb_posts')." WHERE attachment != ''".' AND topic_id IN ('.implode(',', array_keys($topics)).')';
460 460
             if ($result = $this->db->query($sql)) {
461 461
                 while (false !== (list($topic_id) = $this->db->fetchRow($result))) {
462
-                    $topics[$topic_id]['attachment'] = '&nbsp;' . newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT);
462
+                    $topics[$topic_id]['attachment'] = '&nbsp;'.newbbDisplayImage('attachment', _MD_NEWBB_TOPICSHASATT);
463 463
                 }
464 464
             }
465 465
         }
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 
480 480
         $criteria_extra   = '';
481 481
         $criteria_approve = ' AND t.approved = 1'; // any others?
482
-        $leftjoin         = ' LEFT JOIN ' . $this->db->prefix('newbb_posts') . ' p ON p.post_id = t.topic_last_post_id';
483
-        $criteria_post    = ' p.post_time > ' . $startdate;
482
+        $leftjoin         = ' LEFT JOIN '.$this->db->prefix('newbb_posts').' p ON p.post_id = t.topic_last_post_id';
483
+        $criteria_post    = ' p.post_time > '.$startdate;
484 484
         switch ($type) {
485 485
             case 'digest':
486 486
                 $criteria_extra = ' AND topic_digest = 1';
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
                     $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
497 497
                     if (!empty($read_uid)) {
498
-                        $leftjoin      .= ' LEFT JOIN ' . $this->db->prefix('newbb_reads_topic') . ' r ON r.read_item = t.topic_id AND r.uid = ' . $read_uid . ' ';
498
+                        $leftjoin      .= ' LEFT JOIN '.$this->db->prefix('newbb_reads_topic').' r ON r.read_item = t.topic_id AND r.uid = '.$read_uid.' ';
499 499
                         $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
500 500
                     } else {
501 501
                     }
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                 } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
504 504
                     // START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
505 505
                     if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
506
-                        $criteria_post  = ' p.post_time > ' . $time_criterion; // for all users
506
+                        $criteria_post  = ' p.post_time > '.$time_criterion; // for all users
507 507
                         $topics         = [];
508 508
                         $topic_lastread = newbbGetCookie('LT', true);
509 509
                         if (count($topic_lastread) > 0) {
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
                             }
515 515
                         }
516 516
                         if (count($topics) > 0) {
517
-                            $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
517
+                            $criteria_extra = ' AND t.topic_id NOT IN ('.implode(',', $topics).')';
518 518
                         }
519 519
                     }
520 520
                     // END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
@@ -529,22 +529,22 @@  discard block
 block discarded – undo
529 529
             case 'all':
530 530
                 break;
531 531
             default:
532
-                $criteria_post = ' (p.post_time > ' . $startdate . ' OR t.topic_sticky=1)';
532
+                $criteria_post = ' (p.post_time > '.$startdate.' OR t.topic_sticky=1)';
533 533
                 break;
534 534
         }
535 535
         $criteria_forum = '';
536 536
         if (is_object($forum)) {
537
-            $criteria_forum = ' AND t.forum_id = ' . $forum->getVar('forum_id');
537
+            $criteria_forum = ' AND t.forum_id = '.$forum->getVar('forum_id');
538 538
         } else {
539 539
             if (is_array($forum) && count($forum) > 0) {
540
-                $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($forum)) . ')';
540
+                $criteria_forum = ' AND t.forum_id IN ('.implode(',', array_keys($forum)).')';
541 541
             } elseif (!empty($forum)) {
542
-                $criteria_forum = ' AND t.forum_id =' . (int)$forum;
542
+                $criteria_forum = ' AND t.forum_id ='.(int)$forum;
543 543
             }
544 544
         }
545 545
 
546
-        $sql = 'SELECT COUNT(*) AS count FROM ' . $this->db->prefix('newbb_topics') . ' t ' . $leftjoin;
547
-        $sql .= ' WHERE ' . $criteria_post . $criteria_forum . $criteria_extra . $criteria_approve;
546
+        $sql = 'SELECT COUNT(*) AS count FROM '.$this->db->prefix('newbb_topics').' t '.$leftjoin;
547
+        $sql .= ' WHERE '.$criteria_post.$criteria_forum.$criteria_extra.$criteria_approve;
548 548
         if (!$result = $this->db->query($sql)) {
549 549
             //xoops_error($this->db->error().'<br>'.$sql);
550 550
             return null;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
             return true;
573 573
         }
574 574
 
575
-        require_once __DIR__ . '/../include/functions.user.php';
575
+        require_once __DIR__.'/../include/functions.user.php';
576 576
         if (newbbIsAdmin($forum)) {
577 577
             return true;
578 578
         }
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
                     "        OR parent_forum = forum_id";
674 674
         */
675 675
         $criteria = new \CriteriaCompo();
676
-        $criteria->add(new \Criteria('parent_forum', '(' . implode(', ', $forum_ids) . ')', 'NOT IN'), 'AND');
676
+        $criteria->add(new \Criteria('parent_forum', '('.implode(', ', $forum_ids).')', 'NOT IN'), 'AND');
677 677
         $criteria->add(new \Criteria('parent_forum', '`forum_id`', '='), 'OR');
678 678
         $b1 = $this->updateAll('parent_forum', 0, $criteria, true);
679 679
         // check cat_id orphan forums
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
             return false;
684 684
         }
685 685
         $criteria = new \CriteriaCompo();
686
-        $criteria->add(new \Criteria('cat_id', '(' . implode(', ', $cat_ids) . ')', 'NOT IN'), 'AND');
686
+        $criteria->add(new \Criteria('cat_id', '('.implode(', ', $cat_ids).')', 'NOT IN'), 'AND');
687 687
         $b2 = $this->updateAll('cat_id', $cat_ids[0], $criteria, true);
688 688
 
689 689
         return ($b1 && $b2);
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         if (!$object->getVar('forum_id')) {
718 718
             return false;
719 719
         }
720
-        $sql = 'SELECT MAX(post_id) AS last_post, COUNT(*) AS total FROM ' . $this->db->prefix('newbb_posts') . ' AS p LEFT JOIN  ' . $this->db->prefix('newbb_topics') . ' AS t ON p.topic_id=t.topic_id WHERE p.approved=1 AND t.approved=1 AND p.forum_id = ' . $object->getVar('forum_id');
720
+        $sql = 'SELECT MAX(post_id) AS last_post, COUNT(*) AS total FROM '.$this->db->prefix('newbb_posts').' AS p LEFT JOIN  '.$this->db->prefix('newbb_topics').' AS t ON p.topic_id=t.topic_id WHERE p.approved=1 AND t.approved=1 AND p.forum_id = '.$object->getVar('forum_id');
721 721
 
722 722
         if ($result = $this->db->query($sql)) {
723 723
             $last_post = 0;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
             }
735 735
         }
736 736
 
737
-        $sql = 'SELECT COUNT(*) AS total FROM ' . $this->db->prefix('newbb_topics') . ' WHERE approved=1 AND forum_id = ' . $object->getVar('forum_id');
737
+        $sql = 'SELECT COUNT(*) AS total FROM '.$this->db->prefix('newbb_topics').' WHERE approved=1 AND forum_id = '.$object->getVar('forum_id');
738 738
         if ($result = $this->db->query($sql)) {
739 739
             if ($row = $this->db->fetchArray($result)) {
740 740
                 if ($object->getVar('forum_topics') !== $row['total']) {
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
         if (!$forums_id) {
777 777
             return $stats;
778 778
         }
779
-        $sql = '    SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id' . '    FROM ' . $this->table . '    WHERE forum_id IN (' . implode(', ', $forums_id) . ')';
779
+        $sql = '    SELECT forum_posts AS posts, forum_topics AS topics, forum_id AS id'.'    FROM '.$this->table.'    WHERE forum_id IN ('.implode(', ', $forums_id).')';
780 780
         if (!$result = $this->db->query($sql)) {
781 781
             return $stats;
782 782
         }
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
             if (!empty($length_title_index)) {
822 822
                 $tags_post[] = 'subject';
823 823
             }
824
-            $posts = $postHandler->getAll(new \Criteria('post_id', '(' . implode(', ', $posts) . ')', 'IN'), $tags_post, false);
824
+            $posts = $postHandler->getAll(new \Criteria('post_id', '('.implode(', ', $posts).')', 'IN'), $tags_post, false);
825 825
         }
826 826
 
827 827
         // Get topic/post stats per forum
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
         $topics = [];
837 837
 
838 838
         foreach (array_keys($forums) as $id) {
839
-            $forum =& $forums[$id];
839
+            $forum = & $forums[$id];
840 840
 
841 841
             if (!$forum['forum_last_post_id']) {
842 842
                 continue;
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
         $name_anonymous = $myts->htmlSpecialChars($GLOBALS['xoopsConfig']['anonymous']);
869 869
 
870 870
         foreach (array_keys($forums) as $id) {
871
-            $forum =& $forums[$id];
871
+            $forum = & $forums[$id];
872 872
 
873 873
             $_forum_data                 = [];
874 874
             $_forum_data['forum_order']  = $forum['forum_order'];
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 
892 892
             // irmtfan change if/endif to if{} method
893 893
             if ($post_id = $forum['forum_last_post_id']) {
894
-                $post                               =& $posts[$post_id];
894
+                $post                               = & $posts[$post_id];
895 895
                 $_forum_data['forum_lastpost_id']   = $post_id;
896 896
                 $_forum_data['forum_lastpost_time'] = newbbFormatTimestamp($post['post_time']);
897 897
                 if (!empty($users_linked[$post['uid']])) {
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
         }
948 948
         $forumsObject = $this->getByPermission($cat_id, $perm_string, $tags);
949 949
 
950
-        require_once __DIR__ . '/tree.php';
950
+        require_once __DIR__.'/tree.php';
951 951
         $forums_structured = [];
952 952
         foreach (array_keys($forumsObject) as $key) {
953 953
             $forums_structured[$forumsObject[$key]->getVar('cat_id')][$key] = $forumsObject[$key];
@@ -983,10 +983,10 @@  discard block
 block discarded – undo
983 983
         }
984 984
         $forumsObject = $this->getByPermission($cat_id, $perm_string, $tags);
985 985
 
986
-        require_once __DIR__ . '/tree.php';
986
+        require_once __DIR__.'/tree.php';
987 987
         $forums_structured = [];
988 988
         foreach (array_keys($forumsObject) as $key) {
989
-            $forumObject                                             =& $forumsObject[$key];
989
+            $forumObject                                             = & $forumsObject[$key];
990 990
             $forums_structured[$forumObject->getVar('cat_id')][$key] = $forumsObject[$key];
991 991
         }
992 992
         foreach (array_keys($forums_structured) as $cid) {
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
         if (!$parents = newbbGetParentForum($object->getVar('forum_id'))) {
1014 1014
             return $ret;
1015 1015
         }
1016
-        $parents_list = $this->getList(new \Criteria('forum_id', '(' . implode(', ', $parents) . ')', 'IN'));
1016
+        $parents_list = $this->getList(new \Criteria('forum_id', '('.implode(', ', $parents).')', 'IN'));
1017 1017
         foreach ($parents as $key => $id) {
1018 1018
             $ret[] = ['forum_id' => $id, 'forum_name' => $parents_list[$id]];
1019 1019
         }
Please login to merge, or discard this patch.
class/Topic.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     // irmtfan add LAST_INSERT_ID to enhance the mysql performances
54 54
     public function incrementCounter()
55 55
     {
56
-        $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . ' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id =' . $this->getVar('topic_id');
56
+        $sql = 'UPDATE '.$GLOBALS['xoopsDB']->prefix('newbb_topics').' SET topic_views = LAST_INSERT_ID(topic_views + 1) WHERE topic_id ='.$this->getVar('topic_id');
57 57
         $GLOBALS['xoopsDB']->queryF($sql);
58 58
     }
59 59
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
             return $topic_title;
75 75
         }
76 76
 
77
-        require_once __DIR__ . '/../include/functions.topic.php';
77
+        require_once __DIR__.'/../include/functions.topic.php';
78 78
 
79 79
         return getTopicTitle($topic_title, $typeObject->getVar('type_name'), $typeObject->getVar('type_color'));
80 80
     }
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
             /** @var \XoopsPoll $poll */
155 155
             $poll = new $classPoll($poll_id);
156 156
             if (false !== $poll->delete()) {
157
-                $classOption = $classPoll . 'Option';
157
+                $classOption = $classPoll.'Option';
158 158
                 $classOption::deleteByPollId($poll->getVar('poll_id'));
159
-                $classLog = $classPoll . 'Log';
159
+                $classLog = $classPoll.'Log';
160 160
                 $classLog::deleteByPollId($poll->getVar('poll_id'));
161 161
                 xoops_comment_delete($GLOBALS['xoopsModule']->getVar('mid'), $poll->getVar('poll_id'));
162 162
             }
Please login to merge, or discard this patch.
class/OnlineHandler.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -252,18 +252,18 @@
 block discarded – undo
252 252
         $xoopsOnlineTable    = $xoops_onlineHandler->table;
253 253
 
254 254
         $sql = 'DELETE FROM '
255
-               . $this->db->prefix('newbb_online')
256
-               . ' WHERE'
257
-               . ' ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM '
258
-               . $xoopsOnlineTable
259
-               . ' WHERE online_module ='
260
-               . $xoopsModule->getVar('mid')
261
-               . ' ) )'
262
-               . ' OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM '
263
-               . $xoopsOnlineTable
264
-               . ' WHERE online_module ='
265
-               . $xoopsModule->getVar('mid')
266
-               . ' AND online_uid = 0 ) )';
255
+                . $this->db->prefix('newbb_online')
256
+                . ' WHERE'
257
+                . ' ( online_uid > 0 AND online_uid NOT IN ( SELECT online_uid FROM '
258
+                . $xoopsOnlineTable
259
+                . ' WHERE online_module ='
260
+                . $xoopsModule->getVar('mid')
261
+                . ' ) )'
262
+                . ' OR ( online_uid = 0 AND online_ip NOT IN ( SELECT online_ip FROM '
263
+                . $xoopsOnlineTable
264
+                . ' WHERE online_module ='
265
+                . $xoopsModule->getVar('mid')
266
+                . ' AND online_uid = 0 ) )';
267 267
 
268 268
         if ($result = $this->db->queryF($sql)) {
269 269
             return true;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 // defined('XOOPS_ROOT_PATH') || die('Restricted access');
17 17
 
18
-require_once __DIR__ . '/../include/functions.config.php';
18
+require_once __DIR__.'/../include/functions.config.php';
19 19
 
20 20
 /**
21 21
  * Class OnlineHandler
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function render(\Smarty $xoopsTpl)
98 98
     {
99
-        require_once __DIR__ . '/../include/functions.render.php';
100
-        require_once __DIR__ . '/../include/functions.user.php';
99
+        require_once __DIR__.'/../include/functions.render.php';
100
+        require_once __DIR__.'/../include/functions.user.php';
101 101
         $criteria = null;
102 102
         if ($this->topic_id) {
103 103
             $criteria = new \Criteria('online_topic', $this->topic_id);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             }
117 117
             $users_id[]                             = $users[$i]['online_uid'];
118 118
             $users_online[$users[$i]['online_uid']] = [
119
-                'link'  => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
119
+                'link'  => XOOPS_URL.'/userinfo.php?uid='.$users[$i]['online_uid'],
120 120
                 'uname' => $users[$i]['online_uname']
121 121
             ];
122 122
             ++$num_user;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function showOnline()
157 157
     {
158
-        require_once __DIR__ . '/../include/functions.render.php';
159
-        require_once __DIR__ . '/../include/functions.user.php';
158
+        require_once __DIR__.'/../include/functions.render.php';
159
+        require_once __DIR__.'/../include/functions.user.php';
160 160
         $criteria = null;
161 161
         if ($this->topic_id) {
162 162
             $criteria = new \Criteria('online_topic', $this->topic_id);
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
             }
176 176
             $users_id[]                             = $users[$i]['online_uid'];
177 177
             $users_online[$users[$i]['online_uid']] = [
178
-                'link'  => XOOPS_URL . '/userinfo.php?uid=' . $users[$i]['online_uid'],
178
+                'link'  => XOOPS_URL.'/userinfo.php?uid='.$users[$i]['online_uid'],
179 179
                 'uname' => $users[$i]['online_uname']
180 180
             ];
181 181
             ++$num_user;
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 
230 230
         $uid = (int)$uid;
231 231
         if ($uid > 0) {
232
-            $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid;
232
+            $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online').' WHERE online_uid='.$uid;
233 233
         } else {
234
-            $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_uid=' . $uid . " AND online_ip='" . $ip . "'";
234
+            $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online').' WHERE online_uid='.$uid." AND online_ip='".$ip."'";
235 235
         }
236 236
         list($count) = $this->db->fetchRow($this->db->queryF($sql));
237 237
         if ($count > 0) {
238
-            $sql = 'UPDATE ' . $this->db->prefix('newbb_online') . " SET online_updated= '" . $time . "', online_forum = '" . $forum_id . "', online_topic = '" . $topic_id . "' WHERE online_uid = " . $uid;
238
+            $sql = 'UPDATE '.$this->db->prefix('newbb_online')." SET online_updated= '".$time."', online_forum = '".$forum_id."', online_topic = '".$topic_id."' WHERE online_uid = ".$uid;
239 239
             if (0 == $uid) {
240
-                $sql .= " AND online_ip='" . $ip . "'";
240
+                $sql .= " AND online_ip='".$ip."'";
241 241
             }
242 242
         } else {
243 243
             $sql = sprintf('INSERT INTO `%s` (online_uid, online_uname, online_updated, online_ip, online_forum, online_topic) VALUES (%u, %s, %u, %s, %u, %u)', $this->db->prefix('newbb_online'), $uid, $this->db->quote($uname), $time, $this->db->quote($ip), $forum_id, $topic_id);
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     public function gc($expire)
284 284
     {
285 285
         global $xoopsModule;
286
-        $sql = 'DELETE FROM ' . $this->db->prefix('newbb_online') . ' WHERE online_updated < ' . (time() - (int)$expire);
286
+        $sql = 'DELETE FROM '.$this->db->prefix('newbb_online').' WHERE online_updated < '.(time() - (int)$expire);
287 287
         $this->db->queryF($sql);
288 288
 
289 289
         $xoops_onlineHandler = xoops_getHandler('online');
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
     {
301 301
         $ret   = [];
302 302
         $limit = $start = 0;
303
-        $sql   = 'SELECT * FROM ' . $this->db->prefix('newbb_online');
303
+        $sql   = 'SELECT * FROM '.$this->db->prefix('newbb_online');
304 304
         if (is_object($criteria) && is_subclass_of($criteria, 'CriteriaElement')) {
305
-            $sql   .= ' ' . $criteria->renderWhere();
305
+            $sql .= ' '.$criteria->renderWhere();
306 306
             $limit = $criteria->getLimit();
307 307
             $start = $criteria->getStart();
308 308
         }
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
         if (!empty($this->user_ids)) {
334 334
             $online_users = $this->user_ids;
335 335
         } else {
336
-            $sql = 'SELECT online_uid FROM ' . $this->db->prefix('newbb_online');
336
+            $sql = 'SELECT online_uid FROM '.$this->db->prefix('newbb_online');
337 337
             if (!empty($uids)) {
338
-                $sql .= ' WHERE online_uid IN (' . implode(', ', array_map('intval', $uids)) . ')';
338
+                $sql .= ' WHERE online_uid IN ('.implode(', ', array_map('intval', $uids)).')';
339 339
             }
340 340
 
341 341
             $result = $this->db->query($sql);
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
      */
364 364
     public function getCount(\CriteriaElement $criteria = null)
365 365
     {
366
-        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('newbb_online');
366
+        $sql = 'SELECT COUNT(*) FROM '.$this->db->prefix('newbb_online');
367 367
         if (is_object($criteria) && is_subclass_of($criteria, 'CriteriaElement')) {
368
-            $sql .= ' ' . $criteria->renderWhere();
368
+            $sql .= ' '.$criteria->renderWhere();
369 369
         }
370 370
         if (!$result = $this->db->query($sql)) {
371 371
             return false;
Please login to merge, or discard this patch.
class/ReadForumHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 
33 33
 use XoopsModules\Newbb;
34 34
 
35
-require_once __DIR__ . '/read.php';
35
+require_once __DIR__.'/read.php';
36 36
 
37 37
 /**
38 38
  * A handler for read/unread handling
Please login to merge, or discard this patch.
polls.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
             $classOption  = $classPoll . 'Option';
120 120
             $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
121 121
             $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='"
122
-                                                                                                          . XOOPS_URL
123
-                                                                                                          . '/userinfo.php?uid='
124
-                                                                                                          . $GLOBALS['xoopsUser']->getVar('uid')
125
-                                                                                                          . "'>"
126
-                                                                                                          . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
127
-                                                                                                          . '</a>') : $GLOBALS['xoopsConfig']['anonymous']);
122
+                                                                                                            . XOOPS_URL
123
+                                                                                                            . '/userinfo.php?uid='
124
+                                                                                                            . $GLOBALS['xoopsUser']->getVar('uid')
125
+                                                                                                            . "'>"
126
+                                                                                                            . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
127
+                                                                                                            . '</a>') : $GLOBALS['xoopsConfig']['anonymous']);
128 128
             $poll_form->addElement($author_label);
129 129
             $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255);
130 130
             $poll_form->addElement($question_text);
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
                 $color_select->addOptionArray($barcolor_array);
155 155
                 $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'");
156 156
                 $color_label = new \XoopsFormLabel('', "<img src='"
157
-                                                      . XOOPS_URL
158
-                                                      . '/modules/'
159
-                                                      . $GLOBALS['xoopsModuleConfig']['poll_module']
160
-                                                      . '/assets/images/colorbars/'
161
-                                                      . $current_bar
162
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>");
157
+                                                        . XOOPS_URL
158
+                                                        . '/modules/'
159
+                                                        . $GLOBALS['xoopsModuleConfig']['poll_module']
160
+                                                        . '/assets/images/colorbars/'
161
+                                                        . $current_bar
162
+                                                        . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>");
163 163
                 $option_tray->addElement($color_select);
164 164
                 $option_tray->addElement($color_label);
165 165
                 if (!next($barcolor_array)) {
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
                 $color_select->addOptionArray($barcolor_array);
229 229
                 $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
230 230
                 $color_label = new \XoopsFormLabel('', "<img src='"
231
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
232
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
231
+                                                        . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
232
+                                                        . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
233 233
                 $option_tray->addElement($color_select);
234 234
                 $option_tray->addElement($color_label);
235 235
                 unset($color_select, $color_label);
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
                 $color_select->addOptionArray($barcolor_array);
519 519
                 $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
520 520
                 $color_label = new \XoopsFormLabel('', "<img src='"
521
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
522
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
521
+                                                        . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
522
+                                                        . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
523 523
                 $option_tray->addElement($color_select);
524 524
                 $option_tray->addElement($color_label);
525 525
                 unset($color_select, $color_label, $option_text);
@@ -652,9 +652,9 @@  discard block
 block discarded – undo
652 652
         $expire_text = new \XoopsFormText(
653 653
             _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf(
654 654
             _MD_NEWBB_POLL_EXPIREDAT,
655
-                                                                                                                                                                                                                     formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
655
+                                                                                                                                                                                                                        formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
656 656
         ) . '</small>',
657
-                                         'end_time',
657
+                                            'end_time',
658 658
             20,
659 659
             19,
660 660
             formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s')
Please login to merge, or discard this patch.
Switch Indentation   +574 added lines, -574 removed lines patch added patch discarded remove patch
@@ -109,213 +109,377 @@  discard block
 block discarded – undo
109 109
     }
110 110
 }
111 111
 switch ($op) {
112
-    case 'add':
113
-        // new xoopspoll module
114
-        if ($pollModuleHandler->getVar('version') >= 140) {
115
-            echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n";
116
-            $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
117
-        // old xoopspoll or umfrage or any clone from them
118
-        } else {
119
-            $classOption  = $classPoll . 'Option';
120
-            $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
121
-            $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='"
122
-                                                                                                          . XOOPS_URL
123
-                                                                                                          . '/userinfo.php?uid='
124
-                                                                                                          . $GLOBALS['xoopsUser']->getVar('uid')
125
-                                                                                                          . "'>"
126
-                                                                                                          . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
127
-                                                                                                          . '</a>') : $GLOBALS['xoopsConfig']['anonymous']);
128
-            $poll_form->addElement($author_label);
129
-            $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255);
130
-            $poll_form->addElement($question_text);
131
-            $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description');
132
-            $poll_form->addElement($desc_tarea);
133
-            $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s');
134
-            $endtime     = formatTimestamp(time() + 604800, 'Y-m-d H:i:s');
135
-            $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime);
136
-            $poll_form->addElement($expire_text);
112
+        case 'add':
113
+            // new xoopspoll module
114
+            if ($pollModuleHandler->getVar('version') >= 140) {
115
+                echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n";
116
+                $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
117
+            // old xoopspoll or umfrage or any clone from them
118
+            } else {
119
+                $classOption  = $classPoll . 'Option';
120
+                $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
121
+                $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='"
122
+                                                                                                              . XOOPS_URL
123
+                                                                                                              . '/userinfo.php?uid='
124
+                                                                                                              . $GLOBALS['xoopsUser']->getVar('uid')
125
+                                                                                                              . "'>"
126
+                                                                                                              . newbbGetUnameFromId($GLOBALS['xoopsUser']->getVar('uid'), $GLOBALS['xoopsModuleConfig']['show_realname'])
127
+                                                                                                              . '</a>') : $GLOBALS['xoopsConfig']['anonymous']);
128
+                $poll_form->addElement($author_label);
129
+                $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255);
130
+                $poll_form->addElement($question_text);
131
+                $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description');
132
+                $poll_form->addElement($desc_tarea);
133
+                $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s');
134
+                $endtime     = formatTimestamp(time() + 604800, 'Y-m-d H:i:s');
135
+                $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime);
136
+                $poll_form->addElement($expire_text);
137 137
 
138
-            $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0);
139
-            $poll_form->addElement($weight_text);
140
-
141
-            $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0);
142
-            $poll_form->addElement($multi_yn);
143
-
144
-            $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1);
145
-            $poll_form->addElement($notify_yn);
146
-
147
-            $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
148
-            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
149
-            for ($i = 0; $i < 10; ++$i) {
150
-                $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
151
-                $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
152
-                $option_tray->addElement($option_text);
153
-                $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
154
-                $color_select->addOptionArray($barcolor_array);
155
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'");
156
-                $color_label = new \XoopsFormLabel('', "<img src='"
157
-                                                      . XOOPS_URL
158
-                                                      . '/modules/'
159
-                                                      . $GLOBALS['xoopsModuleConfig']['poll_module']
160
-                                                      . '/assets/images/colorbars/'
161
-                                                      . $current_bar
162
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>");
163
-                $option_tray->addElement($color_select);
164
-                $option_tray->addElement($color_label);
165
-                if (!next($barcolor_array)) {
166
-                    reset($barcolor_array);
138
+                $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0);
139
+                $poll_form->addElement($weight_text);
140
+
141
+                $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', 0);
142
+                $poll_form->addElement($multi_yn);
143
+
144
+                $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1);
145
+                $poll_form->addElement($notify_yn);
146
+
147
+                $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
148
+                $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
149
+                for ($i = 0; $i < 10; ++$i) {
150
+                    $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
151
+                    $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
152
+                    $option_tray->addElement($option_text);
153
+                    $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
154
+                    $color_select->addOptionArray($barcolor_array);
155
+                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'");
156
+                    $color_label = new \XoopsFormLabel('', "<img src='"
157
+                                                          . XOOPS_URL
158
+                                                          . '/modules/'
159
+                                                          . $GLOBALS['xoopsModuleConfig']['poll_module']
160
+                                                          . '/assets/images/colorbars/'
161
+                                                          . $current_bar
162
+                                                          . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' align='bottom' height='15' alt='' /><br>");
163
+                    $option_tray->addElement($color_select);
164
+                    $option_tray->addElement($color_label);
165
+                    if (!next($barcolor_array)) {
166
+                        reset($barcolor_array);
167
+                    }
168
+                    unset($color_select, $color_label);
167 169
                 }
168
-                unset($color_select, $color_label);
170
+                $poll_form->addElement($option_tray);
171
+
172
+                $poll_form->addElement(new \XoopsFormHidden('op', 'save'));
173
+                $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
174
+                $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
175
+                $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0));
176
+                $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
177
+                echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>';
178
+                $poll_form->display();
169 179
             }
170
-            $poll_form->addElement($option_tray);
171
-
172
-            $poll_form->addElement(new \XoopsFormHidden('op', 'save'));
173
-            $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
174
-            $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
175
-            $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0));
176
-            $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
177
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>';
178
-            $poll_form->display();
179
-        }
180
-        break; // op: add
180
+            break; // op: add
181 181
 
182
-    case 'edit':
183
-        // new xoopspoll module
184
-        if ($pollModuleHandler->getVar('version') >= 140) {
185
-            echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n";
186
-            $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
187
-        // old xoopspoll or umfrage or any clone from them
188
-        } else {
189
-            $classOption  = $classPoll . 'Option';
190
-            $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true);
191
-            $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>');
192
-            $poll_form->addElement($author_label);
193
-            $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E'));
194
-            $poll_form->addElement($question_text);
195
-            $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E'));
196
-            $poll_form->addElement($desc_tarea);
197
-            $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function
198
-            if (!$pollObject->hasExpired()) {
199
-                $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date);
200
-                $poll_form->addElement($expire_text);
182
+        case 'edit':
183
+            // new xoopspoll module
184
+            if ($pollModuleHandler->getVar('version') >= 140) {
185
+                echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n";
186
+                $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
187
+            // old xoopspoll or umfrage or any clone from them
201 188
             } else {
202
-                // irmtfan full URL - add topic_id
203
-                $restart_label = new \XoopsFormLabel(
204
-                    _MD_NEWBB_POLL_EXPIRATION,
205
-                                                    sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>'
206
-                );
207
-                $poll_form->addElement($restart_label);
208
-            }
209
-            $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight'));
210
-            $poll_form->addElement($weight_text);
211
-            $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple'));
212
-            $poll_form->addElement($multi_yn);
213
-            $options_arr  =& $classOption::getAllByPollId($poll_id);
214
-            $notify_value = 1;
215
-            if (0 !== $pollObject->getVar('mail_status')) {
216
-                $notify_value = 0;
217
-            }
218
-            $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value);
219
-            $poll_form->addElement($notify_yn);
220
-            $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
221
-            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/"));
222
-            $i              = 0;
223
-            foreach ($options_arr as $option) {
224
-                /** @var \XoopsPoll $option */
225
-                $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text')));
226
-                $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id')));
227
-                $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color'));
228
-                $color_select->addOptionArray($barcolor_array);
229
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
230
-                $color_label = new \XoopsFormLabel('', "<img src='"
231
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
232
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
233
-                $option_tray->addElement($color_select);
234
-                $option_tray->addElement($color_label);
235
-                unset($color_select, $color_label);
236
-                ++$i;
189
+                $classOption  = $classPoll . 'Option';
190
+                $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true);
191
+                $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>');
192
+                $poll_form->addElement($author_label);
193
+                $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E'));
194
+                $poll_form->addElement($question_text);
195
+                $desc_tarea = new \XoopsFormTextarea(_MD_NEWBB_POLL_POLLDESC, 'description', $pollObject->getVar('description', 'E'));
196
+                $poll_form->addElement($desc_tarea);
197
+                $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function
198
+                if (!$pollObject->hasExpired()) {
199
+                    $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date);
200
+                    $poll_form->addElement($expire_text);
201
+                } else {
202
+                    // irmtfan full URL - add topic_id
203
+                    $restart_label = new \XoopsFormLabel(
204
+                        _MD_NEWBB_POLL_EXPIRATION,
205
+                                                        sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>'
206
+                    );
207
+                    $poll_form->addElement($restart_label);
208
+                }
209
+                $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, $pollObject->getVar('weight'));
210
+                $poll_form->addElement($weight_text);
211
+                $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple'));
212
+                $poll_form->addElement($multi_yn);
213
+                $options_arr  =& $classOption::getAllByPollId($poll_id);
214
+                $notify_value = 1;
215
+                if (0 !== $pollObject->getVar('mail_status')) {
216
+                    $notify_value = 0;
217
+                }
218
+                $notify_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', $notify_value);
219
+                $poll_form->addElement($notify_yn);
220
+                $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
221
+                $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/"));
222
+                $i              = 0;
223
+                foreach ($options_arr as $option) {
224
+                    /** @var \XoopsPoll $option */
225
+                    $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text')));
226
+                    $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id')));
227
+                    $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color'));
228
+                    $color_select->addOptionArray($barcolor_array);
229
+                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
230
+                    $color_label = new \XoopsFormLabel('', "<img src='"
231
+                                                          . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
232
+                                                          . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
233
+                    $option_tray->addElement($color_select);
234
+                    $option_tray->addElement($color_label);
235
+                    unset($color_select, $color_label);
236
+                    ++$i;
237
+                }
238
+                // irmtfan full URL
239
+                $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>');
240
+                $option_tray->addElement($more_label);
241
+                $poll_form->addElement($option_tray);
242
+                $poll_form->addElement(new \XoopsFormHidden('op', 'update'));
243
+                $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
244
+                $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
245
+                $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
246
+
247
+                echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
248
+                $poll_form->display();
237 249
             }
238
-            // irmtfan full URL
239
-            $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>');
240
-            $option_tray->addElement($more_label);
241
-            $poll_form->addElement($option_tray);
242
-            $poll_form->addElement(new \XoopsFormHidden('op', 'update'));
243
-            $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
244
-            $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
245
-            $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
250
+            break; // op: edit
246 251
 
247
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
248
-            $poll_form->display();
249
-        }
250
-        break; // op: edit
252
+        case 'save':
253
+            // old xoopspoll or umfrage or any clone from them
254
+            if ($pollModuleHandler->getVar('version') < 140) {
255
+                // check security token
256
+                if (!$GLOBALS['xoopsSecurity']->check()) {
257
+                    redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
258
+                }
259
+                /*
260
+             * The option check should be done before submitting
261
+             */
262
+                $option_empty = true;
263
+                if (!Request::getString('option_text', '', 'POST')) {
264
+                    // irmtfan - issue with javascript:history.go(-1)
265
+                    redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
266
+                }
267
+                $option_text = Request::getArray('option_text', '', 'POST');
268
+                foreach ($option_text as $optxt) {
269
+                    if ('' !== trim($optxt)) {
270
+                        $option_empty = false;
271
+                        break;
272
+                    }
273
+                }
274
+                if ($option_empty) {
275
+                    // irmtfan - issue with javascript:history.go(-1)
276
+                    redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
277
+                }
278
+                $pollObject->setVar('question', Request::getString('question', '', 'POST'));
279
+                $pollObject->setVar('description', Request::getString('description', '', 'POST'));
280
+                $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time'];
281
+                if ('' !== $end_time) {
282
+                    $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
283
+                    $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
284
+                } else {
285
+                    // if expiration date is not set, set it to 10 days from now
286
+                    $pollObject->setVar('end_time', time() + (86400 * 10));
287
+                }
251 288
 
252
-    case 'save':
253
-        // old xoopspoll or umfrage or any clone from them
254
-        if ($pollModuleHandler->getVar('version') < 140) {
289
+                $pollObject->setVar('display', 0);
290
+                $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST'));
291
+                $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST'));
292
+                $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST'));
293
+                if (Request::getInt('notify', 0, 'POST') && $end_time > time()) {
294
+                    // if notify, set mail status to "not mailed"
295
+                    $pollObject->setVar('mail_status', POLL_NOTMAILED);
296
+                } else {
297
+                    // if not notify, set mail status to already "mailed"
298
+                    $pollObject->setVar('mail_status', POLL_MAILED);
299
+                }
300
+                $new_poll_id = $pollObject->store();
301
+                if (empty($new_poll_id)) {
302
+                    xoops_error($pollObject->getHtmlErrors);
303
+                    break;
304
+                }
305
+                $i            = 0;
306
+                $option_color = Request::getArray('option_color', null, 'POST');
307
+                $classOption  = $classPoll . 'Option';
308
+                foreach ($option_text as $optxt) {
309
+                    $optxt = trim($optxt);
310
+                    /** @var XoopspollOption $optionObject */
311
+                    $optionObject = new $classOption();
312
+                    if ('' !== $optxt) {
313
+                        $optionObject->setVar('option_text', $optxt);
314
+                        $optionObject->setVar('option_color', $option_color[$i]);
315
+                        $optionObject->setVar('poll_id', $new_poll_id);
316
+                        $optionObject->store();
317
+                    }
318
+                    ++$i;
319
+                }
320
+                // clear the template cache so changes take effect immediately
321
+                require_once $GLOBALS['xoops']->path('class/template.php');
322
+                xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid'));
323
+                xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
324
+
325
+                // update topic to indicate it has a poll
326
+                $topicObject->setVar('topic_haspoll', 1);
327
+                $topicObject->setVar('poll_id', $new_poll_id);
328
+                $success = $topicHandler->insert($topicObject);
329
+                if (!$success) {
330
+                    xoops_error($topicHandler->getHtmlErrors());
331
+                } else {
332
+                    redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
333
+                }
334
+                break;// op: save
335
+            }
336
+        // no break
337
+        case 'update':
255 338
             // check security token
256 339
             if (!$GLOBALS['xoopsSecurity']->check()) {
257 340
                 redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
258 341
             }
259
-            /*
260
-             * The option check should be done before submitting
261
-             */
262
-            $option_empty = true;
263
-            if (!Request::getString('option_text', '', 'POST')) {
264
-                // irmtfan - issue with javascript:history.go(-1)
342
+            /* make sure there's at least one option */
343
+            $option_text   = Request::getString('option_text', '', 'POST');
344
+            $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
345
+            $option_string = trim($option_string);
346
+            if ('' === $option_string) {
265 347
                 redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
266 348
             }
267
-            $option_text = Request::getArray('option_text', '', 'POST');
268
-            foreach ($option_text as $optxt) {
269
-                if ('' !== trim($optxt)) {
270
-                    $option_empty = false;
271
-                    break;
349
+
350
+            // new xoopspoll module
351
+            if ($pollModuleHandler->getVar('version') >= 140) {
352
+                /** @var \XoopspollOptionHandler $xpOptHandler */
353
+                $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
354
+                /** @var \XoopspollLogHandler $xpLogHandler */
355
+                $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
356
+                //            $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request";
357
+                $classConstants   = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
358
+                $notify           = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST');
359
+                $currentTimestamp = time();
360
+                //$xuEndTimestamp   = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST'))
361
+                //                                                             : strtotime(Request::getString('xu_end_time', null, 'POST'));
362
+                $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST'));
363
+                $endTimestamp   = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
364
+                //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST'))
365
+                //                                                             : strtotime(Request::getString('xu_start_time', null, 'POST'));
366
+                $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST'));
367
+                $startTimestamp   = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
368
+
369
+                //  don't allow changing start time if there are votes in the log
370
+                if (($startTimestamp < $pollObject->getVar('start_time'))
371
+                    && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) {
372
+                    $startTimestamp = $pollObject->getVar('start_time'); //don't change start time
272 373
                 }
273
-            }
274
-            if ($option_empty) {
275
-                // irmtfan - issue with javascript:history.go(-1)
276
-                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
277
-            }
278
-            $pollObject->setVar('question', Request::getString('question', '', 'POST'));
279
-            $pollObject->setVar('description', Request::getString('description', '', 'POST'));
280
-            $end_time = Request::getString('end_time', '', 'POST'); // (empty($_POST['end_time'])) ? "" : $_POST['end_time'];
281
-            if ('' !== $end_time) {
282
-                $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
283
-                $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
284
-            } else {
285
-                // if expiration date is not set, set it to 10 days from now
286
-                $pollObject->setVar('end_time', time() + (86400 * 10));
287
-            }
288 374
 
289
-            $pollObject->setVar('display', 0);
290
-            $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST'));
291
-            $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST'));
292
-            $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST'));
293
-            if (Request::getInt('notify', 0, 'POST') && $end_time > time()) {
294
-                // if notify, set mail status to "not mailed"
295
-                $pollObject->setVar('mail_status', POLL_NOTMAILED);
375
+                $poll_vars = [
376
+                    'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
377
+                    'question'    => Request::getString('question', null, 'POST'),
378
+                    'description' => Request::getText('description', null, 'POST'),
379
+                    'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED,
380
+                    'mail_voter'  => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'),
381
+                    'start_time'  => $startTimestamp,
382
+                    'end_time'    => $endTimestamp,
383
+                    'display'     => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'),
384
+                    'visibility'  => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'),
385
+                    'weight'      => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'),
386
+                    'multiple'    => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'),
387
+                    'multilimit'  => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'),
388
+                    'anonymous'   => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST')
389
+                ];
390
+                $pollObject->setVars($poll_vars);
391
+                $poll_id = $xpPollHandler->insert($pollObject);
392
+                if (!$poll_id) {
393
+                    $err = $pollObject->getHtmlErrors();
394
+                    exit($err);
395
+                }
396
+
397
+                // now get the options
398
+                $optionIdArray    = Request::getArray('option_id', [], 'POST');
399
+                $optionIdArray    = array_map('intval', $optionIdArray);
400
+                $optionTextArray  = Request::getArray('option_text', [], 'POST');
401
+                $optionColorArray = Request::getArray('option_color', [], 'POST');
402
+
403
+                foreach ($optionIdArray as $key => $oId) {
404
+                    if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) {
405
+                        // existing option object so need to update it
406
+                        $optionTextArray[$key] = trim($optionTextArray[$key]);
407
+                        if ('' === $optionTextArray[$key]) {
408
+                            // want to delete this option
409
+                            if (false !== $xpOptHandler->delete($optionObject)) {
410
+                                // now remove it from the log
411
+                                $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id'));
412
+                                //update vote count in poll
413
+                                $xpPollHandler->updateCount($pollObject);
414
+                            } else {
415
+                                xoops_error($xpLogHandler->getHtmlErrors());
416
+                                break;
417
+                            }
418
+                        } else {
419
+                            $optionObject->setVar('option_text', $optionTextArray[$key]);
420
+                            $optionObject->setVar('option_color', $optionColorArray[$key]);
421
+                            $optionObject->setVar('poll_id', $poll_id);
422
+                            $xpOptHandler->insert($optionObject);
423
+                        }
424
+                    } else {
425
+                        // new option object
426
+                        $optionObject          = $xpOptHandler->create();
427
+                        $optionTextArray[$key] = trim($optionTextArray[$key]);
428
+                        if ('' !== $optionTextArray[$key]) { // ignore if text is empty
429
+                            $optionObject->setVar('option_text', $optionTextArray[$key]);
430
+                            $optionObject->setVar('option_color', $optionColorArray[$key]);
431
+                            $optionObject->setVar('poll_id', $poll_id);
432
+                            $xpOptHandler->insert($optionObject);
433
+                        }
434
+                        unset($optionObject);
435
+                    }
436
+                }
437
+                // old xoopspoll or umfrage or any clone from them
296 438
             } else {
297
-                // if not notify, set mail status to already "mailed"
298
-                $pollObject->setVar('mail_status', POLL_MAILED);
299
-            }
300
-            $new_poll_id = $pollObject->store();
301
-            if (empty($new_poll_id)) {
302
-                xoops_error($pollObject->getHtmlErrors);
303
-                break;
304
-            }
305
-            $i            = 0;
306
-            $option_color = Request::getArray('option_color', null, 'POST');
307
-            $classOption  = $classPoll . 'Option';
308
-            foreach ($option_text as $optxt) {
309
-                $optxt = trim($optxt);
310
-                /** @var XoopspollOption $optionObject */
311
-                $optionObject = new $classOption();
312
-                if ('' !== $optxt) {
313
-                    $optionObject->setVar('option_text', $optxt);
314
-                    $optionObject->setVar('option_color', $option_color[$i]);
315
-                    $optionObject->setVar('poll_id', $new_poll_id);
316
-                    $optionObject->store();
439
+                $pollObject->setVar('question', Request::getString('question', '', 'POST'));
440
+                $pollObject->setVar('description', Request::getString('description', '', 'POST'));
441
+
442
+                $end_time = Request::getString('end_time', '', 'POST');
443
+                if ('' !== $end_time) {
444
+                    $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
445
+                    $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
317 446
                 }
318
-                ++$i;
447
+                $pollObject->setVar('display', 0);
448
+                $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST'));
449
+                $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST'));
450
+                $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST'));
451
+                if (Request::getInt('notify', 0, 'POST') && $end_time > time()) {
452
+                    // if notify, set mail status to "not mailed"
453
+                    $pollObject->setVar('mail_status', POLL_NOTMAILED);
454
+                } else {
455
+                    // if not notify, set mail status to already "mailed"
456
+                    $pollObject->setVar('mail_status', POLL_MAILED);
457
+                }
458
+
459
+                if (!$pollObject->store()) {
460
+                    xoops_error($pollObject->getHtmlErrors);
461
+                    break;
462
+                }
463
+                $i            = 0;
464
+                $option_id    = Request::getArray('option_id', null, 'POST');
465
+                $option_color = Request::getArray('option_color', null, 'POST');
466
+                $classOption  = $classPoll . 'Option';
467
+                $classLog     = $classPoll . 'Log';
468
+                foreach ($option_id as $opid) {
469
+                    $optionObject    = new $classOption($opid);
470
+                    $option_text[$i] = trim($option_text[$i]);
471
+                    if ('' !== $option_text[$i]) {
472
+                        $optionObject->setVar('option_text', $option_text[$i]);
473
+                        $optionObject->setVar('option_color', $option_color[$i]);
474
+                        $optionObject->store();
475
+                    } else {
476
+                        if (false !== $optionObject->delete()) {
477
+                            $classLog::deleteByOptionId($option->getVar('option_id'));
478
+                        }
479
+                    }
480
+                    ++$i;
481
+                }
482
+                $pollObject->updateCount();
319 483
             }
320 484
             // clear the template cache so changes take effect immediately
321 485
             require_once $GLOBALS['xoops']->path('class/template.php');
@@ -324,433 +488,269 @@  discard block
 block discarded – undo
324 488
 
325 489
             // update topic to indicate it has a poll
326 490
             $topicObject->setVar('topic_haspoll', 1);
327
-            $topicObject->setVar('poll_id', $new_poll_id);
491
+            $topicObject->setVar('poll_id', $pollObject->getVar('poll_id'));
328 492
             $success = $topicHandler->insert($topicObject);
329 493
             if (!$success) {
330 494
                 xoops_error($topicHandler->getHtmlErrors());
331 495
             } else {
332 496
                 redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
333 497
             }
334
-            break;// op: save
335
-        }
336
-    // no break
337
-    case 'update':
338
-        // check security token
339
-        if (!$GLOBALS['xoopsSecurity']->check()) {
340
-            redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
341
-        }
342
-        /* make sure there's at least one option */
343
-        $option_text   = Request::getString('option_text', '', 'POST');
344
-        $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
345
-        $option_string = trim($option_string);
346
-        if ('' === $option_string) {
347
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
348
-        }
349
-
350
-        // new xoopspoll module
351
-        if ($pollModuleHandler->getVar('version') >= 140) {
352
-            /** @var \XoopspollOptionHandler $xpOptHandler */
353
-            $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
354
-            /** @var \XoopspollLogHandler $xpLogHandler */
355
-            $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
356
-            //            $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request";
357
-            $classConstants   = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
358
-            $notify           = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST');
359
-            $currentTimestamp = time();
360
-            //$xuEndTimestamp   = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST'))
361
-            //                                                             : strtotime(Request::getString('xu_end_time', null, 'POST'));
362
-            $xuEndTimestamp = strtotime(Request::getString('xu_end_time', null, 'POST'));
363
-            $endTimestamp   = (!Request::getString('xu_end_time', null, 'POST')) ? ($currentTimestamp + $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);
364
-            //$xuStartTimestamp = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_start_time', null, 'POST'))
365
-            //                                                             : strtotime(Request::getString('xu_start_time', null, 'POST'));
366
-            $xuStartTimestamp = strtotime(Request::getString('xu_start_time', null, 'POST'));
367
-            $startTimestamp   = (!Request::getString('xu_start_time', null, 'POST')) ? ($endTimestamp - $classConstants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);
368
-
369
-            //  don't allow changing start time if there are votes in the log
370
-            if (($startTimestamp < $pollObject->getVar('start_time'))
371
-                && ($xpLogHandler->getTotalVotesByPollId($poll_id) > 0)) {
372
-                $startTimestamp = $pollObject->getVar('start_time'); //don't change start time
498
+            break;// op: save | update
499
+
500
+        case 'addmore':
501
+            $question = $pollObject->getVar('question');
502
+            unset($pollObject);
503
+            $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true);
504
+            $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question));
505
+            // new xoopspoll module
506
+            if ($pollModuleHandler->getVar('version') >= 140) {
507
+                $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
508
+                $option_tray  = $xpOptHandler->renderOptionFormTray($poll_id);
509
+            // old xoopspoll or umfrage or any clone from them
510
+            } else {
511
+                $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
512
+                $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
513
+                for ($i = 0; $i < 10; ++$i) {
514
+                    $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
515
+                    $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
516
+                    $option_tray->addElement($option_text);
517
+                    $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
518
+                    $color_select->addOptionArray($barcolor_array);
519
+                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
520
+                    $color_label = new \XoopsFormLabel('', "<img src='"
521
+                                                          . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
522
+                                                          . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
523
+                    $option_tray->addElement($color_select);
524
+                    $option_tray->addElement($color_label);
525
+                    unset($color_select, $color_label, $option_text);
526
+                    if (!next($barcolor_array)) {
527
+                        reset($barcolor_array);
528
+                    }
529
+                }
373 530
             }
531
+            $poll_form->addElement($option_tray);
532
+            $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
533
+            $poll_form->addElement(new \XoopsFormHidden('op', 'savemore'));
534
+            $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
535
+            $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
374 536
 
375
-            $poll_vars = [
376
-                'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
377
-                'question'    => Request::getString('question', null, 'POST'),
378
-                'description' => Request::getText('description', null, 'POST'),
379
-                'mail_status' => ($classConstants::NOTIFICATION_ENABLED == $notify) ? $classConstants::POLL_NOT_MAILED : $classConstants::POLL_MAILED,
380
-                'mail_voter'  => Request::getInt('mail_voter', $classConstants::NOT_MAIL_POLL_TO_VOTER, 'POST'),
381
-                'start_time'  => $startTimestamp,
382
-                'end_time'    => $endTimestamp,
383
-                'display'     => Request::getInt('display', $classConstants::DO_NOT_DISPLAY_POLL_IN_BLOCK, 'POST'),
384
-                'visibility'  => Request::getInt('visibility', $classConstants::HIDE_NEVER, 'POST'),
385
-                'weight'      => Request::getInt('weight', $classConstants::DEFAULT_WEIGHT, 'POST'),
386
-                'multiple'    => Request::getInt('multiple', $classConstants::NOT_MULTIPLE_SELECT_POLL, 'POST'),
387
-                'multilimit'  => Request::getInt('multilimit', $classConstants::MULTIPLE_SELECT_LIMITLESS, 'POST'),
388
-                'anonymous'   => Request::getInt('anonymous', $classConstants::ANONYMOUS_VOTING_DISALLOWED, 'POST')
389
-            ];
390
-            $pollObject->setVars($poll_vars);
391
-            $poll_id = $xpPollHandler->insert($pollObject);
392
-            if (!$poll_id) {
393
-                $err = $pollObject->getHtmlErrors();
394
-                exit($err);
537
+            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
538
+            $poll_form->display();
539
+            break;
540
+
541
+        case 'savemore':
542
+            // check security token
543
+            if (!$GLOBALS['xoopsSecurity']->check()) {
544
+                redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
395 545
             }
396 546
 
397
-            // now get the options
398
-            $optionIdArray    = Request::getArray('option_id', [], 'POST');
399
-            $optionIdArray    = array_map('intval', $optionIdArray);
400
-            $optionTextArray  = Request::getArray('option_text', [], 'POST');
401
-            $optionColorArray = Request::getArray('option_color', [], 'POST');
402
-
403
-            foreach ($optionIdArray as $key => $oId) {
404
-                if (!empty($oId) && ($optionObject = $xpOptHandler->get($oId))) {
405
-                    // existing option object so need to update it
406
-                    $optionTextArray[$key] = trim($optionTextArray[$key]);
407
-                    if ('' === $optionTextArray[$key]) {
408
-                        // want to delete this option
409
-                        if (false !== $xpOptHandler->delete($optionObject)) {
410
-                            // now remove it from the log
411
-                            $xpLogHandler->deleteByOptionId($optionObject->getVar('option_id'));
412
-                            //update vote count in poll
413
-                            $xpPollHandler->updateCount($pollObject);
414
-                        } else {
415
-                            xoops_error($xpLogHandler->getHtmlErrors());
416
-                            break;
417
-                        }
418
-                    } else {
419
-                        $optionObject->setVar('option_text', $optionTextArray[$key]);
420
-                        $optionObject->setVar('option_color', $optionColorArray[$key]);
547
+            $option_text   = Request::getString('option_text', '', 'POST');
548
+            $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
549
+            $option_string = trim($option_string);
550
+            if ('' === $option_string) {
551
+                // irmtfan - issue with javascript:history.go(-1)
552
+                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
553
+            }
554
+            $i            = 0;
555
+            $option_color = Request::getArray('option_color', null, 'POST');
556
+            foreach ($option_text as $optxt) {
557
+                $optxt = trim($optxt);
558
+                if ('' !== $optxt) {
559
+                    // new xoopspoll module
560
+                    if ($pollModuleHandler->getVar('version') >= 140) {
561
+                        $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
562
+                        $optionObject = $xpOptHandler->create();
563
+                        $optionObject->setVar('option_text', $optxt);
421 564
                         $optionObject->setVar('poll_id', $poll_id);
565
+                        $optionObject->setVar('option_color', $option_color[$i]);
422 566
                         $xpOptHandler->insert($optionObject);
423
-                    }
424
-                } else {
425
-                    // new option object
426
-                    $optionObject          = $xpOptHandler->create();
427
-                    $optionTextArray[$key] = trim($optionTextArray[$key]);
428
-                    if ('' !== $optionTextArray[$key]) { // ignore if text is empty
429
-                        $optionObject->setVar('option_text', $optionTextArray[$key]);
430
-                        $optionObject->setVar('option_color', $optionColorArray[$key]);
567
+                    // old xoopspoll or umfrage or any clone from them
568
+                    } else {
569
+                        $classOption  = $classPoll . 'Option';
570
+                        $optionObject = new $classOption();
571
+                        $optionObject->setVar('option_text', $optxt);
431 572
                         $optionObject->setVar('poll_id', $poll_id);
432
-                        $xpOptHandler->insert($optionObject);
573
+                        $optionObject->setVar('option_color', $option_color[$i]);
574
+                        $optionObject->store();
433 575
                     }
434 576
                     unset($optionObject);
435 577
                 }
578
+                ++$i;
436 579
             }
437
-            // old xoopspoll or umfrage or any clone from them
438
-        } else {
439
-            $pollObject->setVar('question', Request::getString('question', '', 'POST'));
440
-            $pollObject->setVar('description', Request::getString('description', '', 'POST'));
580
+            require_once $GLOBALS['xoops']->path('class/template.php');
581
+            xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid'));
582
+            xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
583
+            redirect_header("polls.php?op=edit&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
584
+            break;
441 585
 
442
-            $end_time = Request::getString('end_time', '', 'POST');
443
-            if ('' !== $end_time) {
444
-                $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
445
-                $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
446
-            }
447
-            $pollObject->setVar('display', 0);
448
-            $pollObject->setVar('weight', Request::getInt('weight', 0, 'POST'));
449
-            $pollObject->setVar('multiple', Request::getInt('multiple', 0, 'POST'));
450
-            $pollObject->setVar('user_id', Request::getInt('user_id', 0, 'POST'));
451
-            if (Request::getInt('notify', 0, 'POST') && $end_time > time()) {
452
-                // if notify, set mail status to "not mailed"
453
-                $pollObject->setVar('mail_status', POLL_NOTMAILED);
454
-            } else {
455
-                // if not notify, set mail status to already "mailed"
456
-                $pollObject->setVar('mail_status', POLL_MAILED);
457
-            }
586
+        case 'delete':
587
+            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
588
+            xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question')));
589
+            break;
458 590
 
459
-            if (!$pollObject->store()) {
460
-                xoops_error($pollObject->getHtmlErrors);
461
-                break;
591
+        case 'delete_ok':
592
+            // check security token
593
+            if (!$GLOBALS['xoopsSecurity']->check()) {
594
+                redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
462 595
             }
463
-            $i            = 0;
464
-            $option_id    = Request::getArray('option_id', null, 'POST');
465
-            $option_color = Request::getArray('option_color', null, 'POST');
466
-            $classOption  = $classPoll . 'Option';
467
-            $classLog     = $classPoll . 'Log';
468
-            foreach ($option_id as $opid) {
469
-                $optionObject    = new $classOption($opid);
470
-                $option_text[$i] = trim($option_text[$i]);
471
-                if ('' !== $option_text[$i]) {
472
-                    $optionObject->setVar('option_text', $option_text[$i]);
473
-                    $optionObject->setVar('option_color', $option_color[$i]);
474
-                    $optionObject->store();
596
+            //try and delete the poll
597
+            // new xoopspoll module
598
+            if ($pollModuleHandler->getVar('version') >= 140) {
599
+                $status = $xpPollHandler->delete($pollObject);
600
+                if (false !== $status) {
601
+                    $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
602
+                    $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
603
+                    $xpOptHandler->deleteByPollId($poll_id);
604
+                    $xpLogHandler->deleteByPollId($poll_id);
475 605
                 } else {
476
-                    if (false !== $optionObject->delete()) {
477
-                        $classLog::deleteByOptionId($option->getVar('option_id'));
478
-                    }
479
-                }
480
-                ++$i;
481
-            }
482
-            $pollObject->updateCount();
483
-        }
484
-        // clear the template cache so changes take effect immediately
485
-        require_once $GLOBALS['xoops']->path('class/template.php');
486
-        xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid'));
487
-        xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
488
-
489
-        // update topic to indicate it has a poll
490
-        $topicObject->setVar('topic_haspoll', 1);
491
-        $topicObject->setVar('poll_id', $pollObject->getVar('poll_id'));
492
-        $success = $topicHandler->insert($topicObject);
493
-        if (!$success) {
494
-            xoops_error($topicHandler->getHtmlErrors());
495
-        } else {
496
-            redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
497
-        }
498
-        break;// op: save | update
499
-
500
-    case 'addmore':
501
-        $question = $pollObject->getVar('question');
502
-        unset($pollObject);
503
-        $poll_form = new \XoopsThemeForm(_MD_NEWBB_POLL_ADDMORE, 'poll_form', 'polls.php', 'post', true);
504
-        $poll_form->addElement(new \XoopsFormLabel(_MD_NEWBB_POLL_POLLQUESTION, $question));
505
-        // new xoopspoll module
506
-        if ($pollModuleHandler->getVar('version') >= 140) {
507
-            $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
508
-            $option_tray  = $xpOptHandler->renderOptionFormTray($poll_id);
509
-        // old xoopspoll or umfrage or any clone from them
510
-        } else {
511
-            $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
512
-            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
513
-            for ($i = 0; $i < 10; ++$i) {
514
-                $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
515
-                $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
516
-                $option_tray->addElement($option_text);
517
-                $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
518
-                $color_select->addOptionArray($barcolor_array);
519
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
520
-                $color_label = new \XoopsFormLabel('', "<img src='"
521
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
522
-                                                      . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
523
-                $option_tray->addElement($color_select);
524
-                $option_tray->addElement($color_label);
525
-                unset($color_select, $color_label, $option_text);
526
-                if (!next($barcolor_array)) {
527
-                    reset($barcolor_array);
606
+                    $msg = $xpPollHandler->getHtmlErrors();
528 607
                 }
529
-            }
530
-        }
531
-        $poll_form->addElement($option_tray);
532
-        $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
533
-        $poll_form->addElement(new \XoopsFormHidden('op', 'savemore'));
534
-        $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
535
-        $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
536
-
537
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
538
-        $poll_form->display();
539
-        break;
540
-
541
-    case 'savemore':
542
-        // check security token
543
-        if (!$GLOBALS['xoopsSecurity']->check()) {
544
-            redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
545
-        }
546
-
547
-        $option_text   = Request::getString('option_text', '', 'POST');
548
-        $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
549
-        $option_string = trim($option_string);
550
-        if ('' === $option_string) {
551
-            // irmtfan - issue with javascript:history.go(-1)
552
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
553
-        }
554
-        $i            = 0;
555
-        $option_color = Request::getArray('option_color', null, 'POST');
556
-        foreach ($option_text as $optxt) {
557
-            $optxt = trim($optxt);
558
-            if ('' !== $optxt) {
559
-                // new xoopspoll module
560
-                if ($pollModuleHandler->getVar('version') >= 140) {
561
-                    $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
562
-                    $optionObject = $xpOptHandler->create();
563
-                    $optionObject->setVar('option_text', $optxt);
564
-                    $optionObject->setVar('poll_id', $poll_id);
565
-                    $optionObject->setVar('option_color', $option_color[$i]);
566
-                    $xpOptHandler->insert($optionObject);
567 608
                 // old xoopspoll or umfrage or any clone from them
609
+            } else {
610
+                $status      = $pollObject->delete();
611
+                $classOption = $classPoll . 'Option';
612
+                $classLog    = $classPoll . 'Log';
613
+                if (false !== $status) {
614
+                    $classOption::deleteByPollId($poll_id);
615
+                    $classLog::deleteByPollId($poll_id);
568 616
                 } else {
569
-                    $classOption  = $classPoll . 'Option';
570
-                    $optionObject = new $classOption();
571
-                    $optionObject->setVar('option_text', $optxt);
572
-                    $optionObject->setVar('poll_id', $poll_id);
573
-                    $optionObject->setVar('option_color', $option_color[$i]);
574
-                    $optionObject->store();
617
+                    $msg = $pollObject->getHtmlErrors();
575 618
                 }
576
-                unset($optionObject);
577 619
             }
578
-            ++$i;
579
-        }
580
-        require_once $GLOBALS['xoops']->path('class/template.php');
581
-        xoops_template_clear_module_cache($GLOBALS['xoopsModule']->getVar('mid'));
582
-        xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
583
-        redirect_header("polls.php?op=edit&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
584
-        break;
585
-
586
-    case 'delete':
587
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
588
-        xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question')));
589
-        break;
590
-
591
-    case 'delete_ok':
592
-        // check security token
593
-        if (!$GLOBALS['xoopsSecurity']->check()) {
594
-            redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
595
-        }
596
-        //try and delete the poll
597
-        // new xoopspoll module
598
-        if ($pollModuleHandler->getVar('version') >= 140) {
599
-            $status = $xpPollHandler->delete($pollObject);
600 620
             if (false !== $status) {
601
-                $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
602
-                $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
603
-                $xpOptHandler->deleteByPollId($poll_id);
604
-                $xpLogHandler->deleteByPollId($poll_id);
621
+                require_once $GLOBALS['xoops']->path('class/template.php');
622
+                xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
623
+                xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
624
+                // delete comments for this poll
625
+                xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id);
626
+
627
+                $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone
628
+                $topicObject->setVar('topic_haspoll', 0);
629
+                $topicObject->setVar('poll_id', 0);
630
+                $success = $topicHandler->insert($topicObject);
631
+                if (!$success) {
632
+                    xoops_error($topicHandler->getHtmlErrors());
633
+                    break;
634
+                }
605 635
             } else {
606
-                $msg = $xpPollHandler->getHtmlErrors();
636
+                xoops_error($msg);
637
+                break;
607 638
             }
639
+            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
640
+            break;
641
+
642
+        case 'restart':
643
+            // new xoopspoll module
644
+            if ($pollModuleHandler->getVar('version') >= 140) {
645
+                $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
646
+                $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
608 647
             // old xoopspoll or umfrage or any clone from them
609
-        } else {
610
-            $status      = $pollObject->delete();
611
-            $classOption = $classPoll . 'Option';
612
-            $classLog    = $classPoll . 'Log';
613
-            if (false !== $status) {
614
-                $classOption::deleteByPollId($poll_id);
615
-                $classLog::deleteByPollId($poll_id);
616 648
             } else {
617
-                $msg = $pollObject->getHtmlErrors();
649
+                $default_poll_duration = (86400 * 10);
618 650
             }
619
-        }
620
-        if (false !== $status) {
621
-            require_once $GLOBALS['xoops']->path('class/template.php');
622
-            xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
623
-            xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
624
-            // delete comments for this poll
625
-            xoops_comment_delete($xoopsModule->getVar('mid'), $poll_id);
651
+            $poll_form   = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true);
652
+            $expire_text = new \XoopsFormText(
653
+                _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf(
654
+                _MD_NEWBB_POLL_EXPIREDAT,
655
+                                                                                                                                                                                                                         formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
656
+            ) . '</small>',
657
+                                             'end_time',
658
+                20,
659
+                19,
660
+                formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s')
661
+            );
662
+            $poll_form->addElement($expire_text);
663
+            $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1));
664
+            $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0));
665
+            $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok'));
666
+            $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
667
+            $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
668
+            $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit'));
626 669
 
627
-            $topicObject->setVar('votes', 0); // not sure why we want to clear votes too... but I left it alone
628
-            $topicObject->setVar('topic_haspoll', 0);
629
-            $topicObject->setVar('poll_id', 0);
630
-            $success = $topicHandler->insert($topicObject);
631
-            if (!$success) {
632
-                xoops_error($topicHandler->getHtmlErrors());
633
-                break;
634
-            }
635
-        } else {
636
-            xoops_error($msg);
670
+            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
671
+            $poll_form->display();
637 672
             break;
638
-        }
639
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
640
-        break;
641
-
642
-    case 'restart':
643
-        // new xoopspoll module
644
-        if ($pollModuleHandler->getVar('version') >= 140) {
645
-            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
646
-            $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
647
-        // old xoopspoll or umfrage or any clone from them
648
-        } else {
649
-            $default_poll_duration = (86400 * 10);
650
-        }
651
-        $poll_form   = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true);
652
-        $expire_text = new \XoopsFormText(
653
-            _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf(
654
-            _MD_NEWBB_POLL_EXPIREDAT,
655
-                                                                                                                                                                                                                     formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
656
-        ) . '</small>',
657
-                                         'end_time',
658
-            20,
659
-            19,
660
-            formatTimestamp(time() + $default_poll_duration, 'Y-m-d H:i:s')
661
-        );
662
-        $poll_form->addElement($expire_text);
663
-        $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_NOTIFY, 'notify', 1));
664
-        $poll_form->addElement(new \XoopsFormRadioYN(_MD_NEWBB_POLL_RESET, 'reset', 0));
665
-        $poll_form->addElement(new \XoopsFormHidden('op', 'restart_ok'));
666
-        $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
667
-        $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
668
-        $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit'));
669
-
670
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
671
-        $poll_form->display();
672
-        break;
673
-
674
-    case 'restart_ok':
675
-        // check security token
676
-        if (!$GLOBALS['xoopsSecurity']->check()) {
677
-            redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
678
-        }
679 673
 
680
-        // new xoopspoll module
681
-        if ($pollModuleHandler->getVar('version') >= 140) {
682
-            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
683
-            $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
684
-            $poll_not_mailed       = $classConstants::POLL_NOT_MAILED;
685
-            $poll_mailed           = $classConstants::POLL_MAILED;
686
-        // old xoopspoll or umfrage or any clone from them
687
-        } else {
688
-            $default_poll_duration = (86400 * 10);
689
-            $poll_not_mailed       = POLL_NOTMAILED;
690
-            $poll_mailed           = POLL_MAILED;
691
-        }
674
+        case 'restart_ok':
675
+            // check security token
676
+            if (!$GLOBALS['xoopsSecurity']->check()) {
677
+                redirect_header(Request::getString('PHP_SELF', '', 'SERVER'), 2, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
678
+            }
692 679
 
693
-        $end_time = !Request::getInt('end_time', 0, 'POST');
694
-        if (0 !== $end_time) {
695
-            $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
696
-            $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
697
-        } else {
698
-            $pollObject->setVar('end_time', time() + $default_poll_duration);
699
-        }
680
+            // new xoopspoll module
681
+            if ($pollModuleHandler->getVar('version') >= 140) {
682
+                $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
683
+                $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
684
+                $poll_not_mailed       = $classConstants::POLL_NOT_MAILED;
685
+                $poll_mailed           = $classConstants::POLL_MAILED;
686
+            // old xoopspoll or umfrage or any clone from them
687
+            } else {
688
+                $default_poll_duration = (86400 * 10);
689
+                $poll_not_mailed       = POLL_NOTMAILED;
690
+                $poll_mailed           = POLL_MAILED;
691
+            }
700 692
 
701
-        $isNotify = Request::getInt('notify', 0, 'POST');
702
-        if (!empty($isNotify) && ($end_time > time())) {
703
-            // if notify, set mail status to "not mailed"
704
-            $pollObject->setVar('mail_status', $poll_not_mailed);
705
-        } else {
706
-            // if not notify, set mail status to already "mailed"
707
-            $pollObject->setVar('mail_status', $poll_mailed);
708
-        }
693
+            $end_time = !Request::getInt('end_time', 0, 'POST');
694
+            if (0 !== $end_time) {
695
+                $timezone = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
696
+                $pollObject->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
697
+            } else {
698
+                $pollObject->setVar('end_time', time() + $default_poll_duration);
699
+            }
709 700
 
710
-        // new xoopspoll module
711
-        if ($pollModuleHandler->getVar('version') >= 140) {
712
-            if (!$xpPollHandler->insert($pollObject)) {  // update the poll
713
-                xoops_error($pollObject->getHtmlErrors());
714
-                exit();
701
+            $isNotify = Request::getInt('notify', 0, 'POST');
702
+            if (!empty($isNotify) && ($end_time > time())) {
703
+                // if notify, set mail status to "not mailed"
704
+                $pollObject->setVar('mail_status', $poll_not_mailed);
705
+            } else {
706
+                // if not notify, set mail status to already "mailed"
707
+                $pollObject->setVar('mail_status', $poll_mailed);
715 708
             }
716
-            if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters
717
-                /** @var \XoopspollOptionHandler $xpOptHandler */
718
-                $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
719
-                /** @var \XoopspollLogHandler $xpLogHandler */
720
-                $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
721
-                $xpLogHandler->deleteByPollId($poll_id);
722
-                $xpOptHandler->resetCountByPollId($poll_id);
723
-                $xpPollHandler->updateCount($pollObject);
709
+
710
+            // new xoopspoll module
711
+            if ($pollModuleHandler->getVar('version') >= 140) {
712
+                if (!$xpPollHandler->insert($pollObject)) {  // update the poll
713
+                    xoops_error($pollObject->getHtmlErrors());
714
+                    exit();
715
+                }
716
+                if (Request::getInt('reset', 0, 'POST')) { // reset all vote/voter counters
717
+                    /** @var \XoopspollOptionHandler $xpOptHandler */
718
+                    $xpOptHandler = Xoopspoll\Helper::getInstance()->getHandler('Option');
719
+                    /** @var \XoopspollLogHandler $xpLogHandler */
720
+                    $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
721
+                    $xpLogHandler->deleteByPollId($poll_id);
722
+                    $xpOptHandler->resetCountByPollId($poll_id);
723
+                    $xpPollHandler->updateCount($pollObject);
724
+                }
725
+                // old xoopspoll or umfrage or any clone from them
726
+            } else {
727
+                if (!$pollObject->store()) { // update the poll
728
+                    xoops_error($pollObject->getHtmlErrors());
729
+                    exit();
730
+                }
731
+                if (Request::getInt('reset', 0, 'POST')) { // reset all logs
732
+                    $classOption = $classPoll . 'Option';
733
+                    $classLog    = $classPoll . 'Log';
734
+                    $classLog::deleteByPollId($poll_id);
735
+                    $classOption::resetCountByPollId($poll_id);
736
+                    $pollObject->updateCount();
737
+                }
724 738
             }
739
+            require_once $GLOBALS['xoops']->path('class/template.php');
740
+            xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
741
+            xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
742
+            redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
743
+            break;
744
+
745
+        case 'log':
746
+            // new xoopspoll module
747
+            if ($pollModuleHandler->getVar('version') >= 140) {
748
+                redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
725 749
             // old xoopspoll or umfrage or any clone from them
726
-        } else {
727
-            if (!$pollObject->store()) { // update the poll
728
-                xoops_error($pollObject->getHtmlErrors());
729
-                exit();
730
-            }
731
-            if (Request::getInt('reset', 0, 'POST')) { // reset all logs
732
-                $classOption = $classPoll . 'Option';
733
-                $classLog    = $classPoll . 'Log';
734
-                $classLog::deleteByPollId($poll_id);
735
-                $classOption::resetCountByPollId($poll_id);
736
-                $pollObject->updateCount();
750
+            } else {
751
+                redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
737 752
             }
738
-        }
739
-        require_once $GLOBALS['xoops']->path('class/template.php');
740
-        xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
741
-        xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
742
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
743
-        break;
744
-
745
-    case 'log':
746
-        // new xoopspoll module
747
-        if ($pollModuleHandler->getVar('version') >= 140) {
748
-            redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/main.php?op=log&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
749
-        // old xoopspoll or umfrage or any clone from them
750
-        } else {
751
-            redirect_header($GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/admin/index.php?op=log&amp;poll_id={$poll_id}"), 2, _MD_NEWBB_POLL_VIEWLOG);
752
-        }
753
-        break;
753
+            break;
754 754
 } // switch
755 755
 
756 756
 // irmtfan move to footer.php
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 // rewrite by irmtfan and zyspec to accept xoopspoll 1.4 and all old xoopspoll and umfrage versions and all clones
23 23
 
24
-require_once __DIR__ . '/header.php';
24
+require_once __DIR__.'/header.php';
25 25
 require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
26 26
 require_once $GLOBALS['xoops']->path('class/xoopslists.php');
27 27
 require_once $GLOBALS['xoops']->path('class/xoopsblock.php');
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
 if (is_object($topicObject)) {
55 55
     $forum_id = $topicObject->getVar('forum_id');
56 56
 } else {
57
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR . ': ' . _MD_NEWBB_FORUMNOEXIST);
57
+    redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_POLLMODULE_ERROR.': '._MD_NEWBB_FORUMNOEXIST);
58 58
 }
59 59
 // forum access permission
60 60
 /** @var Newbb\ForumHandler $forumHandler */
61 61
 $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
62 62
 $forumObject  = $forumHandler->get($forum_id);
63 63
 if (!$forumHandler->getPermission($forumObject)) {
64
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
64
+    redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
65 65
 }
66 66
 // topic view permission
67 67
 if (!$topicHandler->getPermission($forumObject, $topicObject->getVar('topic_status'), 'view')) {
68
-    redirect_header('viewforum.php?forum=' . $forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
68
+    redirect_header('viewforum.php?forum='.$forum_id, 2, _MD_NEWBB_NORIGHTTOVIEW);
69 69
 }
70 70
 // poll module
71 71
 $pollModuleHandler = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         $pollObject = $xpPollHandler->get($poll_id); // will create poll if poll_id = 0 exist
83 83
         // old xoopspoll or umfrage or any clone from them
84 84
     } else {
85
-        include $GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/include/constants.php');
85
+        include $GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/include/constants.php');
86 86
         $classPoll  = $topicObject->loadOldPoll();
87 87
         $pollObject = new $classPoll($poll_id); // will create poll if poll_id = 0 exist
88 88
     }
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
     case 'add':
113 113
         // new xoopspoll module
114 114
         if ($pollModuleHandler->getVar('version') >= 140) {
115
-            echo '<h4>' . _MD_NEWBB_POLL_CREATNEWPOLL . "</h4>\n";
115
+            echo '<h4>'._MD_NEWBB_POLL_CREATNEWPOLL."</h4>\n";
116 116
             $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
117 117
         // old xoopspoll or umfrage or any clone from them
118 118
         } else {
119
-            $classOption  = $classPoll . 'Option';
119
+            $classOption  = $classPoll.'Option';
120 120
             $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_CREATNEWPOLL, 'poll_form', 'polls.php', 'post', true);
121 121
             $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, is_object($GLOBALS['xoopsUser']) ? ("<a href='"
122 122
                                                                                                           . XOOPS_URL
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             $poll_form->addElement($desc_tarea);
133 133
             $currenttime = formatTimestamp(time(), 'Y-m-d H:i:s');
134 134
             $endtime     = formatTimestamp(time() + 604800, 'Y-m-d H:i:s');
135
-            $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime) . '</small>', 'end_time', 30, 19, $endtime);
135
+            $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, $currenttime).'</small>', 'end_time', 30, 19, $endtime);
136 136
             $poll_form->addElement($expire_text);
137 137
 
138 138
             $weight_text = new \XoopsFormText(_MD_NEWBB_POLL_DISPLAYORDER, 'weight', 6, 5, 0);
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
             $poll_form->addElement($notify_yn);
146 146
 
147 147
             $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
148
-            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
148
+            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/'));
149 149
             for ($i = 0; $i < 10; ++$i) {
150 150
                 $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
151 151
                 $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
152 152
                 $option_tray->addElement($option_text);
153 153
                 $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
154 154
                 $color_select->addOptionArray($barcolor_array);
155
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/" . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars", "", "' . XOOPS_URL . "\")'");
155
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/".$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars", "", "'.XOOPS_URL."\")'");
156 156
                 $color_label = new \XoopsFormLabel('', "<img src='"
157 157
                                                       . XOOPS_URL
158 158
                                                       . '/modules/'
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
175 175
             $poll_form->addElement(new \XoopsFormHidden('user_id', is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0));
176 176
             $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
177
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . '</h4>';
177
+            echo '<h4>'._MD_NEWBB_POLL_POLLCONF.'</h4>';
178 178
             $poll_form->display();
179 179
         }
180 180
         break; // op: add
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
     case 'edit':
183 183
         // new xoopspoll module
184 184
         if ($pollModuleHandler->getVar('version') >= 140) {
185
-            echo '<h4>' . _MD_NEWBB_POLL_EDITPOLL . "</h4>\n";
185
+            echo '<h4>'._MD_NEWBB_POLL_EDITPOLL."</h4>\n";
186 186
             $pollObject->renderForm(Request::getString('PHP_SELF', '', 'SERVER'), 'post', ['topic_id' => $topic_id]);
187 187
         // old xoopspoll or umfrage or any clone from them
188 188
         } else {
189
-            $classOption  = $classPoll . 'Option';
189
+            $classOption  = $classPoll.'Option';
190 190
             $poll_form    = new \XoopsThemeForm(_MD_NEWBB_POLL_EDITPOLL, 'poll_form', 'polls.php', 'post', true);
191
-            $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $pollObject->getVar('user_id') . "'>" . newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>');
191
+            $author_label = new \XoopsFormLabel(_MD_NEWBB_POLL_AUTHOR, "<a href='".XOOPS_URL.'/userinfo.php?uid='.$pollObject->getVar('user_id')."'>".newbbGetUnameFromId($pollObject->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']).'</a>');
192 192
             $poll_form->addElement($author_label);
193 193
             $question_text = new \XoopsFormText(_MD_NEWBB_POLL_POLLQUESTION, 'question', 50, 255, $pollObject->getVar('question', 'E'));
194 194
             $poll_form->addElement($question_text);
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
             $poll_form->addElement($desc_tarea);
197 197
             $date = formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s'); // important "Y-m-d H:i:s" use in jdf function
198 198
             if (!$pollObject->hasExpired()) {
199
-                $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date);
199
+                $expire_text = new \XoopsFormText(_MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')).'</small>', 'end_time', 20, 19, $date);
200 200
                 $poll_form->addElement($expire_text);
201 201
             } else {
202 202
                 // irmtfan full URL - add topic_id
203 203
                 $restart_label = new \XoopsFormLabel(
204 204
                     _MD_NEWBB_POLL_EXPIRATION,
205
-                                                    sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_RESTART . '</a>'
205
+                                                    sprintf(_MD_NEWBB_POLL_EXPIREDAT, $date)."<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>"._MD_NEWBB_POLL_RESTART.'</a>'
206 206
                 );
207 207
                 $poll_form->addElement($restart_label);
208 208
             }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             $poll_form->addElement($weight_text);
211 211
             $multi_yn = new \XoopsFormRadioYN(_MD_NEWBB_POLL_ALLOWMULTI, 'multiple', $pollObject->getVar('multiple'));
212 212
             $poll_form->addElement($multi_yn);
213
-            $options_arr  =& $classOption::getAllByPollId($poll_id);
213
+            $options_arr  = & $classOption::getAllByPollId($poll_id);
214 214
             $notify_value = 1;
215 215
             if (0 !== $pollObject->getVar('mail_status')) {
216 216
                 $notify_value = 0;
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
                 $option_tray->addElement(new \XoopsFormHidden('option_id[]', $option->getVar('option_id')));
227 227
                 $color_select = new \XoopsFormSelect('', 'option_color[{$i}]', $option->getVar('option_color'));
228 228
                 $color_select->addOptionArray($barcolor_array);
229
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
229
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[".$i."]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
230 230
                 $color_label = new \XoopsFormLabel('', "<img src='"
231
-                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/" . $option->getVar('option_color', 'E'))
231
+                                                      . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/".$option->getVar('option_color', 'E'))
232 232
                                                       . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
233 233
                 $option_tray->addElement($color_select);
234 234
                 $option_tray->addElement($color_label);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
                 ++$i;
237 237
             }
238 238
             // irmtfan full URL
239
-            $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_NEWBB_POLL_ADDMORE . '</a>');
239
+            $more_label = new \XoopsFormLabel('', "<br><a href='".XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname')."/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>"._MD_NEWBB_POLL_ADDMORE.'</a>');
240 240
             $option_tray->addElement($more_label);
241 241
             $poll_form->addElement($option_tray);
242 242
             $poll_form->addElement(new \XoopsFormHidden('op', 'update'));
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
             $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
245 245
             $poll_form->addElement(new \XoopsFormButtonTray('poll_submit', _SUBMIT, 'submit'));
246 246
 
247
-            echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
247
+            echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
248 248
             $poll_form->display();
249 249
         }
250 250
         break; // op: edit
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             $option_empty = true;
263 263
             if (!Request::getString('option_text', '', 'POST')) {
264 264
                 // irmtfan - issue with javascript:history.go(-1)
265
-                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
265
+                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
266 266
             }
267 267
             $option_text = Request::getArray('option_text', '', 'POST');
268 268
             foreach ($option_text as $optxt) {
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
             }
274 274
             if ($option_empty) {
275 275
                 // irmtfan - issue with javascript:history.go(-1)
276
-                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
276
+                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
277 277
             }
278 278
             $pollObject->setVar('question', Request::getString('question', '', 'POST'));
279 279
             $pollObject->setVar('description', Request::getString('description', '', 'POST'));
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             }
305 305
             $i            = 0;
306 306
             $option_color = Request::getArray('option_color', null, 'POST');
307
-            $classOption  = $classPoll . 'Option';
307
+            $classOption  = $classPoll.'Option';
308 308
             foreach ($option_text as $optxt) {
309 309
                 $optxt = trim($optxt);
310 310
                 /** @var XoopspollOption $optionObject */
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
             } else {
332 332
                 redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
333 333
             }
334
-            break;// op: save
334
+            break; // op: save
335 335
         }
336 336
     // no break
337 337
     case 'update':
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         $option_string = is_array($option_text) ? implode('', $option_text) : $option_text;
345 345
         $option_string = trim($option_string);
346 346
         if ('' === $option_string) {
347
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
347
+            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
348 348
         }
349 349
 
350 350
         // new xoopspoll module
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
             /** @var \XoopspollLogHandler $xpLogHandler */
355 355
             $xpLogHandler = Xoopspoll\Helper::getInstance()->getHandler('Log');
356 356
             //            $classRequest = ucfirst($GLOBALS['xoopsModuleConfig']["poll_module"]) . "Request";
357
-            $classConstants   = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
357
+            $classConstants   = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']).'Constants';
358 358
             $notify           = Request::getInt('notify', $classConstants::NOTIFICATION_ENABLED, 'POST');
359 359
             $currentTimestamp = time();
360 360
             //$xuEndTimestamp   = method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime(Request::getString('xu_end_time', null, 'POST'))
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
             $i            = 0;
464 464
             $option_id    = Request::getArray('option_id', null, 'POST');
465 465
             $option_color = Request::getArray('option_color', null, 'POST');
466
-            $classOption  = $classPoll . 'Option';
467
-            $classLog     = $classPoll . 'Log';
466
+            $classOption  = $classPoll.'Option';
467
+            $classLog     = $classPoll.'Log';
468 468
             foreach ($option_id as $opid) {
469 469
                 $optionObject    = new $classOption($opid);
470 470
                 $option_text[$i] = trim($option_text[$i]);
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
         } else {
496 496
             redirect_header("viewtopic.php?topic_id={$topic_id}", 2, _MD_NEWBB_POLL_DBUPDATED);
497 497
         }
498
-        break;// op: save | update
498
+        break; // op: save | update
499 499
 
500 500
     case 'addmore':
501 501
         $question = $pollObject->getVar('question');
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
         // old xoopspoll or umfrage or any clone from them
510 510
         } else {
511 511
             $option_tray    = new \XoopsFormElementTray(_MD_NEWBB_POLL_POLLOPTIONS, '');
512
-            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/' . $GLOBALS['xoopsModuleConfig']['poll_module'] . '/assets/images/colorbars/'));
512
+            $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path('modules/'.$GLOBALS['xoopsModuleConfig']['poll_module'].'/assets/images/colorbars/'));
513 513
             for ($i = 0; $i < 10; ++$i) {
514 514
                 $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);
515 515
                 $option_text = new \XoopsFormText('', 'option_text[]', 50, 255);
516 516
                 $option_tray->addElement($option_text);
517 517
                 $color_select = new \XoopsFormSelect('', "option_color[{$i}]", $current_bar);
518 518
                 $color_select->addOptionArray($barcolor_array);
519
-                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");
519
+                $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars\", \"\", \"".XOOPS_URL."\")'");
520 520
                 $color_label = new \XoopsFormLabel('', "<img src='"
521 521
                                                       . $GLOBALS['xoops']->url("modules/{$GLOBALS['xoopsModuleConfig']['poll_module']}/assets/images/colorbars/{$current_bar}")
522 522
                                                       . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt='' /><br>");
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         $poll_form->addElement(new \XoopsFormHidden('topic_id', $topic_id));
535 535
         $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
536 536
 
537
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
537
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
538 538
         $poll_form->display();
539 539
         break;
540 540
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
         $option_string = trim($option_string);
550 550
         if ('' === $option_string) {
551 551
             // irmtfan - issue with javascript:history.go(-1)
552
-            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED . ': ' . _MD_NEWBB_POLL_POLLOPTIONS . ' !');
552
+            redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_NEWBB_ERROROCCURED.': '._MD_NEWBB_POLL_POLLOPTIONS.' !');
553 553
         }
554 554
         $i            = 0;
555 555
         $option_color = Request::getArray('option_color', null, 'POST');
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                     $xpOptHandler->insert($optionObject);
567 567
                 // old xoopspoll or umfrage or any clone from them
568 568
                 } else {
569
-                    $classOption  = $classPoll . 'Option';
569
+                    $classOption  = $classPoll.'Option';
570 570
                     $optionObject = new $classOption();
571 571
                     $optionObject->setVar('option_text', $optxt);
572 572
                     $optionObject->setVar('poll_id', $poll_id);
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
         break;
585 585
 
586 586
     case 'delete':
587
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
587
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
588 588
         xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_NEWBB_POLL_RUSUREDEL, $pollObject->getVar('question')));
589 589
         break;
590 590
 
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
             // old xoopspoll or umfrage or any clone from them
609 609
         } else {
610 610
             $status      = $pollObject->delete();
611
-            $classOption = $classPoll . 'Option';
612
-            $classLog    = $classPoll . 'Log';
611
+            $classOption = $classPoll.'Option';
612
+            $classLog    = $classPoll.'Log';
613 613
             if (false !== $status) {
614 614
                 $classOption::deleteByPollId($poll_id);
615 615
                 $classLog::deleteByPollId($poll_id);
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
             xoops_error($msg);
637 637
             break;
638 638
         }
639
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
639
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
640 640
         break;
641 641
 
642 642
     case 'restart':
643 643
         // new xoopspoll module
644 644
         if ($pollModuleHandler->getVar('version') >= 140) {
645
-            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
645
+            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']).'Constants';
646 646
             $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
647 647
         // old xoopspoll or umfrage or any clone from them
648 648
         } else {
@@ -650,10 +650,10 @@  discard block
 block discarded – undo
650 650
         }
651 651
         $poll_form   = new \XoopsThemeForm(_MD_NEWBB_POLL_RESTARTPOLL, 'poll_form', 'polls.php', 'post', true);
652 652
         $expire_text = new \XoopsFormText(
653
-            _MD_NEWBB_POLL_EXPIRATION . '<br><small>' . _MD_NEWBB_POLL_FORMAT . '<br>' . sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '<br>' . sprintf(
653
+            _MD_NEWBB_POLL_EXPIRATION.'<br><small>'._MD_NEWBB_POLL_FORMAT.'<br>'.sprintf(_MD_NEWBB_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')).'<br>'.sprintf(
654 654
             _MD_NEWBB_POLL_EXPIREDAT,
655 655
                                                                                                                                                                                                                      formatTimestamp($pollObject->getVar('end_time'), 'Y-m-d H:i:s')
656
-        ) . '</small>',
656
+        ).'</small>',
657 657
                                          'end_time',
658 658
             20,
659 659
             19,
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
         $poll_form->addElement(new \XoopsFormHidden('poll_id', $poll_id));
668 668
         $poll_form->addElement(new \XoopsFormButton('', 'poll_submit', _MD_NEWBB_POLL_RESTART, 'submit'));
669 669
 
670
-        echo '<h4>' . _MD_NEWBB_POLL_POLLCONF . "</h4>\n";
670
+        echo '<h4>'._MD_NEWBB_POLL_POLLCONF."</h4>\n";
671 671
         $poll_form->display();
672 672
         break;
673 673
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
         // new xoopspoll module
681 681
         if ($pollModuleHandler->getVar('version') >= 140) {
682
-            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']) . 'Constants';
682
+            $classConstants        = ucfirst($GLOBALS['xoopsModuleConfig']['poll_module']).'Constants';
683 683
             $default_poll_duration = $classConstants::DEFAULT_POLL_DURATION;
684 684
             $poll_not_mailed       = $classConstants::POLL_NOT_MAILED;
685 685
             $poll_mailed           = $classConstants::POLL_MAILED;
@@ -729,8 +729,8 @@  discard block
 block discarded – undo
729 729
                 exit();
730 730
             }
731 731
             if (Request::getInt('reset', 0, 'POST')) { // reset all logs
732
-                $classOption = $classPoll . 'Option';
733
-                $classLog    = $classPoll . 'Log';
732
+                $classOption = $classPoll.'Option';
733
+                $classLog    = $classPoll.'Log';
734 734
                 $classLog::deleteByPollId($poll_id);
735 735
                 $classOption::resetCountByPollId($poll_id);
736 736
                 $pollObject->updateCount();
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
         require_once $GLOBALS['xoops']->path('class/template.php');
740 740
         xoops_template_clear_module_cache($xoopsModule->getVar('mid'));
741 741
         xoops_template_clear_module_cache($pollModuleHandler->getVar('mid'));
742
-        redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
742
+        redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id={$topic_id}", 1, _MD_NEWBB_POLL_DBUPDATED);
743 743
         break;
744 744
 
745 745
     case 'log':
@@ -754,5 +754,5 @@  discard block
 block discarded – undo
754 754
 } // switch
755 755
 
756 756
 // irmtfan move to footer.php
757
-require_once __DIR__ . '/footer.php';
757
+require_once __DIR__.'/footer.php';
758 758
 include $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 $xoopsTpl->assign('notifyicon', $category_icon);
221 221
 
222 222
 $xoopsTpl->assign([
223
-                      'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
224
-                      'index_desc'  => _MD_NEWBB_TOSTART
225
-                  ]);
223
+                        'index_title' => sprintf(_MD_NEWBB_WELCOME, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES)),
224
+                        'index_desc'  => _MD_NEWBB_TOSTART
225
+                    ]);
226 226
 
227 227
 /* display user stats */
228 228
 if (!empty($GLOBALS['xoopsModuleConfig']['statistik_enabled'])) {
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
     $xoopsTpl->assign('rss_button', newbbDisplayImage('rss', 'RSS feed'));
281 281
 }
282 282
 $xoopsTpl->assign([
283
-                      'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS),
284
-                      'img_forum'     => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS),
285
-                      'img_subforum'  => newbbDisplayImage('subforum')
286
-                  ]);
283
+                        'img_forum_new' => newbbDisplayImage('forum_new', _MD_NEWBB_NEWPOSTS),
284
+                        'img_forum'     => newbbDisplayImage('forum', _MD_NEWBB_NONEWPOSTS),
285
+                        'img_subforum'  => newbbDisplayImage('subforum')
286
+                    ]);
287 287
 
288 288
 // irmtfan move to footer.php
289 289
 require_once __DIR__ . '/footer.php';
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use Xmf\Request;
13 13
 use XoopsModules\Newbb;
14 14
 
15
-require_once __DIR__ . '/header.php';
15
+require_once __DIR__.'/header.php';
16 16
 
17 17
 /* deal with marks */
18 18
 if (Request::getInt('mark_read', 0)) {
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
         $markvalue  = 0;
24 24
         $markresult = _MD_NEWBB_MARK_UNREAD;
25 25
     }
26
-    require_once __DIR__ . '/include/functions.read.php';
26
+    require_once __DIR__.'/include/functions.read.php';
27 27
     newbbSetReadForum($markvalue);
28
-    $url = XOOPS_URL . '/modules/newbb/index.php';
29
-    redirect_header($url, 2, _MD_NEWBB_ALL_FORUM_MARKED . ' ' . $markresult);
28
+    $url = XOOPS_URL.'/modules/newbb/index.php';
29
+    redirect_header($url, 2, _MD_NEWBB_ALL_FORUM_MARKED.' '.$markresult);
30 30
 }
31 31
 
32
-$viewcat = Request::getInt('cat', 0, 'GET');//TODO mb check if this is GET or POST?
32
+$viewcat = Request::getInt('cat', 0, 'GET'); //TODO mb check if this is GET or POST?
33 33
 ///** @var Newbb\CategoryHandler $categoryHandler */
34 34
 //$categoryHandler = Newbb\Helper::getInstance()->getHandler('Category');
35 35
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
         $categories[$viewcat] = $categoryObject->getValues();
45 45
     }
46 46
     $forum_index_title = sprintf(_MD_NEWBB_FORUMINDEX, htmlspecialchars($GLOBALS['xoopsConfig']['sitename'], ENT_QUOTES));
47
-    $xoops_pagetitle   = $categoryObject->getVar('cat_title') . ' [' . $xoopsModule->getVar('name') . ']';
47
+    $xoops_pagetitle   = $categoryObject->getVar('cat_title').' ['.$xoopsModule->getVar('name').']';
48 48
 }
49 49
 
50 50
 if (0 === count($categories)) {
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 //$xoopsOption['xoops_module_header'] = $xoops_module_header;
58 58
 // irmtfan include header.php after defining $xoopsOption['template_main']
59 59
 require_once $GLOBALS['xoops']->path('header.php');
60
-require_once __DIR__ . '/include/functions.render.php';
60
+require_once __DIR__.'/include/functions.render.php';
61 61
 /* rss feed */
62 62
 // irmtfan new method
63 63
 if (!empty($GLOBALS['xoopsModuleConfig']['rss_enable'])) {
64 64
     $xoopsTpl->assign('xoops_module_header', '
65
-    <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name') . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/rss.php" />
65
+    <link rel="alternate" type="application/xml+rss" title="' . $xoopsModule->getVar('name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/rss.php" />
66 66
     ' . @$xoopsTpl->get_template_vars('xoops_module_header'));
67 67
 }
68 68
 $xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 
90 90
 if (!empty($forums_allowed)) {
91 91
     $crit_top = new \CriteriaCompo(new \Criteria('parent_forum', 0));
92
-    $crit_top->add(new \Criteria('cat_id', '(' . implode(', ', array_keys($categories)) . ')', 'IN'));
93
-    $crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN'));
92
+    $crit_top->add(new \Criteria('cat_id', '('.implode(', ', array_keys($categories)).')', 'IN'));
93
+    $crit_top->add(new \Criteria('forum_id', '('.implode(', ', $forums_allowed).')', 'IN'));
94 94
     $forums_top = $forumHandler->getIds($crit_top);
95 95
 }
96 96
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 if ('hidden' === $GLOBALS['xoopsModuleConfig']['subforum_display'] || 0 === count($forums_top)) {
99 99
     $forums_sub = [];
100 100
 } else {
101
-    $crit_sub = new \CriteriaCompo(new \Criteria('parent_forum', '(' . implode(', ', $forums_top) . ')', 'IN'));
102
-    $crit_sub->add(new \Criteria('forum_id', '(' . implode(', ', $forums_allowed) . ')', 'IN'));
101
+    $crit_sub = new \CriteriaCompo(new \Criteria('parent_forum', '('.implode(', ', $forums_top).')', 'IN'));
102
+    $crit_sub->add(new \Criteria('forum_id', '('.implode(', ', $forums_allowed).')', 'IN'));
103 103
     $forums_sub = $forumHandler->getIds($crit_sub);
104 104
 }
105 105
 
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
 $newposts         = 0;
112 112
 $deleteposts      = 0;
113 113
 if (0 !== count($forums_available)) {
114
-    $crit_forum = new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN');
114
+    $crit_forum = new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN');
115 115
     $crit_forum->setSort('cat_id ASC, parent_forum ASC, forum_order');
116 116
     $crit_forum->setOrder('ASC');
117 117
     $forums       = $forumHandler->getAll($crit_forum, null, false);
118 118
     $newtopics    = $forumHandler->getTopicCount($forums, 0, 'pending');
119 119
     $deletetopics = $forumHandler->getTopicCount($forums, 0, 'deleted');
120 120
     $forums_array = $forumHandler->display($forums, $GLOBALS['xoopsModuleConfig']['length_title_index'], $GLOBALS['xoopsModuleConfig']['count_subforum']);
121
-    $crit         = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN'));
121
+    $crit         = new \CriteriaCompo(new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN'));
122 122
     $crit->add(new \Criteria('approved', '-1'));
123 123
     $deleteposts = $postHandler->getCount($crit);
124
-    $crit        = new \CriteriaCompo(new \Criteria('forum_id', '(' . implode(', ', $forums_available) . ')', 'IN'));
124
+    $crit        = new \CriteriaCompo(new \Criteria('forum_id', '('.implode(', ', $forums_available).')', 'IN'));
125 125
     $crit->add(new \Criteria('approved', '0'));
126 126
     $newposts = $postHandler->getCount($crit);
127 127
 }
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
     $forums = [];
169 169
     $onecat = $categories[$id];
170 170
 
171
-    $cat_element_id = 'cat_' . $onecat['cat_id'];
171
+    $cat_element_id = 'cat_'.$onecat['cat_id'];
172 172
     $expand         = (count($toggles) > 0) ? (in_array($cat_element_id, $toggles) ? false : true) : true;
173 173
     // START irmtfan to improve newbbDisplayImage
174 174
     if ($expand) {
175
-        $cat_display      = 'block';        //irmtfan move semicolon
175
+        $cat_display      = 'block'; //irmtfan move semicolon
176 176
         $cat_icon_display = 'minus';
177 177
         $cat_alt          = _MD_NEWBB_HIDE;
178 178
     } else {
179
-        $cat_display      = 'none';        //irmtfan move semicolon
179
+        $cat_display      = 'none'; //irmtfan move semicolon
180 180
         $cat_icon_display = 'plus';
181 181
         $cat_alt          = _MD_NEWBB_SEE;
182 182
     }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     $cat_image = '';
200 200
     $cat_image = $onecat['cat_image'];
201 201
     if ('' !== $cat_image && 'blank.gif' !== $cat_image && $cat_image) {
202
-        $cat_image = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/assets/images/category/' . $cat_image;
202
+        $cat_image = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/assets/images/category/'.$cat_image;
203 203
     }
204 204
     $category_array[] = [
205 205
         'cat_id'           => $onecat['cat_id'],
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 $stats = $statsHandler->getStats(array_merge([0], $forums_available));
251 251
 $xoopsTpl->assign_by_ref('stats', $stats);
252 252
 $xoopsTpl->assign('subforum_display', $GLOBALS['xoopsModuleConfig']['subforum_display']);
253
-$xoopsTpl->assign('mark_read', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=1');
254
-$xoopsTpl->assign('mark_unread', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/index.php?mark_read=2');
253
+$xoopsTpl->assign('mark_read', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/index.php?mark_read=1');
254
+$xoopsTpl->assign('mark_unread', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/index.php?mark_read=2');
255 255
 
256
-$xoopsTpl->assign('all_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=all');
257
-$xoopsTpl->assign('post_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=all');
258
-$xoopsTpl->assign('newpost_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/viewpost.php?status=new');
259
-$xoopsTpl->assign('digest_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=digest');
260
-$xoopsTpl->assign('unreplied_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unreplied');
261
-$xoopsTpl->assign('unread_link', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/list.topic.php?status=unread');
256
+$xoopsTpl->assign('all_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=all');
257
+$xoopsTpl->assign('post_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewpost.php?status=all');
258
+$xoopsTpl->assign('newpost_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/viewpost.php?status=new');
259
+$xoopsTpl->assign('digest_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=digest');
260
+$xoopsTpl->assign('unreplied_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=unreplied');
261
+$xoopsTpl->assign('unread_link', XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname', 'n').'/list.topic.php?status=unread');
262 262
 $xoopsTpl->assign('menumode', $menumode);
263 263
 $xoopsTpl->assign('menumode_other', $menumode_other);
264 264
 
@@ -286,5 +286,5 @@  discard block
 block discarded – undo
286 286
                   ]);
287 287
 
288 288
 // irmtfan move to footer.php
289
-require_once __DIR__ . '/footer.php';
289
+require_once __DIR__.'/footer.php';
290 290
 include $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
blocks/list_topic.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -20,16 +20,16 @@  discard block
 block discarded – undo
20 20
 define('LIST_TOPIC_DEFINED', true);
21 21
 
22 22
 //require_once dirname(__DIR__) . '/include/functions.ini.php';
23
-require_once dirname(__DIR__) . '/class/TopicRenderer.php';
24
-require_once dirname(__DIR__) . '/footer.php'; // to include js/style files like validate function
23
+require_once dirname(__DIR__).'/class/TopicRenderer.php';
24
+require_once dirname(__DIR__).'/footer.php'; // to include js/style files like validate function
25 25
 
26 26
 xoops_loadLanguage('main', 'newbb');
27 27
 
28
-require_once __DIR__ . '/../include/functions.config.php';
29
-require_once __DIR__ . '/../include/functions.time.php';
30
-require_once __DIR__ . '/../include/functions.session.php';
31
-require_once __DIR__ . '/../include/functions.render.php';
32
-require_once __DIR__ . '/../include/functions.user.php';
28
+require_once __DIR__.'/../include/functions.config.php';
29
+require_once __DIR__.'/../include/functions.time.php';
30
+require_once __DIR__.'/../include/functions.session.php';
31
+require_once __DIR__.'/../include/functions.render.php';
32
+require_once __DIR__.'/../include/functions.user.php';
33 33
 
34 34
 // options[0] - Status in WHERE claus: all(by default), sticky, digest,lock, poll, voted, viewed, replied, read, (UN_) , active, pending, deleted (admin) (It is  multi-select)
35 35
 // options[1] - Uid in WHERE claus: uid of the topic poster : -1 - all users (by default)
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $topicRenderer->force = true; // force against static vars for parse
60 60
 
61 61
     $topicRenderer->is_multiple = true; // is it for multiple forums
62
-    $topicRenderer->config      =& $newbbConfig; // get all configs
62
+    $topicRenderer->config      = & $newbbConfig; // get all configs
63 63
     if (!empty($options[6])) {
64 64
         $topicRenderer->config['topics_per_page'] = (int)$options[6]; // number of topics (items) to display
65 65
     }
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
     $topicPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER);
122 122
     $topicPosterRadioEle->addOption((-1 !== $options[1]) ? $options[1] : 0, _SELECT); // if no user in selection box it select uid=0 anon users
123 123
     $topicPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[1]'); el.disabled=(this.id == 'options[1]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
124
-    $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true);// show $limit = 200 users when no user is selected;
125
-    $topicPosterEle       = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render() . $topicPosterSelectEle->render());
124
+    $topicPosterSelectEle = new \XoopsFormSelectUser(_MB_NEWBB_AUTHOR, 'options[1]', true, explode(',', $options[1]), 5, true); // show $limit = 200 users when no user is selected;
125
+    $topicPosterEle       = new \XoopsFormLabel(_MB_NEWBB_AUTHOR, $topicPosterRadioEle->render().$topicPosterSelectEle->render());
126 126
 
127 127
     // lastposter element
128 128
     $lastPosterRadioEle = new \XoopsFormRadio(_MD_NEWBB_POSTER, 'options[2]', $options[2]);
129 129
     $lastPosterRadioEle->addOption(-1, _MD_NEWBB_TOTALUSER);
130 130
     $lastPosterRadioEle->addOption((-1 !== $options[2]) ? $options[2] : 0, _SELECT); // if no user in selection box it select uid=1
131 131
     $lastPosterRadioEle->setExtra("onchange=\"var el=document.getElementById('options[2]'); el.disabled=(this.id == 'options[2]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
132
-    $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true);// show $limit = 200 users when no user is selected;
133
-    $lastPosterEle       = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render() . $lastPosterSelectEle->render());
132
+    $lastPosterSelectEle = new \XoopsFormSelectUser(_MD_NEWBB_POSTER, 'options[2]', true, explode(',', $options[2]), 5, true); // show $limit = 200 users when no user is selected;
133
+    $lastPosterEle       = new \XoopsFormLabel(_MD_NEWBB_POSTER, $lastPosterRadioEle->render().$lastPosterSelectEle->render());
134 134
 
135 135
     // type element
136 136
     $types   = $topicRenderer->getTypes(); // get all available types in all forums
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
 
181 181
     //  forum element
182 182
     $optionsForum = explode(',', $options[12]);
183
-    require_once __DIR__ . '/../include/functions.forum.php';
183
+    require_once __DIR__.'/../include/functions.forum.php';
184 184
     /** @var Newbb\ForumHandler $forumHandler */
185 185
     $forumHandler = Newbb\Helper::getInstance()->getHandler('Forum');
186 186
     //get forum Ids by values. parse positive values to forum IDs and negative values to category IDs. value=0 => all valid forums
187 187
     // Get accessible forums
188 188
     $accessForums = $forumHandler->getIdsByValues(array_map('intval', $optionsForum));
189 189
     $isAll        = (0 === count($optionsForum) || empty($optionsForum[0]));
190
-    $forumSel     = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">";// if user dont select any it select "0"
191
-    $forumSel     .= '<option value="0" ';
190
+    $forumSel     = "<select name=\"options[12][]\" multiple=\"multiple\" onchange = \"validate('options[12][]','select', true)\">"; // if user dont select any it select "0"
191
+    $forumSel .= '<option value="0" ';
192 192
     if ($isAll) {
193
-        $forumSel     .= ' selected';
193
+        $forumSel .= ' selected';
194 194
         $accessForums = null; // just select _ALL option
195 195
     }
196
-    $forumSel .= '>' . _ALL . '</option>';
196
+    $forumSel .= '>'._ALL.'</option>';
197 197
     $forumSel .= newbbForumSelectBox($accessForums, 'access', false); //$accessForums, $permission = "access", $delimitorCategory = false
198 198
     $forumSel .= '</select>';
199 199
     $forumEle = new \XoopsFormLabel(_MB_NEWBB_FORUMLIST, $forumSel);
Please login to merge, or discard this patch.
action.post.php 2 patches
Switch Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -46,179 +46,179 @@
 block discarded – undo
46 46
 }
47 47
 
48 48
 switch ($op) {
49
-    case 'restore':
50
-        $post_id = array_values($post_id);
51
-        sort($post_id);
52
-        $topics = [];
53
-        $forums = [];
54
-        foreach ($post_id as $post) {
55
-            $postObject = $postHandler->get($post);
56
-            if ($postObject->getVar('topic_id') < 1) {
57
-                continue;
49
+        case 'restore':
50
+            $post_id = array_values($post_id);
51
+            sort($post_id);
52
+            $topics = [];
53
+            $forums = [];
54
+            foreach ($post_id as $post) {
55
+                $postObject = $postHandler->get($post);
56
+                if ($postObject->getVar('topic_id') < 1) {
57
+                    continue;
58
+                }
59
+
60
+                $postHandler->approve($postObject, true);
61
+                $topics[$postObject->getVar('topic_id')] = 1;
62
+                $forums[$postObject->getVar('forum_id')] = 1;
63
+                unset($postObject);
64
+            }
65
+            foreach (array_keys($topics) as $topic) {
66
+                $topicHandler->synchronization($topic);
67
+            }
68
+            foreach (array_keys($forums) as $forum) {
69
+                $forumHandler->synchronization($forum);
70
+            }
71
+            break;
72
+        case 'approve':
73
+            $post_id = array_values($post_id);
74
+            sort($post_id);
75
+            $topics      = [];
76
+            $forums      = [];
77
+            $criteria    = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN');
78
+            $postsObject = $postHandler->getObjects($criteria, true);
79
+            foreach ($post_id as $post) {
80
+                /** @var Newbb\Post $postObject */
81
+                $postObject = $postsObject[$post];
82
+                if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) {
83
+                    continue;
84
+                }
85
+                $postHandler->approve($postObject);
86
+                $topics[$postObject->getVar('topic_id')] = $post;
87
+                $forums[$postObject->getVar('forum_id')] = 1;
88
+            }
89
+            foreach (array_keys($topics) as $topic) {
90
+                $topicHandler->synchronization($topic);
91
+            }
92
+            foreach (array_keys($forums) as $forum) {
93
+                $forumHandler->synchronization($forum);
58 94
             }
59 95
 
60
-            $postHandler->approve($postObject, true);
61
-            $topics[$postObject->getVar('topic_id')] = 1;
62
-            $forums[$postObject->getVar('forum_id')] = 1;
63
-            unset($postObject);
64
-        }
65
-        foreach (array_keys($topics) as $topic) {
66
-            $topicHandler->synchronization($topic);
67
-        }
68
-        foreach (array_keys($forums) as $forum) {
69
-            $forumHandler->synchronization($forum);
70
-        }
71
-        break;
72
-    case 'approve':
73
-        $post_id = array_values($post_id);
74
-        sort($post_id);
75
-        $topics      = [];
76
-        $forums      = [];
77
-        $criteria    = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN');
78
-        $postsObject = $postHandler->getObjects($criteria, true);
79
-        foreach ($post_id as $post) {
80
-            /** @var Newbb\Post $postObject */
81
-            $postObject = $postsObject[$post];
82
-            if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) {
83
-                continue;
96
+            if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) {
97
+                break;
98
+            }
99
+
100
+            $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN');
101
+            $topic_list     = $topicHandler->getList($criteria_topic, true);
102
+
103
+            $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
104
+            $forum_list     = $forumHandler->getList($criteria_forum);
105
+
106
+            require_once __DIR__ . '/include/notification.inc.php';
107
+            /** @var \XoopsNotificationHandler $notificationHandler */
108
+            $notificationHandler = xoops_getHandler('notification');
109
+            foreach ($post_id as $post) {
110
+                $tags = [];
111
+                /** @var Newbb\Post[] $postsObject [$post] */
112
+                $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')];
113
+                $tags['THREAD_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&amp;forum=' . $postsObject[$post]->getVar('forum_id');
114
+                $tags['FORUM_NAME']  = $forum_list[$postsObject[$post]->getVar('forum_id')];
115
+                $tags['FORUM_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id');
116
+                $tags['POST_URL']    = $tags['THREAD_URL'] . '#forumpost' . $post;
117
+                $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags);
118
+                $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags);
119
+                $notificationHandler->triggerEvent('global', 0, 'new_post', $tags);
120
+                $tags['POST_CONTENT'] = $postsObject[$post]->getVar('post_text');
121
+                $tags['POST_NAME']    = $postsObject[$post]->getVar('subject');
122
+                $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags);
123
+                $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_fullpost', $tags);
84 124
             }
85
-            $postHandler->approve($postObject);
86
-            $topics[$postObject->getVar('topic_id')] = $post;
87
-            $forums[$postObject->getVar('forum_id')] = 1;
88
-        }
89
-        foreach (array_keys($topics) as $topic) {
90
-            $topicHandler->synchronization($topic);
91
-        }
92
-        foreach (array_keys($forums) as $forum) {
93
-            $forumHandler->synchronization($forum);
94
-        }
95
-
96
-        if (empty($GLOBALS['xoopsModuleConfig']['notification_enabled'])) {
97 125
             break;
98
-        }
99
-
100
-        $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN');
101
-        $topic_list     = $topicHandler->getList($criteria_topic, true);
102
-
103
-        $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
104
-        $forum_list     = $forumHandler->getList($criteria_forum);
105
-
106
-        require_once __DIR__ . '/include/notification.inc.php';
107
-        /** @var \XoopsNotificationHandler $notificationHandler */
108
-        $notificationHandler = xoops_getHandler('notification');
109
-        foreach ($post_id as $post) {
110
-            $tags = [];
111
-            /** @var Newbb\Post[] $postsObject [$post] */
112
-            $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')];
113
-            $tags['THREAD_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&amp;forum=' . $postsObject[$post]->getVar('forum_id');
114
-            $tags['FORUM_NAME']  = $forum_list[$postsObject[$post]->getVar('forum_id')];
115
-            $tags['FORUM_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id');
116
-            $tags['POST_URL']    = $tags['THREAD_URL'] . '#forumpost' . $post;
117
-            $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags);
118
-            $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags);
119
-            $notificationHandler->triggerEvent('global', 0, 'new_post', $tags);
120
-            $tags['POST_CONTENT'] = $postsObject[$post]->getVar('post_text');
121
-            $tags['POST_NAME']    = $postsObject[$post]->getVar('subject');
122
-            $notificationHandler->triggerEvent('global', 0, 'new_fullpost', $tags);
123
-            $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_fullpost', $tags);
124
-        }
125
-        break;
126
-    case 'delete':
127
-        $post_id = array_values($post_id);
128
-        rsort($post_id);
129
-        $topics = [];
130
-        $forums = [];
131
-        foreach ($post_id as $post) {
132
-            $postObject = $postHandler->get($post);
133
-            if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) {
134
-                continue;
126
+        case 'delete':
127
+            $post_id = array_values($post_id);
128
+            rsort($post_id);
129
+            $topics = [];
130
+            $forums = [];
131
+            foreach ($post_id as $post) {
132
+                $postObject = $postHandler->get($post);
133
+                if (!empty($topic_id) && $topic_id !== $postObject->getVar('topic_id')) {
134
+                    continue;
135
+                }
136
+                $topics[$postObject->getVar('topic_id')] = 1;
137
+                $forums[$postObject->getVar('forum_id')] = 1;
138
+                $postHandler->delete($postObject, true);
139
+                unset($postObject);
140
+            }
141
+            foreach (array_keys($topics) as $topic) {
142
+                $topicHandler->synchronization($topic);
143
+            }
144
+            foreach (array_keys($forums) as $forum) {
145
+                $forumHandler->synchronization($forum);
135 146
             }
136
-            $topics[$postObject->getVar('topic_id')] = 1;
137
-            $forums[$postObject->getVar('forum_id')] = 1;
138
-            $postHandler->delete($postObject, true);
139
-            unset($postObject);
140
-        }
141
-        foreach (array_keys($topics) as $topic) {
142
-            $topicHandler->synchronization($topic);
143
-        }
144
-        foreach (array_keys($forums) as $forum) {
145
-            $forumHandler->synchronization($forum);
146
-        }
147
-        break;
148
-    case 'split':
149
-        /** @var Newbb\Post $postObject */
150
-        $postObject = $postHandler->get($post_id);
151
-        if (0 === count($post_id) || $postObject->isTopic()) {
152 147
             break;
153
-        }
154
-        $topic_id = $postObject->getVar('topic_id');
155
-
156
-        $newtopic = $topicHandler->create();
157
-        $newtopic->setVar('topic_title', $postObject->getVar('subject'), true);
158
-        $newtopic->setVar('topic_poster', $postObject->getVar('uid'), true);
159
-        $newtopic->setVar('forum_id', $postObject->getVar('forum_id'), true);
160
-        $newtopic->setVar('topic_time', $postObject->getVar('post_time'), true);
161
-        $newtopic->setVar('poster_name', $postObject->getVar('poster_name'), true);
162
-        $newtopic->setVar('approved', 1, true);
163
-        $topicHandler->insert($newtopic, true);
164
-        $new_topic_id = $newtopic->getVar('topic_id');
165
-
166
-        $pid = $postObject->getVar('pid');
167
-
168
-        $postObject->setVar('topic_id', $new_topic_id, true);
169
-        $postObject->setVar('pid', 0, true);
170
-        $postHandler->insert($postObject);
171
-
172
-        /* split a single post */
173
-        if (1 === $mode) {
174
-            $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
175
-            $criteria->add(new \Criteria('pid', $post_id));
176
-            $postHandler->updateAll('pid', $pid, $criteria, true);
177
-        /* split a post and its children posts */
178
-        } elseif (2 === $mode) {
179
-            require_once $GLOBALS['xoops']->path('class/xoopstree.php');
180
-            $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid');
181
-            $posts  = $mytree->getAllChildId($post_id);
182
-            if (count($posts) > 0) {
183
-                $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN');
184
-                $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true);
148
+        case 'split':
149
+            /** @var Newbb\Post $postObject */
150
+            $postObject = $postHandler->get($post_id);
151
+            if (0 === count($post_id) || $postObject->isTopic()) {
152
+                break;
185 153
             }
186
-            /* split a post and all posts coming after */
187
-        } elseif (3 === $mode) {
188
-            $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
189
-            $criteria->add(new \Criteria('post_id', $post_id, '>'));
190
-            $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true);
191
-
192
-            unset($criteria);
193
-            $criteria = new \CriteriaCompo(new \Criteria('topic_id', $new_topic_id));
194
-            $criteria->add(new \Criteria('post_id', $post_id, '>'));
195
-            $postHandler->identifierName = 'pid';
196
-            $posts                       = $postHandler->getList($criteria);
197
-
198
-            unset($criteria);
199
-            $post_update = [];
200
-            foreach ($posts as $postid => $pid) {
201
-                //                if (!in_array($pid, array_keys($posts))) {
202
-                if (!array_key_exists($pid, $posts)) {
203
-                    $post_update[] = $pid;
154
+            $topic_id = $postObject->getVar('topic_id');
155
+
156
+            $newtopic = $topicHandler->create();
157
+            $newtopic->setVar('topic_title', $postObject->getVar('subject'), true);
158
+            $newtopic->setVar('topic_poster', $postObject->getVar('uid'), true);
159
+            $newtopic->setVar('forum_id', $postObject->getVar('forum_id'), true);
160
+            $newtopic->setVar('topic_time', $postObject->getVar('post_time'), true);
161
+            $newtopic->setVar('poster_name', $postObject->getVar('poster_name'), true);
162
+            $newtopic->setVar('approved', 1, true);
163
+            $topicHandler->insert($newtopic, true);
164
+            $new_topic_id = $newtopic->getVar('topic_id');
165
+
166
+            $pid = $postObject->getVar('pid');
167
+
168
+            $postObject->setVar('topic_id', $new_topic_id, true);
169
+            $postObject->setVar('pid', 0, true);
170
+            $postHandler->insert($postObject);
171
+
172
+            /* split a single post */
173
+            if (1 === $mode) {
174
+                $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
175
+                $criteria->add(new \Criteria('pid', $post_id));
176
+                $postHandler->updateAll('pid', $pid, $criteria, true);
177
+            /* split a post and its children posts */
178
+            } elseif (2 === $mode) {
179
+                require_once $GLOBALS['xoops']->path('class/xoopstree.php');
180
+                $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid');
181
+                $posts  = $mytree->getAllChildId($post_id);
182
+                if (count($posts) > 0) {
183
+                    $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN');
184
+                    $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true);
204 185
                 }
205
-                if (!array_key_exists($pid, $posts)) {
206
-                    $post_update2[] = $pid;
186
+                /* split a post and all posts coming after */
187
+            } elseif (3 === $mode) {
188
+                $criteria = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
189
+                $criteria->add(new \Criteria('post_id', $post_id, '>'));
190
+                $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true);
191
+
192
+                unset($criteria);
193
+                $criteria = new \CriteriaCompo(new \Criteria('topic_id', $new_topic_id));
194
+                $criteria->add(new \Criteria('post_id', $post_id, '>'));
195
+                $postHandler->identifierName = 'pid';
196
+                $posts                       = $postHandler->getList($criteria);
197
+
198
+                unset($criteria);
199
+                $post_update = [];
200
+                foreach ($posts as $postid => $pid) {
201
+                    //                if (!in_array($pid, array_keys($posts))) {
202
+                    if (!array_key_exists($pid, $posts)) {
203
+                        $post_update[] = $pid;
204
+                    }
205
+                    if (!array_key_exists($pid, $posts)) {
206
+                        $post_update2[] = $pid;
207
+                    }
208
+                }
209
+                if (count($post_update)) {
210
+                    $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN');
211
+                    $postHandler->updateAll('pid', $post_id, $criteria, true);
207 212
                 }
208 213
             }
209
-            if (count($post_update)) {
210
-                $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN');
211
-                $postHandler->updateAll('pid', $post_id, $criteria, true);
212
-            }
213
-        }
214 214
 
215
-        $forum_id = $postObject->getVar('forum_id');
216
-        $topicHandler->synchronization($topic_id);
217
-        $topicHandler->synchronization($new_topic_id);
218
-        $sql    = sprintf('UPDATE "%s" SET forum_topics = forum_topics+1 WHERE forum_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_forums'), $forum_id);
219
-        $result = $GLOBALS['xoopsDB']->queryF($sql);
215
+            $forum_id = $postObject->getVar('forum_id');
216
+            $topicHandler->synchronization($topic_id);
217
+            $topicHandler->synchronization($new_topic_id);
218
+            $sql    = sprintf('UPDATE "%s" SET forum_topics = forum_topics+1 WHERE forum_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_forums'), $forum_id);
219
+            $result = $GLOBALS['xoopsDB']->queryF($sql);
220 220
 
221
-        break;
221
+            break;
222 222
 }
223 223
 if (!empty($topic_id)) {
224 224
     redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED);
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use Xmf\Request;
13 13
 use XoopsModules\Newbb;
14 14
 
15
-require_once __DIR__ . '/header.php';
15
+require_once __DIR__.'/header.php';
16 16
 
17 17
 $topic_id = Request::getInt('topic_id', 0, 'POST');
18 18
 $post_id  = Request::getArray('post_id', Request::getArray('post_id', [], 'POST'), 'GET');
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $isAdmin = newbbIsAdmin($forumObject);
43 43
 
44 44
 if (!$isAdmin) {
45
-    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
45
+    redirect_header(XOOPS_URL.'/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
46 46
 }
47 47
 
48 48
 switch ($op) {
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
         sort($post_id);
75 75
         $topics      = [];
76 76
         $forums      = [];
77
-        $criteria    = new \Criteria('post_id', '(' . implode(',', $post_id) . ')', 'IN');
77
+        $criteria    = new \Criteria('post_id', '('.implode(',', $post_id).')', 'IN');
78 78
         $postsObject = $postHandler->getObjects($criteria, true);
79 79
         foreach ($post_id as $post) {
80 80
             /** @var Newbb\Post $postObject */
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
             break;
98 98
         }
99 99
 
100
-        $criteria_topic = new \Criteria('topic_id', '(' . implode(',', array_keys($topics)) . ')', 'IN');
100
+        $criteria_topic = new \Criteria('topic_id', '('.implode(',', array_keys($topics)).')', 'IN');
101 101
         $topic_list     = $topicHandler->getList($criteria_topic, true);
102 102
 
103
-        $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
103
+        $criteria_forum = new \Criteria('forum_id', '('.implode(',', array_keys($forums)).')', 'IN');
104 104
         $forum_list     = $forumHandler->getList($criteria_forum);
105 105
 
106
-        require_once __DIR__ . '/include/notification.inc.php';
106
+        require_once __DIR__.'/include/notification.inc.php';
107 107
         /** @var \XoopsNotificationHandler $notificationHandler */
108 108
         $notificationHandler = xoops_getHandler('notification');
109 109
         foreach ($post_id as $post) {
110 110
             $tags = [];
111 111
             /** @var Newbb\Post[] $postsObject [$post] */
112 112
             $tags['THREAD_NAME'] = $topic_list[$postsObject[$post]->getVar('topic_id')];
113
-            $tags['THREAD_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?topic_id=' . $postsObject[$post]->getVar('topic_id') . '&amp;forum=' . $postsObject[$post]->getVar('forum_id');
113
+            $tags['THREAD_URL']  = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewtopic.php?topic_id='.$postsObject[$post]->getVar('topic_id').'&amp;forum='.$postsObject[$post]->getVar('forum_id');
114 114
             $tags['FORUM_NAME']  = $forum_list[$postsObject[$post]->getVar('forum_id')];
115
-            $tags['FORUM_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewforum.php?forum=' . $postsObject[$post]->getVar('forum_id');
116
-            $tags['POST_URL']    = $tags['THREAD_URL'] . '#forumpost' . $post;
115
+            $tags['FORUM_URL']   = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/viewforum.php?forum='.$postsObject[$post]->getVar('forum_id');
116
+            $tags['POST_URL']    = $tags['THREAD_URL'].'#forumpost'.$post;
117 117
             $notificationHandler->triggerEvent('thread', $postsObject[$post]->getVar('topic_id'), 'new_post', $tags);
118 118
             $notificationHandler->triggerEvent('forum', $postsObject[$post]->getVar('forum_id'), 'new_post', $tags);
119 119
             $notificationHandler->triggerEvent('global', 0, 'new_post', $tags);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             $mytree = new \XoopsTree($GLOBALS['xoopsDB']->prefix('newbb_posts'), 'post_id', 'pid');
181 181
             $posts  = $mytree->getAllChildId($post_id);
182 182
             if (count($posts) > 0) {
183
-                $criteria = new \Criteria('post_id', '(' . implode(',', $posts) . ')', 'IN');
183
+                $criteria = new \Criteria('post_id', '('.implode(',', $posts).')', 'IN');
184 184
                 $postHandler->updateAll('topic_id', $new_topic_id, $criteria, true);
185 185
             }
186 186
             /* split a post and all posts coming after */
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
                 }
208 208
             }
209 209
             if (count($post_update)) {
210
-                $criteria = new \Criteria('post_id', '(' . implode(',', $post_update) . ')', 'IN');
210
+                $criteria = new \Criteria('post_id', '('.implode(',', $post_update).')', 'IN');
211 211
                 $postHandler->updateAll('pid', $post_id, $criteria, true);
212 212
             }
213 213
         }
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
         break;
222 222
 }
223 223
 if (!empty($topic_id)) {
224
-    redirect_header(XOOPS_URL . "/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED);
224
+    redirect_header(XOOPS_URL."/modules/newbb/viewtopic.php?topic_id=$topic_id", 2, _MD_NEWBB_DBUPDATED);
225 225
 } elseif (!empty($forum_id)) {
226
-    redirect_header(XOOPS_URL . "/modules/newbb/viewforum.php?forum=$forum_id", 2, _MD_NEWBB_DBUPDATED);
226
+    redirect_header(XOOPS_URL."/modules/newbb/viewforum.php?forum=$forum_id", 2, _MD_NEWBB_DBUPDATED);
227 227
 } else {
228
-    redirect_header(XOOPS_URL . "/modules/newbb/viewpost.php?uid=$uid", 2, _MD_NEWBB_DBUPDATED);
228
+    redirect_header(XOOPS_URL."/modules/newbb/viewpost.php?uid=$uid", 2, _MD_NEWBB_DBUPDATED);
229 229
 }
230 230
 // irmtfan move to footer.php
231
-require_once __DIR__ . '/footer.php';
231
+require_once __DIR__.'/footer.php';
232 232
 include $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.
ratethread.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 use Xmf\Request;
33 33
 
34
-require_once __DIR__ . '/header.php';
34
+require_once __DIR__.'/header.php';
35 35
 
36 36
 $ratinguser   = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
37 37
 $anonwaitdays = 1;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 if (empty($rate)) {
54
-    redirect_header('viewtopic.php?topic_id=' . $topic_id . '&amp;forum=' . $forum . '', 4, _MD_NEWBB_NOVOTERATE);
54
+    redirect_header('viewtopic.php?topic_id='.$topic_id.'&amp;forum='.$forum.'', 4, _MD_NEWBB_NOVOTERATE);
55 55
 }
56 56
 ///** @var Newbb\RateHandler $rateHandler */
57 57
 //$rateHandler = Newbb\Helper::getInstance()->getHandler('Rate');
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
     //    /** @var Newbb\PostHandler $postHandler */
63 63
     //    $postHandler = Newbb\Helper::getInstance()->getHandler('Post');
64 64
     if ($postHandler->getCount($crit_post)) {
65
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&amp;forum=' . $forum . '', 4, _MD_NEWBB_CANTVOTEOWN);
65
+        redirect_header('viewtopic.php?topic_id='.$topic_id.'&amp;forum='.$forum.'', 4, _MD_NEWBB_CANTVOTEOWN);
66 66
     }
67 67
     // Check if REG user is trying to vote twice.
68 68
     $crit_rate = new \CriteriaCompo(new \Criteria('topic_id', $topic_id));
69 69
     $crit_rate->add(new \Criteria('ratinguser', $ratinguser));
70 70
     if ($rateHandler->getCount($crit_rate)) {
71
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&amp;forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
71
+        redirect_header('viewtopic.php?topic_id='.$topic_id.'&amp;forum='.$forum.'', 4, _MD_NEWBB_VOTEONCE);
72 72
     }
73 73
 } else {
74 74
     // Check if ANONYMOUS user is trying to vote more than once per day.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     $crit_rate->add(new \Criteria('ratinghostname', $ip));
78 78
     $crit_rate->add(new \Criteria('ratingtimestamp', time() - (86400 * $anonwaitdays), '>'));
79 79
     if ($rateHandler->getCount($crit_rate)) {
80
-        redirect_header('viewtopic.php?topic_id=' . $topic_id . '&amp;forum=' . $forum . '', 4, _MD_NEWBB_VOTEONCE);
80
+        redirect_header('viewtopic.php?topic_id='.$topic_id.'&amp;forum='.$forum.'', 4, _MD_NEWBB_VOTEONCE);
81 81
     }
82 82
 }
83 83
 $rateObject = $rateHandler->create();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 $ratingid = $rateHandler->insert($rateObject);
91 91
 
92
-$query       = 'SELECT rating FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_votedata') . ' WHERE topic_id = ' . $topic_id . ' ';
92
+$query       = 'SELECT rating FROM '.$GLOBALS['xoopsDB']->prefix('newbb_votedata').' WHERE topic_id = '.$topic_id.' ';
93 93
 $voteresult  = $GLOBALS['xoopsDB']->query($query);
94 94
 $votesDB     = $GLOBALS['xoopsDB']->getRowsNum($voteresult);
95 95
 $totalrating = 0;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 $sql         = sprintf('UPDATE "%s" SET rating = "%u", votes = "%u" WHERE topic_id = "%u"', $GLOBALS['xoopsDB']->prefix('newbb_topics'), $finalrating, $votesDB, $topic_id);
102 102
 $GLOBALS['xoopsDB']->queryF($sql);
103 103
 
104
-$ratemessage = _MD_NEWBB_VOTEAPPRE . '<br>' . sprintf(_MD_NEWBB_THANKYOU, $GLOBALS['xoopsConfig']['sitename']);
105
-redirect_header('viewtopic.php?topic_id=' . $topic_id . '&amp;forum=' . $forum . '', 2, $ratemessage);
104
+$ratemessage = _MD_NEWBB_VOTEAPPRE.'<br>'.sprintf(_MD_NEWBB_THANKYOU, $GLOBALS['xoopsConfig']['sitename']);
105
+redirect_header('viewtopic.php?topic_id='.$topic_id.'&amp;forum='.$forum.'', 2, $ratemessage);
106 106
 // irmtfan enhance include footer.php
107 107
 include $GLOBALS['xoops']->path('footer.php');
Please login to merge, or discard this patch.