Code Duplication    Length = 17-18 lines in 2 locations

action.topic.php 2 locations

@@ 40-56 (lines=17) @@
37
    redirect_header(XOOPS_URL . '/index.php', 2, _MD_NEWBB_NORIGHTTOACCESS);
38
}
39
switch ($op) {
40
    case 'restore':
41
        $forums       = [];
42
        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
43
        foreach (array_keys($topicsObject) as $id) {
44
            /** @var Newbb\Topic $topicObject */
45
            $topicObject = $topicsObject[$id];
46
            $topicHandler->approve($topicObject);
47
            $topicHandler->synchronization($topicObject);
48
            $forums[$topicObject->getVar('forum_id')] = 1;
49
        }
50
        $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
51
        $forumsObject   = $forumHandler->getAll($criteria_forum);
52
        foreach (array_keys($forumsObject) as $id) {
53
            $forumHandler->synchronization($forumsObject[$id]);
54
        }
55
        unset($topicsObject, $forumsObject);
56
        break;
57
    case 'approve':
58
        $forums       = [];
59
        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
@@ 104-121 (lines=18) @@
101
        }
102
        unset($topicsObject, $forumsObject);
103
        break;
104
    case 'delete':
105
        $forums = [];
106
        /** @var Newbb\TopicHandler|\XoopsPersistableObjectHandler $topicHandler */
107
        $topicsObject = $topicHandler->getAll(new \Criteria('topic_id', '(' . implode(',', $topic_id) . ')', 'IN'));
108
        foreach (array_keys($topicsObject) as $id) {
109
            /** @var Newbb\Topic $topicObject */
110
            $topicObject = $topicsObject[$id];
111
            // irmtfan should be set to false to not delete topic from database
112
            $topicHandler->delete($topicObject, false);
113
            $topicHandler->synchronization($topicObject);
114
            $forums[$topicObject->getVar('forum_id')] = 1;
115
        }
116
117
        $criteria_forum = new \Criteria('forum_id', '(' . implode(',', array_keys($forums)) . ')', 'IN');
118
        $forumsObject   = $forumHandler->getAll($criteria_forum);
119
        foreach (array_keys($forumsObject) as $id) {
120
            $forumHandler->synchronization($forumsObject[$id]);
121
        }
122
        unset($topicsObject, $forumsObject);
123
        break;
124
    case 'move':