Skip to content

Commit

Permalink
Internal: Remove check_if_exist_language_by_id function for being dup…
Browse files Browse the repository at this point in the history
…licated - refs BT#21568
  • Loading branch information
AngelFQC committed Jan 3, 2025
1 parent d8d5d7b commit 33b068c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
2 changes: 1 addition & 1 deletion public/main/admin/sub_language.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function(data) {
$sub_language_name = SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']);
$all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']);
$all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']);
if (true === SubLanguageManager::check_if_exist_language_by_id($_GET['id'])) {
if (true === SubLanguageManager::languageExistsById((int) $_GET['id'])) {
$language_id_exist = true;
} else {
$language_id_exist = false;
Expand Down
28 changes: 3 additions & 25 deletions public/main/inc/lib/sub_language.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */

use Chamilo\CoreBundle\Entity\Language;
use Doctrine\ORM\Exception\NotSupported;

/**
* This is used in some scripts inside tests.
Expand Down Expand Up @@ -200,31 +201,6 @@ public static function addPoFileForSubLanguage($subLanguageIsoCode)
return true;
}

/**
* check if language exist by id.
*
* @param int $language_id
*
* @return bool
*/
public static function check_if_exist_language_by_id($language_id)
{
$table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$sql = 'SELECT count(*) as count
FROM '.$table.'
WHERE id="'.intval($language_id).'"';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if (1 == Database::result($rs, 0, 'count')) {
return true;
} else {
return false;
}
} else {
return false;
}
}

/**
* Get name of language by id.
*
Expand Down Expand Up @@ -768,6 +744,8 @@ public static function removePoFileForSubLanguage(string $isoCode): bool

/**
* Check if a language exists by its ID.
*
* @throws NotSupported
*/
public static function languageExistsById(int $languageId): bool
{
Expand Down

0 comments on commit 33b068c

Please sign in to comment.