display shares to circles moderator

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
Maxence Lange 2018-10-30 09:58:43 +01:00 committed by Julius Härtl
parent 68c44bb642
commit 72ad2d60b5
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 22 additions and 0 deletions

View File

@ -240,6 +240,9 @@ class ShareAPIController extends OCSController {
$shareWithStart = ($hasCircleId? strrpos($share->getSharedWith(), '[') + 1: 0);
$shareWithLength = ($hasCircleId? -1: strpos($share->getSharedWith(), ' '));
if (is_bool($shareWithLength)) {
$shareWithLength = -1;
}
$result['share_with'] = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
} else if ($share->getShareType() === Share::SHARE_TYPE_ROOM) {
$result['share_with'] = $share->getSharedWith();
@ -1137,6 +1140,25 @@ class ShareAPIController extends OCSController {
return true;
}
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE && \OC::$server->getAppManager()->isEnabledForUser('circles') &&
class_exists('\OCA\Circles\Api\v1\Circles')) {
$hasCircleId = (substr($share->getSharedWith(), -1) === ']');
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
$shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' '));
if (is_bool($shareWithLength)) {
$shareWithLength = -1;
}
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
try {
$member = \OCA\Circles\Api\v1\Circles::getMember($sharedWith, $userId, 1);
if ($member->getLevel() > 0) {
return true;
}
} catch (QueryException $e) {
return false;
}
}
return false;
}