From f8dc0803cf1f198863b52acd199602fb5f69f7d6 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Wed, 10 May 2023 10:47:39 +0200 Subject: [PATCH] fix(form_language): restrict languages to those known by GLPI --- inc/form_language.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/inc/form_language.class.php b/inc/form_language.class.php index 98f9d0da5..002f0b693 100644 --- a/inc/form_language.class.php +++ b/inc/form_language.class.php @@ -111,10 +111,12 @@ 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 ); @@ -122,7 +124,15 @@ public function prepareInputForAdd($input) { } 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 );