mirror of
https://github.com/netzbegruenung/circles.git
synced 2024-05-11 23:56:06 +02:00
fixing
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
e2979b01c4
commit
04805b2e7f
|
@ -1,112 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Circles - Bring cloud-users closer together.
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later. See the COPYING file.
|
|
||||||
*
|
|
||||||
* @author Maxence Lange <maxence@artificial-owl.com>
|
|
||||||
* @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 <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
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<string,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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -33,15 +33,9 @@ namespace OCA\Circles\Collaboration\v2;
|
||||||
|
|
||||||
|
|
||||||
use daita\MySmallPhpTools\Model\SimpleDataStore;
|
use daita\MySmallPhpTools\Model\SimpleDataStore;
|
||||||
|
use Exception;
|
||||||
use OC\Share20\Share;
|
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\Circle;
|
||||||
use OCA\Circles\Model\Member;
|
|
||||||
use OCA\Circles\Service\CircleService;
|
use OCA\Circles\Service\CircleService;
|
||||||
use OCA\Circles\Service\FederatedUserService;
|
use OCA\Circles\Service\FederatedUserService;
|
||||||
use OCP\Collaboration\Collaborators\ISearchPlugin;
|
use OCP\Collaboration\Collaborators\ISearchPlugin;
|
||||||
|
@ -83,42 +77,31 @@ class CollaboratorSearchPlugin implements ISearchPlugin {
|
||||||
* @param ISearchResult $searchResult
|
* @param ISearchResult $searchResult
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws FederatedUserException
|
|
||||||
* @throws FederatedUserNotFoundException
|
|
||||||
* @throws InitiatorNotFoundException
|
|
||||||
* @throws InvalidIdException
|
|
||||||
* @throws SingleCircleNotFoundException
|
|
||||||
*/
|
*/
|
||||||
public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
|
public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
|
||||||
$this->federatedUserService->initCurrentUser();
|
|
||||||
|
|
||||||
$wide = $exact = [];
|
$wide = $exact = [];
|
||||||
|
|
||||||
$filterCircle = new Circle();
|
$filterCircle = new Circle();
|
||||||
$filterCircle->setName($search)
|
$filterCircle->setName($search)
|
||||||
->setDisplayName($search);
|
->setDisplayName($search);
|
||||||
|
|
||||||
$filterMember = new Member();
|
try {
|
||||||
$filterMember->importFromIFederatedUser($this->federatedUserService->getCurrentUser());
|
$this->federatedUserService->initCurrentUser();
|
||||||
$filterMember->setLevel(Member::LEVEL_MEMBER);
|
$circles = $this->circleService->getCircles(
|
||||||
|
$filterCircle, null,
|
||||||
$circles = $this->circleService->getCircles(
|
new SimpleDataStore(
|
||||||
$filterCircle, $filterMember,
|
[
|
||||||
new SimpleDataStore(
|
'limit' => $limit,
|
||||||
[
|
'offset' => $offset
|
||||||
'limit' => $limit,
|
]
|
||||||
'offset' => $offset
|
)
|
||||||
]
|
);
|
||||||
)
|
} catch (Exception $e) {
|
||||||
);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($circles as $circle) {
|
foreach ($circles as $circle) {
|
||||||
try {
|
$entry = $this->addResultEntry($circle);
|
||||||
$entry = $this->addResultEntry($circle);
|
|
||||||
} catch (NoUserException $e) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strtolower($circle->getName()) === strtolower($search)) {
|
if (strtolower($circle->getName()) === strtolower($search)) {
|
||||||
$exact[] = $entry;
|
$exact[] = $entry;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -36,8 +36,6 @@ use OCA\Circles\Exceptions\SingleCircleNotFoundException;
|
||||||
use OCA\Circles\Model\Member;
|
use OCA\Circles\Model\Member;
|
||||||
use OCA\Circles\Service\CircleService;
|
use OCA\Circles\Service\CircleService;
|
||||||
use OCA\Circles\Service\FederatedUserService;
|
use OCA\Circles\Service\FederatedUserService;
|
||||||
use OCP\IL10N;
|
|
||||||
use OCP\IUserManager;
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
@ -52,12 +50,6 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
class CirclesCreate extends Base {
|
class CirclesCreate extends Base {
|
||||||
|
|
||||||
|
|
||||||
/** @var IL10N */
|
|
||||||
private $l10n;
|
|
||||||
|
|
||||||
/** @var IUserManager */
|
|
||||||
private $userManager;
|
|
||||||
|
|
||||||
/** @var FederatedUserService */
|
/** @var FederatedUserService */
|
||||||
private $federatedUserService;
|
private $federatedUserService;
|
||||||
|
|
||||||
|
@ -68,18 +60,14 @@ class CirclesCreate extends Base {
|
||||||
/**
|
/**
|
||||||
* CirclesCreate constructor.
|
* CirclesCreate constructor.
|
||||||
*
|
*
|
||||||
* @param IL10N $l10n
|
|
||||||
* @param IUserManager $userManager
|
|
||||||
* @param FederatedUserService $federatedUserService
|
* @param FederatedUserService $federatedUserService
|
||||||
* @param CircleService $circleService
|
* @param CircleService $circleService
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IL10N $l10n, IUserManager $userManager, FederatedUserService $federatedUserService,
|
FederatedUserService $federatedUserService,
|
||||||
CircleService $circleService
|
CircleService $circleService
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->l10n = $l10n;
|
|
||||||
$this->userManager = $userManager;
|
|
||||||
$this->federatedUserService = $federatedUserService;
|
$this->federatedUserService = $federatedUserService;
|
||||||
$this->circleService = $circleService;
|
$this->circleService = $circleService;
|
||||||
|
|
||||||
|
@ -130,7 +118,9 @@ class CirclesCreate extends Base {
|
||||||
throw $e;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,9 @@ class MembersAdd extends Base {
|
||||||
throw $e;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1085,7 +1085,7 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
|
||||||
*
|
*
|
||||||
* @return ICompositeExpression
|
* @return ICompositeExpression
|
||||||
*/
|
*/
|
||||||
private function limitRemoteVisibility_Sensitive_Members(string $alias = 'ri'): ICompositeExpression {
|
private function limitRemoteVisibility_Sensitive_Members(string $alias): ICompositeExpression {
|
||||||
$expr = $this->expr();
|
$expr = $this->expr();
|
||||||
$andPassive = $expr->andX();
|
$andPassive = $expr->andX();
|
||||||
$andPassive->add(
|
$andPassive->add(
|
||||||
|
@ -1137,12 +1137,17 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
|
||||||
$aliasStorages = $this->generateAlias($aliasFileCache, self::STORAGES);
|
$aliasStorages = $this->generateAlias($aliasFileCache, self::STORAGES);
|
||||||
|
|
||||||
$this->generateSelectAlias(
|
$this->generateSelectAlias(
|
||||||
CoreRequestBuilder::$outsideTables[self::FILE_CACHE],
|
CoreRequestBuilder::$outsideTables[CoreRequestBuilder::TABLE_FILE_CACHE],
|
||||||
$aliasFileCache,
|
$aliasFileCache,
|
||||||
$aliasFileCache,
|
$aliasFileCache,
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
->generateSelectAlias(CoreRequestBuilder::$outsideTables[self::STORAGES], $aliasStorages, $aliasStorages, [])
|
->generateSelectAlias(
|
||||||
|
CoreRequestBuilder::$outsideTables[CoreRequestBuilder::TABLE_STORAGES],
|
||||||
|
$aliasStorages,
|
||||||
|
$aliasStorages,
|
||||||
|
[]
|
||||||
|
)
|
||||||
->leftJoin(
|
->leftJoin(
|
||||||
$aliasShare, CoreRequestBuilder::TABLE_FILE_CACHE, $aliasFileCache,
|
$aliasShare, CoreRequestBuilder::TABLE_FILE_CACHE, $aliasFileCache,
|
||||||
$expr->eq($aliasShare . '.file_source', $aliasFileCache . '.fileid')
|
$expr->eq($aliasShare . '.file_source', $aliasFileCache . '.fileid')
|
||||||
|
@ -1176,8 +1181,13 @@ class CoreQueryBuilder extends NC22ExtendedQueryBuilder {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->selectAlias($aliasShareChild . '.id', 'child_id');
|
$this->generateSelectAlias(
|
||||||
$this->selectAlias($aliasShareChild . '.file_target', 'child_file_target');
|
['id', 'file_target', 'permissions'],
|
||||||
|
$aliasShareChild,
|
||||||
|
'child_',
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
// $this->selectAlias($aliasShareParent . '.permissions', 'parent_perms');
|
// $this->selectAlias($aliasShareParent . '.permissions', 'parent_perms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 Circle|null $circleFilter
|
||||||
* @param Member|null $memberFilter
|
* @param Member|null $memberFilter
|
||||||
|
@ -397,6 +421,7 @@ class CircleService {
|
||||||
*
|
*
|
||||||
* @return Circle[]
|
* @return Circle[]
|
||||||
* @throws InitiatorNotFoundException
|
* @throws InitiatorNotFoundException
|
||||||
|
* @throws RequestBuilderException
|
||||||
*/
|
*/
|
||||||
public function getCircles(
|
public function getCircles(
|
||||||
?Circle $circleFilter = null,
|
?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
|
* @param Circle $circle
|
||||||
*
|
*
|
||||||
|
|
|
@ -402,7 +402,6 @@ class FederatedEventService extends NC22Signature {
|
||||||
if ($event->isAsync()) {
|
if ($event->isAsync()) {
|
||||||
$wrapper->setInstance($this->configService->getLoopbackInstance());
|
$wrapper->setInstance($this->configService->getLoopbackInstance());
|
||||||
$this->eventWrapperRequest->save($wrapper);
|
$this->eventWrapperRequest->save($wrapper);
|
||||||
echo json_encode($wrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($instances as $instance) {
|
foreach ($instances as $instance) {
|
||||||
|
|
Loading…
Reference in a new issue