diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-09-06 21:57:00 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-09-26 23:10:23 +0200 |
commit | f7713e5f3f14db6f15eeec2aba7cbbdcb70830ab (patch) | |
tree | d20f50d3dbcc458beca9f091cb9efecc50ddfa3a /lib/private/Collaboration | |
parent | 4a96e222588104f647f911857e370b3ab692ea22 (diff) | |
download | nextcloud-server-f7713e5f3f14db6f15eeec2aba7cbbdcb70830ab.tar.gz nextcloud-server-f7713e5f3f14db6f15eeec2aba7cbbdcb70830ab.zip |
make it possible to register plugins and kick out the circle one
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Collaboration')
-rw-r--r-- | lib/private/Collaboration/Collaborators/CirclePlugin.php | 52 | ||||
-rw-r--r-- | lib/private/Collaboration/Collaborators/Search.php | 27 |
2 files changed, 17 insertions, 62 deletions
diff --git a/lib/private/Collaboration/Collaborators/CirclePlugin.php b/lib/private/Collaboration/Collaborators/CirclePlugin.php deleted file mode 100644 index 951f70e968b..00000000000 --- a/lib/private/Collaboration/Collaborators/CirclePlugin.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OC\Collaboration\Collaborators; - - -use OCA\Circles\Api\Sharees; -use OCP\Collaboration\Collaborators\ISearchPlugin; -use OCP\Collaboration\Collaborators\ISearchResult; -use OCP\Collaboration\Collaborators\SearchResultType; - -class CirclePlugin implements ISearchPlugin { - - public function search($search, $limit, $offset, ISearchResult $searchResult) { - $result = ['wide' => [], 'exact' => []]; - - if(\OC_App::isEnabled('circles')) { - $circles = Sharees::search($search); - if (array_key_exists('circles', $circles['exact'])) { - $result['exact'] = $circles['exact']['circles']; - } - if (array_key_exists('circles', $circles)) { - $result['wide'] = $circles['circles']; - } - - $type = new SearchResultType('circles'); - $searchResult->addResultSet($type, $result['wide'], $result['exact']); - } - - return false; - } -} diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 815b9eea3e9..97ec301ded5 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -34,6 +34,13 @@ class Search implements ISearch { /** @var IContainer */ 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, + ]; + public function __construct(IContainer $c) { $this->c = $c; } @@ -41,23 +48,15 @@ class Search implements ISearch { public function search($search, array $shareTypes, $lookup, $limit, $offset) { $hasMoreResults = false; - $pluginList = [ - Share::SHARE_TYPE_USER => UserPlugin::class, - Share::SHARE_TYPE_GROUP => GroupPlugin::class, - Share::SHARE_TYPE_CIRCLE => CirclePlugin::class, - Share::SHARE_TYPE_EMAIL => MailPlugin::class, - Share::SHARE_TYPE_REMOTE => RemotePlugin::class, - ]; - /** @var ISearchResult $searchResult */ $searchResult = $this->c->resolve(SearchResult::class); foreach ($shareTypes as $type) { - if(!isset($pluginList[$type])) { + if(!isset($this->pluginList[$type])) { continue; } /** @var ISearchPlugin $searchPlugin */ - $searchPlugin = $this->c->resolve($pluginList[$type]); + $searchPlugin = $this->c->resolve($this->pluginList[$type]); $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult); } @@ -82,4 +81,12 @@ class Search implements ISearch { return [$searchResult->asArray(), $hasMoreResults]; } + + public function registerPlugin(array $pluginInfo) { + $shareType = constant(Share::class . '::' . $pluginInfo['shareType']); + if($shareType === null) { + throw new \InvalidArgumentException('Provided ShareType is invalid'); + } + $this->pluginList[$shareType] = $pluginInfo['class']; + } } |