Skip to content

Commit

Permalink
User: Fix Availability of Language Field
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Mar 6, 2024
1 parent 775393f commit c6a828b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,10 @@ public function initGeneralSettingsForm(): void
$si = new ilSelectInputGUI($this->lng->txt("language"), "language");
$si->setOptions($options);
$si->setValue($ilUser->getLanguage());
$si->setDisabled((bool) $ilSetting->get("usr_settings_disable_language"));
$si->setDisabled(
$ilSetting->get("usr_settings_disable_language") === '1'
|| count($options) <= 1
);
$this->form->addItem($si);
}

Expand Down
17 changes: 10 additions & 7 deletions Services/User/classes/class.ilObjUserGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,18 +1382,21 @@ public function initForm(string $a_mode): void

// language
if ($this->isSettingChangeable('language')) {
$lang = new ilSelectInputGUI(
$lng->txt("language"),
'language'
);
$languages = $lng->getInstalledLanguages();
$lng->loadLanguageModule("meta");
$options = array();
$languages = $this->lng->getInstalledLanguages();
$this->lng->loadLanguageModule('meta');
$options = [];
foreach ($languages as $l) {
$options[$l] = $lng->txt("meta_l_" . $l);
}
$lang = new ilSelectInputGUI(
$this->lng->txt('language'),
'language'
);
$lang->setOptions($options);
$lang->setValue($ilSetting->get("language"));
if (count($options) <= 1) {
$lang->setDisabled(true);
}
$this->form_gui->addItem($lang);
}

Expand Down
5 changes: 4 additions & 1 deletion Services/User/classes/class.ilUserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,10 @@ public function addStandardFieldsToForm(
$ta->setOptions($options);
$ta->setRequired((bool) $ilSetting->get("require_" . $f));
if (!$ta->getRequired() || $ta->getValue()) {
$ta->setDisabled((bool) $ilSetting->get("usr_settings_disable_" . $f));
$ta->setDisabled(
$ilSetting->get("usr_settings_disable_" . $f) === '1'
|| count($options) <= 1
);
}
$a_form->addItem($ta);
}
Expand Down

0 comments on commit c6a828b

Please sign in to comment.