Code Duplication    Length = 13-15 lines in 2 locations

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

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

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

@@ 5663-5677 (lines=15) @@
5660
 * @author Julio Montoya <[email protected]>
5661
 * @return int access_url_id of the current Chamilo Installation
5662
 */
5663
function api_get_current_access_url_id() {
5664
    $access_url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
5665
    $path = Database::escape_string(api_get_path(WEB_PATH));
5666
    $sql = "SELECT id FROM $access_url_table WHERE url = '".$path."'";
5667
    $result = Database::query($sql);
5668
    if (Database::num_rows($result) > 0) {
5669
        $access_url_id = Database::result($result, 0, 0);
5670
        return $access_url_id;
5671
    }
5672
    //if the url in WEB_PATH was not found, it can only mean that there is
5673
    // either a configuration problem or the first URL has not been defined yet
5674
    // (by default it is http://localhost/). Thus the more sensible thing we can
5675
    // do is return 1 (the main URL) as the user cannot hack this value anyway
5676
    return 1;
5677
}
5678
5679
/**
5680
 * Gets the registered urls from a given user id