Code Duplication    Length = 30-34 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 1534-1567 (lines=34) @@
1531
1532
1533
        // Course Admin
1534
        if (api_is_allowed_to_edit()) {
1535
            // Select all the forum information of all forums (that are not deleted).
1536
            $sql = "SELECT item_properties.*, forum.* 
1537
                    FROM $table_forums forum
1538
                    INNER JOIN $table_item_property item_properties
1539
                    ON (
1540
                        forum.forum_id = item_properties.ref AND
1541
                        forum.c_id = item_properties.c_id
1542
                    )
1543
                    WHERE
1544
                        item_properties.visibility <> 2 AND
1545
                        item_properties.tool = '".TOOL_FORUM."'
1546
                        $condition_session AND
1547
                        forum.c_id = $course_id AND
1548
                        item_properties.c_id = $course_id
1549
                        $includeGroupsForumSelect
1550
                    ORDER BY forum_order ASC";
1551
1552
            // Select the number of threads of the forums (only the threads that are not deleted).
1553
            $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id
1554
                    FROM $table_threads threads
1555
                    INNER JOIN $table_item_property item_properties
1556
                    ON (
1557
                        threads.thread_id = item_properties.ref AND
1558
                        threads.c_id = item_properties.c_id
1559
                        $sessionIdLink
1560
                    )
1561
                    WHERE
1562
                        item_properties.visibility<>2 AND
1563
                        item_properties.tool='".TOOL_FORUM_THREAD."' AND
1564
                        threads.c_id = $course_id AND
1565
                        item_properties.c_id = $course_id
1566
                    GROUP BY threads.forum_id";
1567
        }
1568
    } else {
1569
        // GETTING ONE SPECIFIC FORUM
1570
        /* We could do the splitup into student and course admin also but we want
@@ 5088-5117 (lines=30) @@
5085
            GROUP BY threads.forum_id";
5086
5087
    // Course Admin
5088
    if (api_is_allowed_to_edit()) {
5089
        // Select all the forum information of all forums (that are not deleted).
5090
        $sql = "SELECT *
5091
                FROM $table_forums forum, $table_item_property item_properties
5092
                WHERE
5093
                    forum.forum_of_group = $groupId AND
5094
                    forum.c_id = $course_id AND
5095
                    item_properties.c_id = $course_id AND
5096
                    forum.forum_id = item_properties.ref AND
5097
                    item_properties.visibility <> 2 AND
5098
                    item_properties.tool = '".TOOL_FORUM."'
5099
                ORDER BY forum_order ASC";
5100
5101
        // Select the number of threads of the forums (only the threads that are not deleted).
5102
        $sql2 = "SELECT count(thread_id) AS number_of_threads, threads.forum_id
5103
                 FROM $table_threads threads, $table_item_property item_properties
5104
                 WHERE
5105
                    threads.thread_id=item_properties.ref AND
5106
                    threads.c_id = $course_id AND
5107
                    item_properties.c_id = $course_id AND
5108
                    item_properties.visibility <> 2 AND
5109
                    item_properties.tool='".TOOL_FORUM_THREAD."'
5110
                GROUP BY threads.forum_id";
5111
        // Select the number of posts of the forum.
5112
        $sql3 = "SELECT count(post_id) AS number_of_posts, forum_id
5113
                FROM $table_posts
5114
                WHERE c_id = $course_id 
5115
                GROUP BY forum_id";
5116
5117
    }
5118
5119
    // Handling all the forum information.
5120