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

@@ 8186-8200 (lines=15) @@
8183
     *
8184
     * @return array
8185
     */
8186
    public static function searchCourseInSessionsFromUser($userId, $courseId)
8187
    {
8188
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
8189
        $userId = (int) $userId;
8190
        $courseId = (int) $courseId;
8191
        if (empty($userId) || empty($courseId)) {
8192
            return [];
8193
        }
8194
8195
        $sql = "SELECT * FROM $table 
8196
                WHERE c_id = $courseId AND user_id = $userId";
8197
        $result = Database::query($sql);
8198
8199
        return Database::store_result($result, 'ASSOC');
8200
    }
8201
8202
    /**
8203
     * Subscribe and redirect to session after inscription