Code Duplication    Length = 16-24 lines in 3 locations

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

@@ 364-379 (lines=16) @@
361
     *
362
     * @return array
363
     */
364
    function getChildren($categoryCode)
365
    {
366
        $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
367
        $categoryCode = Database::escape_string($categoryCode);
368
        $result = Database::query(
369
            "SELECT code, id FROM $tbl_category WHERE parent_id = '$categoryCode'"
370
        );
371
        $children = array();
372
        while ($row = Database::fetch_array($result, 'ASSOC')) {
373
            $children[] = $row;
374
            $subChildren = self::getChildren($row['code']);
375
            $children = array_merge($children, $subChildren);
376
        }
377
378
        return $children;
379
    }
380
381
    /**
382
     * @param string $categoryCode

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

@@ 3192-3214 (lines=23) @@
3189
     * @param    int        Session id
3190
     * @return    array    Courses list
3191
     */
3192
    public static function get_courses_list_from_session($session_id)
3193
    {
3194
        $session_id = intval($session_id);
3195
3196
        // table definition
3197
        $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
3198
        $courseTable = Database :: get_main_table(TABLE_MAIN_COURSE);
3199
3200
        $sql = "SELECT DISTINCT code, c_id
3201
                FROM $tbl_session_course sc
3202
                INNER JOIN $courseTable c
3203
                ON sc.c_id = c.id
3204
                WHERE session_id= $session_id";
3205
3206
        $result = Database::query($sql);
3207
3208
        $courses = array();
3209
        while ($row = Database::fetch_array($result)) {
3210
            $courses[$row['code']] = $row;
3211
        }
3212
3213
        return $courses;
3214
    }
3215
3216
    /**
3217
     * Count the number of documents that an user has uploaded to a course

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

@@ 5183-5206 (lines=24) @@
5180
     * @param string $lastname Lastname to search
5181
     * @return array The user list
5182
     */
5183
    public static function getUserByName($firstname, $lastname)
5184
    {
5185
        $firstname = Database::escape_string($firstname);
5186
        $lastname = Database::escape_string($lastname);
5187
5188
        $userTable = Database::get_main_table(TABLE_MAIN_USER);
5189
5190
        $sql = <<<SQL
5191
            SELECT id, username, lastname, firstname
5192
            FROM $userTable
5193
            WHERE firstname LIKE '$firstname%' AND
5194
                lastname LIKE '$lastname%'
5195
SQL;
5196
5197
        $result = Database::query($sql);
5198
5199
        $users = [];
5200
5201
        while ($resultData = Database::fetch_object($result)) {
5202
            $users[] = $resultData;
5203
        }
5204
5205
        return $users;
5206
    }
5207
5208
    /**
5209
     * @param int $optionSelected