Code Duplication    Length = 14-14 lines in 4 locations

class/class.newsstory.php 4 locations

@@ 266-279 (lines=14) @@
263
                    return null;
264
                }
265
            }
266
        } else {
267
            if ($checkRight) {
268
                $topics = news_MygetItemIds('news_view');
269
                if (count($topics) > 0) {
270
                    $topics = implode(',', $topics);
271
                    $sql .= ' AND s.topicid IN (' . $topics . ')';
272
                } else {
273
                    return null;
274
                }
275
            }
276
            if ((int)$ihome == 0) {
277
                $sql .= ' AND s.ihome=0';
278
            }
279
        }
280
        if ($topic_frontpage) {
281
            $sql .= ' AND t.topic_frontpage=1';
282
        }
@@ 386-399 (lines=14) @@
383
                    return null;
384
                }
385
            }
386
        } else {
387
            if ($checkRight) {
388
                $topics = news_MygetItemIds('news_view');
389
                if (count($topics) > 0) {
390
                    $topics = implode(',', $topics);
391
                    $sql .= ' AND topicid IN (' . $topics . ')';
392
                } else {
393
                    return null;
394
                }
395
            }
396
            if ((int)$ihome == 0) {
397
                $sql .= ' AND ihome=0';
398
            }
399
        }
400
        $sql .= " ORDER BY $order DESC";
401
        $result = $db->query($sql, (int)$limit, (int)$start);
402
        while ($myrow = $db->fetchArray($result)) {
@@ 667-680 (lines=14) @@
664
    {
665
        $db  = XoopsDatabaseFactory::getDatabaseConnection();
666
        $sql = 'SELECT COUNT(*) FROM ' . $db->prefix('news_stories') . ' WHERE published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')';
667
        if (!empty($topicid)) {
668
            $sql .= ' AND topicid=' . (int)$topicid;
669
        } else {
670
            $sql .= ' AND ihome=0';
671
            if ($checkRight) {
672
                $topics = news_MygetItemIds('news_view');
673
                if (count($topics) > 0) {
674
                    $topics = implode(',', $topics);
675
                    $sql .= ' AND topicid IN (' . $topics . ')';
676
                } else {
677
                    return null;
678
                }
679
            }
680
        }
681
        $result = $db->query($sql);
682
        list($count) = $db->fetchRow($result);
683
@@ 1311-1324 (lines=14) @@
1308
                    return null;
1309
                }
1310
            }
1311
        } else {
1312
            if ($checkRight) {
1313
                $topics = news_MygetItemIds('news_view');
1314
                if (count($topics) > 0) {
1315
                    $topics = implode(',', $topics);
1316
                    $sql .= ' AND topicid IN (' . $topics . ')';
1317
                } else {
1318
                    return null;
1319
                }
1320
            }
1321
            if ((int)$ihome == 0) {
1322
                $sql .= ' AND ihome=0';
1323
            }
1324
        }
1325
        if ($topic_frontpage) {
1326
            $sql .= ' AND t.topic_frontpage=1';
1327
        }