summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-06-25 14:55:49 -0400
committerBart Visscher <bartv@thisnet.nl>2012-06-27 01:05:36 +0200
commitb5961635eac898ee8a8c67aaa9f46fd91cbf53d0 (patch)
treeb9cfda2437bcd949433ed26d726f6414ff828465
parent9fdfcc29febe4ae7d1f8f056878cd04f5596f1e0 (diff)
downloadnextcloud-server-b5961635eac898ee8a8c67aaa9f46fd91cbf53d0.tar.gz
nextcloud-server-b5961635eac898ee8a8c67aaa9f46fd91cbf53d0.zip
Fix ajax share file and replace 'User or Group' select form with a textbox
-rw-r--r--core/ajax/share.php15
-rw-r--r--core/js/share.js47
2 files changed, 17 insertions, 45 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 11fee4a000b..3582f8596b9 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -18,37 +18,38 @@
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+require_once '../../lib/base.php';
-OCP\JSON::checkLoggedIn();
+OC_JSON::checkLoggedIn();
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'share':
$return = OCP\Share::share($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
// TODO May need to return private link
- ($return) ? OCP\JSON::success() : OCP\JSON::error();
+ ($return) ? OC_JSON::success() : OC_JSON::error();
break;
case 'unshare':
$return = OCP\Share::unshare($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith']);
- ($return) ? OCP\JSON::success() : OCP\JSON::error();
+ ($return) ? OC_JSON::success() : OC_JSON::error();
break;
case 'setTarget':
$return = OCP\Share::setTarget($_POST['itemType'], $_POST['item'], $_POST['newTarget']);
- ($return) ? OCP\JSON::success() : OCP\JSON::error();
+ ($return) ? OC_JSON::success() : OC_JSON::error();
break;
case 'setPermissions':
$return = OCP\Share::setPermissions($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
- ($return) ? OCP\JSON::success() : OCP\JSON::error();
+ ($return) ? OC_JSON::success() : OC_JSON::error();
break;
}
} else if (isset($_GET['fetch'])) {
switch ($_GET['fetch']) {
case 'getItemsSharedStatuses':
$return = OCP\Share::getItemsSharedStatuses($_POST['itemType']);
- ($return) ? OCP\JSON::success(array('data' => $return)) : OCP\JSON::error();
+ ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
break;
case 'getItemShared':
$return = OCP\Share::getItemShared($_POST['itemType'], $_POST['item']);
- ($return) ? OCP\JSON::success(array('data' => $return)) : OCP\JSON::error();
+ ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
break;
case 'getShareWith':
// TODO Autocomplete for all users, groups, etc.
diff --git a/core/js/share.js b/core/js/share.js
index b7821ce14b5..73a7ff86c2d 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -21,20 +21,20 @@ OC.Share={
});
},
loadItem:function(itemType, item) {
- $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemShared', itemType: itemType, item: item }, async: false, function(result) {
+ $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemShared', itemType: itemType, item: item }, function(result) {
if (result && result.status === 'success') {
OC.Share.item = result.data;
}
});
},
- share:function(itemType, shareType, shareWith, permissions, callback) {
- $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) {
+ share:function(itemType, item, shareType, shareWith, permissions, callback) {
+ $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, item: item, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) {
if (result && result.status === 'success') {
if (callback) {
callback(result.data);
}
} else {
- OC.dialogs.alert(result.data.message, 'Error while sharing');
+ OC.dialogs.alert('Error', 'Error while sharing');
}
});
},
@@ -58,11 +58,9 @@ OC.Share={
},
showDropDown:function(itemType, item, appendTo) {
OC.Share.loadItem(item);
- var html = '<div id="dropdown" class="drop" data-item="'+item+'">';
+ var html = '<div id="dropdown" class="drop" data-item-type="'+itemType+'" data-item="'+item+'">';
// TODO replace with autocomplete textbox
- html += '<select data-placeholder="User or Group" id="share_with" class="chzen-select">';
- html += '<option value="" selected="selected" disabled="disabled">Your groups & members</option>';
- html += '</select>';
+ html += '<input id="shareWith" type="text" placeholder="Share with" />';
html += '<div id="sharedWithList">';
html += '<ul id="userList"></ul>';
html += '<div id="groups" style="display:none;">';
@@ -253,35 +251,8 @@ $(document).ready(function() {
}
});
- $('#share_with').live('change', function() {
- var item = $('#dropdown').data('item');
- var uid_shared_with = $(this).val();
- var pos = uid_shared_with.indexOf('(group)');
- var isGroup = false;
- if (pos != -1) {
- // Remove '(group)' from uid_shared_with
- uid_shared_with = uid_shared_with.substr(0, pos);
- isGroup = true;
- }
- OC.Share.share(item, uid_shared_with, 0, function() {
- if (isGroup) {
- // Reload item because we don't know which users are in the group
- OC.Share.loadItem(item);
- var users;
- $.each(OC.Share.itemGroups, function(index, group) {
- if (group.gid == uid_shared_with) {
- users = group.users;
- }
- });
- OC.Share.addSharedWith(uid_shared_with, 0, users, false);
- } else {
- OC.Share.addSharedWith(uid_shared_with, 0, false, false);
- }
- // Change icon
- if (!OC.Share.itemPrivateLink) {
- OC.Share.icons[item] = OC.imagePath('core', 'actions/shared');
- }
- });
+ $('#shareWith').live('change', function() {
+ OC.Share.share($('#dropdown').data('item-type'), $('#dropdown').data('item'), 0, $(this).val(), 0, false);
});
$('.unshare').live('click', function() {
@@ -334,4 +305,4 @@ $(document).ready(function() {
$('#emailPrivateLink').live('submit', function() {
OC.Share.emailPrivateLink();
});
-}); \ No newline at end of file
+});