start to get fed group shares into the share dialog
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
1d5a9c3f97
commit
2abc705632
|
@ -67,12 +67,14 @@ class ShareesAPIController extends OCSController {
|
|||
'users' => [],
|
||||
'groups' => [],
|
||||
'remotes' => [],
|
||||
'remote_groups' => [],
|
||||
'emails' => [],
|
||||
'circles' => [],
|
||||
],
|
||||
'users' => [],
|
||||
'groups' => [],
|
||||
'remotes' => [],
|
||||
'remote_groups' => [],
|
||||
'emails' => [],
|
||||
'lookup' => [],
|
||||
'circles' => [],
|
||||
|
@ -153,6 +155,10 @@ class ShareesAPIController extends OCSController {
|
|||
$shareTypes[] = Share::SHARE_TYPE_REMOTE;
|
||||
}
|
||||
|
||||
if ($this->isRemoteGroupSharingAllowed($itemType)) {
|
||||
$shareTypes[] = Share::SHARE_TYPE_REMOTE_GROUP;
|
||||
}
|
||||
|
||||
if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) {
|
||||
$shareTypes[] = Share::SHARE_TYPE_EMAIL;
|
||||
}
|
||||
|
@ -216,6 +222,10 @@ class ShareesAPIController extends OCSController {
|
|||
}
|
||||
}
|
||||
|
||||
protected function isRemoteGroupSharingAllowed(string $itemType): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a bunch of pagination links for the current page
|
||||
|
|
|
@ -11,6 +11,7 @@ OC.Share = _.extend(OC.Share || {}, {
|
|||
SHARE_TYPE_REMOTE:6,
|
||||
SHARE_TYPE_CIRCLE:7,
|
||||
SHARE_TYPE_GUEST:8,
|
||||
SHARE_TYPE_REMOTE_GROUP:9,
|
||||
|
||||
/**
|
||||
* Regular expression for splitting parts of remote share owners:
|
||||
|
|
|
@ -198,6 +198,8 @@
|
|||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
|
||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote group') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'email') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||
|
@ -207,7 +209,10 @@
|
|||
shareWithTitle = shareWith + " (" + t('core', 'group') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
||||
shareWithTitle = shareWith + " (" + t('core', 'remote') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
|
||||
shareWithTitle = shareWith + " (" + t('core', 'remote group') + ')';
|
||||
}
|
||||
else if (shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||
shareWithTitle = shareWith + " (" + t('core', 'email') + ')';
|
||||
} else if (shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||
shareWithTitle = shareWith;
|
||||
|
@ -243,6 +248,7 @@
|
|||
shareId: this.model.get('shares')[shareIndex].id,
|
||||
modSeed: shareType !== OC.Share.SHARE_TYPE_USER && shareType !== OC.Share.SHARE_TYPE_CIRCLE,
|
||||
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE,
|
||||
isRemoteGroupShare: shareType === OC.Share.SHARE_TYPE_REMOTE_GROUP,
|
||||
isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL,
|
||||
isCircleShare: shareType === OC.Share.SHARE_TYPE_CIRCLE,
|
||||
isFileSharedByMail: shareType === OC.Share.SHARE_TYPE_EMAIL && !this.model.isFolder(),
|
||||
|
|
|
@ -93,6 +93,9 @@
|
|||
this.configModel.on('change:isRemoteShareAllowed', function() {
|
||||
view.render();
|
||||
});
|
||||
this.configModel.on('change:isRemoteGroupShareAllowed', function() {
|
||||
view.render();
|
||||
});
|
||||
this.model.on('change:permissions', function() {
|
||||
view.render();
|
||||
});
|
||||
|
@ -161,7 +164,7 @@
|
|||
},
|
||||
function (result) {
|
||||
if (result.ocs.meta.statuscode === 100) {
|
||||
var filter = function(users, groups, remotes, emails, circles) {
|
||||
var filter = function(users, groups, remotes, remote_groups, emails, circles) {
|
||||
if (typeof(emails) === 'undefined') {
|
||||
emails = [];
|
||||
}
|
||||
|
@ -172,6 +175,7 @@
|
|||
var usersLength;
|
||||
var groupsLength;
|
||||
var remotesLength;
|
||||
var remoteGroupsLength;
|
||||
var emailsLength;
|
||||
var circlesLength;
|
||||
|
||||
|
@ -228,6 +232,14 @@
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
|
||||
remoteGroupsLength = remote_groups.length;
|
||||
for (j = 0; j < remoteGroupsLength; j++) {
|
||||
if (remote_groups[j].value.shareWith === share.share_with) {
|
||||
remote_groups.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (share.share_type === OC.Share.SHARE_TYPE_EMAIL) {
|
||||
emailsLength = emails.length;
|
||||
for (j = 0; j < emailsLength; j++) {
|
||||
|
@ -252,6 +264,7 @@
|
|||
result.ocs.data.exact.users,
|
||||
result.ocs.data.exact.groups,
|
||||
result.ocs.data.exact.remotes,
|
||||
result.ocs.data.exact.remote_groups,
|
||||
result.ocs.data.exact.emails,
|
||||
result.ocs.data.exact.circles
|
||||
);
|
||||
|
@ -259,6 +272,7 @@
|
|||
var exactUsers = result.ocs.data.exact.users;
|
||||
var exactGroups = result.ocs.data.exact.groups;
|
||||
var exactRemotes = result.ocs.data.exact.remotes;
|
||||
var exactRemoteGroups = result.ocs.data.exact.remote_groups;
|
||||
var exactEmails = [];
|
||||
if (typeof(result.ocs.data.emails) !== 'undefined') {
|
||||
exactEmails = result.ocs.data.exact.emails;
|
||||
|
@ -268,12 +282,13 @@
|
|||
exactCircles = result.ocs.data.exact.circles;
|
||||
}
|
||||
|
||||
var exactMatches = exactUsers.concat(exactGroups).concat(exactRemotes).concat(exactEmails).concat(exactCircles);
|
||||
var exactMatches = exactUsers.concat(exactGroups).concat(exactRemotes).concat(exactRemoteGroups).concat(exactEmails).concat(exactCircles);
|
||||
|
||||
filter(
|
||||
result.ocs.data.users,
|
||||
result.ocs.data.groups,
|
||||
result.ocs.data.remotes,
|
||||
result.ocs.data.remote_groups,
|
||||
result.ocs.data.emails,
|
||||
result.ocs.data.circles
|
||||
);
|
||||
|
@ -281,6 +296,7 @@
|
|||
var users = result.ocs.data.users;
|
||||
var groups = result.ocs.data.groups;
|
||||
var remotes = result.ocs.data.remotes;
|
||||
var remoteGroups = result.ocs.data.remote_groups;
|
||||
var lookup = result.ocs.data.lookup;
|
||||
var emails = [];
|
||||
if (typeof(result.ocs.data.emails) !== 'undefined') {
|
||||
|
@ -291,7 +307,7 @@
|
|||
circles = result.ocs.data.circles;
|
||||
}
|
||||
|
||||
var suggestions = exactMatches.concat(users).concat(groups).concat(remotes).concat(emails).concat(circles).concat(lookup);
|
||||
var suggestions = exactMatches.concat(users).concat(groups).concat(remotes).concat(remoteGroups).concat(emails).concat(circles).concat(lookup);
|
||||
|
||||
deferred.resolve(suggestions, exactMatches);
|
||||
} else {
|
||||
|
@ -414,7 +430,9 @@
|
|||
if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
|
||||
text = t('core', '{sharee} (group)', { sharee: text }, undefined, { escape: false });
|
||||
} else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
|
||||
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_REMOTE_GROUP) {
|
||||
text = t('core', '{sharee} (remote group)', { sharee: text }, undefined, { escape: false });
|
||||
} else if (item.value.shareType === OC.Share.SHARE_TYPE_EMAIL) {
|
||||
text = t('core', '{sharee} (email)', { sharee: text }, undefined, { escape: false });
|
||||
} else if (item.value.shareType === OC.Share.SHARE_TYPE_CIRCLE) {
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Collaboration\Collaborators;
|
||||
|
||||
|
||||
use OCP\Collaboration\Collaborators\ISearchPlugin;
|
||||
use OCP\Collaboration\Collaborators\ISearchResult;
|
||||
use OCP\Collaboration\Collaborators\SearchResultType;
|
||||
use OCP\Contacts\IManager;
|
||||
use OCP\Federation\ICloudFederationProviderManager;
|
||||
use OCP\Federation\ICloudIdManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\Share;
|
||||
|
||||
class RemoteGroupPlugin implements ISearchPlugin {
|
||||
protected $shareeEnumeration;
|
||||
|
||||
/** @var ICloudIdManager */
|
||||
private $cloudIdManager;
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
/** @var bool */
|
||||
private $enabled = false;
|
||||
|
||||
public function __construct(ICloudFederationProviderManager $cloudFederationProviderManager, ICloudIdManager $cloudIdManager) {
|
||||
try {
|
||||
$fileSharingProvider = $cloudFederationProviderManager->getCloudFederationProvider('file');
|
||||
$supportedShareTypes = $fileSharingProvider->getSupportedShareTypes();
|
||||
if (in_array('group', $supportedShareTypes)) {
|
||||
$this->enabled = true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// do nothing, just don't enable federated group shares
|
||||
}
|
||||
$this->cloudIdManager = $cloudIdManager;
|
||||
}
|
||||
|
||||
public function search($search, $limit, $offset, ISearchResult $searchResult) {
|
||||
$result = ['wide' => [], 'exact' => []];
|
||||
$resultType = new SearchResultType('remote_groups');
|
||||
|
||||
if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
|
||||
$result['exact'][] = [
|
||||
'label' => $search,
|
||||
'value' => [
|
||||
'shareType' => Share::SHARE_TYPE_REMOTE_GROUP,
|
||||
'shareWith' => $search,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -60,6 +60,7 @@ use OC\Authentication\LoginCredentials\Store;
|
|||
use OC\Authentication\Token\IProvider;
|
||||
use OC\Collaboration\Collaborators\GroupPlugin;
|
||||
use OC\Collaboration\Collaborators\MailPlugin;
|
||||
use OC\Collaboration\Collaborators\RemoteGroupPlugin;
|
||||
use OC\Collaboration\Collaborators\RemotePlugin;
|
||||
use OC\Collaboration\Collaborators\UserPlugin;
|
||||
use OC\Command\CronBus;
|
||||
|
@ -1066,6 +1067,7 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
|
||||
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
|
||||
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
|
||||
$instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
|
||||
|
||||
return $instance;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue