@@ -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 " ) {
@@ -296,11 +298,14 @@ public static function showForTag(PluginTagTag $tag)
296298 'WHERE ' => [
297299 'glpi_plugin_tag_tagitems.plugin_tag_tags_id ' => $ instID ,
298300 ] + getEntitiesRestrictCriteria ($ itemtable , '' , '' , $ item ->maybeRecursive ()),
299- 'ORDERBY ' => [
300- $ itemtable . '. ' . $ column ,
301- ],
302301 ];
303302
303+ if (!empty ($ column )) {
304+ $ criteria ['ORDERBY ' ] = [
305+ $ itemtable . '. ' . $ column ,
306+ ];
307+ }
308+
304309 if ($ item ->maybeTemplate ()) {
305310 $ criteria ['WHERE ' ][$ itemtable . '.is_template ' ] = 0 ;
306311 }
@@ -339,6 +344,10 @@ public static function showForTag(PluginTagTag $tag)
339344 ],
340345 ],
341346 ];
347+ if (!isset ($ criteria ['ORDERBY ' ]) || !is_array ($ criteria ['ORDERBY ' ])) {
348+ $ criteria ['ORDERBY ' ] = [];
349+ }
350+
342351 array_unshift ($ criteria ['ORDERBY ' ], 'glpi_entities.completename ' );
343352 } else {
344353 $ criteria ['SELECT ' ][] = new QueryExpression ('-1 AS ' . $ DB ::quoteName ('entity ' ));
@@ -364,7 +373,7 @@ public static function showForTag(PluginTagTag $tag)
364373 );
365374 }
366375
367- $ linkname = $ data [$ column ];
376+ $ linkname = $ data [$ column ] ?? "" ;
368377
369378 if ($ _SESSION ["glpiis_ids_visible " ] || empty ($ data [$ column ])) {
370379 $ linkname = sprintf (__s ('%1$s (%2$s) ' ), $ linkname , $ data ["id " ]);
0 commit comments