summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-03-16 16:42:31 +0100
committerGitHub <noreply@github.com>2018-03-16 16:42:31 +0100
commite56759917b4d31b5e6629d2a4ff603e6745446bb (patch)
tree9e2cb1b7a8f6d18b06c12340a079fc1a99d5b9bd /apps
parentf83aa58d1f82beee86d3e91f390efb48b98a52e0 (diff)
parented4b4458eb8bce2e461d952f11756e24c4e7f3c6 (diff)
downloadnextcloud-server-e56759917b4d31b5e6629d2a4ff603e6745446bb.tar.gz
nextcloud-server-e56759917b4d31b5e6629d2a4ff603e6745446bb.zip
Merge pull request #8843 from nextcloud/set-share-with-field-to-the-id-of-the-circle
Set "share with" field to the ID of the circle
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 1e121d8c868..1390eedf26e 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -207,8 +207,16 @@ class ShareAPIController extends OCSController {
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
$result['token'] = $share->getToken();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
- $result['share_with_displayname'] = $share->getSharedWith();
- $result['share_with'] = explode(' ', $share->getSharedWith(), 2)[0];
+ // getSharedWith() returns either "name (type, owner)" or
+ // "name (type, owner) [id]", depending on the Circles app version.
+ $hasCircleId = (substr($share->getSharedWith(), -1) === ']');
+
+ $displayNameLength = ($hasCircleId? strrpos($share->getSharedWith(), ' '): strlen($share->getSharedWith()));
+ $result['share_with_displayname'] = substr($share->getSharedWith(), 0, $displayNameLength);
+
+ $shareWithStart = ($hasCircleId? strrpos($share->getSharedWith(), '[') + 1: 0);
+ $shareWithLength = ($hasCircleId? -1: strpos($share->getSharedWith(), ' '));
+ $result['share_with'] = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
}