Share with circles

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-03-05 18:52:54 +01:00
parent a842fd6d26
commit ed3991b7bd
12 changed files with 155 additions and 7 deletions

View File

@@ -97,7 +97,8 @@ class BoardService {
$userInfo = $this->getBoardPrerequisites();
$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null, $since);
$groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups'],null, null, $since);
$complete = array_merge($userBoards, $groupBoards);
$circleBoards = $this->boardMapper->findAllByCircles($userInfo['user'], null, null, $since);
$complete = array_merge($userBoards, $groupBoards, $circleBoards);
$result = [];
/** @var Board $item */
foreach ($complete as &$item) {

View File

@@ -33,6 +33,7 @@ use OCA\Deck\NoPermissionException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\QueryException;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\ILogger;
@@ -61,6 +62,8 @@ class PermissionService {
/** @var array */
private $users = [];
private $circlesEnabled = false;
public function __construct(
ILogger $logger,
AclMapper $aclMapper,
@@ -79,6 +82,8 @@ class PermissionService {
$this->shareManager = $shareManager;
$this->config = $config;
$this->userId = $userId;
$this->circlesEnabled = \OC::$server->getAppManager()->isEnabledForUser('circles');
}
/**
@@ -182,6 +187,16 @@ class PermissionService {
if ($acl->getType() === Acl::PERMISSION_TYPE_USER && $acl->getParticipant() === $this->userId) {
return $acl->getPermission($permission);
}
if ($this->circlesEnabled && $acl->getType() === Acl::PERMISSION_TYPE_CIRCLE) {
try {
\OCA\Circles\Api\v1\Circles::getMember($acl->getParticipant(), $this->userId, 1);
return $acl->getPermission($permission);
} catch (\Exception $e) {
// TODO: getMember doesn't work for personal circles
$this->logger->info('Member not found in circle that was accessed. This should not happen.');
}
}
}
// check for groups
$hasGroupPermission = false;