Code Duplication    Length = 14-14 lines in 4 locations

blocks/news_topicsnav.php 1 location

@@ 37-50 (lines=14) @@
34
    $perms            = '';
35
    $xt               = new NewsTopic();
36
    $restricted       = NewsUtility::getModuleOption('restrictindex');
37
    if ($restricted) {
38
        global $xoopsUser;
39
        /** @var XoopsModuleHandler $moduleHandler */
40
        $moduleHandler = xoops_getHandler('module');
41
        $newsModule    = $moduleHandler->getByDirname('news');
42
        $groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
43
        $gpermHandler  = xoops_getHandler('groupperm');
44
        $topics        = $gpermHandler->getItemIds('news_view', $groups, $newsModule->getVar('mid'));
45
        if (count($topics) > 0) {
46
            $topics = implode(',', $topics);
47
            $perms  = ' AND topic_id IN (' . $topics . ') ';
48
        } else {
49
            return '';
50
        }
51
    }
52
    $topics_arr = $xt->getChildTreeArray(0, 'topic_title', $perms);
53
    if (1 == $options[0]) {

class/class.newstopic.php 2 locations

@@ 75-88 (lines=14) @@
72
        $perm_type = 'news_view'
73
    ) {
74
        $perms = '';
75
        if ($checkRight) {
76
            global $xoopsUser;
77
            /** @var XoopsModuleHandler $moduleHandler */
78
            $moduleHandler = xoops_getHandler('module');
79
            $newsModule    = $moduleHandler->getByDirname('news');
80
            $groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
81
            $gpermHandler  = xoops_getHandler('groupperm');
82
            $topics        = $gpermHandler->getItemIds($perm_type, $groups, $newsModule->getVar('mid'));
83
            if (count($topics) > 0) {
84
                $topics = implode(',', $topics);
85
                $perms  = ' AND topic_id IN (' . $topics . ') ';
86
            } else {
87
                return null;
88
            }
89
        }
90
91
        if ($seltopic != -1) {
@@ 214-227 (lines=14) @@
211
    public function getAllTopicsCount($checkRight = true)
212
    {
213
        $perms = '';
214
        if ($checkRight) {
215
            global $xoopsUser;
216
            /** @var XoopsModuleHandler $moduleHandler */
217
            $moduleHandler = xoops_getHandler('module');
218
            $newsModule    = $moduleHandler->getByDirname('news');
219
            $groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
220
            $gpermHandler  = xoops_getHandler('groupperm');
221
            $topics        = $gpermHandler->getItemIds('news_submit', $groups, $newsModule->getVar('mid'));
222
            if (count($topics) > 0) {
223
                $topics = implode(',', $topics);
224
                $perms  = ' WHERE topic_id IN (' . $topics . ') ';
225
            } else {
226
                return null;
227
            }
228
        }
229
230
        $sql   = 'SELECT count(topic_id) AS cpt FROM ' . $this->table . $perms;

topics_directory.php 1 location

@@ 43-56 (lines=14) @@
40
$perms            = '';
41
$xt               = new NewsTopic();
42
$restricted       = NewsUtility::getModuleOption('restrictindex');
43
if ($restricted) {
44
    global $xoopsUser;
45
    /** @var XoopsModuleHandler $moduleHandler */
46
    $moduleHandler = xoops_getHandler('module');
47
    $newsModule    = $moduleHandler->getByDirname('news');
48
    $groups        = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
49
    $gpermHandler  = xoops_getHandler('groupperm');
50
    $topics        = $gpermHandler->getItemIds('news_view', $groups, $newsModule->getVar('mid'));
51
    if (count($topics) > 0) {
52
        $topics = implode(',', $topics);
53
        $perms  = ' AND topic_id IN (' . $topics . ') ';
54
    } else {
55
        return '';
56
    }
57
}
58
$topics_arr       = $xt->getChildTreeArray(0, 'topic_title', $perms);
59
$newscountbytopic = $xt->getNewsCountByTopic();