diff options
Diffstat (limited to 'apps/dashboard/lib/Service/DashboardService.php')
-rw-r--r-- | apps/dashboard/lib/Service/DashboardService.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/apps/dashboard/lib/Service/DashboardService.php b/apps/dashboard/lib/Service/DashboardService.php index 041d4a5c772..bb5333c2cc7 100644 --- a/apps/dashboard/lib/Service/DashboardService.php +++ b/apps/dashboard/lib/Service/DashboardService.php @@ -9,12 +9,17 @@ declare(strict_types=1); namespace OCA\Dashboard\Service; use JsonException; +use OCP\Accounts\IAccountManager; +use OCP\Accounts\PropertyDoesNotExistException; use OCP\IConfig; +use OCP\IUserManager; class DashboardService { public function __construct( private IConfig $config, - private String $userId, + private ?string $userId, + private IUserManager $userManager, + private IAccountManager $accountManager, ) { } @@ -42,4 +47,25 @@ class DashboardService { return array_values(array_filter(explode(',', $configStatuses), fn (string $value) => $value !== '')); } } + + public function getBirthdate(): string { + if ($this->userId === null) { + return ''; + } + + $user = $this->userManager->get($this->userId); + if ($user === null) { + return ''; + } + + $account = $this->accountManager->getAccount($user); + + try { + $birthdate = $account->getProperty(IAccountManager::PROPERTY_BIRTHDATE); + } catch (PropertyDoesNotExistException) { + return ''; + } + + return $birthdate->getValue(); + } } |