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

@@ 6314-6342 (lines=29) @@
6311
     * @param int $sessionId The session id
6312
     * @return array
6313
     */
6314
    public static function getTotalUserCoursesInSession($sessionId)
6315
    {
6316
        $tableUser = Database::get_main_table(TABLE_MAIN_USER);
6317
        $table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
6318
6319
        if (empty($sessionId)) {
6320
            return [];
6321
        }
6322
6323
        $sql = "SELECT 
6324
                    COUNT(u.id) as count, 
6325
                    u.id, 
6326
                    scu.status status_in_session, 
6327
                    u.status user_status
6328
                FROM $table scu
6329
                INNER JOIN $tableUser u 
6330
                ON scu.user_id = u.id
6331
                WHERE scu.session_id = " . intval($sessionId) ."
6332
                GROUP BY u.id";
6333
6334
        $result = Database::query($sql);
6335
6336
        $list = array();
6337
        while ($data = Database::fetch_assoc($result)) {
6338
            $list[] = $data;
6339
        }
6340
6341
        return $list;
6342
    }
6343
6344
6345
    /**