Code Duplication    Length = 31-32 lines in 2 locations

class/ForumHandler.php 2 locations

@@ 211-241 (lines=31) @@
208
                $criteria_extra = ' AND t.topic_replies < 1';
209
                break;
210
211
            case 'unread':
212
                if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) {
213
                } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
214
                    // START irmtfan use read_uid to find the unread posts when the user is logged in
215
                    $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
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 . ' ';
218
                        $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
219
                    } else {
220
                    }
221
                    // END irmtfan use read_uid to find the unread posts when the user is logged in
222
                } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
223
                    // START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
224
                    if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
225
                        $criteria_post  = ' p.post_time > ' . $time_criterion; // for all users
226
                        $topics         = [];
227
                        $topic_lastread = newbbGetCookie('LT', true);
228
                        if (count($topic_lastread) > 0) {
229
                            foreach ($topic_lastread as $id => $time) {
230
                                if ($time > $time_criterion) {
231
                                    $topics[] = $id;
232
                                }
233
                            }
234
                        }
235
                        if (count($topics) > 0) {
236
                            $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
237
                        }
238
                    }
239
                    // END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
240
                }
241
                break;
242
            case 'pending':
243
                $post_on          = ' p.topic_id = t.topic_id';
244
                $criteria_post    .= ' AND p.pid = 0';
@@ 491-522 (lines=32) @@
488
            case 'unreplied':
489
                $criteria_extra = ' AND topic_replies < 1';
490
                break;
491
            case 'unread':
492
                if (empty($GLOBALS['xoopsModuleConfig']['read_mode'])) {
493
                } elseif (2 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
494
                    // START irmtfan use read_uid to find the unread posts when the user is logged in
495
496
                    $read_uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
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 . ' ';
499
                        $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
500
                    } else {
501
                    }
502
                    // END irmtfan use read_uid to find the unread posts when the user is logged in
503
                } elseif (1 == $GLOBALS['xoopsModuleConfig']['read_mode']) {
504
                    // START irmtfan fix read_mode = 1 bugs - for all users (member and anon)
505
                    if ($time_criterion = max($GLOBALS['last_visit'], $startdate)) {
506
                        $criteria_post  = ' p.post_time > ' . $time_criterion; // for all users
507
                        $topics         = [];
508
                        $topic_lastread = newbbGetCookie('LT', true);
509
                        if (count($topic_lastread) > 0) {
510
                            foreach ($topic_lastread as $id => $time) {
511
                                if ($time > $time_criterion) {
512
                                    $topics[] = $id;
513
                                }
514
                            }
515
                        }
516
                        if (count($topics) > 0) {
517
                            $criteria_extra = ' AND t.topic_id NOT IN (' . implode(',', $topics) . ')';
518
                        }
519
                    }
520
                    // END irmtfan fix read_mode = 1 bugs - for all users (member and anon)
521
                }
522
                break;
523
            case 'pending':
524
                $criteria_approve = ' AND t.approved = 0';
525
                break;