diff --git a/lib/Api/Sharees.php b/lib/Api/Sharees.php
deleted file mode 100644
index 76cf92e3..00000000
--- a/lib/Api/Sharees.php
+++ /dev/null
@@ -1,112 +0,0 @@
-
- * @copyright 2017
- * @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 .
- *
- */
-
-namespace OCA\Circles\Api;
-
-use OCA\Circles\AppInfo\Application;
-use OCA\Circles\Model\DeprecatedCircle;
-use OCA\Circles\Model\DeprecatedMember;
-use OCA\Circles\Service\CirclesService;
-use OCA\Circles\Service\MiscService;
-use OCP\Share;
-
-
-/**
- * ############### WARNING #################
- * ###
- * ### This file is needed and used by Nextcloud 12 and lower.
- * ###
- *
- * @package OCA\Circles\Api
- */
-class Sharees {
-
-
- protected static function getContainer() {
- $app = \OC::$server->query(Application::class);
-
- return $app->getContainer();
- }
-
- /**
- * returns circles with
- *
- * @param $search
- *
- * @return array
- */
-// public static function search($search, $limit, $offset) {
- public static function search($search) {
- $c = self::getContainer();
- $userId = \OC::$server->getUserSession()
- ->getUser()
- ->getUID();
-
- $data = $c->query(CirclesService::class)
- ->listCircles($userId, DeprecatedCircle::CIRCLES_ALL, $search, DeprecatedMember::LEVEL_MEMBER);
- $result = array(
- 'exact' => ['circles'],
- 'circles' => []
- );
-
- foreach ($data as $entry) {
- self::addResultEntry(
- $result, $entry, (strtolower($entry->getName()) === strtolower($search))
- );
- }
-
- return $result;
- }
-
-
- /**
- * @param $result
- * @param DeprecatedCircle $entry
- * @param bool $exact
- *
- */
- private static function addResultEntry(&$result, $entry, $exact = false) {
-
- $arr = [
- 'label' => $entry->getName(),
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_CIRCLE,
- 'shareWith' => $entry->getUniqueId(),
- 'circleInfo' => $entry->getInfo(),
- 'circleOwner' => $entry->getOwner()
- ->getCachedName()
- ],
- ];
-
- if ($exact) {
- $result['exact']['circles'][] = $arr;
- } else {
- $result['circles'][] = $arr;
- }
-
- }
-
-}
diff --git a/lib/Collaboration/v2/CollaboratorSearchPlugin.php b/lib/Collaboration/v2/CollaboratorSearchPlugin.php
index ab82cce1..16ddc9aa 100644
--- a/lib/Collaboration/v2/CollaboratorSearchPlugin.php
+++ b/lib/Collaboration/v2/CollaboratorSearchPlugin.php
@@ -33,15 +33,9 @@ namespace OCA\Circles\Collaboration\v2;
use daita\MySmallPhpTools\Model\SimpleDataStore;
+use Exception;
use OC\Share20\Share;
-use OC\User\NoUserException;
-use OCA\Circles\Exceptions\FederatedUserException;
-use OCA\Circles\Exceptions\FederatedUserNotFoundException;
-use OCA\Circles\Exceptions\InitiatorNotFoundException;
-use OCA\Circles\Exceptions\InvalidIdException;
-use OCA\Circles\Exceptions\SingleCircleNotFoundException;
use OCA\Circles\Model\Circle;
-use OCA\Circles\Model\Member;
use OCA\Circles\Service\CircleService;
use OCA\Circles\Service\FederatedUserService;
use OCP\Collaboration\Collaborators\ISearchPlugin;
@@ -83,42 +77,31 @@ class CollaboratorSearchPlugin implements ISearchPlugin {
* @param ISearchResult $searchResult
*
* @return bool
- * @throws FederatedUserException
- * @throws FederatedUserNotFoundException
- * @throws InitiatorNotFoundException
- * @throws InvalidIdException
- * @throws SingleCircleNotFoundException
*/
public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
- $this->federatedUserService->initCurrentUser();
-
$wide = $exact = [];
$filterCircle = new Circle();
$filterCircle->setName($search)
->setDisplayName($search);
- $filterMember = new Member();
- $filterMember->importFromIFederatedUser($this->federatedUserService->getCurrentUser());
- $filterMember->setLevel(Member::LEVEL_MEMBER);
-
- $circles = $this->circleService->getCircles(
- $filterCircle, $filterMember,
- new SimpleDataStore(
- [
- 'limit' => $limit,
- 'offset' => $offset
- ]
- )
- );
+ try {
+ $this->federatedUserService->initCurrentUser();
+ $circles = $this->circleService->getCircles(
+ $filterCircle, null,
+ new SimpleDataStore(
+ [
+ 'limit' => $limit,
+ 'offset' => $offset
+ ]
+ )
+ );
+ } catch (Exception $e) {
+ return false;
+ }
foreach ($circles as $circle) {
- try {
- $entry = $this->addResultEntry($circle);
- } catch (NoUserException $e) {
- continue;
- }
-
+ $entry = $this->addResultEntry($circle);
if (strtolower($circle->getName()) === strtolower($search)) {
$exact[] = $entry;
} else {
diff --git a/lib/Command/CirclesCreate.php b/lib/Command/CirclesCreate.php
index 98478f7f..5fa06a23 100644
--- a/lib/Command/CirclesCreate.php
+++ b/lib/Command/CirclesCreate.php
@@ -36,8 +36,6 @@ use OCA\Circles\Exceptions\SingleCircleNotFoundException;
use OCA\Circles\Model\Member;
use OCA\Circles\Service\CircleService;
use OCA\Circles\Service\FederatedUserService;
-use OCP\IL10N;
-use OCP\IUserManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
@@ -52,12 +50,6 @@ use Symfony\Component\Console\Output\OutputInterface;
class CirclesCreate extends Base {
- /** @var IL10N */
- private $l10n;
-
- /** @var IUserManager */
- private $userManager;
-
/** @var FederatedUserService */
private $federatedUserService;
@@ -68,18 +60,14 @@ class CirclesCreate extends Base {
/**
* CirclesCreate constructor.
*
- * @param IL10N $l10n
- * @param IUserManager $userManager
* @param FederatedUserService $federatedUserService
* @param CircleService $circleService
*/
public function __construct(
- IL10N $l10n, IUserManager $userManager, FederatedUserService $federatedUserService,
+ FederatedUserService $federatedUserService,
CircleService $circleService
) {
parent::__construct();
- $this->l10n = $l10n;
- $this->userManager = $userManager;
$this->federatedUserService = $federatedUserService;
$this->circleService = $circleService;
@@ -130,7 +118,9 @@ class CirclesCreate extends Base {
throw $e;
}
- $output->writeln(json_encode($outcome, JSON_PRETTY_PRINT));
+ if (strtolower($input->getOption('output')) !== 'none') {
+ $output->writeln(json_encode($outcome, JSON_PRETTY_PRINT));
+ }
return 0;
}
diff --git a/lib/Command/MembersAdd.php b/lib/Command/MembersAdd.php
index 4d34b2f4..80638c54 100644
--- a/lib/Command/MembersAdd.php
+++ b/lib/Command/MembersAdd.php
@@ -146,7 +146,9 @@ class MembersAdd extends Base {
throw $e;
}
- $output->writeln(json_encode($outcome, JSON_PRETTY_PRINT));
+ if (strtolower($input->getOption('output')) !== 'none') {
+ $output->writeln(json_encode($outcome, JSON_PRETTY_PRINT));
+ }
return 0;
}
diff --git a/lib/Db/CoreQueryBuilder.php b/lib/Db/CoreQueryBuilder.php
index b5ed2fc1..dc3a8ad9 100644
--- a/lib/Db/CoreQueryBuilder.php
+++ b/lib/Db/CoreQueryBuilder.php
@@ -1085,7 +1085,7 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
*
* @return ICompositeExpression
*/
- private function limitRemoteVisibility_Sensitive_Members(string $alias = 'ri'): ICompositeExpression {
+ private function limitRemoteVisibility_Sensitive_Members(string $alias): ICompositeExpression {
$expr = $this->expr();
$andPassive = $expr->andX();
$andPassive->add(
@@ -1137,12 +1137,17 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
$aliasStorages = $this->generateAlias($aliasFileCache, self::STORAGES);
$this->generateSelectAlias(
- CoreRequestBuilder::$outsideTables[self::FILE_CACHE],
+ CoreRequestBuilder::$outsideTables[CoreRequestBuilder::TABLE_FILE_CACHE],
$aliasFileCache,
$aliasFileCache,
[]
)
- ->generateSelectAlias(CoreRequestBuilder::$outsideTables[self::STORAGES], $aliasStorages, $aliasStorages, [])
+ ->generateSelectAlias(
+ CoreRequestBuilder::$outsideTables[CoreRequestBuilder::TABLE_STORAGES],
+ $aliasStorages,
+ $aliasStorages,
+ []
+ )
->leftJoin(
$aliasShare, CoreRequestBuilder::TABLE_FILE_CACHE, $aliasFileCache,
$expr->eq($aliasShare . '.file_source', $aliasFileCache . '.fileid')
@@ -1176,8 +1181,13 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
)
);
- $this->selectAlias($aliasShareChild . '.id', 'child_id');
- $this->selectAlias($aliasShareChild . '.file_target', 'child_file_target');
+ $this->generateSelectAlias(
+ ['id', 'file_target', 'permissions'],
+ $aliasShareChild,
+ 'child_',
+ []
+ );
+
// $this->selectAlias($aliasShareParent . '.permissions', 'parent_perms');
}
diff --git a/lib/Service/CircleService.php b/lib/Service/CircleService.php
index 8958a68d..2681b4e3 100644
--- a/lib/Service/CircleService.php
+++ b/lib/Service/CircleService.php
@@ -390,6 +390,30 @@ class CircleService {
}
+ /**
+ * @param string $circleId
+ * @param int $filter
+ *
+ * @return Circle
+ * @throws CircleNotFoundException
+ * @throws InitiatorNotFoundException
+ * @throws RequestBuilderException
+ */
+ public function getCircle(
+ string $circleId,
+ int $filter = Circle::CFG_BACKEND | Circle::CFG_SINGLE | Circle::CFG_HIDDEN
+ ): Circle {
+ $this->federatedUserService->mustHaveCurrentUser();
+
+ return $this->circleRequest->getCircle(
+ $circleId,
+ $this->federatedUserService->getCurrentUser(),
+ $this->federatedUserService->getRemoteInstance(),
+ $filter
+ );
+ }
+
+
/**
* @param Circle|null $circleFilter
* @param Member|null $memberFilter
@@ -397,6 +421,7 @@ class CircleService {
*
* @return Circle[]
* @throws InitiatorNotFoundException
+ * @throws RequestBuilderException
*/
public function getCircles(
?Circle $circleFilter = null,
@@ -426,30 +451,6 @@ class CircleService {
}
- /**
- * @param string $circleId
- * @param int $filter
- *
- * @return Circle
- * @throws CircleNotFoundException
- * @throws InitiatorNotFoundException
- * @throws RequestBuilderException
- */
- public function getCircle(
- string $circleId,
- int $filter = Circle::CFG_BACKEND | Circle::CFG_SINGLE | Circle::CFG_HIDDEN
- ): Circle {
- $this->federatedUserService->mustHaveCurrentUser();
-
- return $this->circleRequest->getCircle(
- $circleId,
- $this->federatedUserService->getCurrentUser(),
- $this->federatedUserService->getRemoteInstance(),
- $filter
- );
- }
-
-
/**
* @param Circle $circle
*
diff --git a/lib/Service/FederatedEventService.php b/lib/Service/FederatedEventService.php
index bf6f20a6..888e721b 100644
--- a/lib/Service/FederatedEventService.php
+++ b/lib/Service/FederatedEventService.php
@@ -402,7 +402,6 @@ class FederatedEventService extends NC22Signature {
if ($event->isAsync()) {
$wrapper->setInstance($this->configService->getLoopbackInstance());
$this->eventWrapperRequest->save($wrapper);
- echo json_encode($wrapper);
}
foreach ($instances as $instance) {