Skip to content
18 changes: 18 additions & 0 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use OCP\Notification\IManager;
use OCP\Server;
use OCP\Settings\ISettings;
use OCP\Teams\ITeamManager;
use OCP\Teams\Team;
use OCP\Util;

class PersonalInfo implements ISettings {
Expand All @@ -40,6 +42,7 @@ public function __construct(
private IConfig $config,
private IUserManager $userManager,
private IGroupManager $groupManager,
private ITeamManager $teamManager,
private IAccountManager $accountManager,
ProfileManager $profileManager,
private IAppManager $appManager,
Expand Down Expand Up @@ -87,6 +90,7 @@ public function getForm(): TemplateResponse {
'userId' => $uid,
'avatar' => $this->getProperty($account, IAccountManager::PROPERTY_AVATAR),
'groups' => $this->getGroups($user),
'teams' => $this->getTeamMemberships($user),
'quota' => $storageInfo['quota'],
'totalSpace' => $totalSpace,
'usage' => Util::humanFileSize($storageInfo['used']),
Expand Down Expand Up @@ -192,6 +196,20 @@ static function (IGroup $group) {
return $groups;
}

/**
* returns a list of the user's team memberships, sorted alphabetically
* @return list<string> team names
*/
private function getTeamMemberships(IUser $user): array {
$teams = array_map(
static fn (Team $team): string => $team->getDisplayName(),
$this->teamManager->getTeamsForUser($user->getUID())
);
sort($teams);

return $teams;
}

/**
* returns the primary email and additional emails in an
* associative array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="details__groups-info">
<p>{{ t('settings', 'You are a member of the following groups:') }}</p>
<p class="details__groups-list">
{{ groups.join(', ') }}
{{ [...groups, ...teams].join(', ') }}
</p>
</div>
</div>
Expand Down Expand Up @@ -43,7 +43,7 @@ import HeaderBar from './shared/HeaderBar.vue'
/** SYNC to be kept in sync with `lib/public/Files/FileInfo.php` */
const SPACE_UNLIMITED = -3

const { groups, quota, totalSpace, usage, usageRelative } = loadState('settings', 'personalInfoParameters', {})
const { groups, teams, quota, totalSpace, usage, usageRelative } = loadState('settings', 'personalInfoParameters', {})

export default {
name: 'DetailsSection',
Expand All @@ -58,6 +58,7 @@ export default {
data() {
return {
groups,
teams,
usageRelative,
}
},
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-vue-settings-personal-info.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-personal-info.js.map

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions lib/private/Teams/TeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,23 @@ private function getTeams(array $teams, string $userId): array {
$this->circlesManager->startSession($federatedUser);
return $this->circlesManager->getCirclesByIds($teams);
}

public function getTeamsForUser(string $userId): array {
if (!$this->hasTeamSupport()) {
return [];
}

$federatedUser = $this->circlesManager->getFederatedUser($userId, Member::TYPE_USER);
$this->circlesManager->startSession($federatedUser);
$teams = [];
foreach ($this->circlesManager->probeCircles() as $team) {
$teams[] = new Team(
$team->getSingleId(),
$team->getDisplayName(),
$this->urlGenerator->linkToRouteAbsolute('contacts.contacts.directcircle', ['singleId' => $team->getSingleId()]),
);
}

return $teams;
}
}
8 changes: 8 additions & 0 deletions lib/public/Teams/ITeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ public function getTeamsForResource(string $providerId, string $resourceId, stri
* @since 33.0.0
*/
public function getSharedWithList(array $teams, string $userId): array;

/**
* Returns all teams that a given user is a member of
*
* @return list<Team>
* @since 33.0.0
*/
public function getTeamsForUser(string $userId): array;
}
Loading