aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Contacts/ContactsMenu/ContactsStore.php
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2021-10-14 08:19:40 +0000
committerChristopher Ng <chrng8@gmail.com>2021-10-19 04:59:35 +0000
commit309354852f12ae88d5eef05d311d6ebcba8ee762 (patch)
tree640c4e2394ba2a868d8d1cb6b5271fd1271bbdab /lib/private/Contacts/ContactsMenu/ContactsStore.php
parent7215148a242815a5064ce5d00a387c634dc936f3 (diff)
downloadnextcloud-server-309354852f12ae88d5eef05d311d6ebcba8ee762.tar.gz
nextcloud-server-309354852f12ae88d5eef05d311d6ebcba8ee762.zip
Profile backend
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'lib/private/Contacts/ContactsMenu/ContactsStore.php')
-rw-r--r--lib/private/Contacts/ContactsMenu/ContactsStore.php54
1 files changed, 46 insertions, 8 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php
index 31e13bbe8f2..a4a53bf8774 100644
--- a/lib/private/Contacts/ContactsMenu/ContactsStore.php
+++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright 2017 Lukas Reschke <lukas@statuscode.ch>
@@ -27,18 +28,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OC\Contacts\ContactsMenu;
use OC\KnownUser\KnownUserService;
+use OCP\Accounts\IAccountManager;
use OCP\Contacts\ContactsMenu\IContactsStore;
use OCP\Contacts\ContactsMenu\IEntry;
use OCP\Contacts\IManager;
use OCP\IConfig;
use OCP\IGroupManager;
+use OCP\IURLGenerator;
use OCP\IUser;
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;
@@ -49,22 +58,36 @@ class ContactsStore implements IContactsStore {
/** @var IUserManager */
private $userManager;
+ /** @var IURLGenerator */
+ private $urlGenerator;
+
/** @var IGroupManager */
private $groupManager;
/** @var KnownUserService */
private $knownUserService;
- public function __construct(IManager $contactsManager,
- IConfig $config,
- IUserManager $userManager,
- IGroupManager $groupManager,
- KnownUserService $knownUserService) {
+ /** @var IL10NFactory */
+ private $l10nFactory;
+
+ public function __construct(
+ IAccountManager $accountManager,
+ IManager $contactsManager,
+ IConfig $config,
+ IUserManager $userManager,
+ IURLGenerator $urlGenerator,
+ IGroupManager $groupManager,
+ KnownUserService $knownUserService,
+ IL10NFactory $l10nFactory
+ ) {
+ $this->accountManager = $accountManager;
$this->contactsManager = $contactsManager;
$this->config = $config;
$this->userManager = $userManager;
+ $this->urlGenerator = $urlGenerator;
$this->groupManager = $groupManager;
$this->knownUserService = $knownUserService;
+ $this->l10nFactory = $l10nFactory;
}
/**
@@ -116,9 +139,11 @@ class ContactsStore implements IContactsStore {
* @param string $filter
* @return Entry[] the filtered contacts
*/
- private function filterContacts(IUser $self,
- array $entries,
- $filter) {
+ private function filterContacts(
+ IUser $self,
+ array $entries,
+ $filter
+ ) {
$disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
$restrictEnumerationGroup = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
$restrictEnumerationPhone = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes';
@@ -302,6 +327,19 @@ 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)) {
+ $entry->setProfileTitle($this->l10nFactory->get('core')->t('View profile'));
+ $entry->setProfileUrl($this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $targetUserId]));
+ }
+ }
+ }
+
// Attach all other properties to the entry too because some
// providers might make use of it.
$entry->setProperties($contact);