@@ -265,7 +265,9 @@ public static function showForTag(PluginTagTag $tag)
265265 $ item_id = $ result2 [$ i ]['items_id ' ];
266266
267267 if ($ item ->canView ()) {
268- $ column = (strtolower (substr ((string ) $ itemtype , 0 , 6 )) === "device " ) ? "designation " : "name " ;
268+ $ column = (stripos ((string ) $ itemtype , 'item_device ' ) !== false )
269+ ? ''
270+ : ((stripos ((string ) $ itemtype , 'device ' ) === 0 ) ? 'designation ' : 'name ' );
269271
270272 // For rules itemtypes (example : ruledictionnaryphonemodel)
271273 if (strtolower (substr ((string ) $ itemtype , 0 , 4 )) === 'rule ' || $ itemtype == "PluginResourcesRulechecklist " ) {
@@ -297,10 +299,15 @@ public static function showForTag(PluginTagTag $tag)
297299 'glpi_plugin_tag_tagitems.plugin_tag_tags_id ' => $ instID ,
298300 ] + getEntitiesRestrictCriteria ($ itemtable , '' , '' , $ item ->maybeRecursive ()),
299301 'ORDERBY ' => [
300- $ itemtable . '. ' . $ column ,
301- ],
302+ ]
302303 ];
303304
305+ if ($ column !== '' ) {
306+ $ criteria ['ORDERBY ' ] = [
307+ $ itemtable . '. ' . $ column ,
308+ ];
309+ }
310+
304311 if ($ item ->maybeTemplate ()) {
305312 $ criteria ['WHERE ' ][$ itemtable . '.is_template ' ] = 0 ;
306313 }
@@ -364,7 +371,7 @@ public static function showForTag(PluginTagTag $tag)
364371 );
365372 }
366373
367- $ linkname = $ data [$ column ];
374+ $ linkname = $ data [$ column ] ?? "" ;
368375
369376 if ($ _SESSION ["glpiis_ids_visible " ] || empty ($ data [$ column ])) {
370377 $ linkname = sprintf (__s ('%1$s (%2$s) ' ), $ linkname , $ data ["id " ]);
0 commit comments