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

@@ 6349-6377 (lines=29) @@
6346
     * @param int $sessionId The session id
6347
     * @return array
6348
     */
6349
    public static function getTotalUserCoursesInSession($sessionId)
6350
    {
6351
        $tableUser = Database::get_main_table(TABLE_MAIN_USER);
6352
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
6353
6354
        if (empty($sessionId)) {
6355
            return [];
6356
        }
6357
6358
        $sql = "SELECT 
6359
                    COUNT(u.id) as count, 
6360
                    u.id, 
6361
                    scu.status status_in_session, 
6362
                    u.status user_status
6363
                FROM $table scu
6364
                INNER JOIN $tableUser u 
6365
                ON scu.user_id = u.id
6366
                WHERE scu.session_id = " . intval($sessionId) ."
6367
                GROUP BY u.id";
6368
6369
        $result = Database::query($sql);
6370
6371
        $list = array();
6372
        while ($data = Database::fetch_assoc($result)) {
6373
            $list[] = $data;
6374
        }
6375
6376
        return $list;
6377
    }
6378
6379
6380
    /**