diff options
Diffstat (limited to 'lib/private/User')
-rw-r--r-- | lib/private/User/LazyUser.php | 8 | ||||
-rw-r--r-- | lib/private/User/User.php | 25 |
2 files changed, 33 insertions, 0 deletions
diff --git a/lib/private/User/LazyUser.php b/lib/private/User/LazyUser.php index 5472cf6f2b4..396d3c252f1 100644 --- a/lib/private/User/LazyUser.php +++ b/lib/private/User/LazyUser.php @@ -159,4 +159,12 @@ class LazyUser implements IUser { public function setQuota($quota) { $this->getUser()->setQuota($quota); } + + public function getManagerUids(): array { + return $this->getUser()->getManagerUids(); + } + + public function setManagerUids(array $uids): void { + $this->getUser()->setManagerUids($uids); + } } diff --git a/lib/private/User/User.php b/lib/private/User/User.php index ff357a3badb..c68d4ee290a 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -59,8 +59,12 @@ use OCP\User\Backend\IGetHomeBackend; use OCP\UserInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; +use function json_decode; +use function json_encode; class User implements IUser { + private const CONFIG_KEY_MANAGERS = 'manager'; + /** @var IAccountManager */ protected $accountManager; /** @var string */ @@ -532,6 +536,27 @@ class User implements IUser { \OC_Helper::clearStorageInfo('/' . $this->uid . '/files'); } + public function getManagerUids(): array { + $encodedUids = $this->config->getUserValue( + $this->uid, + 'settings', + self::CONFIG_KEY_MANAGERS, + '[]' + ); + return json_decode($encodedUids, false, 512, JSON_THROW_ON_ERROR); + } + + public function setManagerUids(array $uids): void { + $oldUids = $this->getManagerUids(); + $this->config->setUserValue( + $this->uid, + 'settings', + self::CONFIG_KEY_MANAGERS, + json_encode($uids, JSON_THROW_ON_ERROR) + ); + $this->triggerChange('managers', $uids, $oldUids); + } + /** * get the avatar image if it exists * |