Skip to content

Commit 6d872a6

Browse files
committed
Feat(Fields): add compatibility with GLPI
1 parent caf661a commit 6d872a6

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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+
## [UNRELEASED]
9+
10+
### Added
11+
12+
- Add compatibility with GLPI `CustomAsset`
13+
14+
815
## [1.23.2] - 2025-12-22
916

1017
- Fix prevent failure when attempting to delete an actor

hook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
353353
/** @var DBmysql $DB */
354354
global $DB;
355355

356-
$searchopt = &Search::getOptions($itemtype);
356+
$searchopt = Search::getOptions($itemtype);
357357
$table = $searchopt[$ID]['table'];
358358
$field = $searchopt[$ID]['field'];
359359
$pfields_type = $searchopt[$ID]['pfields_type'] ?? '';

inc/container.class.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,11 @@ public static function getAddSearchOptions($itemtype, $containers_id = false)
20132013
// > To search for \, specify it as \\\\; this is because the backslashes are stripped
20142014
// > once by the parser and again when the pattern match is made,
20152015
// > leaving a single backslash to be matched against.
2016-
$search_string = str_replace('\\', '\\\\', $search_string);
2016+
2017+
// But do not escape backslashes for CustomAsset, as they are alrady escaped
2018+
if (!str_contains($search_string, 'CustomAsset')) {
2019+
$search_string = str_replace('\\', '\\\\', $search_string);
2020+
}
20172021

20182022
$request = [
20192023
'SELECT' => [

inc/toolbox.class.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ public static function getGlpiItemtypes(): array
232232
Socket::class,
233233
];
234234

235+
foreach ($CFG_GLPI['asset_types'] as $asset_type) {
236+
if (str_starts_with($asset_type, "Glpi\CustomAsset")) {
237+
$assets_itemtypes[] = $asset_type;
238+
}
239+
}
240+
235241
$assistance_itemtypes = [
236242
Ticket::class,
237243
Problem::class,

0 commit comments

Comments
 (0)