fix: Properly display teams in usergroup

Signed-off-by: Cleopatra Enjeck M. <patrathewhiz@gmail.com>
This commit is contained in:
Cleopatra Enjeck M.
2025-04-16 05:47:02 +01:00
committed by Enjeck
parent b12c22d4fe
commit fca79c7352
4 changed files with 45 additions and 3 deletions

View File

@ -0,0 +1,14 @@
<?php
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Tables\Constants;
class UsergroupType {
public const USER = 0;
public const GROUP = 1;
public const CIRCLE = 2;
}

View File

@ -7,8 +7,11 @@
namespace OCA\Tables\Db;
use OCA\Tables\Constants\UsergroupType;
use OCA\Tables\Helper\CircleHelper;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\IUserSession;
/** @template-extends RowCellMapperSuper<RowCellUsergroup, array, array> */
class RowCellUsergroupMapper extends RowCellMapperSuper {
@ -17,6 +20,8 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
public function __construct(
IDBConnection $db,
private IUserManager $userManager,
private CircleHelper $circleHelper,
protected IUserSession $userSession,
) {
parent::__construct($db, $this->table, RowCellUsergroup::class);
}
@ -34,7 +39,12 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
}
public function formatEntity(Column $column, RowCellSuper $cell) {
$displayName = $cell->getValueType() === 0 ? ($this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue()) : $cell->getValue();
$displayName = $cell->getValue();
if ($cell->getValueType() === UsergroupType::USER) {
$displayName = $this->userManager->getDisplayName($cell->getValue()) ?? $cell->getValue();
} elseif ($cell->getValueType() === UsergroupType::CIRCLE) {
$displayName = $this->circleHelper->getCircleDisplayName($cell->getValue(), $this->userSession->getUser()->getUID() ?? '') ?? $cell->getValue();
}
return [
'id' => $cell->getValue(),
'type' => $cell->getValueType(),