Skip to content

Commit 9f4ac13

Browse files
committed
fix
1 parent ca4a862 commit 9f4ac13

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

inc/field/filefield.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,13 @@ private function saveDocument($file, $prefix) {
241241
$entities_id = $form->fields['entities_id'];
242242
if ($form->fields['is_recursive']) {
243243
$entities_sons = getSonsOf('glpi_entities', $form->fields['entities_id']);
244-
if (in_array($_SESSION['glpiactive_entity'], $entities_sons)) {
244+
if (in_array($_SESSION['glpiactive_entity'] ?? 0, $entities_sons)) {
245245
$entities_id = $_SESSION['glpiactive_entity'];
246246
}
247247
}
248248

249+
$entities_id = $_SESSION['glpiactive_entity'] ?? $form->getField('entities_id');
250+
249251
$file_data = [
250252
'name' => Toolbox::addslashes_deep($form->fields['name'] . ' - ' . $this->question->fields['name']),
251253
'entities_id' => $entities_id,

inc/formanswer.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,13 @@ public function prepareInputForAdd($input) {
856856
$input['entities_id'] = $form->fields['entities_id'];
857857
if ($form->fields['is_recursive']) {
858858
$entities_sons = getSonsOf('glpi_entities', $form->fields['entities_id']);
859-
if (in_array($_SESSION['glpiactive_entity'], $entities_sons)) {
859+
if (in_array($_SESSION['glpiactive_entity'] ?? 0, $entities_sons)) {
860860
$input['entities_id'] = $_SESSION['glpiactive_entity'];
861861
}
862862
}
863863

864+
$input['entities_id'] = $_SESSION['glpiactive_entity'] ?? $form->getField('entities_id');
865+
864866
$input['is_recursive'] = $form->fields['is_recursive'];
865867
$input['plugin_formcreator_forms_id'] = $form->getID();
866868
// requester_id is actually the author

0 commit comments

Comments
 (0)