Code Duplication    Length = 13-15 lines in 3 locations

main/gradebook/lib/be/category.class.php 1 location

@@ 762-776 (lines=15) @@
759
    /**
760
     * Shows all information of an category
761
     */
762
    public function shows_all_information_an_category($selectcat = '')
763
    {
764
        if ($selectcat == '') {
765
            return null;
766
        } else {
767
            $tbl_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
768
            $sql = 'SELECT name,description,user_id,course_code,parent_id,weight,visible,certif_min_score,session_id, generate_certificates, is_requirement
769
                    FROM '.$tbl_category.' c
770
                    WHERE c.id='.intval($selectcat);
771
            $result = Database::query($sql);
772
            $row = Database::fetch_array($result, 'ASSOC');
773
774
            return $row;
775
        }
776
    }
777
778
    /**
779
     * Check if a category name (with the same parent category) already exists

main/inc/lib/sub_language.class.php 1 location

@@ 416-428 (lines=13) @@
413
     * Get platform language ID
414
     * @return     int     The platform language ID
415
     */
416
    public static function get_platform_language_id()
417
    {
418
        $name = api_get_setting('platformLanguage');
419
        $tbl_admin_languages = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
420
        $sql = "SELECT id FROM " . $tbl_admin_languages . " WHERE english_name ='$name'";
421
        $res = Database::query($sql);
422
        if (Database::num_rows($res) < 1) {
423
            return false;
424
        }
425
        $row = Database::fetch_array($res);
426
427
        return $row['id'];
428
    }
429
430
    /**
431
     * Get parent language path (or null if no parent)

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

@@ 5554-5568 (lines=15) @@
5551
 * @author Julio Montoya <[email protected]>
5552
 * @return int access_url_id of the current Chamilo Installation
5553
 */
5554
function api_get_current_access_url_id() {
5555
    $access_url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
5556
    $path = Database::escape_string(api_get_path(WEB_PATH));
5557
    $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'";
5558
    $result = Database::query($sql);
5559
    if (Database::num_rows($result) > 0) {
5560
        $access_url_id = Database::result($result, 0, 0);
5561
        return $access_url_id;
5562
    }
5563
    //if the url in WEB_PATH was not found, it can only mean that there is
5564
    // either a configuration problem or the first URL has not been defined yet
5565
    // (by default it is http://localhost/). Thus the more sensible thing we can
5566
    // do is return 1 (the main URL) as the user cannot hack this value anyway
5567
    return 1;
5568
}
5569
5570
/**
5571
 * Gets the registered urls from a given user id