shares-circles
Signed-off-by: Maxence Lange <maxence@nextcloud.com>
This commit is contained in:
parent
3c66ad64e6
commit
69694012ab
|
@ -134,6 +134,8 @@
|
||||||
hasShares = true;
|
hasShares = true;
|
||||||
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
||||||
hasShares = true;
|
hasShares = true;
|
||||||
|
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||||
|
hasShares = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink);
|
OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink);
|
||||||
|
|
|
@ -192,8 +192,12 @@ class ShareAPIController extends OCSController {
|
||||||
$result['share_with'] = $share->getSharedWith();
|
$result['share_with'] = $share->getSharedWith();
|
||||||
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
|
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
|
||||||
$result['token'] = $share->getToken();
|
$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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result['mail_send'] = $share->getMailSend() ? 1 : 0;
|
$result['mail_send'] = $share->getMailSend() ? 1 : 0;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -443,6 +447,19 @@ class ShareAPIController extends OCSController {
|
||||||
\OCP\Constants::PERMISSION_DELETE);
|
\OCP\Constants::PERMISSION_DELETE);
|
||||||
}
|
}
|
||||||
$share->setSharedWith($shareWith);
|
$share->setSharedWith($shareWith);
|
||||||
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
||||||
|
if (!\OCP\App::isEnabled('circles')) {
|
||||||
|
throw new OCSNotFoundException($this->l->t('You cannot share to a Circle if the app is not enabled'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$circle = \OCA\Circles\Api\Circles::detailsCircle($shareWith);
|
||||||
|
|
||||||
|
// Valid circle is required to share
|
||||||
|
if ($circle === null) {
|
||||||
|
throw new OCSNotFoundException($this->l->t('Please specify a valid circle'));
|
||||||
|
}
|
||||||
|
$share->setSharedWith($shareWith);
|
||||||
|
$share->setPermissions($permissions);
|
||||||
} else {
|
} else {
|
||||||
throw new OCSBadRequestException($this->l->t('Unknown share type'));
|
throw new OCSBadRequestException($this->l->t('Unknown share type'));
|
||||||
}
|
}
|
||||||
|
@ -469,10 +486,12 @@ class ShareAPIController extends OCSController {
|
||||||
* @return DataResponse
|
* @return DataResponse
|
||||||
*/
|
*/
|
||||||
private function getSharedWithMe($node = null) {
|
private function getSharedWithMe($node = null) {
|
||||||
|
|
||||||
$userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
|
$userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0);
|
||||||
$groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
|
$groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
|
||||||
|
$circleShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $node, -1, 0);
|
||||||
|
|
||||||
$shares = array_merge($userShares, $groupShares);
|
$shares = array_merge($userShares, $groupShares, $circleShares);
|
||||||
|
|
||||||
$shares = array_filter($shares, function (IShare $share) {
|
$shares = array_filter($shares, function (IShare $share) {
|
||||||
return $share->getShareOwner() !== $this->currentUser;
|
return $share->getShareOwner() !== $this->currentUser;
|
||||||
|
@ -592,7 +611,13 @@ class ShareAPIController extends OCSController {
|
||||||
} else {
|
} else {
|
||||||
$mailShares = [];
|
$mailShares = [];
|
||||||
}
|
}
|
||||||
$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares);
|
if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
|
||||||
|
$circleShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_CIRCLE, $path, $reshares, -1, 0);
|
||||||
|
} else {
|
||||||
|
$circleShares = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares, $circleShares);
|
||||||
|
|
||||||
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
|
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
|
||||||
$federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
|
$federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
|
||||||
|
@ -784,6 +809,11 @@ class ShareAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
||||||
|
// TODO: have a sanity check like above?
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -832,6 +862,16 @@ class ShareAPIController extends OCSController {
|
||||||
// Do nothing, just try the other share type
|
// Do nothing, just try the other share type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
|
||||||
|
$share = $this->shareManager->getShareById('ocCircleShare:' . $id);
|
||||||
|
return $share;
|
||||||
|
}
|
||||||
|
} catch (ShareNotFound $e) {
|
||||||
|
// Do nothing, just try the other share type
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
|
if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
|
||||||
$share = $this->shareManager->getShareById('ocMailShare:' . $id);
|
$share = $this->shareManager->getShareById('ocMailShare:' . $id);
|
||||||
|
|
|
@ -92,12 +92,14 @@ class ShareesAPIController extends OCSController {
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
],
|
],
|
||||||
'users' => [],
|
'users' => [],
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
|
'circles' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $reachedEndFor = [];
|
protected $reachedEndFor = [];
|
||||||
|
@ -294,6 +296,23 @@ class ShareesAPIController extends OCSController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $search
|
||||||
|
*/
|
||||||
|
protected function getCircles($search) {
|
||||||
|
$this->result['circles'] = $this->result['exact']['circles'] = [];
|
||||||
|
|
||||||
|
$result = \OCA\Circles\Api\Sharees::search($search, $this->limit, $this->offset);
|
||||||
|
if (array_key_exists('circles', $result['exact'])) {
|
||||||
|
$this->result['exact']['circles'] = $result['exact']['circles'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('circles', $result)) {
|
||||||
|
$this->result['circles'] = $result['circles'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $search
|
* @param string $search
|
||||||
* @return array
|
* @return array
|
||||||
|
@ -453,6 +472,10 @@ class ShareesAPIController extends OCSController {
|
||||||
$shareTypes[] = Share::SHARE_TYPE_EMAIL;
|
$shareTypes[] = Share::SHARE_TYPE_EMAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\OCP\App::isEnabled('circles')) {
|
||||||
|
$shareTypes[] = Share::SHARE_TYPE_CIRCLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
|
if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
|
||||||
$shareTypes = array_intersect($shareTypes, $_GET['shareType']);
|
$shareTypes = array_intersect($shareTypes, $_GET['shareType']);
|
||||||
sort($shareTypes);
|
sort($shareTypes);
|
||||||
|
@ -512,6 +535,12 @@ class ShareesAPIController extends OCSController {
|
||||||
$this->getGroups($search);
|
$this->getGroups($search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get circles
|
||||||
|
if (in_array(Share::SHARE_TYPE_CIRCLE, $shareTypes)) {
|
||||||
|
$this->getCircles($search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get remote
|
// Get remote
|
||||||
$remoteResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
|
$remoteResults = ['results' => [], 'exact' => [], 'exactIdMatch' => false];
|
||||||
if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes)) {
|
if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes)) {
|
||||||
|
|
|
@ -68,8 +68,11 @@ class MountProvider implements IMountProvider {
|
||||||
* @return \OCP\Files\Mount\IMountPoint[]
|
* @return \OCP\Files\Mount\IMountPoint[]
|
||||||
*/
|
*/
|
||||||
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
|
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
|
||||||
|
|
||||||
$shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1);
|
$shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1);
|
||||||
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1));
|
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1));
|
||||||
|
$shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1));
|
||||||
|
|
||||||
// filter out excluded shares and group shares that includes self
|
// filter out excluded shares and group shares that includes self
|
||||||
$shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {
|
$shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {
|
||||||
return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID();
|
return $share->getPermissions() > 0 && $share->getShareOwner() !== $user->getUID();
|
||||||
|
|
|
@ -1576,20 +1576,22 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
return [
|
return [
|
||||||
['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
|
['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [],
|
'users' => [],
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], false],
|
], false],
|
||||||
['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
|
['test', 'folder', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, false, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [],
|
'users' => [],
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], false],
|
], false],
|
||||||
[
|
[
|
||||||
|
@ -1601,7 +1603,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
|
'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [
|
'users' => [
|
||||||
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
||||||
],
|
],
|
||||||
|
@ -1612,6 +1614,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
|
['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
|
||||||
],
|
],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], true,
|
], true,
|
||||||
],
|
],
|
||||||
|
@ -1623,7 +1626,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
|
'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [
|
'users' => [
|
||||||
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
||||||
],
|
],
|
||||||
|
@ -1632,6 +1635,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
|
['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
|
||||||
],
|
],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], false,
|
], false,
|
||||||
],
|
],
|
||||||
|
@ -1641,13 +1645,14 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
||||||
], null, null,
|
], null, null,
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [
|
'users' => [
|
||||||
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
||||||
],
|
],
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], false,
|
], false,
|
||||||
],
|
],
|
||||||
|
@ -1658,7 +1663,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
|
['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
|
||||||
], null, null,
|
], null, null,
|
||||||
[
|
[
|
||||||
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'emails' => []],
|
'exact' => ['users' => [], 'groups' => [], 'remotes' => [], 'circles' => [], 'emails' => []],
|
||||||
'users' => [
|
'users' => [
|
||||||
['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
|
||||||
['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
|
['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
|
||||||
|
@ -1666,6 +1671,7 @@ class ShareesAPIControllerTest extends TestCase {
|
||||||
'groups' => [],
|
'groups' => [],
|
||||||
'remotes' => [],
|
'remotes' => [],
|
||||||
'emails' => [],
|
'emails' => [],
|
||||||
|
'circles' => [],
|
||||||
'lookup' => [],
|
'lookup' => [],
|
||||||
], true,
|
], true,
|
||||||
],
|
],
|
||||||
|
|
|
@ -113,6 +113,8 @@ class MountProviderTest extends \Test\TestCase {
|
||||||
$this->makeMockShare(4, 101, 'user2', '/share4', 31),
|
$this->makeMockShare(4, 101, 'user2', '/share4', 31),
|
||||||
$this->makeMockShare(5, 100, 'user1', '/share4', 31),
|
$this->makeMockShare(5, 100, 'user1', '/share4', 31),
|
||||||
];
|
];
|
||||||
|
// tests regarding circles are made in the app itself.
|
||||||
|
$circleShares = [];
|
||||||
$this->user->expects($this->any())
|
$this->user->expects($this->any())
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('user1'));
|
->will($this->returnValue('user1'));
|
||||||
|
@ -124,6 +126,10 @@ class MountProviderTest extends \Test\TestCase {
|
||||||
->method('getSharedWith')
|
->method('getSharedWith')
|
||||||
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
|
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
|
||||||
->will($this->returnValue($groupShares));
|
->will($this->returnValue($groupShares));
|
||||||
|
$this->shareManager->expects($this->at(2))
|
||||||
|
->method('getSharedWith')
|
||||||
|
->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
|
||||||
|
->will($this->returnValue($circleShares));
|
||||||
$this->shareManager->expects($this->any())
|
$this->shareManager->expects($this->any())
|
||||||
->method('newShare')
|
->method('newShare')
|
||||||
->will($this->returnCallback(function() use ($rootFolder, $userManager) {
|
->will($this->returnCallback(function() use ($rootFolder, $userManager) {
|
||||||
|
@ -293,6 +299,8 @@ class MountProviderTest extends \Test\TestCase {
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('user1'));
|
->will($this->returnValue('user1'));
|
||||||
|
|
||||||
|
// tests regarding circles are made in the app itself.
|
||||||
|
$circleShares = [];
|
||||||
$this->shareManager->expects($this->at(0))
|
$this->shareManager->expects($this->at(0))
|
||||||
->method('getSharedWith')
|
->method('getSharedWith')
|
||||||
->with('user1', \OCP\Share::SHARE_TYPE_USER)
|
->with('user1', \OCP\Share::SHARE_TYPE_USER)
|
||||||
|
@ -301,6 +309,10 @@ class MountProviderTest extends \Test\TestCase {
|
||||||
->method('getSharedWith')
|
->method('getSharedWith')
|
||||||
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
|
->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
|
||||||
->will($this->returnValue($groupShares));
|
->will($this->returnValue($groupShares));
|
||||||
|
$this->shareManager->expects($this->at(2))
|
||||||
|
->method('getSharedWith')
|
||||||
|
->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
|
||||||
|
->will($this->returnValue($circleShares));
|
||||||
$this->shareManager->expects($this->any())
|
$this->shareManager->expects($this->any())
|
||||||
->method('newShare')
|
->method('newShare')
|
||||||
->will($this->returnCallback(function() use ($rootFolder, $userManager) {
|
->will($this->returnCallback(function() use ($rootFolder, $userManager) {
|
||||||
|
|
|
@ -120,6 +120,21 @@ describe('OCA.Sharing.ShareBreadCrumbView tests', function() {
|
||||||
expect(bc.$el.find('.shared').length).toEqual(1);
|
expect(bc.$el.find('.shared').length).toEqual(1);
|
||||||
expect(bc.$el.find('.icon-public').length).toEqual(1);
|
expect(bc.$el.find('.icon-public').length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
it('Render shared if dir is shared by circle', function() {
|
||||||
|
var dirInfo = new OC.Files.FileInfo({
|
||||||
|
id: 42,
|
||||||
|
path: '/foo',
|
||||||
|
type: 'dir',
|
||||||
|
shareTypes: [OC.Share.SHARE_TYPE_CIRCLE]
|
||||||
|
});
|
||||||
|
bc.setDirectoryInfo(dirInfo);
|
||||||
|
bc.setDirectory('/foo');
|
||||||
|
bc.render();
|
||||||
|
expect(bc.$el.hasClass('breadcrumb')).toEqual(true);
|
||||||
|
expect(bc.$el.find('.icon-share').length).toEqual(1);
|
||||||
|
expect(bc.$el.find('.shared').length).toEqual(1);
|
||||||
|
expect(bc.$el.find('.icon-public').length).toEqual(0);
|
||||||
|
});
|
||||||
it('Render shared if dir is shared with remote', function() {
|
it('Render shared if dir is shared with remote', function() {
|
||||||
var dirInfo = new OC.Files.FileInfo({
|
var dirInfo = new OC.Files.FileInfo({
|
||||||
id: 42,
|
id: 42,
|
||||||
|
@ -145,7 +160,8 @@ describe('OCA.Sharing.ShareBreadCrumbView tests', function() {
|
||||||
OC.Share.SHARE_TYPE_GROUP,
|
OC.Share.SHARE_TYPE_GROUP,
|
||||||
OC.Share.SHARE_TYPE_LINK,
|
OC.Share.SHARE_TYPE_LINK,
|
||||||
OC.Share.SHARE_TYPE_EMAIL,
|
OC.Share.SHARE_TYPE_EMAIL,
|
||||||
OC.Share.SHARE_TYPE_REMOTE
|
OC.Share.SHARE_TYPE_REMOTE,
|
||||||
|
OC.Share.SHARE_TYPE_CIRCLE
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
bc.setDirectoryInfo(dirInfo);
|
bc.setDirectoryInfo(dirInfo);
|
||||||
|
|
|
@ -9,6 +9,7 @@ OC.Share = _.extend(OC.Share || {}, {
|
||||||
SHARE_TYPE_LINK:3,
|
SHARE_TYPE_LINK:3,
|
||||||
SHARE_TYPE_EMAIL:4,
|
SHARE_TYPE_EMAIL:4,
|
||||||
SHARE_TYPE_REMOTE:6,
|
SHARE_TYPE_REMOTE:6,
|
||||||
|
SHARE_TYPE_CIRCLE:7,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regular expression for splitting parts of remote share owners:
|
* Regular expression for splitting parts of remote share owners:
|
||||||
|
|
|
@ -158,6 +158,7 @@
|
||||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
|
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
|
||||||
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'email') + ')';
|
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'email') + ')';
|
||||||
|
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
if (shareType === OC.Share.SHARE_TYPE_GROUP) {
|
||||||
|
@ -166,6 +167,8 @@
|
||||||
shareWithTitle = shareWith + " (" + t('core', 'remote') + ')';
|
shareWithTitle = shareWith + " (" + t('core', 'remote') + ')';
|
||||||
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||||
shareWithTitle = shareWith + " (" + t('core', 'email') + ')';
|
shareWithTitle = shareWith + " (" + t('core', 'email') + ')';
|
||||||
|
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||||
|
shareWithTitle = shareWith;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _.extend(hasPermissionOverride, {
|
return _.extend(hasPermissionOverride, {
|
||||||
|
@ -183,6 +186,7 @@
|
||||||
modSeed: shareType !== OC.Share.SHARE_TYPE_USER,
|
modSeed: shareType !== OC.Share.SHARE_TYPE_USER,
|
||||||
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE,
|
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE,
|
||||||
isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL,
|
isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL,
|
||||||
|
isCircleShare: shareType === OC.Share.SHARE_TYPE_CIRCLE,
|
||||||
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder()
|
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder()
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -186,18 +186,24 @@
|
||||||
} else {
|
} else {
|
||||||
var emails = [];
|
var emails = [];
|
||||||
}
|
}
|
||||||
|
if (typeof(result.ocs.data.circles) !== 'undefined') {
|
||||||
|
var circles = result.ocs.data.exact.circles.concat(result.ocs.data.circles);
|
||||||
|
} else {
|
||||||
|
var circles = [];
|
||||||
|
}
|
||||||
|
|
||||||
var usersLength;
|
var usersLength;
|
||||||
var groupsLength;
|
var groupsLength;
|
||||||
var remotesLength;
|
var remotesLength;
|
||||||
var emailsLength;
|
var emailsLength;
|
||||||
|
var circlesLength;
|
||||||
var lookupLength;
|
var lookupLength;
|
||||||
|
|
||||||
var i, j;
|
var i, j;
|
||||||
|
|
||||||
//Filter out the current user
|
//Filter out the current user
|
||||||
usersLength = users.length;
|
usersLength = users.length;
|
||||||
for (i = 0 ; i < usersLength; i++) {
|
for (i = 0; i < usersLength; i++) {
|
||||||
if (users[i].value.shareWith === OC.currentUser) {
|
if (users[i].value.shareWith === OC.currentUser) {
|
||||||
users.splice(i, 1);
|
users.splice(i, 1);
|
||||||
break;
|
break;
|
||||||
|
@ -254,10 +260,18 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (share.share_type === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||||
|
circlesLength = circles.length;
|
||||||
|
for (j = 0; j < circlesLength; j++) {
|
||||||
|
if (circles[j].value.shareWith === share.share_with) {
|
||||||
|
circles.splice(j, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(lookup);
|
var suggestions = users.concat(groups).concat(remotes).concat(emails).concat(circles).concat(lookup);
|
||||||
|
|
||||||
if (suggestions.length > 0) {
|
if (suggestions.length > 0) {
|
||||||
$shareWithField
|
$shareWithField
|
||||||
|
@ -313,6 +327,8 @@
|
||||||
text = t('core', '{sharee} (remote)', { sharee: text }, undefined, { escape: false });
|
text = t('core', '{sharee} (remote)', { sharee: text }, undefined, { escape: false });
|
||||||
} else if (item.value.shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
} else if (item.value.shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||||
text = t('core', '{sharee} (email)', { sharee: text }, undefined, { escape: false });
|
text = t('core', '{sharee} (email)', { sharee: text }, undefined, { escape: false });
|
||||||
|
} else if (item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||||
|
text = t('core', '{sharee} ({type}, {owner})', {sharee: text, type: item.value.circleInfo, owner: item.value.circleOwner}, undefined, {escape: false});
|
||||||
}
|
}
|
||||||
var insert = $("<div class='share-autocomplete-item'/>");
|
var insert = $("<div class='share-autocomplete-item'/>");
|
||||||
var avatar = $("<div class='avatardiv'></div>").appendTo(insert);
|
var avatar = $("<div class='avatardiv'></div>").appendTo(insert);
|
||||||
|
|
|
@ -32,6 +32,7 @@ class Constants {
|
||||||
const SHARE_TYPE_EMAIL = 4;
|
const SHARE_TYPE_EMAIL = 4;
|
||||||
const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
|
const SHARE_TYPE_CONTACT = 5; // ToDo Check if it is still in use otherwise remove it
|
||||||
const SHARE_TYPE_REMOTE = 6;
|
const SHARE_TYPE_REMOTE = 6;
|
||||||
|
const SHARE_TYPE_CIRCLE = 7;
|
||||||
|
|
||||||
const FORMAT_NONE = -1;
|
const FORMAT_NONE = -1;
|
||||||
const FORMAT_STATUSES = -2;
|
const FORMAT_STATUSES = -2;
|
||||||
|
|
|
@ -190,9 +190,14 @@ class Manager implements IManager {
|
||||||
if ($share->getSharedWith() === null) {
|
if ($share->getSharedWith() === null) {
|
||||||
throw new \InvalidArgumentException('SharedWith should not be empty');
|
throw new \InvalidArgumentException('SharedWith should not be empty');
|
||||||
}
|
}
|
||||||
|
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
||||||
|
$circle = \OCA\Circles\Api\Circles::detailsCircle($share->getSharedWith());
|
||||||
|
if ($circle === null) {
|
||||||
|
throw new \InvalidArgumentException('SharedWith is not a valid circle');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// We can't handle other types yet
|
// We can't handle other types yet
|
||||||
throw new \InvalidArgumentException('unkown share type');
|
throw new \InvalidArgumentException('unknown share type');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the initiator of the share is set
|
// Verify the initiator of the share is set
|
||||||
|
|
|
@ -48,9 +48,13 @@ class ProviderFactory implements IProviderFactory {
|
||||||
private $federatedProvider = null;
|
private $federatedProvider = null;
|
||||||
/** @var ShareByMailProvider */
|
/** @var ShareByMailProvider */
|
||||||
private $shareByMailProvider;
|
private $shareByMailProvider;
|
||||||
|
/** @var \OCA\Circles\ShareByCircleProvider;
|
||||||
|
* ShareByCircleProvider */
|
||||||
|
private $shareByCircleProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IProviderFactory constructor.
|
* IProviderFactory constructor.
|
||||||
|
*
|
||||||
* @param IServerContainer $serverContainer
|
* @param IServerContainer $serverContainer
|
||||||
*/
|
*/
|
||||||
public function __construct(IServerContainer $serverContainer) {
|
public function __construct(IServerContainer $serverContainer) {
|
||||||
|
@ -164,6 +168,36 @@ class ProviderFactory implements IProviderFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the circle share provider
|
||||||
|
*
|
||||||
|
* @return FederatedShareProvider
|
||||||
|
*/
|
||||||
|
protected function getShareByCircleProvider() {
|
||||||
|
|
||||||
|
$appManager = $this->serverContainer->getAppManager();
|
||||||
|
if (!$appManager->isEnabledForUser('circles')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->shareByCircleProvider === null) {
|
||||||
|
|
||||||
|
$this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
|
||||||
|
$this->serverContainer->getDatabaseConnection(),
|
||||||
|
$this->serverContainer->getSecureRandom(),
|
||||||
|
$this->serverContainer->getUserManager(),
|
||||||
|
$this->serverContainer->getLazyRootFolder(),
|
||||||
|
$this->serverContainer->getL10N('circles'),
|
||||||
|
$this->serverContainer->getLogger(),
|
||||||
|
$this->serverContainer->getURLGenerator()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->shareByCircleProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
@ -175,6 +209,8 @@ class ProviderFactory implements IProviderFactory {
|
||||||
$provider = $this->federatedShareProvider();
|
$provider = $this->federatedShareProvider();
|
||||||
} else if ($id === 'ocMailShare') {
|
} else if ($id === 'ocMailShare') {
|
||||||
$provider = $this->getShareByMailProvider();
|
$provider = $this->getShareByMailProvider();
|
||||||
|
} else if ($id === 'ocCircleShare') {
|
||||||
|
$provider = $this->getShareByCircleProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($provider === null) {
|
if ($provider === null) {
|
||||||
|
@ -190,16 +226,20 @@ class ProviderFactory implements IProviderFactory {
|
||||||
public function getProviderForType($shareType) {
|
public function getProviderForType($shareType) {
|
||||||
$provider = null;
|
$provider = null;
|
||||||
|
|
||||||
if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
|
if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
|
||||||
$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
|
$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
|
||||||
$shareType === \OCP\Share::SHARE_TYPE_LINK) {
|
$shareType === \OCP\Share::SHARE_TYPE_LINK
|
||||||
|
) {
|
||||||
$provider = $this->defaultShareProvider();
|
$provider = $this->defaultShareProvider();
|
||||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
|
||||||
$provider = $this->federatedShareProvider();
|
$provider = $this->federatedShareProvider();
|
||||||
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
|
||||||
$provider = $this->getShareByMailProvider();
|
$provider = $this->getShareByMailProvider();
|
||||||
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
|
||||||
|
$provider = $this->getShareByCircleProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($provider === null) {
|
if ($provider === null) {
|
||||||
throw new ProviderException('No share provider for share type ' . $shareType);
|
throw new ProviderException('No share provider for share type ' . $shareType);
|
||||||
}
|
}
|
||||||
|
@ -208,10 +248,16 @@ class ProviderFactory implements IProviderFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllProviders() {
|
public function getAllProviders() {
|
||||||
|
$shares = [$this->defaultShareProvider(), $this->federatedShareProvider()];
|
||||||
$shareByMail = $this->getShareByMailProvider();
|
$shareByMail = $this->getShareByMailProvider();
|
||||||
if ($shareByMail !== null) {
|
if ($shareByMail !== null) {
|
||||||
return [$this->defaultShareProvider(), $this->federatedShareProvider(), $shareByMail];
|
$shares[] = $shareByMail;
|
||||||
}
|
}
|
||||||
return [$this->defaultShareProvider(), $this->federatedShareProvider()];
|
$shareByCircle = $this->getShareByCircleProvider();
|
||||||
|
if ($shareByCircle !== null) {
|
||||||
|
$shares[] = $shareByCircle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $shares;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,7 +622,7 @@ class ManagerTest extends \Test\TestCase {
|
||||||
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
||||||
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
||||||
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
[$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
|
||||||
[$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unkown share type', true],
|
[$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unknown share type', true],
|
||||||
|
|
||||||
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
|
[$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
|
||||||
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
|
[$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
|
||||||
|
|
Loading…
Reference in New Issue