diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2022-03-17 21:35:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 21:35:58 -0700 |
commit | b0fbcccfe66474d79586001ce9509d346919ae74 (patch) | |
tree | 3c2d3f2382b83eb93cae4f974d20bbbbe2b9789b /lib/private/Contacts | |
parent | d364edcf6a18fa237dc53f6b95614851ed5fdc9a (diff) | |
parent | 108abd77ed0ee29bca4019f6a212ba1b2bdad5e7 (diff) | |
download | nextcloud-server-b0fbcccfe66474d79586001ce9509d346919ae74.tar.gz nextcloud-server-b0fbcccfe66474d79586001ce9509d346919ae74.zip |
Merge pull request #29372 from nextcloud/feat/28139/global-profile-toggle
Diffstat (limited to 'lib/private/Contacts')
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 20 | ||||
-rw-r--r-- | lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php | 18 |
2 files changed, 17 insertions, 21 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index a27c2ae455a..5b7a942a244 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -32,7 +32,7 @@ namespace OC\Contacts\ContactsMenu; use OC\KnownUser\KnownUserService; -use OCP\Accounts\IAccountManager; +use OC\Profile\ProfileManager; use OCP\Contacts\ContactsMenu\IContactsStore; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\IManager; @@ -44,10 +44,6 @@ use OCP\IUserManager; use OCP\L10N\IFactory as IL10NFactory; class ContactsStore implements IContactsStore { - use \OC\Profile\TProfileHelper; - - /** @var IAccountManager */ - private $accountManager; /** @var IManager */ private $contactsManager; @@ -55,6 +51,9 @@ class ContactsStore implements IContactsStore { /** @var IConfig */ private $config; + /** @var ProfileManager */ + private $profileManager; + /** @var IUserManager */ private $userManager; @@ -71,18 +70,18 @@ class ContactsStore implements IContactsStore { private $l10nFactory; public function __construct( - IAccountManager $accountManager, IManager $contactsManager, IConfig $config, + ProfileManager $profileManager, IUserManager $userManager, IURLGenerator $urlGenerator, IGroupManager $groupManager, KnownUserService $knownUserService, IL10NFactory $l10nFactory ) { - $this->accountManager = $accountManager; $this->contactsManager = $contactsManager; $this->config = $config; + $this->profileManager = $profileManager; $this->userManager = $userManager; $this->urlGenerator = $urlGenerator; $this->groupManager = $groupManager; @@ -335,10 +334,9 @@ class ContactsStore implements IContactsStore { // Provide profile parameters for core/src/OC/contactsmenu/contact.handlebars template if (isset($contact['UID']) && isset($contact['FN'])) { $targetUserId = $contact['UID']; - $user = $this->userManager->get($targetUserId); - if (!empty($user)) { - $account = $this->accountManager->getAccount($user); - if ($this->isProfileEnabled($account)) { + $targetUser = $this->userManager->get($targetUserId); + if (!empty($targetUser)) { + if ($this->profileManager->isProfileEnabled($targetUser)) { $entry->setProfileTitle($this->l10nFactory->get('lib')->t('View profile')); $entry->setProfileUrl($this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $targetUserId])); } diff --git a/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php b/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php index 15d24fc7773..e654319c3fa 100644 --- a/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php +++ b/lib/private/Contacts/ContactsMenu/Providers/ProfileProvider.php @@ -24,7 +24,7 @@ namespace OC\Contacts\ContactsMenu\Providers; -use OCP\Accounts\IAccountManager; +use OC\Profile\ProfileManager; use OCP\Contacts\ContactsMenu\IActionFactory; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IProvider; @@ -33,14 +33,13 @@ use OCP\IUserManager; use OCP\L10N\IFactory as IL10NFactory; class ProfileProvider implements IProvider { - use \OC\Profile\TProfileHelper; - - /** @var IAccountManager */ - private $accountManager; /** @var IActionFactory */ private $actionFactory; + /** @var ProfileManager */ + private $profileManager; + /** @var IL10NFactory */ private $l10nFactory; @@ -51,21 +50,21 @@ class ProfileProvider implements IProvider { private $userManager; /** - * @param IAccountManager $accountManager * @param IActionFactory $actionFactory + * @param ProfileManager $profileManager * @param IL10NFactory $l10nFactory * @param IURLGenerator $urlGenerator * @param IUserManager $userManager */ public function __construct( - IAccountManager $accountManager, IActionFactory $actionFactory, + ProfileManager $profileManager, IL10NFactory $l10nFactory, IURLGenerator $urlGenerator, IUserManager $userManager ) { - $this->accountManager = $accountManager; $this->actionFactory = $actionFactory; + $this->profileManager = $profileManager; $this->l10nFactory = $l10nFactory; $this->urlGenerator = $urlGenerator; $this->userManager = $userManager; @@ -78,8 +77,7 @@ class ProfileProvider implements IProvider { $targetUserId = $entry->getProperty('UID'); $targetUser = $this->userManager->get($targetUserId); if (!empty($targetUser)) { - $account = $this->accountManager->getAccount($targetUser); - if ($this->isProfileEnabled($account)) { + if ($this->profileManager->isProfileEnabled($targetUser)) { $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/profile.svg')); $profileActionText = $this->l10nFactory->get('lib')->t('View profile'); $profileUrl = $this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $targetUserId]); |