Code Duplication    Length = 30-34 lines in 2 locations

main/forum/forumfunction.inc.php 2 locations

@@ 1535-1568 (lines=34) @@
1532
                GROUP BY threads.forum_id";
1533
1534
        // Course Admin
1535
        if (api_is_allowed_to_edit()) {
1536
            // Select all the forum information of all forums (that are not deleted).
1537
            $sql = "SELECT item_properties.*, forum.* 
1538
                    FROM $table_forums forum
1539
                    INNER JOIN $table_item_property item_properties
1540
                    ON (
1541
                        forum.forum_id = item_properties.ref AND
1542
                        forum.c_id = item_properties.c_id
1543
                    )
1544
                    WHERE
1545
                        item_properties.visibility <> 2 AND
1546
                        item_properties.tool = '".TOOL_FORUM."'
1547
                        $condition_session AND
1548
                        forum.c_id = $course_id AND
1549
                        item_properties.c_id = $course_id
1550
                        $includeGroupsForumSelect
1551
                    ORDER BY forum_order ASC";
1552
1553
            // Select the number of threads of the forums (only the threads that are not deleted).
1554
            $sql2 = "SELECT count(*) AS number_of_threads, threads.forum_id
1555
                    FROM $table_threads threads
1556
                    INNER JOIN $table_item_property item_properties
1557
                    ON (
1558
                        threads.thread_id = item_properties.ref AND
1559
                        threads.c_id = item_properties.c_id
1560
                        $sessionIdLink
1561
                    )
1562
                    WHERE
1563
                        item_properties.visibility<>2 AND
1564
                        item_properties.tool='".TOOL_FORUM_THREAD."' AND
1565
                        threads.c_id = $course_id AND
1566
                        item_properties.c_id = $course_id
1567
                    GROUP BY threads.forum_id";
1568
        }
1569
    } else {
1570
        // GETTING ONE SPECIFIC FORUM
1571
        /* We could do the splitup into student and course admin also but we want
@@ 4961-4990 (lines=30) @@
4958
            GROUP BY threads.forum_id";
4959
4960
    // Course Admin
4961
    if (api_is_allowed_to_edit()) {
4962
        // Select all the forum information of all forums (that are not deleted).
4963
        $sql = "SELECT *
4964
                FROM $table_forums forum INNER JOIN $table_item_property item_properties
4965
                ON (forum.forum_id = item_properties.ref AND item_properties.c_id = forum.c_id)
4966
                WHERE
4967
                    forum.forum_of_group = $groupId AND
4968
                    forum.c_id = $course_id AND
4969
                    item_properties.c_id = $course_id AND                    
4970
                    item_properties.visibility <> 2 AND
4971
                    item_properties.tool = '".TOOL_FORUM."'
4972
                ORDER BY forum_order ASC";
4973
4974
        // Select the number of threads of the forums (only the threads that are not deleted).
4975
        $sql2 = "SELECT count(thread_id) AS number_of_threads, threads.forum_id
4976
                 FROM $table_threads threads INNER JOIN $table_item_property item_properties
4977
                 ON (threads.thread_id=item_properties.ref AND item_properties.c_id = threads.c_id)
4978
                 WHERE
4979
                    threads.c_id = $course_id AND
4980
                    item_properties.c_id = $course_id AND
4981
                    item_properties.visibility <> 2 AND
4982
                    item_properties.tool='".TOOL_FORUM_THREAD."'
4983
                GROUP BY threads.forum_id";
4984
        // Select the number of posts of the forum.
4985
        $sql3 = "SELECT count(post_id) AS number_of_posts, forum_id
4986
                FROM $table_posts
4987
                WHERE c_id = $course_id 
4988
                GROUP BY forum_id";
4989
    }
4990
4991
    // Handling all the forum information.
4992
    $result = Database::query($sql);
4993
    $forum_list = array();