summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-12-18 14:08:52 +0100
committerGitHub <noreply@github.com>2017-12-18 14:08:52 +0100
commit3da92a9a781a4f16ef9cf14aebb47a6f44945fd8 (patch)
tree3b0ae45bd4fd7708db41d39439f16cf418344b4a /lib
parent97f80f558178b9fc7844148c13b41e52ee4c0c47 (diff)
parente8a4f8300048e20fcc02709d3d0a77348022219e (diff)
downloadnextcloud-server-3da92a9a781a4f16ef9cf14aebb47a6f44945fd8.tar.gz
nextcloud-server-3da92a9a781a4f16ef9cf14aebb47a6f44945fd8.zip
Merge pull request #7490 from nextcloud/fix_7428
Respect sharing options when searching using MailPlugin #7428
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Collaboration/Collaborators/MailPlugin.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php
index d28bd3692a4..2e946c4a872 100644
--- a/lib/private/Collaboration/Collaborators/MailPlugin.php
+++ b/lib/private/Collaboration/Collaborators/MailPlugin.php
@@ -30,10 +30,13 @@ use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
use OCP\Federation\ICloudIdManager;
use OCP\IConfig;
+use OCP\IGroupManager;
+use OCP\IUserSession;
use OCP\Share;
class MailPlugin implements ISearchPlugin {
protected $shareeEnumeration;
+ protected $shareWithGroupOnly;
/** @var IManager */
private $contactsManager;
@@ -42,12 +45,21 @@ class MailPlugin implements ISearchPlugin {
/** @var IConfig */
private $config;
- public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config) {
+ /** @var IGroupManager */
+ private $groupManager;
+
+ /** @var IUserSession */
+ private $userSession;
+
+ public function __construct(IManager $contactsManager, ICloudIdManager $cloudIdManager, IConfig $config, IGroupManager $groupManager, IUserSession $userSession) {
$this->contactsManager = $contactsManager;
$this->cloudIdManager = $cloudIdManager;
$this->config = $config;
+ $this->groupManager = $groupManager;
+ $this->userSession = $userSession;
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
+ $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
}
/**
@@ -77,6 +89,22 @@ class MailPlugin implements ISearchPlugin {
$exactEmailMatch = strtolower($emailAddress) === $lowerSearch;
if (isset($contact['isLocalSystemBook'])) {
+ if ($this->shareWithGroupOnly) {
+ /*
+ * Check if the user may share with the user associated with the e-mail of the just found contact
+ */
+ $userGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
+ $found = false;
+ foreach ($userGroups as $userGroup) {
+ if ($this->groupManager->isInGroup($contact['UID'], $userGroup)) {
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ continue;
+ }
+ }
if ($exactEmailMatch) {
try {
$cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]);