Skip to content

Commit

Permalink
Portfolio: Avoid depending on language field in Entity if not properl…
Browse files Browse the repository at this point in the history
…y enabled. Add documentation. Use api_get_language_interface() instead of global - refs BT#19052
  • Loading branch information
ywarnier committed Sep 28, 2021
1 parent a1f6fc2 commit b5a3d35
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion main/admin/settings.lib.php
Expand Up @@ -1363,7 +1363,7 @@ function searchImageFilter($image)
*/
function addEditTemplate()
{
global $language_interface;
$language_interface = api_get_interface_language();

$em = Database::getManager();
// Initialize the object.
Expand Down
16 changes: 8 additions & 8 deletions main/inc/lib/internationalization.lib.php
Expand Up @@ -165,19 +165,19 @@ function get_lang($variable, $returnEmptyIfNotFound = false, $language = null)
/**
* Gets the current interface language.
*
* @param bool $purified (optional) When it is true, a purified (refined)
* language value will be returned, for example 'french' instead of 'french_unicode'
* @param bool $setParentLanguageName
* @param bool $purified (optional) When it is true, a purified (refined) language value will be returned, for example 'french' instead of 'french_unicode'
* @param bool $check_sub_language (optional) Whether we have to consider sub-languages for the determination of a common parent language
* @param bool $setParentLanguageName (optional) If $check_sub_language is true and there is a parent, return the parent language rather than the sub-language
*
* @throws Exception
*
* @return string the current language of the interface
*/
function api_get_interface_language(
$purified = false,
$check_sub_language = false,
$setParentLanguageName = true
) {
bool $purified = false,
bool $check_sub_language = false,
bool $setParentLanguageName = true
): string {
global $language_interface;

if (empty($language_interface)) {
Expand All @@ -188,7 +188,7 @@ function api_get_interface_language(
static $parent_language_name = null;

if (!isset($parent_language_name)) {
// 2. The current language is a sub language so we grab the father's
// 2. The current language is a sub language, so we grab the father's
// setting according to the internalization_database/name_order_convetions.php file
$language_id = api_get_language_id($language_interface);
$language_info = api_get_language_info($language_id);
Expand Down
3 changes: 2 additions & 1 deletion main/install/configuration.dist.php
Expand Up @@ -1134,7 +1134,8 @@
// $_configuration['mail_template_system'] = false;

// Enable filter by language for system and courses templates
//ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT 'english';
//ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT 'english';
//Edit src/Chamilo/CoreBundle/Entity/SystemTemplate.php and add a '@' character in front of 'ORM\Column(name="language"'
// $_configuration['template_activate_language_filter'] = false;

// Students can only upload one publication
Expand Down
2 changes: 1 addition & 1 deletion src/Chamilo/CoreBundle/Entity/SystemTemplate.php
Expand Up @@ -53,7 +53,7 @@ class SystemTemplate
/**
* @var string
*
* @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false)
* ORM\Column(name="language", type="string", length=40, nullable=true, unique=false)
*/
protected $language;

Expand Down

0 comments on commit b5a3d35

Please sign in to comment.