Code Duplication    Length = 14-14 lines in 4 locations

class/class.newsstory.php 4 locations

@@ 245-258 (lines=14) @@
242
                    return null;
243
                }
244
            }
245
        } else {
246
            if ($checkRight) {
247
                $topics = NewsUtility::getMyItemIds('news_view');
248
                if (count($topics) > 0) {
249
                    $topics = implode(',', $topics);
250
                    $sql    .= ' AND s.topicid IN (' . $topics . ')';
251
                } else {
252
                    return null;
253
                }
254
            }
255
            if (0 == (int)$ihome) {
256
                $sql .= ' AND s.ihome=0';
257
            }
258
        }
259
        if ($topic_frontpage) {
260
            $sql .= ' AND t.topic_frontpage=1';
261
        }
@@ 357-370 (lines=14) @@
354
                    return null;
355
                }
356
            }
357
        } else {
358
            if ($checkRight) {
359
                $topics = NewsUtility::getMyItemIds('news_view');
360
                if (count($topics) > 0) {
361
                    $topics = implode(',', $topics);
362
                    $sql    .= ' AND topicid IN (' . $topics . ')';
363
                } else {
364
                    return null;
365
                }
366
            }
367
            if (0 == (int)$ihome) {
368
                $sql .= ' AND ihome=0';
369
            }
370
        }
371
        $sql    .= " ORDER BY $order DESC";
372
        $result = $db->query($sql, (int)$limit, (int)$start);
373
        while ($myrow = $db->fetchArray($result)) {
@@ 638-651 (lines=14) @@
635
    {
636
        $db  = XoopsDatabaseFactory::getDatabaseConnection();
637
        $sql = 'SELECT COUNT(*) FROM ' . $db->prefix('news_stories') . ' WHERE published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')';
638
        if (!empty($topicid)) {
639
            $sql .= ' AND topicid=' . (int)$topicid;
640
        } else {
641
            $sql .= ' AND ihome=0';
642
            if ($checkRight) {
643
                $topics = NewsUtility::getMyItemIds('news_view');
644
                if (count($topics) > 0) {
645
                    $topics = implode(',', $topics);
646
                    $sql    .= ' AND topicid IN (' . $topics . ')';
647
                } else {
648
                    return null;
649
                }
650
            }
651
        }
652
        $result = $db->query($sql);
653
        list($count) = $db->fetchRow($result);
654
@@ 1307-1320 (lines=14) @@
1304
                    return null;
1305
                }
1306
            }
1307
        } else {
1308
            if ($checkRight) {
1309
                $topics = NewsUtility::getMyItemIds('news_view');
1310
                if (count($topics) > 0) {
1311
                    $topics = implode(',', $topics);
1312
                    $sql    .= ' AND topicid IN (' . $topics . ')';
1313
                } else {
1314
                    return null;
1315
                }
1316
            }
1317
            if (0 == (int)$ihome) {
1318
                $sql .= ' AND ihome=0';
1319
            }
1320
        }
1321
        if ($topic_frontpage) {
1322
            $sql .= ' AND t.topic_frontpage=1';
1323
        }