glpi
glpi copied to clipboard
[GLPI 10 Buxfixes] Cannot access save searches lists from some plugins
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- [X] I have searched the existing issues
Version
[GLPI 10 Bugfixes]
Bug description
When you use Order plugin or Resouces plugin, the default loaded item is PluginOrderMenu for example :
$PLUGIN_HOOKS['menu_toadd']['order']['management'] = 'PluginOrderMenu';
So the getMenuContent() is defined on this class (and the headers too)
But when you go on order list, even if you add $menu['options']['order']['links']['lists'] = ""; the used class used by data-itemtype into templates/layout/parts/context_links.html.twig is 'PluginOrderMenu' so the saved searches are not loaded.
I propose to patch templates/layout/parts/context_links.html.twig like that :
diff --git a/templates/layout/parts/context_links.html.twig b/templates/layout/parts/context_links.html.twig
index 6d46a0a9e1..34aa45cc21 100644
--- a/templates/layout/parts/context_links.html.twig
+++ b/templates/layout/parts/context_links.html.twig
@@ -32,6 +32,12 @@
#}
{% set links = menu[sector]['content'][item]['options'][option]['links'] ?? menu[sector]['content'][item]['links'] %}
+{% set lists_itemtype = menu[sector]['content'][item]['options'][option]['lists_itemtype'] ?? menu[sector]['content'][item]['lists_itemtype'] %}
+
+{% set itemlinks = item ?? item %}
+{% if lists_itemtype is defined %}
+ {% set itemlinks = lists_itemtype %}
+{% endif %}
{# @TODO border-start is not implemented in current boostrap beta (remove border-left when done) #}
<ul class="nav navbar-nav border-start border-left ps-1 ps-sm-2 flex-row">
@@ -57,7 +63,7 @@
{% if links['lists'] is defined %}
<li class="nav-item">
<a href="#" class="btn btn-icon btn-sm btn-outline-secondary me-1 pe-2 show-saved-searches"
- data-itemtype="{{ item }}" title="{{ __('Lists') }}">
+ data-itemtype="{{ itemlinks }}" title="{{ __('Lists') }}">
<i class="ti ti-star"></i>
<span class="d-none d-xxl-block">{{ __('Lists') }}</span>
</a>
And define into plugins the used itemtype like this :
$menu['options']['order']['links']['lists'] = "";
$menu['options']['order']['lists_itemtype'] = PluginOrderOrder::getType();
...
$menu['options']['bill']['links']['lists'] = "";
$menu['options']['bill']['lists_itemtype'] = PluginOrderBill::getType();
Can you tell me is you are ok with this solution before doing a PR ?
Relevant log output
No response
Page URL
No response
Steps To reproduce
No response
Your GLPI setup information
No response
Anything else?
No response