Code Duplication    Length = 15-19 lines in 2 locations

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

@@ 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

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

@@ 8124-8138 (lines=15) @@
8121
     *
8122
     * @return array
8123
     */
8124
    public static function searchCourseInSessionsFromUser($userId, $courseId)
8125
    {
8126
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
8127
        $userId = (int) $userId;
8128
        $courseId = (int) $courseId;
8129
        if (empty($userId) || empty($courseId)) {
8130
            return [];
8131
        }
8132
8133
        $sql = "SELECT * FROM $table 
8134
                WHERE c_id = $courseId AND user_id = $userId";
8135
        $result = Database::query($sql);
8136
8137
        return Database::store_result($result, 'ASSOC');
8138
    }
8139
}
8140