diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e8930c7..ee6bf7bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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/). +## [UNRELEASED] + +### Added + +- Add compatibility with GLPI `CustomAsset` + + ## [1.23.2] - 2025-12-22 - Fix prevent failure when attempting to delete an actor diff --git a/hook.php b/hook.php index 0eabc024..3ccd34ea 100644 --- a/hook.php +++ b/hook.php @@ -353,7 +353,7 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype) /** @var DBmysql $DB */ global $DB; - $searchopt = &Search::getOptions($itemtype); + $searchopt = Search::getOptions($itemtype); $table = $searchopt[$ID]['table']; $field = $searchopt[$ID]['field']; $pfields_type = $searchopt[$ID]['pfields_type'] ?? ''; diff --git a/inc/container.class.php b/inc/container.class.php index 16d249c5..f31e4241 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -2013,7 +2013,11 @@ public static function getAddSearchOptions($itemtype, $containers_id = false) // > To search for \, specify it as \\\\; this is because the backslashes are stripped // > once by the parser and again when the pattern match is made, // > leaving a single backslash to be matched against. - $search_string = str_replace('\\', '\\\\', $search_string); + + // But do not escape backslashes for CustomAsset, as they are alrady escaped + if (!str_contains($search_string, 'CustomAsset')) { + $search_string = str_replace('\\', '\\\\', $search_string); + } $request = [ 'SELECT' => [ diff --git a/inc/toolbox.class.php b/inc/toolbox.class.php index 6b95ceb9..a8e114a7 100644 --- a/inc/toolbox.class.php +++ b/inc/toolbox.class.php @@ -232,6 +232,12 @@ public static function getGlpiItemtypes(): array Socket::class, ]; + foreach ($CFG_GLPI['asset_types'] as $asset_type) { + if (str_starts_with((string) $asset_type, "Glpi\CustomAsset")) { + $assets_itemtypes[] = $asset_type; + } + } + $assistance_itemtypes = [ Ticket::class, Problem::class,