'id',
]
);
+ } elseif ($params['shareType'] === IShare::TYPE_SCIENCEMESH) {
+ $this->log(
+ 'The %s "%s" with ID "%s" has been shared to the sciencemesh user "%s" with permissions "%s" (Share ID: %s)',
+ $params,
+ [
+ 'itemType',
+ 'path',
+ 'itemSource',
+ 'shareWith',
+ 'permissions',
+ 'id',
+ ]
+ );
}
}
'id',
]
);
+ } elseif ($params['shareType'] === IShare::TYPE_SCIENCEMESH) {
+ $this->log(
+ 'The %s "%s" with ID "%s" has been unshared from the sciencemesh user "%s" (Share ID: %s)',
+ $params,
+ [
+ 'itemType',
+ 'fileTarget',
+ 'itemSource',
+ 'shareWith',
+ 'id',
+ ]
+ );
}
}
IShare::TYPE_ROOM,
IShare::TYPE_CIRCLE,
IShare::TYPE_DECK,
+ IShare::TYPE_SCIENCEMESH,
];
foreach ($requestedShareTypes as $requestedShareType) {
$shares = $this->shareManager->getSharesBy(
[[IShare::TYPE_REMOTE]],
[[IShare::TYPE_ROOM]],
[[IShare::TYPE_DECK]],
+ [[IShare::TYPE_SCIENCEMESH]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP]],
[[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
[[IShare::TYPE_USER, IShare::TYPE_LINK]],
IShare::TYPE_EMAIL,
IShare::TYPE_ROOM,
IShare::TYPE_DECK,
+ IShare::TYPE_SCIENCEMESH,
];
$shareTypes = [];
$shares = [];
$progress = new ProgressBar($output);
- foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM, IShare::TYPE_EMAIL, IShare::TYPE_CIRCLE, IShare::TYPE_DECK] as $shareType) {
+ foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM, IShare::TYPE_EMAIL, IShare::TYPE_CIRCLE, IShare::TYPE_DECK, IShare::TYPE_SCIENCEMESH] as $shareType) {
$offset = 0;
while (true) {
$sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset);
$result = array_merge($result, $this->getDeckShareHelper()->formatShare($share));
} catch (QueryException $e) {
}
+ } elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = '';
+
+ try {
+ $result = array_merge($result, $this->getSciencemeshShareHelper()->formatShare($share));
+ } catch (QueryException $e) {
+ }
}
return $result;
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
$roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0);
$deckShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_DECK, null, -1, 0);
+ $sciencemeshShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_SCIENCEMESH, null, -1, 0);
- $shares = array_merge($groupShares, $roomShares, $deckShares);
+ $shares = array_merge($groupShares, $roomShares, $deckShares, $sciencemeshShares);
$shares = array_map(function (IShare $share) {
return $this->formatShare($share);
}
/**
- * Returns the helper of ShareAPIHelper for deck shares.
+ * Returns the helper of DeletedShareAPIHelper for deck shares.
*
* If the Deck application is not enabled or the helper is not available
* a QueryException is thrown instead.
return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper');
}
+
+ /**
+ * Returns the helper of DeletedShareAPIHelper for sciencemesh shares.
+ *
+ * If the sciencemesh application is not enabled or the helper is not available
+ * a QueryException is thrown instead.
+ *
+ * @return \OCA\Deck\Sharing\ShareAPIHelper
+ * @throws QueryException
+ */
+ private function getSciencemeshShareHelper() {
+ if (!$this->appManager->isEnabledForUser('sciencemesh')) {
+ throw new QueryException();
+ }
+
+ return $this->serverContainer->get('\OCA\ScienceMesh\Sharing\ShareAPIHelper');
+ }
}
$result = array_merge($result, $this->getDeckShareHelper()->formatShare($share));
} catch (QueryException $e) {
}
+ } elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
+ $result['share_with'] = $share->getSharedWith();
+ $result['share_with_displayname'] = '';
+
+ try {
+ $result = array_merge($result, $this->getSciencemeshShareHelper()->formatShare($share));
+ } catch (QueryException $e) {
+ }
}
} catch (QueryException $e) {
throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support room shares', [$node->getPath()]));
}
+ } elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
+ try {
+ $this->getSciencemeshShareHelper()->createShare($share, $shareWith, $permissions, $expireDate);
+ } catch (QueryException $e) {
+ throw new OCSForbiddenException($this->l->t('Sharing %s failed because the back end does not support sciencemesh shares', [$node->getPath()]));
+ }
} else {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
$circleShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_CIRCLE, $node, -1, 0);
$roomShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_ROOM, $node, -1, 0);
$deckShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_DECK, $node, -1, 0);
+ $sciencemeshShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_SCIENCEMESH, $node, -1, 0);
- $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares);
+ $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares);
$filteredShares = array_filter($shares, function (IShare $share) {
return $share->getShareOwner() !== $this->currentUser;
}
}
+ if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
+ try {
+ return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser);
+ } catch (QueryException $e) {
+ return false;
+ }
+ }
+
return false;
}
protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM &&
- $share->getShareType() !== IShare::TYPE_DECK
+ $share->getShareType() !== IShare::TYPE_DECK &&
+ $share->getShareType() !== IShare::TYPE_SCIENCEMESH
) {
return false;
}
}
}
+ if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
+ try {
+ return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser);
+ } catch (QueryException $e) {
+ return false;
+ }
+ }
+
return false;
}
// Do nothing, just try the other share type
}
+ try {
+ if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
+ $share = $this->shareManager->getShareById('sciencemesh:' . $id, $this->currentUser);
+ return $share;
+ }
+ } catch (ShareNotFound $e) {
+ // Do nothing, just try the other share type
+ }
+
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
throw new ShareNotFound();
}
return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper');
}
+ /**
+ * Returns the helper of ShareAPIHelper for sciencemesh shares.
+ *
+ * If the sciencemesh application is not enabled or the helper is not available
+ * a QueryException is thrown instead.
+ *
+ * @return \OCA\Deck\Sharing\ShareAPIHelper
+ * @throws QueryException
+ */
+ private function getSciencemeshShareHelper() {
+ if (!$this->appManager->isEnabledForUser('sciencemesh')) {
+ throw new QueryException();
+ }
+
+ return $this->serverContainer->get('\OCA\ScienceMesh\Sharing\ShareAPIHelper');
+ }
+
/**
* @param string $viewer
* @param Node $node
IShare::TYPE_EMAIL,
IShare::TYPE_CIRCLE,
IShare::TYPE_ROOM,
- IShare::TYPE_DECK
+ IShare::TYPE_DECK,
+ IShare::TYPE_SCIENCEMESH
];
// Should we assume that the (currentUser) viewer is the owner of the node !?
// TALK SHARES
$roomShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_ROOM, $path, $reshares, -1, 0);
+ // DECK SHARES
$deckShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_DECK, $path, $reshares, -1, 0);
+ // SCIENCEMESH SHARES
+ $sciencemeshShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_SCIENCEMESH, $path, $reshares, -1, 0);
+
// FEDERATION
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->currentUser, IShare::TYPE_REMOTE, $path, $reshares, -1, 0);
$federatedGroupShares = [];
}
- return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $federatedShares, $federatedGroupShares);
+ return array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares, $roomShares, $deckShares, $sciencemeshShares, $federatedShares, $federatedGroupShares);
}
if ($this->shareManager->shareProviderExists(IShare::TYPE_ROOM)) {
$shareTypes[] = IShare::TYPE_ROOM;
}
+
+ if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
+ $shareTypes[] = IShare::TYPE_SCIENCEMESH;
+ }
} else {
if ($this->shareManager->allowGroupSharing()) {
$shareTypes[] = IShare::TYPE_GROUP;
$shareTypes[] = IShare::TYPE_CIRCLE;
}
+ if ($this->shareManager->shareProviderExists(IShare::TYPE_SCIENCEMESH)) {
+ $shareTypes[] = IShare::TYPE_SCIENCEMESH;
+ }
+
if ($shareType !== null && is_array($shareType)) {
$shareTypes = array_intersect($shareTypes, $shareType);
} elseif (is_numeric($shareType)) {
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1));
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1));
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_DECK, null, -1));
+ $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_SCIENCEMESH, null, -1));
// filter out excluded shares and group shares that includes self
this.SHARE_TYPES.SHARE_TYPE_ROOM,
this.SHARE_TYPES.SHARE_TYPE_GUEST,
this.SHARE_TYPES.SHARE_TYPE_DECK,
+ this.SHARE_TYPES.SHARE_TYPE_SCIENCEMESH,
]
if (OC.getCapabilities().files_sharing.public.enabled === true) {
icon: 'icon-deck',
iconTitle: t('files_sharing', 'Deck board'),
}
+ case this.SHARE_TYPES.SHARE_TYPE_SCIENCEMESH:
+ return {
+ icon: 'icon-sciencemesh',
+ iconTitle: t('files_sharing', 'Science Mesh'),
+ }
default:
return {}
}
SHARE_TYPE_REMOTE_GROUP: 9,
SHARE_TYPE_ROOM: 10,
SHARE_TYPE_DECK: 12,
+ SHARE_TYPE_SCIENCEMESH: 15,
},
})
hasShares = true
} else if (shareType === ShareTypes.SHARE_TYPE_DECK) {
hasShares = true
+ } else if (shareType === ShareTypes.SHARE_TYPE_SCIENCEMESH) {
+ hasShares = true
}
})
OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink)
$this->expectExceptionMessage('Wrong share ID, share does not exist');
$this->shareManager
- ->expects($this->exactly(6))
+ ->expects($this->exactly(7))
->method('getShareById')
->willReturnCallback(function ($id) {
- if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42') {
+ if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42' || $id === 'deck:42' || $id === 'sciencemesh:42') {
throw new \OCP\Share\Exceptions\ShareNotFound();
} else {
throw new \Exception();
$this->makeMockShare(12, 103, 'user2', '/share7', 31),
$this->makeMockShare(13, 103, 'user2', '/share7', 31),
];
- // tests regarding circles are made in the app itself.
+ // tests regarding circles and sciencemesh are made in the apps themselves.
$circleShares = [];
+ $sciencemeshShares = [];
$this->user->expects($this->any())
->method('getUID')
->willReturn('user1');
- $this->shareManager->expects($this->exactly(5))
+ $this->shareManager->expects($this->exactly(6))
->method('getSharedWith')
->withConsecutive(
['user1', IShare::TYPE_USER],
['user1', IShare::TYPE_CIRCLE, null, -1],
['user1', IShare::TYPE_ROOM, null, -1],
['user1', IShare::TYPE_DECK, null, -1],
+ ['user1', IShare::TYPE_SCIENCEMESH, null, -1],
)->willReturnOnConsecutiveCalls(
$userShares,
$groupShares,
$circleShares,
$roomShares,
$deckShares,
+ $sciencemeshShares
);
$this->shareManager->expects($this->any())
->method('newShare')
$circleShares = [];
$roomShares = [];
$deckShares = [];
- $this->shareManager->expects($this->exactly(5))
+ $sciencemeshShares = [];
+ $this->shareManager->expects($this->exactly(6))
->method('getSharedWith')
->withConsecutive(
['user1', IShare::TYPE_USER],
['user1', IShare::TYPE_CIRCLE, null, -1],
['user1', IShare::TYPE_ROOM, null, -1],
['user1', IShare::TYPE_DECK, null, -1],
+ ['user1', IShare::TYPE_SCIENCEMESH, null, -1],
)->willReturnOnConsecutiveCalls(
$userShares,
$groupShares,
$circleShares,
$roomShares,
$deckShares,
+ $sciencemeshShares
);
$this->shareManager->expects($this->any())
->method('newShare')
public const SHARE_TYPE_DECK = 12;
// const SHARE_TYPE_DECK_USER = 13; // Internal type used by DeckShareProvider
+ // Note to developers: Do not add new share types here
+
public const FORMAT_NONE = -1;
public const FORMAT_STATUSES = -2;
public const FORMAT_SOURCES = -3; // ToDo Check if it is still in use otherwise remove it
}
} elseif ($share->getShareType() === IShare::TYPE_ROOM) {
} elseif ($share->getShareType() === IShare::TYPE_DECK) {
+ } elseif ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
} else {
// We cannot handle other types yet
throw new \InvalidArgumentException('unknown share type');
$provider = $this->getRoomShareProvider();
} elseif ($shareType === IShare::TYPE_DECK) {
$provider = $this->getProvider('deck');
+ } elseif ($shareType === IShare::TYPE_SCIENCEMESH) {
+ $provider = $this->getProvider('sciencemesh');
}
*/
public const TYPE_DECK_USER = 13;
+ /**
+ * @since 26.0.0
+ */
+ public const TYPE_SCIENCEMESH = 15;
+
/**
* @since 18.0.0
*/