diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-02 08:59:46 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-05-12 13:56:48 +0200 |
commit | 1381c4c157f3174917c994038ab74074a42a2aa8 (patch) | |
tree | fe70c5181a99330f4f3292ca217b386a2c6ff354 /apps/dav/lib/CardDAV/Converter.php | |
parent | 1399c88ee178d9fd60f3e9356f1d8c498c6c97e1 (diff) | |
download | nextcloud-server-1381c4c157f3174917c994038ab74074a42a2aa8.tar.gz nextcloud-server-1381c4c157f3174917c994038ab74074a42a2aa8.zip |
feat(users): Store and load a user's manager
Co-Authored-By: hamza221 <hamzamahjoubi221@gmail.com>
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib/CardDAV/Converter.php')
-rw-r--r-- | apps/dav/lib/CardDAV/Converter.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/Converter.php b/apps/dav/lib/CardDAV/Converter.php index e35bc41abd2..d2d646a5a59 100644 --- a/apps/dav/lib/CardDAV/Converter.php +++ b/apps/dav/lib/CardDAV/Converter.php @@ -31,15 +31,19 @@ use Exception; use OCP\Accounts\IAccountManager; use OCP\IImage; use OCP\IUser; +use OCP\IUserManager; use Sabre\VObject\Component\VCard; use Sabre\VObject\Property\Text; class Converter { /** @var IAccountManager */ private $accountManager; + private IUserManager $userManager; - public function __construct(IAccountManager $accountManager) { + public function __construct(IAccountManager $accountManager, + IUserManager $userManager) { $this->accountManager = $accountManager; + $this->userManager = $userManager; } public function createCardFromUser(IUser $user): ?VCard { @@ -102,6 +106,20 @@ class Converter { } } + // Local properties + $managers = $user->getManagerUids(); + // X-MANAGERSNAME only allows a single value, so we take the first manager + if (isset($managers[0])) { + $displayName = $this->userManager->getDisplayName($managers[0]); + // Only set the manager if a user object is found + if ($displayName !== null) { + $vCard->add(new Text($vCard, 'X-MANAGERSNAME', $displayName, [ + 'uid' => $managers[0], + 'X-NC-SCOPE' => IAccountManager::SCOPE_LOCAL, + ])); + } + } + if ($publish && !empty($cloudId)) { $vCard->add(new Text($vCard, 'CLOUD', $cloudId)); $vCard->validate(); |