group in list
This commit is contained in:
+25
-1
@@ -1122,7 +1122,7 @@ class Server extends CommonDBTM
|
|||||||
$locationName = self::getCachedLocationName($assetLocationId, $cacheLocation);
|
$locationName = self::getCachedLocationName($assetLocationId, $cacheLocation);
|
||||||
$stateName = self::getCachedName('State', (int) ($assetRow['states_id'] ?? 0), $cacheState);
|
$stateName = self::getCachedName('State', (int) ($assetRow['states_id'] ?? 0), $cacheState);
|
||||||
$userName = self::getCachedName('User', (int) ($assetRow['users_id'] ?? 0), $cacheUser);
|
$userName = self::getCachedName('User', (int) ($assetRow['users_id'] ?? 0), $cacheUser);
|
||||||
$groupName = self::getCachedName('Group', (int) ($assetRow['groups_id'] ?? 0), $cacheGroup);
|
$groupName = self::getAssetGroupName($itemtype, $assetId, $cacheGroup);
|
||||||
|
|
||||||
$ip = self::getAssetIp($itemtype, $assetId);
|
$ip = self::getAssetIp($itemtype, $assetId);
|
||||||
|
|
||||||
@@ -1209,6 +1209,30 @@ class Server extends CommonDBTM
|
|||||||
return $cache[$id];
|
return $cache[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getAssetGroupName(string $itemtype, int $items_id, array &$cache): string
|
||||||
|
{
|
||||||
|
global $DB;
|
||||||
|
|
||||||
|
$iterator = $DB->request([
|
||||||
|
'FROM' => 'glpi_groups_items',
|
||||||
|
'WHERE' => [
|
||||||
|
'itemtype' => $itemtype,
|
||||||
|
'items_id' => $items_id,
|
||||||
|
'type' => \Group_Item::GROUP_TYPE_NORMAL,
|
||||||
|
],
|
||||||
|
'LIMIT' => 1,
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($iterator as $row) {
|
||||||
|
$groupId = (int) ($row['groups_id'] ?? 0);
|
||||||
|
if ($groupId > 0) {
|
||||||
|
return self::getCachedName('Group', $groupId, $cache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
private static function getCachedLocationName(int $id, array &$cache): string
|
private static function getCachedLocationName(int $id, array &$cache): string
|
||||||
{
|
{
|
||||||
if ($id <= 0) {
|
if ($id <= 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user