Code Duplication    Length = 14-14 lines in 4 locations

class/class.newsstory.php 4 locations

@@ 244-257 (lines=14) @@
241
                    return null;
242
                }
243
            }
244
        } else {
245
            if ($checkRight) {
246
                $topics = news_MygetItemIds('news_view');
247
                if (count($topics) > 0) {
248
                    $topics = implode(',', $topics);
249
                    $sql .= ' AND s.topicid IN (' . $topics . ')';
250
                } else {
251
                    return null;
252
                }
253
            }
254
            if ((int)$ihome == 0) {
255
                $sql .= ' AND s.ihome=0';
256
            }
257
        }
258
        if ($topic_frontpage) {
259
            $sql .= ' AND t.topic_frontpage=1';
260
        }
@@ 344-357 (lines=14) @@
341
                    return null;
342
                }
343
            }
344
        } else {
345
            if ($checkRight) {
346
                $topics = news_MygetItemIds('news_view');
347
                if (count($topics) > 0) {
348
                    $topics = implode(',', $topics);
349
                    $sql .= ' AND topicid IN (' . $topics . ')';
350
                } else {
351
                    return null;
352
                }
353
            }
354
            if ((int)$ihome == 0) {
355
                $sql .= ' AND ihome=0';
356
            }
357
        }
358
        $sql .= " ORDER BY $order DESC";
359
        $result = $db->query($sql, (int)$limit, (int)$start);
360
        while ($myrow = $db->fetchArray($result)) {
@@ 606-619 (lines=14) @@
603
    {
604
        $db  = XoopsDatabaseFactory::getDatabaseConnection();
605
        $sql = 'SELECT COUNT(*) FROM ' . $db->prefix('news_stories') . ' WHERE published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')';
606
        if (!empty($topicid)) {
607
            $sql .= ' AND topicid=' . (int)$topicid;
608
        } else {
609
            $sql .= ' AND ihome=0';
610
            if ($checkRight) {
611
                $topics = news_MygetItemIds('news_view');
612
                if (count($topics) > 0) {
613
                    $topics = implode(',', $topics);
614
                    $sql .= ' AND topicid IN (' . $topics . ')';
615
                } else {
616
                    return null;
617
                }
618
            }
619
        }
620
        $result = $db->query($sql);
621
        list($count) = $db->fetchRow($result);
622
@@ 1182-1195 (lines=14) @@
1179
                    return null;
1180
                }
1181
            }
1182
        } else {
1183
            if ($checkRight) {
1184
                $topics = news_MygetItemIds('news_view');
1185
                if (count($topics) > 0) {
1186
                    $topics = implode(',', $topics);
1187
                    $sql .= ' AND topicid IN (' . $topics . ')';
1188
                } else {
1189
                    return null;
1190
                }
1191
            }
1192
            if ((int)$ihome == 0) {
1193
                $sql .= ' AND ihome=0';
1194
            }
1195
        }
1196
        if ($topic_frontpage) {
1197
            $sql .= ' AND t.topic_frontpage=1';
1198
        }