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

@@ 4492-4507 (lines=16) @@
4489
 * @param integer $user_id
4490
 * @return int the value of the highest sort of the user_course_category
4491
 */
4492
function api_max_sort_value($user_course_category, $user_id)
4493
{
4494
    $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
4495
    $sql = "SELECT max(sort) as max_sort FROM $tbl_course_user
4496
            WHERE
4497
                user_id='".intval($user_id)."' AND
4498
                relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
4499
                user_course_cat='".intval($user_course_category)."'";
4500
    $result_max = Database::query($sql);
4501
    if (Database::num_rows($result_max) == 1) {
4502
        $row_max = Database::fetch_array($result_max);
4503
        return $row_max['max_sort'];
4504
    }
4505
    return 0;
4506
}
4507
4508
/**
4509
 * Transforms a number of seconds in hh:mm:ss format
4510
 * @author Julian Prud'homme

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

@@ 4654-4668 (lines=15) @@
4651
     * @param int $user_id The user id
4652
     * @return boolean
4653
     */
4654
    public static function is_user_certified($cat_id, $user_id)
4655
    {
4656
        $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
4657
        $sql = 'SELECT path_certificate FROM '.$table_certificate.'
4658
                WHERE
4659
                    cat_id="'.intval($cat_id).'" AND
4660
                    user_id="'.intval($user_id).'"';
4661
        $rs = Database::query($sql);
4662
        $row = Database::fetch_array($rs);
4663
        if ($row['path_certificate'] == '' || is_null($row['path_certificate'])) {
4664
            return false;
4665
        } else {
4666
            return true;
4667
        }
4668
    }
4669
4670
    /**
4671
     * Gets the info about a gradebook certificate for a user by course