Skip to content

Commit cf9adac

Browse files
authored
Merge branch 'main' into fix/form-question-handle-null-value
2 parents 5d494f7 + b3d4f91 commit cf9adac

30 files changed

+3654
-2044
lines changed

API.md

Lines changed: 793 additions & 0 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [1.23.4] - Unreleased
8+
## [1.23.5] - Unreleased
99

1010
### Fixed
1111

1212
- Fix error when submitting a form with an hidden question of type `Field`
1313

14+
## [1.23.4] - 2026-03-26
15+
16+
### Fixed
17+
18+
- Fix CRUD hooks to support the REST API regardless of session state
19+
- Fix SQL errors with custom dropdown fields
20+
- Fix wrong values displayed in massive actions when a form contains multiple custom dropdowns
21+
- Fix field entity during parent asset entity transfer
22+
1423
## [1.23.3] - 2026-02-12
1524

1625
### Added
@@ -19,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1928

2029
### Fixed
2130

31+
- Fix `CVE-2026-23489`
2232
- Fix migration error caused by unknown itemtype in containers
2333
- Fix empty default value in multiple dropdown fields
2434

hook.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function plugin_fields_MassiveActionsFieldsDisplay($options = [])
211211
$itemtypes = PluginFieldsContainer::getEntries('all');
212212

213213
if (in_array($options['itemtype'], $itemtypes)) {
214-
if ($options['options']['is_multiple']) {
214+
if (isset($options['options']['is_multiple']) && $options['options']['is_multiple']) {
215215
Dropdown::showFromArray(
216216
'multiple_dropdown_action',
217217
[
@@ -434,3 +434,21 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
434434

435435
return null;
436436
}
437+
438+
function plugin_item_transfer_fields(array $options): void
439+
{
440+
$itemtype = $options['type'] ?? null;
441+
$container_ids = PluginFieldsContainer::findAllContainers($itemtype);
442+
443+
$container = new PluginFieldsContainer();
444+
foreach ($container_ids as $id) {
445+
$container->getFromDB($id);
446+
$data = [
447+
'plugin_fields_containers_id' => $id,
448+
'itemtype' => $itemtype,
449+
'items_id' => $options['newID'],
450+
'entities_id' => $options['entities_id'],
451+
];
452+
$container->updateFieldsValues($data, $itemtype, true);
453+
}
454+
}

inc/container.class.php

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,6 +1793,38 @@ public static function findContainer($itemtype, $type = 'tab', $subtype = '')
17931793
return $id;
17941794
}
17951795

1796+
public static function findAllContainers($itemtype)
1797+
{
1798+
$condition = ['is_active' => 1];
1799+
1800+
$entity = $_SESSION['glpiactiveentities'] ?? 0;
1801+
$condition += getEntitiesRestrictCriteria('', '', $entity, true, true);
1802+
1803+
$container = new PluginFieldsContainer();
1804+
$itemtypes = $container->find($condition);
1805+
1806+
if (empty($itemtypes)) {
1807+
return false;
1808+
}
1809+
1810+
$ids = [];
1811+
foreach ($itemtypes as $data) {
1812+
$dataitemtypes = PluginFieldsToolbox::decodeJSONItemtypes($data['itemtypes']);
1813+
if (in_array($itemtype, $dataitemtypes)) {
1814+
$id = $data['id'];
1815+
//profiles restriction
1816+
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $id > 0) {
1817+
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $id);
1818+
if ($right >= READ) {
1819+
$ids[] = $id;
1820+
}
1821+
}
1822+
}
1823+
}
1824+
1825+
return $ids;
1826+
}
1827+
17961828
/**
17971829
* Post item hook for add
17981830
* Do store data in db
@@ -1889,14 +1921,15 @@ public static function preItem(CommonDBTM $item)
18891921
$loc_c->getFromDB($c_id);
18901922

18911923
// check rights on $c_id
1892-
1924+
// The profile check is only enforced when an active user profile is present in session.
1925+
// Automated contexts (cron jobs, API token sessions without profile) bypass the check
1926+
// so that plugin fields can still be persisted — authentication is already enforced
1927+
// at a higher level by the GLPI API/cron layer.
18931928
if (isset($_SESSION['glpiactiveprofile']['id']) && $_SESSION['glpiactiveprofile']['id'] != null && $c_id > 0) {
18941929
$right = PluginFieldsProfile::getRightOnContainer($_SESSION['glpiactiveprofile']['id'], $c_id);
18951930
if (($right > READ) === false) {
18961931
return false;
18971932
}
1898-
} else {
1899-
return false;
19001933
}
19011934

19021935

@@ -2217,8 +2250,11 @@ public static function getAddSearchOptions($itemtype, $containers_id = false)
22172250
$opt[$i]['datatype'] = 'specific';
22182251
$opt[$i]['searchtype'] = ['equals', 'notequals'];
22192252
} else {
2220-
$opt[$i]['table'] = CommonDBTM::getTable($dropdown_matches['class']);
2221-
$opt[$i]['field'] = 'name';
2253+
$opt[$i]['table'] = getTableForItemType($dropdown_matches['class']);
2254+
$opt[$i]['field'] = is_a($dropdown_matches['class'], CommonTreeDropdown::class, true)
2255+
? 'completename'
2256+
: 'name';
2257+
$opt[$i]['itemtype'] = $dropdown_matches['class'];
22222258
$opt[$i]['right'] = 'all';
22232259
$opt[$i]['datatype'] = 'dropdown';
22242260

inc/field.class.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,13 +1151,15 @@ public static function prepareHtmlFields(
11511151
$classname = PluginFieldsContainer::getClassname($item->getType(), $container_obj->fields['name']);
11521152
$dbu = new DbUtils();
11531153
$obj = $dbu->getItemForItemtype($classname);
1154-
$found_values = $obj->find(
1155-
[
1156-
'plugin_fields_containers_id' => $first_field['plugin_fields_containers_id'],
1157-
'items_id' => $item->getID(),
1158-
],
1159-
);
1160-
$found_v = array_shift($found_values);
1154+
if ($obj instanceof CommonDBTM) {
1155+
$found_values = $obj->find(
1156+
[
1157+
'plugin_fields_containers_id' => $first_field['plugin_fields_containers_id'],
1158+
'items_id' => $item->getID(),
1159+
],
1160+
);
1161+
$found_v = array_shift($found_values);
1162+
}
11611163
}
11621164

11631165
// test status for "CommonITILObject" objects

0 commit comments

Comments
 (0)