Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNREALEASED]

### Fixed

- Fix field entity during parent asset entity transfer

## [1.23.3] - 2026-02-12

### Added
Expand Down
17 changes: 17 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,20 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)

return null;
}

function plugin_item_transfer_fields(array $options): void
{
$itemtype = $options['type'] ?? null;
$container_ids = PluginFieldsContainer::findAllContainers($itemtype);

$container = new PluginFieldsContainer();
foreach ($container_ids as $id) {
$container->getFromDB($id);
$data = [
'plugin_fields_containers_id' => $id,
'items_id' => $options['newID'],
'entities_id' => $options['entities_id'],
];
$container->updateFieldsValues($data, $itemtype, true);
}
}
32 changes: 32 additions & 0 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,38 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '')
return $id;
}

public static function findAllContainers($itemtype)
{
$condition = ['is_active' => 1];

$entity = $_SESSION['glpiactiveentities'] ?? 0;
$condition += getEntitiesRestrictCriteria('', '', $entity, true, true);

$container = new PluginFieldsContainer();
$itemtypes = $container->find($condition);

if (empty($itemtypes)) {
return false;
}

$ids = [];
foreach ($itemtypes as $data) {
$dataitemtypes = PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes']);
if (in_array($itemtype, $dataitemtypes)) {
$id = $data['id'];
//profiles restriction
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $id > 0) {
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $id);
if ($right >= READ) {
$ids[] = $id;
}
}
}
}

return $ids;
}

/**
* Post item hook for add
* Do store data in db
Expand Down
3 changes: 3 additions & 0 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
use Glpi\Form\Destination\FormDestinationTicket;
use Glpi\Form\Migration\TypesConversionMapper;
use Glpi\Form\QuestionType\QuestionTypesManager;
use Glpi\Plugin\Hooks;
use Symfony\Component\Yaml\Yaml;

/**
Expand Down Expand Up @@ -206,6 +207,8 @@ function plugin_init_fields()
'showForTab',
];

$PLUGIN_HOOKS[Hooks::ITEM_TRANSFER]['fields'] = 'plugin_item_transfer_fields';

// Register fields question type
plugin_fields_register_plugin_types();
}
Expand Down