diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-23 10:16:57 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2015-12-30 08:58:04 +0100 |
commit | fa7996aa8aad67992556ba8f64cb4d7ada0d44f8 (patch) | |
tree | 2a9d5bb0ccb5552f50753aa8a5212446191780f2 /core | |
parent | 45c41e2b2cefa97c9d8c3bc73cfc088839640d1d (diff) | |
download | nextcloud-server-fa7996aa8aad67992556ba8f64cb4d7ada0d44f8.tar.gz nextcloud-server-fa7996aa8aad67992556ba8f64cb4d7ada0d44f8.zip |
Web sharing uses sharee endpoint
Diffstat (limited to 'core')
-rw-r--r-- | core/js/sharedialogview.js | 90 |
1 files changed, 75 insertions, 15 deletions
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index dd07adceac4..b8d07bad992 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -117,22 +117,82 @@ var $loading = this.$el.find('.shareWithLoading'); $loading.removeClass('hidden'); $loading.addClass('inlineblock'); - $.get(OC.filePath('core', 'ajax', 'share.php'), { - fetch: 'getShareWith', - search: search.term.trim(), - limit: 200, - itemShares: OC.Share.itemShares, - itemType: view.model.get('itemType') - }, function (result) { - $loading.addClass('hidden'); - $loading.removeClass('inlineblock'); - if (result.status == 'success' && result.data.length > 0) { - $('.shareWithField').autocomplete("option", "autoFocus", true); - response(result.data); - } else { - response(); + $.get( + OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', + { + format: 'json', + search: search.term.trim(), + perPage: 200, + itemType: view.model.get('itemType') + }, + function (result) { + $loading.addClass('hidden'); + $loading.removeClass('inlineblock'); + if (result.ocs.meta.statuscode == 100) { + var users = [].concat(result.ocs.data.exact.users).concat(result.ocs.data.users); + var groups = result.ocs.data.exact.groups.concat(result.ocs.data.groups); + var remotes = result.ocs.data.exact.remotes.concat(result.ocs.data.remotes); + + var usersLength; + var groupsLength; + var remotesLength; + + var i, j; + + //Filter out the current user + usersLength = users.length; + for (i = 0 ; i < usersLength; i++) { + if (users[i].value.shareWith === OC.currentUser) { + users.splice(i, 1); + break; + } + } + + // Filter out the owner of the share + + var shares = view.model.get('shares'); + var sharesLength = shares.length; + + // Now filter out all sharees that are already shared with + for (i = 0; i < sharesLength; i++) { + var share = shares[i]; + + if (share.share_type === OC.Share.SHARE_TYPE_USER) { + usersLength = users.length; + for (j = 0; j < usersLength; j++) { + if (users[j].value.shareWith === share.share_with) { + users.splice(j, 1); + break; + } + } + } else if (share.share_type === OC.Share.SHARE_TYPE_GROUP) { + groupsLength = groups.length; + for (j = 0; j < groupsLength; j++) { + if (groups[j].value.shareWith === share.share_with) { + groups.splice(j, 1); + break; + } + } + } else if (share.share_type === OC.Share.SHARE_TYPE_REMOTE) { + remotesLength = remotes.length; + for (j = 0; j < remotesLength; j++) { + if (remotes[j].value.shareWith === share.share_with) { + remotes.splice(j, 1); + break; + } + } + } + } + + var suggestions = users.concat(groups).concat(remotes); + + $('.shareWithField').autocomplete("option", "autoFocus", true); + response(suggestions); + } else { + response(); + } } - }).fail(function () { + ).fail(function() { $loading.addClass('hidden'); $loading.removeClass('inlineblock'); OC.Notification.show(t('core', 'An error occured. Please try again')); |