From c55583d1b43d1cc72e831a8ff113bd8c60b1a6d3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 6 Sep 2017 22:51:18 +0200 Subject: [PATCH] allow more than one plugin per share type however it does not dedupe (appears too complex/expensive while we don't havve the issue currently) Signed-off-by: Arthur Schiwon --- .../lib/Controller/ShareesAPIController.php | 2 ++ .../Collaboration/Collaborators/Search.php | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 9e714226d29..45c1b5e6dcf 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -198,6 +198,8 @@ class ShareesAPIController extends OCSController { list($result, $hasMoreResults) = $this->collaboratorSearch->search($search, $shareTypes, $lookup, $this->limit, $this->offset); + // extra treatment for 'exact' subarray, with a single merge expected keys might be lost + $result['exact'] = array_merge($this->result['exact'], $result['exact']); $this->result = array_merge($this->result, $result); $response = new DataResponse($this->result); diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 97ec301ded5..5a17a3fb653 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -35,10 +35,10 @@ class Search implements ISearch { private $c; protected $pluginList = [ - Share::SHARE_TYPE_USER => UserPlugin::class, - Share::SHARE_TYPE_GROUP => GroupPlugin::class, - Share::SHARE_TYPE_EMAIL => MailPlugin::class, - Share::SHARE_TYPE_REMOTE => RemotePlugin::class, + Share::SHARE_TYPE_USER => [UserPlugin::class], + Share::SHARE_TYPE_GROUP => [GroupPlugin::class], + Share::SHARE_TYPE_EMAIL => [MailPlugin::class], + Share::SHARE_TYPE_REMOTE => [RemotePlugin::class], ]; public function __construct(IContainer $c) { @@ -55,9 +55,11 @@ class Search implements ISearch { if(!isset($this->pluginList[$type])) { continue; } - /** @var ISearchPlugin $searchPlugin */ - $searchPlugin = $this->c->resolve($this->pluginList[$type]); - $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); + foreach ($this->pluginList[$type] as $plugin) { + /** @var ISearchPlugin $searchPlugin */ + $searchPlugin = $this->c->resolve($plugin); + $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); + } } // Get from lookup server, not a separate share type @@ -87,6 +89,6 @@ class Search implements ISearch { if($shareType === null) { throw new \InvalidArgumentException('Provided ShareType is invalid'); } - $this->pluginList[$shareType] = $pluginInfo['class']; + $this->pluginList[$shareType][] = $pluginInfo['class']; } }