Skip to content

Commit

Permalink
fix(form_language): restrict languages to those known by GLPI
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed May 15, 2023
1 parent 18c9430 commit f8dc080
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions inc/form_language.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,28 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
}

public function prepareInputForAdd($input) {
global $CFG_GLPI;

$formFk = PluginFormcreatorForm::getForeignKeyField();
if (!isset($input['name'])) {
Session::addMessageAfterRedirect(
__('The name cannot be empty!', 'formcreator'),
__('The name cannot be empty.', 'formcreator'),
false,
ERROR
);
return [];
}
if (!isset($input[$formFk])) {
Session::addMessageAfterRedirect(
__('The language must be associated to a form!', 'formcreator'),
__('The language must be associated to a form.', 'formcreator'),
false,
ERROR
);
return [];
}
if (!isset($CFG_GLPI['languages'][$input['name']])) {
Session::addMessageAfterRedirect(
__('The specified language is not available.', 'formcreator'),
false,
ERROR
);
Expand Down

0 comments on commit f8dc080

Please sign in to comment.