Code Duplication    Length = 17-18 lines in 2 locations

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

@@ 637-653 (lines=17) @@
634
     * @param int $urlId
635
     * @return int
636
     */
637
    public static function addCourseCategoryToUrl($categoryId, $urlId)
638
    {
639
        $exists = self::relationUrlCourseCategoryExist($categoryId, $urlId);
640
        if (empty($exists)) {
641
            $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
642
643
            $sql = "INSERT INTO $table
644
                    SET
645
                    course_category_id = '".intval($categoryId)."',
646
                    access_url_id = ".intval($urlId);
647
            Database::query($sql);
648
649
            return Database::insert_id();
650
        }
651
652
        return 0;
653
    }
654
655
    /**
656
     * Add a group of sessions into a group of URLs

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

@@ 327-344 (lines=18) @@
324
     *
325
     * @return int|bool the status of the user in that course (or false if the user is not in that course)
326
     */
327
    public static function get_user_in_course_status($user_id, $course_code)
328
    {
329
        $courseInfo = api_get_course_info($course_code);
330
        $courseId = $courseInfo['real_id'];
331
        if (empty($courseId)) {
332
            return false;
333
        }
334
        $result = Database::fetch_array(
335
            Database::query(
336
                "SELECT status FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "
337
                WHERE
338
                    c_id  = $courseId AND
339
                    user_id = " . intval($user_id)
340
            )
341
        );
342
343
        return $result['status'];
344
    }
345
346
    /**
347
     * @param int $userId