Code Duplication    Length = 16-29 lines in 3 locations

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

@@ 476-493 (lines=18) @@
473
     * @return array link info
474
     *
475
     **/
476
    public static function get_link_info($id)
477
    {
478
        $tbl_link = Database:: get_course_table(TABLE_LINK);
479
        $course_id = api_get_course_int_id();
480
481
        if (empty($id) || empty($course_id)) {
482
            return [];
483
        }
484
485
        $sql = "SELECT * FROM $tbl_link
486
                WHERE c_id = $course_id AND id='" . intval($id) . "' ";
487
        $result = Database::query($sql);
488
        $data = array();
489
        if (Database::num_rows($result)) {
490
            $data = Database::fetch_array($result);
491
        }
492
        return $data;
493
    }
494
495
    /**
496
     * @param int $id
@@ 1796-1811 (lines=16) @@
1793
     * @param int $id
1794
     * @return array
1795
     */
1796
    public static function getCategory($id)
1797
    {
1798
        $table = Database::get_course_table(TABLE_LINK_CATEGORY);
1799
        $id = intval($id);
1800
        $courseId = api_get_course_int_id();
1801
1802
        if (empty($id) || empty($courseId)) {
1803
            return [];
1804
        }
1805
        $sql = "SELECT * FROM $table 
1806
                WHERE id = $id AND c_id = $courseId";
1807
        $result = Database::query($sql);
1808
        $category = Database::fetch_array($result, 'ASSOC');
1809
1810
        return $category;
1811
    }
1812
1813
    /**
1814
     * Move a link inside its category (display_order field)

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

@@ 6368-6396 (lines=29) @@
6365
     * @param int $sessionId The session id
6366
     * @return array
6367
     */
6368
    public static function getTotalUserCoursesInSession($sessionId)
6369
    {
6370
        $tableUser = Database::get_main_table(TABLE_MAIN_USER);
6371
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
6372
6373
        if (empty($sessionId)) {
6374
            return [];
6375
        }
6376
6377
        $sql = "SELECT 
6378
                    COUNT(u.id) as count, 
6379
                    u.id, 
6380
                    scu.status status_in_session, 
6381
                    u.status user_status
6382
                FROM $table scu
6383
                INNER JOIN $tableUser u 
6384
                ON scu.user_id = u.id
6385
                WHERE scu.session_id = " . intval($sessionId) ."
6386
                GROUP BY u.id";
6387
6388
        $result = Database::query($sql);
6389
6390
        $list = array();
6391
        while ($data = Database::fetch_assoc($result)) {
6392
            $list[] = $data;
6393
        }
6394
6395
        return $list;
6396
    }
6397
6398
6399
    /**