Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable23] better display of federated user #876

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ class ConfigService {
];


public const DISPLAY_NONE = 0;
public const DISPLAY_AT = 1;
public const DISPLAY_PARENTHESIS = 2;


/** @var IConfig */
private $config;

Expand Down Expand Up @@ -629,24 +634,34 @@ public function displayFederatedUser(IFederatedUser $federatedUser, bool $displa
$name = ($displayName) ? $federatedUser->getDisplayName() : $federatedUser->getUserId();

if ($federatedUser->getUserType() === Member::TYPE_MAIL) {
return $name . ' (' . $this->displayInstance($federatedUser->getInstance(), false) . ')';
return $name . ' ' . $this->displayInstance(
$federatedUser->getInstance(),
self::DISPLAY_PARENTHESIS
);
}

return $name . $this->displayInstance($federatedUser->getInstance(), true);
return $name . $this->displayInstance($federatedUser->getInstance(), self::DISPLAY_AT);
}

/**
* @param string $instance
* @param bool $showAt
* @param int $type
*
* @return string
*/
public function displayInstance(string $instance, bool $showAt = false): string {
public function displayInstance(string $instance, int $type = self::DISPLAY_NONE): string {
if ($this->isLocalInstance($instance)) {
return '';
}

return (($showAt) ? '@' : '') . $instance;
switch ($type) {
case self::DISPLAY_AT:
return '@' . $instance;
case self::DISPLAY_PARENTHESIS:
return '(' . $instance . ')';
}

return $instance;
}


Expand Down