Code Duplication    Length = 15-19 lines in 3 locations

main/inc/lib/groupmanager.lib.php 2 locations

@@ 1679-1697 (lines=19) @@
1676
     * @param int $group_id iid
1677
     * @return bool TRUE if successful
1678
     */
1679
    public static function unsubscribe_all_users($groupId)
1680
    {
1681
        $course_id = api_get_course_int_id();
1682
        //api_is_element_in_the_session(TOOL_GROUP, $group_ids[$i])
1683
1684
        $groupId = (int) $groupId;
1685
        if (empty($course_id) || empty($groupId)) {
1686
            return false;
1687
        }
1688
1689
        $table_group_user = Database :: get_course_table(TABLE_GROUP_USER);
1690
        $sql = "DELETE FROM $table_group_user
1691
                WHERE 
1692
                    group_id = $groupId AND 
1693
                    c_id = $course_id";
1694
        $result = Database::query($sql);
1695
1696
        return $result;
1697
    }
1698
1699
    /**
1700
     * Unsubscribe all tutors from one or more groups
@@ 1706-1723 (lines=18) @@
1703
     * @return bool TRUE if successful
1704
     * @author Patrick Cool <[email protected]>, Ghent University
1705
     */
1706
    public static function unsubscribe_all_tutors($groupId)
1707
    {
1708
        $courseId = api_get_course_int_id();
1709
        $groupId = (int) $groupId;
1710
1711
        if (empty($courseId) || empty($groupId)) {
1712
            return false;
1713
        }
1714
1715
        if (!empty($groupId) > 0) {
1716
            $table_group_tutor = Database :: get_course_table(TABLE_GROUP_TUTOR);
1717
            $sql = "DELETE FROM $table_group_tutor
1718
                    WHERE group_id = $groupId AND c_id = $courseId";
1719
            $result = Database::query($sql);
1720
            return $result;
1721
        }
1722
        return true;
1723
    }
1724
1725
    /**
1726
     * Is the user a tutor of this group?

main/inc/lib/sessionmanager.lib.php 1 location

@@ 8052-8066 (lines=15) @@
8049
     *
8050
     * @return array
8051
     */
8052
    public static function searchCourseInSessionsFromUser($userId, $courseId)
8053
    {
8054
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
8055
        $userId = (int) $userId;
8056
        $courseId = (int) $courseId;
8057
        if (empty($userId) || empty($courseId)) {
8058
            return [];
8059
        }
8060
8061
        $sql = "SELECT * FROM $table 
8062
                WHERE c_id = $courseId AND user_id = $userId";
8063
        $result = Database::query($sql);
8064
8065
        return Database::store_result($result, 'ASSOC');
8066
    }
8067
}
8068