Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/Command/CirclesDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
use OCA\Circles\Exceptions\UnknownRemoteException;
use OCA\Circles\Exceptions\UserTypeNotFoundException;
use OCA\Circles\Model\Member;
use OCA\Circles\Model\Probes\CircleProbe;
use OCA\Circles\Service\CircleService;
use OCA\Circles\Service\ConfigService;
use OCA\Circles\Service\FederatedUserService;
Expand Down Expand Up @@ -165,7 +166,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
true
);

$circle = $this->circleService->getCircle($circleId, 0);

$probe = new CircleProbe();
$probe->includeNonVisibleCircles();

$circle = $this->circleService->getCircle($circleId, $probe);
} catch (CircleNotFoundException $e) {
throw new CircleNotFoundException(
'unknown circle, use --instance to retrieve the data from a remote instance'
Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ public function circleDetails(string $emulated, string $circleId): DataResponse
try {
$this->setLocalFederatedUser($emulated);

return new DataResponse($this->serialize($this->circleService->getCircle($circleId)));
$probe = new CircleProbe();
$probe->includeNonVisibleCircles();

return new DataResponse($this->serialize($this->circleService->getCircle($circleId, $probe)));
} catch (Exception $e) {
$this->e($e, ['emulated' => $emulated, 'circleId' => $circleId]);
throw new OcsException($e->getMessage(), $e->getCode());
Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/LocalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ public function circleDetails(string $circleId): DataResponse {
try {
$this->setCurrentFederatedUser();

return new DataResponse($this->serialize($this->circleService->getCircle($circleId)));
$probe = new CircleProbe();
$probe->includeNonVisibleCircles();

return new DataResponse($this->serialize($this->circleService->getCircle($circleId, $probe)));
} catch (Exception $e) {
$this->e($e, ['circleId' => $circleId]);
throw new OcsException($e->getMessage(), $e->getCode());
Expand Down
7 changes: 7 additions & 0 deletions lib/Db/CoreQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,13 @@ protected function limitInitiatorVisibility(string $alias): ICompositeExpression
$orX->add($this->exprLimitBitwise('config', Circle::CFG_VISIBLE, $alias));
}

if ($this->getBool('includeNonVisibleCircles', $options)) {
$andXNonVisible = $expr->andX();
$andXNonVisible->add($this->exprLimitBitwise('config', Circle::CFG_OPEN, $alias));
$andXNonVisible->add($this->exprFilterBitwise('config', Circle::CFG_VISIBLE, $alias));
$orX->add($andXNonVisible);
}

// if Member can be Visitor, we only filter access to Personal Circles
if ($this->getBool('viewableThroughKeyhole', $options, false)) {
$andOpen = $expr->andX();
Expand Down
22 changes: 22 additions & 0 deletions lib/Model/Probes/CircleProbe.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class CircleProbe extends MemberProbe {
/** @var int */
private $filter = Circle::CFG_SINGLE;

/** @var bool */
private $includeNonVisible = false;


/**
* CircleProbe constructor.
Expand Down Expand Up @@ -125,6 +128,24 @@ public function includeBackendCircles(bool $include = true): self {
return $this;
}

/**
* @param bool $include
*
* @return $this
*/
public function includeNonVisibleCircles(bool $include = true): self {
$this->includeNonVisible = $include;

return $this;
}

/**
* @return bool
*/
public function nonVisibleCirclesIncluded(): bool {
return $this->includeNonVisible;
}


/**
* @return int
Expand Down Expand Up @@ -259,6 +280,7 @@ public function getAsOptions(): array {
'includeBackendCircles' => $this->isIncluded(Circle::CFG_BACKEND),
'includeSystemCircles' => $this->isIncluded(Circle::CFG_SYSTEM),
'includePersonalCircles' => $this->isIncluded(Circle::CFG_PERSONAL),
'includeNonVisibleCircles' => $this->nonVisibleCirclesIncluded(),
'filtered' => $this->included(),
'filterHiddenCircles' => $this->isIncluded(Circle::CFG_HIDDEN),
'filterSingleCircles' => $this->isIncluded(Circle::CFG_SINGLE),
Expand Down
7 changes: 5 additions & 2 deletions lib/Service/CircleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ public function updateSettings(string $circleId, array $settings): array {
public function circleJoin(string $circleId): array {
$this->federatedUserService->mustHaveCurrentUser();

$circle = $this->circleRequest->getCircle($circleId, $this->federatedUserService->getCurrentUser());
$probe = new CircleProbe();
$probe->includeNonVisibleCircles();

$circle = $this->circleRequest->getCircle($circleId, $this->federatedUserService->getCurrentUser(), $probe);
if (!$circle->getInitiator()->hasInvitedBy()) {
$this->federatedUserService->setMemberPatron($circle->getInitiator());
}
Expand Down Expand Up @@ -425,7 +428,7 @@ public function circleLeave(string $circleId, bool $force = false): array {

/**
* @param string $circleId
* @param int $filter
* @param CircleProbe|null $probe
*
* @return Circle
* @throws CircleNotFoundException
Expand Down