summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-11-10 14:16:35 +0100
committerJoas Schilling <coding@schilljs.com>2016-11-10 16:46:01 +0100
commitcbc6118f5118cf2201f951db640c32d91d3f5631 (patch)
treefc1b8324b4c0890f950e2acdcdd7b64545931df7 /apps
parentcfda17d8f3c55cbbd8decb134c82c499e3c2c2f4 (diff)
downloadnextcloud-server-cbc6118f5118cf2201f951db640c32d91d3f5631.tar.gz
nextcloud-server-cbc6118f5118cf2201f951db640c32d91d3f5631.zip
Only check the sharing backends for file/folder items
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php27
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php51
2 files changed, 54 insertions, 24 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index 5e01c9bfb09..09912b7758a 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -427,12 +427,23 @@ class ShareesAPIController extends OCSController {
$shareTypes = [
Share::SHARE_TYPE_USER,
- Share::SHARE_TYPE_REMOTE,
- Share::SHARE_TYPE_EMAIL
];
- if ($this->shareManager->allowGroupSharing()) {
+ if ($itemType === 'file' || $itemType === 'folder') {
+ if ($this->shareManager->allowGroupSharing()) {
+ $shareTypes[] = Share::SHARE_TYPE_GROUP;
+ }
+
+ if ($this->isRemoteSharingAllowed($itemType)) {
+ $shareTypes[] = Share::SHARE_TYPE_REMOTE;
+ }
+
+ if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
+ $shareTypes[] = Share::SHARE_TYPE_EMAIL;
+ }
+ } else {
$shareTypes[] = Share::SHARE_TYPE_GROUP;
+ $shareTypes[] = Share::SHARE_TYPE_EMAIL;
}
if (isset($_GET['shareType']) && is_array($_GET['shareType'])) {
@@ -443,16 +454,6 @@ class ShareesAPIController extends OCSController {
sort($shareTypes);
}
- if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes) && !$this->isRemoteSharingAllowed($itemType)) {
- // Remove remote shares from type array, because it is not allowed.
- $shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_REMOTE]);
- }
-
- if (!$this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
- // Remove mail shares from type array, because the share provider is not loaded
- $shareTypes = array_diff($shareTypes, [Share::SHARE_TYPE_EMAIL]);
- }
-
$this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes';
$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
$this->limit = (int) $perPage;
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index e8ee55d1845..336dcb70f0e 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -1221,93 +1221,121 @@ class ShareesAPIControllerTest extends TestCase {
}
public function dataSearch() {
+ $noRemote = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_EMAIL];
$allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL];
return [
- [[], '', 'yes', true, true, $allTypes, false, true, true],
+ [[], '', 'yes', true, true, $noRemote, false, true, true],
// Test itemType
[[
'search' => '',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, $noRemote, false, true, true],
[[
'search' => 'foobar',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, $noRemote, false, true, true],
[[
'search' => 0,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, $noRemote, false, true, true],
// Test itemType
[[
'itemType' => '',
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, $noRemote, false, true, true],
[[
'itemType' => 'folder',
], '', 'yes', true, true, $allTypes, false, true, true],
[[
'itemType' => 0,
- ], '', 'yes', true, true, $allTypes, false, true, true],
+ ], '', 'yes', true, true, $noRemote, false, true, true],
// Test shareType
[[
+ 'itemType' => 'call',
+ ], '', 'yes', true, true, $noRemote, false, true, true],
+ [[
+ 'itemType' => 'folder',
], '', 'yes', true, true, $allTypes, false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => 0,
], '', 'yes', true, false, [0], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => '0',
], '', 'yes', true, false, [0], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => 1,
], '', 'yes', true, false, [1], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => 12,
], '', 'yes', true, false, [], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => 'foobar',
], '', 'yes', true, true, $allTypes, false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => [0, 1, 2],
], '', 'yes', false, false, [0, 1], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => [0, 1],
], '', 'yes', false, false, [0, 1], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => $allTypes,
], '', 'yes', true, true, $allTypes, false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => $allTypes,
], '', 'yes', false, false, [0, 1], false, true, true],
[[
+ 'itemType' => 'folder',
'shareType' => $allTypes,
], '', 'yes', true, false, [0, 6], false, true, false],
[[
+ 'itemType' => 'folder',
'shareType' => $allTypes,
], '', 'yes', false, true, [0, 4], false, true, false],
// Test pagination
[[
+ 'itemType' => 'folder',
'page' => 1,
], '', 'yes', true, true, $allTypes, false, true, true],
[[
+ 'itemType' => 'folder',
'page' => 10,
], '', 'yes', true, true, $allTypes, false, true, true],
// Test perPage
[[
+ 'itemType' => 'folder',
'perPage' => 1,
], '', 'yes', true, true, $allTypes, false, true, true],
[[
+ 'itemType' => 'folder',
'perPage' => 10,
], '', 'yes', true, true, $allTypes, false, true, true],
// Test $shareWithGroupOnly setting
- [[], 'no', 'yes', true, true, $allTypes, false, true, true],
- [[], 'yes', 'yes', true, true, $allTypes, true, true, true],
+ [[
+ 'itemType' => 'folder',
+ ], 'no', 'yes', true, true, $allTypes, false, true, true],
+ [[
+ 'itemType' => 'folder',
+ ], 'yes', 'yes', true, true, $allTypes, true, true, true],
// Test $shareeEnumeration setting
- [[], 'no', 'yes', true, true, $allTypes, false, true, true],
- [[], 'no', 'no', true, true, $allTypes, false, false, true],
+ [[
+ 'itemType' => 'folder',
+ ], 'no', 'yes', true, true, $allTypes, false, true, true],
+ [[
+ 'itemType' => 'folder',
+ ], 'no', 'no', true, true, $allTypes, false, false, true],
];
}
@@ -1318,6 +1346,7 @@ class ShareesAPIControllerTest extends TestCase {
* @param string $apiSetting
* @param string $enumSetting
* @param bool $remoteSharingEnabled
+ * @param bool $emailSharingEnabled
* @param array $shareTypes
* @param bool $shareWithGroupOnly
* @param bool $shareeEnumeration
@@ -1341,7 +1370,7 @@ class ShareesAPIControllerTest extends TestCase {
['core', 'shareapi_allow_share_dialog_user_enumeration', 'yes', $enumSetting],
]);
- $this->shareManager->expects($this->once())
+ $this->shareManager->expects($itemType === 'file' || $itemType === 'folder' ? $this->once() : $this->never())
->method('allowGroupSharing')
->willReturn($allowGroupSharing);