Skip to content

Commit f1ecc2d

Browse files
authored
fix(files): entity (#3566)
* fix(files): entity * fix
1 parent f336e1b commit f1ecc2d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

inc/field/filefield.class.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,20 @@ private function saveDocument($file, $prefix) {
238238
return;
239239
}
240240

241+
$entities_id = $form->getField('entities_id');
242+
if ($form->getField('is_recursive')) {
243+
$entities_sons = getSonsOf('glpi_entities', $entities_id);
244+
if (isset($_SESSION['glpiactive_entity'])
245+
&& $_SESSION['glpiactive_entity'] != $entities_id
246+
&& in_array($_SESSION['glpiactive_entity'], $entities_sons)
247+
) {
248+
$entities_id = $_SESSION['glpiactive_entity'];
249+
}
250+
}
251+
241252
$file_data = [
242253
'name' => Toolbox::addslashes_deep($form->fields['name'] . ' - ' . $this->question->fields['name']),
243-
'entities_id' => $_SESSION['glpiactive_entity'] ?? $form->getField('entities_id'),
254+
'entities_id' => $entities_id,
244255
'is_recursive' => $form->getField('is_recursive'),
245256
'_filename' => [$file],
246257
'_prefix_filename' => [$prefix],

0 commit comments

Comments
 (0)