Skip to content

Commit f8dc080

Browse files
committed
fix(form_language): restrict languages to those known by GLPI
1 parent 18c9430 commit f8dc080

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

inc/form_language.class.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,28 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
111111
}
112112

113113
public function prepareInputForAdd($input) {
114+
global $CFG_GLPI;
115+
114116
$formFk = PluginFormcreatorForm::getForeignKeyField();
115117
if (!isset($input['name'])) {
116118
Session::addMessageAfterRedirect(
117-
__('The name cannot be empty!', 'formcreator'),
119+
__('The name cannot be empty.', 'formcreator'),
118120
false,
119121
ERROR
120122
);
121123
return [];
122124
}
123125
if (!isset($input[$formFk])) {
124126
Session::addMessageAfterRedirect(
125-
__('The language must be associated to a form!', 'formcreator'),
127+
__('The language must be associated to a form.', 'formcreator'),
128+
false,
129+
ERROR
130+
);
131+
return [];
132+
}
133+
if (!isset($CFG_GLPI['languages'][$input['name']])) {
134+
Session::addMessageAfterRedirect(
135+
__('The specified language is not available.', 'formcreator'),
126136
false,
127137
ERROR
128138
);

0 commit comments

Comments
 (0)