summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2016-05-23 11:48:14 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2016-07-14 11:22:35 +0200
commitf5d0b464a718a32d78226836417c7ab35203f275 (patch)
tree0d82c78c009ce186409f68847e3991890bc2e3b1 /apps/files_sharing
parent762d76f0c3222dd8fc2cd4759af3d42606c15785 (diff)
downloadnextcloud-server-f5d0b464a718a32d78226836417c7ab35203f275.tar.gz
nextcloud-server-f5d0b464a718a32d78226836417c7ab35203f275.zip
create a real federated share if a user add a public link to his ownCloud
this way the owner sees all mounted public links and control them individually
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/public.js73
-rw-r--r--apps/files_sharing/templates/public.php2
2 files changed, 33 insertions, 42 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index 3befeaeda1f..38dc40eeb1e 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -244,10 +244,8 @@ OCA.Sharing.PublicApp = {
var remote = $(this).find('input[type="text"]').val();
var token = $('#sharingToken').val();
var owner = $('#save').data('owner');
- var ownerDisplayName = $('#save').data('owner-display-name');
var name = $('#save').data('name');
- var isProtected = $('#save').data('protected') ? 1 : 0;
- OCA.Sharing.PublicApp._saveToOwnCloud(remote, token, owner, ownerDisplayName, name, isProtected);
+ OCA.Sharing.PublicApp._saveToOwnCloud(remote, token);
});
$('#remote_address').on("keyup paste", function() {
@@ -294,50 +292,43 @@ OCA.Sharing.PublicApp = {
this.fileList.changeDirectory(params.path || params.dir, false, true);
},
- _saveToOwnCloud: function (remote, token, owner, ownerDisplayName, name, isProtected) {
- var toggleLoading = function() {
- var iconClass = $('#save-button-confirm').attr('class');
- var loading = iconClass.indexOf('icon-loading-small') !== -1;
- if(loading) {
- $('#save-button-confirm')
- .removeClass("icon-loading-small")
- .addClass("icon-confirm");
- }
- else {
- $('#save-button-confirm')
- .removeClass("icon-confirm")
- .addClass("icon-loading-small");
+ _saveToOwnCloud: function (remote, token) {
+ $.post(
+ OC.generateUrl('/apps/federatedfilesharing/saveToOwnCloud'),
+ {
+ 'shareWith': remote,
+ 'token': token
}
- };
-
- toggleLoading();
- var location = window.location.protocol + '//' + window.location.host + OC.webroot;
-
- if(remote.substr(-1) !== '/') {
- remote += '/'
- };
-
- var url = remote + 'index.php/apps/files#' + 'remote=' + encodeURIComponent(location) // our location is the remote for the other server
- + "&token=" + encodeURIComponent(token) + "&owner=" + encodeURIComponent(owner) +"&ownerDisplayName=" + encodeURIComponent(ownerDisplayName) + "&name=" + encodeURIComponent(name) + "&protected=" + isProtected;
+ ).done(
+ function (data) {
+ var url = data.remoteUrl;
-
- if (remote.indexOf('://') > 0) {
- OC.redirect(url);
- } else {
- // if no protocol is specified, we automatically detect it by testing https and http
- // this check needs to happen on the server due to the Content Security Policy directive
- $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) {
- if (protocol !== 'http' && protocol !== 'https') {
- toggleLoading();
- OC.dialogs.alert(t('files_sharing', 'No compatible server found at {remote}', {remote: remote}),
- t('files_sharing', 'Invalid server URL'));
+ if (url.indexOf('://') > 0) {
+ OC.redirect(url);
} else {
- OC.redirect(protocol + '://' + url);
+ // if no protocol is specified, we automatically detect it by testing https and http
+ // this check needs to happen on the server due to the Content Security Policy directive
+ $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) {
+ if (protocol !== 'http' && protocol !== 'https') {
+ toggleLoading();
+ OC.dialogs.alert(t('files_sharing', 'No ownCloud installation (7 or higher) found at {remote}', {remote: remote}),
+ t('files_sharing', 'Invalid ownCloud url'));
+ } else {
+ OC.redirect(protocol + '://' + url);
+ }
+ });
}
- });
- }
+ }
+ ).fail(
+ function (jqXHR) {
+ console.log("ERROR!");
+ console.log(jqXHR);
+ OC.dialogs.alert(JSON.parse(jqXHR.responseText).message,
+ t('files_sharing', 'Failed to add the public link to your ownCloud'));
+ }
+ );
}
};
diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index c15001ad24b..8b8267a4e3f 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -84,7 +84,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
data-owner-display-name="<?php p($_['displayName']) ?>" data-owner="<?php p($_['owner']) ?>" data-name="<?php p($_['filename']) ?>">
<button id="save-button"><?php p($l->t('Add to your ownCloud')) ?></button>
<form class="save-form hidden" action="#">
- <input type="text" id="remote_address" placeholder="example.com/owncloud"/>
+ <input type="text" id="remote_address" placeholder="user@example.com/owncloud"/>
<button id="save-button-confirm" class="icon-confirm svg" disabled></button>
</form>
</span>