Skip to content

Fix TreeView support for GLPI 11 Custom Assets - #132

Open
BenLasTed wants to merge 29 commits into
pluginsGLPI:mainfrom
BenLasTed:feature/glpi11-custom-assets
Open

BenLasTed wants to merge 29 commits into
pluginsGLPI:mainfrom
BenLasTed:feature/glpi11-custom-assets

Conversation

@BenLasTed

Copy link
Copy Markdown

Description

GLPI 11 moves GenericObject-based assets to the core Custom Assets system. TreeView currently only discovers its static list of item types, so migrated Custom Assets are not displayed.

This PR adds GLPI 11 Custom Asset support by:

  • discovering Custom Asset classes through AssetDefinitionManager;
  • restricting queries to the current asset definition because all Custom Assets share glpi_assets_assets;
  • using the Custom Asset getSearchURL() and getFormURL() methods for navigation.

Testing

Tested with:

  • GLPI 11.0.8
  • TreeView 1.20.3
  • 15 Custom Asset definitions
  • 1,099 assets migrated from GenericObject

Verified:

  • Custom Asset types are displayed in TreeView;
  • filtering by type returns the correct assets;
  • location search links work;
  • individual asset links open the correct Custom Asset.

Related to #108

Add support for GLPI 11 Custom Assets in TreeView.

- Discover Custom Asset classes through AssetDefinitionManager
- Filter the shared assets table by asset definition
- Use Custom Asset search and form URLs

Related to pluginsGLPI#108
@Rom1-B
Rom1-B self-requested a review September 29, 2026 08:29

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a functional test covering the assets_assetdefinitions_id filter? E.g. two active AssetDefinitions with an item each under the same location, asserting getNodesFromDb() only shows the item matching the requested type (regression guard against cross-definition leakage on the shared glpi_assets_assets table).

Please also fix lint and update CHANGELOG.

@BenLasTed
BenLasTed requested a review from Rom1-B September 29, 2026 12:14
@Rom1-B
Rom1-B requested a review from stonebuzz September 29, 2026 14:37
Comment thread inc/config.class.php Outdated
Comment thread inc/config.class.php
Comment thread CHANGELOG.md
@stonebuzz stonebuzz closed this Sep 30, 2026
@stonebuzz stonebuzz reopened this Sep 30, 2026
@BenLasTed
BenLasTed requested a review from stonebuzz September 30, 2026 09:46
@stonebuzz

Copy link
Copy Markdown
Contributor

@BenLasTed please fix CI

@Rom1-B Rom1-B left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenLasTed please fix CI

Comment thread inc/config.class.php Outdated
Comment on lines +133 to +138
if (class_exists(AssetDefinitionManager::class)) {
$types = array_merge(
$types,
AssetDefinitionManager::getInstance()->getCustomObjectClassNames()
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the plugin requires GLPI >= 11.0.0 (PLUGIN_TREEVIEW_MIN_GLPI), AssetDefinitionManager always exists here; this class_exists() guard is dead code.

Suggested change
if (class_exists(AssetDefinitionManager::class)) {
$types = array_merge(
$types,
AssetDefinitionManager::getInstance()->getCustomObjectClassNames()
);
}
$types = array_merge(
$types,
AssetDefinitionManager::getInstance()->getCustomObjectClassNames()
);

@stonebuzz

Copy link
Copy Markdown
Contributor

I'm putting the PR back in draft status so I won't be contacted while you're fixing the CI issues and reviews.

@stonebuzz
stonebuzz marked this pull request as draft October 1, 2026 14:03
@BenLasTed
BenLasTed marked this pull request as ready for review October 9, 2026 08:54
@BenLasTed

Copy link
Copy Markdown
Author

CI now passes on my fork after fixing the test permissions, Composer configuration, formatting and licence headers. The conflict with main is resolved. Ready for review: https://github.com/BenLasTed/treeview/actions/runs/37907430048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants