Code Duplication    Length = 12-16 lines in 3 locations

main/gradebook/lib/GradebookUtils.php 1 location

@@ 429-440 (lines=12) @@
426
     * @param    int
427
     * @return   String
428
     */
429
    public static function get_course_id_by_link_id($id_link)
430
    {
431
        $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
432
        $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
433
        $sql = 'SELECT c.id FROM ' . $course_table . ' c
434
                INNER JOIN ' . $tbl_grade_links . ' l
435
                ON c.id = l.c_id
436
                WHERE l.id=' . intval($id_link) . ' OR l.category_id=' . intval($id_link);
437
        $res = Database::query($sql);
438
        $array = Database::fetch_array($res, 'ASSOC');
439
        return $array['id'];
440
    }
441
442
    /**
443
     * @param $type

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

@@ 4416-4431 (lines=16) @@
4413
 * @param integer $user_id
4414
 * @return int the value of the highest sort of the user_course_category
4415
 */
4416
function api_max_sort_value($user_course_category, $user_id)
4417
{
4418
    $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
4419
    $sql = "SELECT max(sort) as max_sort FROM $tbl_course_user
4420
            WHERE
4421
                user_id='".intval($user_id)."' AND
4422
                relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
4423
                user_course_cat='".intval($user_course_category)."'";
4424
    $result_max = Database::query($sql);
4425
    if (Database::num_rows($result_max) == 1) {
4426
        $row_max = Database::fetch_array($result_max);
4427
        return $row_max['max_sort'];
4428
    }
4429
    return 0;
4430
}
4431
4432
/**
4433
 * Determines the number of plugins installed for a given location
4434
 */

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

@@ 4604-4618 (lines=15) @@
4601
     * @param int $user_id The user id
4602
     * @return boolean
4603
     */
4604
    public static function is_user_certified($cat_id, $user_id)
4605
    {
4606
        $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
4607
        $sql = 'SELECT path_certificate FROM '.$table_certificate.'
4608
                WHERE
4609
                    cat_id="'.intval($cat_id).'" AND
4610
                    user_id="'.intval($user_id).'"';
4611
        $rs = Database::query($sql);
4612
        $row = Database::fetch_array($rs);
4613
        if ($row['path_certificate'] == '' || is_null($row['path_certificate'])) {
4614
            return false;
4615
        } else {
4616
            return true;
4617
        }
4618
    }
4619
4620
    /**
4621
     * Gets the info about a gradebook certificate for a user by course