summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-12-04 19:51:04 +0100
committerBjoern Schiessle <schiessle@owncloud.com>2014-12-19 15:20:24 +0100
commit24993280edcf66f9daa5a5e82428fefef4a3ab56 (patch)
treeede7ca0417af874185588a845fe5f7f754076f60 /core
parentf671b232cc122cdb8e993c8b35bd5419b32a9ae4 (diff)
downloadnextcloud-server-24993280edcf66f9daa5a5e82428fefef4a3ab56.tar.gz
nextcloud-server-24993280edcf66f9daa5a5e82428fefef4a3ab56.zip
Next step in server-to-server sharing next generation, see #12285
Beside some small improvements and bug fixes this will probably the final state for OC8. To test this you need to set up two ownCloud instances. Let's say: URL: myPC/firstOwnCloud user: user1 URL: myPC/secondOwnCloud user: user2 Now user1 can share a file with user2 by entering the username and the URL to the second ownCloud to the share-drop-down, in this case "user2@myPC/secondOwnCloud". The next time user2 login he will get a notification that he received a server-to-server share with the option to accept/decline it. If he accept it the share will be mounted. In both cases a event will be send back to user1 and add a notification to the activity stream that the share was accepted/declined. If user1 decides to unshare the file again from user2 the share will automatically be removed from the second ownCloud server and user2 will see a notification in his activity stream that user1@myPC/firstOwnCloud has unshared the file/folder from him.
Diffstat (limited to 'core')
-rw-r--r--core/ajax/share.php17
-rw-r--r--core/js/share.js82
2 files changed, 68 insertions, 31 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 9f758b4e44e..2831d42a367 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -36,7 +36,7 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$shareWith = null;
}
$itemSourceName=(isset($_POST['itemSourceName'])) ? $_POST['itemSourceName']:'';
-
+
$token = OCP\Share::shareItem(
$_POST['itemType'],
$_POST['itemSource'],
@@ -309,6 +309,21 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
break;
}
}
+
+ // allow user to add unknown remote addresses for server-to-server share
+ $backend = \OCP\Share::getBackend($_GET['itemType']);
+ if ($backend->isShareTypeAllowed(\OCP\Share::SHARE_TYPE_REMOTE)) {
+ if (substr_count($_GET['search'], '@') === 1) {
+ $shareWith[] = array(
+ 'label' => $_GET['search'],
+ 'value' => array(
+ 'shareType' => \OCP\Share::SHARE_TYPE_REMOTE,
+ 'shareWith' => $_GET['search']
+ )
+ );
+ }
+ }
+
$sorter = new \OC\Share\SearchResultSorter($_GET['search'],
'label',
new \OC\Log());
diff --git a/core/js/share.js b/core/js/share.js
index b8717d94ed2..00d1dab519c 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -8,6 +8,7 @@ OC.Share={
SHARE_TYPE_GROUP:1,
SHARE_TYPE_LINK:3,
SHARE_TYPE_EMAIL:4,
+ SHARE_TYPE_REMOTE:6,
/**
* Regular expression for splitting parts of remote share owners:
@@ -444,7 +445,11 @@ OC.Share={
if (share.collection) {
OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, share.collection);
} else {
- OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, false);
+ if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) {
+ OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, OC.PERMISSION_READ | OC.PERMISSION_UPDATE | OC.PERMISSION_CREATE, share.mail_send, false);
+ } else {
+ OC.Share.addShareWith(share.share_type, share.share_with, share.share_with_displayname, share.permissions, possiblePermissions, share.mail_send, false);
+ }
}
}
if (share.expiration != null) {
@@ -455,7 +460,7 @@ OC.Share={
$('#shareWith').autocomplete({minLength: 2, delay: 750, source: function(search, response) {
var $loading = $('#dropdown .shareWithLoading');
$loading.removeClass('hidden');
- $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term.trim(), itemShares: OC.Share.itemShares }, function(result) {
+ $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term.trim(), itemShares: OC.Share.itemShares, itemType: itemType }, function(result) {
$loading.addClass('hidden');
if (result.status == 'success' && result.data.length > 0) {
$( "#shareWith" ).autocomplete( "option", "autoFocus", true );
@@ -484,20 +489,23 @@ OC.Share={
// Default permissions are Edit (CRUD) and Share
// Check if these permissions are possible
var permissions = OC.PERMISSION_READ;
- if (possiblePermissions & OC.PERMISSION_UPDATE) {
- permissions = permissions | OC.PERMISSION_UPDATE;
- }
- if (possiblePermissions & OC.PERMISSION_CREATE) {
- permissions = permissions | OC.PERMISSION_CREATE;
- }
- if (possiblePermissions & OC.PERMISSION_DELETE) {
- permissions = permissions | OC.PERMISSION_DELETE;
- }
- if (oc_appconfig.core.resharingAllowed && (possiblePermissions & OC.PERMISSION_SHARE)) {
- permissions = permissions | OC.PERMISSION_SHARE;
+ if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ permissions = OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_READ;
+ } else {
+ if (possiblePermissions & OC.PERMISSION_UPDATE) {
+ permissions = permissions | OC.PERMISSION_UPDATE;
+ }
+ if (possiblePermissions & OC.PERMISSION_CREATE) {
+ permissions = permissions | OC.PERMISSION_CREATE;
+ }
+ if (possiblePermissions & OC.PERMISSION_DELETE) {
+ permissions = permissions | OC.PERMISSION_DELETE;
+ }
+ if (oc_appconfig.core.resharingAllowed && (possiblePermissions & OC.PERMISSION_SHARE)) {
+ permissions = permissions | OC.PERMISSION_SHARE;
+ }
}
-
var $input = $(this);
var $loading = $dropDown.find('.shareWithLoading');
$loading.removeClass('hidden');
@@ -507,7 +515,11 @@ OC.Share={
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, expirationDate, function() {
$input.prop('disabled', false);
$loading.addClass('hidden');
- OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, possiblePermissions);
+ var posPermissions = possiblePermissions;
+ if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ posPermissions = permissions;
+ }
+ OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, posPermissions);
$('#shareWith').val('');
$('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
OC.Share.updateIcon(itemType, itemSource);
@@ -518,13 +530,18 @@ OC.Share={
// customize internal _renderItem function to display groups and users differently
.data("ui-autocomplete")._renderItem = function( ul, item ) {
var insert = $( "<a>" );
- var text = (item.value.shareType == 1)? item.label + ' ('+t('core', 'group')+')' : item.label;
+ var text = item.label;
+ if (item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
+ text = text + ' ('+t('core', 'group')+')';
+ } else if (item.value.shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ text = text + ' ('+t('core', 'remote')+')';
+ }
insert.text( text );
- if(item.value.shareType == 1) {
+ if(item.value.shareType === OC.Share.SHARE_TYPE_GROUP) {
insert = insert.wrapInner('<strong></strong>');
}
return $( "<li>" )
- .addClass((item.value.shareType == 1)?'group':'user')
+ .addClass((item.value.shareType === OC.Share.SHARE_TYPE_GROUP)?'group':'user')
.append( insert )
.appendTo( ul );
};
@@ -585,9 +602,12 @@ OC.Share={
share_with_displayname: shareWithDisplayName,
permissions: permissions
};
- if (shareType === 1) {
+ if (shareType === OC.Share.SHARE_TYPE_GROUP) {
shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'group') + ')';
}
+ if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ shareWithDisplayName = shareWithDisplayName + " (" + t('core', 'remote') + ')';
+ }
if (!OC.Share.itemShares[shareType]) {
OC.Share.itemShares[shareType] = [];
}
@@ -627,7 +647,7 @@ OC.Share={
html += '<a href="#" class="unshare"><img class="svg" alt="'+t('core', 'Unshare')+'" title="'+t('core', 'Unshare')+'" src="'+OC.imagePath('core', 'actions/delete')+'"/></a>';
html += '<span class="username">' + escapeHTML(shareWithDisplayName) + '</span>';
var mailNotificationEnabled = $('input:hidden[name=mailNotificationEnabled]').val();
- if (mailNotificationEnabled === 'yes') {
+ if (mailNotificationEnabled === 'yes' && shareType !== OC.Share.SHARE_TYPE_REMOTE) {
var checked = '';
if (mailSend === '1') {
checked = 'checked';
@@ -640,17 +660,19 @@ OC.Share={
if (possiblePermissions & OC.PERMISSION_CREATE || possiblePermissions & OC.PERMISSION_UPDATE || possiblePermissions & OC.PERMISSION_DELETE) {
html += '<input id="canEdit-'+escapeHTML(shareWith)+'" type="checkbox" name="edit" class="permissions" '+editChecked+' /><label for="canEdit-'+escapeHTML(shareWith)+'">'+t('core', 'can edit')+'</label>';
}
- showCrudsButton = '<a href="#" class="showCruds"><img class="svg" alt="'+t('core', 'access control')+'" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>';
+ if (shareType !== OC.Share.SHARE_TYPE_REMOTE) {
+ showCrudsButton = '<a href="#" class="showCruds"><img class="svg" alt="'+t('core', 'access control')+'" src="'+OC.imagePath('core', 'actions/triangle-s')+'"/></a>';
+ }
html += '<div class="cruds" style="display:none;">';
- if (possiblePermissions & OC.PERMISSION_CREATE) {
- html += '<input id="canCreate-'+escapeHTML(shareWith)+'" type="checkbox" name="create" class="permissions" '+createChecked+' data-permissions="'+OC.PERMISSION_CREATE+'"/><label for="canCreate-'+escapeHTML(shareWith)+'">'+t('core', 'create')+'</label>';
- }
- if (possiblePermissions & OC.PERMISSION_UPDATE) {
- html += '<input id="canUpdate-'+escapeHTML(shareWith)+'" type="checkbox" name="update" class="permissions" '+updateChecked+' data-permissions="'+OC.PERMISSION_UPDATE+'"/><label for="canUpdate-'+escapeHTML(shareWith)+'">'+t('core', 'change')+'</label>';
- }
- if (possiblePermissions & OC.PERMISSION_DELETE) {
- html += '<input id="canDelete-'+escapeHTML(shareWith)+'" type="checkbox" name="delete" class="permissions" '+deleteChecked+' data-permissions="'+OC.PERMISSION_DELETE+'"/><label for="canDelete-'+escapeHTML(shareWith)+'">'+t('core', 'delete')+'</label>';
- }
+ if (possiblePermissions & OC.PERMISSION_CREATE) {
+ html += '<input id="canCreate-' + escapeHTML(shareWith) + '" type="checkbox" name="create" class="permissions" ' + createChecked + ' data-permissions="' + OC.PERMISSION_CREATE + '"/><label for="canCreate-' + escapeHTML(shareWith) + '">' + t('core', 'create') + '</label>';
+ }
+ if (possiblePermissions & OC.PERMISSION_UPDATE) {
+ html += '<input id="canUpdate-' + escapeHTML(shareWith) + '" type="checkbox" name="update" class="permissions" ' + updateChecked + ' data-permissions="' + OC.PERMISSION_UPDATE + '"/><label for="canUpdate-' + escapeHTML(shareWith) + '">' + t('core', 'change') + '</label>';
+ }
+ if (possiblePermissions & OC.PERMISSION_DELETE) {
+ html += '<input id="canDelete-' + escapeHTML(shareWith) + '" type="checkbox" name="delete" class="permissions" ' + deleteChecked + ' data-permissions="' + OC.PERMISSION_DELETE + '"/><label for="canDelete-' + escapeHTML(shareWith) + '">' + t('core', 'delete') + '</label>';
+ }
html += '</div>';
html += '</li>';
html = $(html).appendTo('#shareWithList');