|
@@ -320,6 +320,14 @@ class ShareAPIController extends OCSController {
|
|
|
$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) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -692,6 +700,12 @@ class ShareAPIController extends OCSController {
|
|
|
} 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'));
|
|
|
}
|
|
@@ -730,8 +744,9 @@ class ShareAPIController extends OCSController {
|
|
|
$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;
|
|
@@ -1414,6 +1429,14 @@ class ShareAPIController extends OCSController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
|
|
+ try {
|
|
|
+ return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser);
|
|
|
+ } catch (QueryException $e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -1490,7 +1513,8 @@ class ShareAPIController extends OCSController {
|
|
|
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;
|
|
|
}
|
|
@@ -1527,6 +1551,14 @@ class ShareAPIController extends OCSController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if ($share->getShareType() === IShare::TYPE_SCIENCEMESH) {
|
|
|
+ try {
|
|
|
+ return $this->getSciencemeshShareHelper()->canAccessShare($share, $this->currentUser);
|
|
|
+ } catch (QueryException $e) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -1606,6 +1638,15 @@ class ShareAPIController extends OCSController {
|
|
|
// 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();
|
|
|
}
|
|
@@ -1669,6 +1710,23 @@ class ShareAPIController extends OCSController {
|
|
|
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
|
|
@@ -1684,7 +1742,8 @@ class ShareAPIController extends OCSController {
|
|
|
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 !?
|
|
@@ -1837,8 +1896,12 @@ class ShareAPIController extends OCSController {
|
|
|
// 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);
|
|
@@ -1851,7 +1914,7 @@ class ShareAPIController extends OCSController {
|
|
|
$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);
|
|
|
}
|
|
|
|
|
|
|