diff --git a/core/ajax/share.php b/core/ajax/share.php index 9376f18e8a..04294a36ac 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -24,9 +24,9 @@ OC_JSON::checkLoggedIn(); if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSource'])) { switch ($_POST['action']) { case 'share': - if (isset($_POST['itemName']) && isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) { + if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) { try { - OCP\Share::shareItem($_POST['itemType'], $_POST['itemName'], $_POST['itemSource'], (int)$_POST['shareType'], $_POST['shareWith'], $_POST['permissions']); + OCP\Share::shareItem($_POST['itemType'], $_POST['itemSource'], (int)$_POST['shareType'], $_POST['shareWith'], $_POST['permissions']); // TODO May need to return private link OC_JSON::success(); } catch (Exception $exception) { @@ -56,9 +56,9 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo } break; case 'getItem': - if (isset($_GET['itemType']) && isset($_GET['itemName']) && isset($_GET['itemSource'])) { - $reshare = OCP\Share::getItemSharedWith($_GET['itemType'], $_GET['itemName'], OCP\Share::FORMAT_NONE, null, true); - if ($_GET['itemSource'] !== false) { + if (isset($_GET['itemType']) && isset($_GET['itemSource']) && isset($_GET['checkShares'])) { + $reshare = OCP\Share::getItemSharedWithBySource($_GET['itemType'], $_GET['itemSource'], OCP\Share::FORMAT_NONE, null, true); + if ($_GET['checkShares'] == "true") { $shares = OCP\Share::getItemShared($_GET['itemType'], $_GET['itemSource']); } else { $shares = false; diff --git a/core/js/share.js b/core/js/share.js index 418d18f86b..c1d66ee921 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -30,12 +30,14 @@ OC.Share={ } }); }, - loadItem:function(itemType, itemName, itemSource) { + loadItem:function(itemType, itemSource) { var data = ''; - if (typeof OC.Share.statuses[itemName] === 'undefined') { - itemSource = false; + if (typeof OC.Share.statuses[itemSource] === 'undefined') { + checkShares = false; + } else { + checkShares = true; } - $.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, itemName: itemName, itemSource: itemSource }, async: false, success: function(result) { + $.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, itemSource: itemSource, checkShares: checkShares }, async: false, success: function(result) { if (result && result.status === 'success') { data = result.data; } else { @@ -44,8 +46,8 @@ OC.Share={ }}); return data; }, - share:function(itemType, itemName, itemSource, shareType, shareWith, permissions, callback) { - $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, itemName: itemName, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { + share:function(itemType, itemSource, shareType, shareWith, permissions, callback) { + $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { if (result && result.status === 'success') { if (callback) { callback(result.data); @@ -73,9 +75,9 @@ OC.Share={ } }); }, - showDropDown:function(itemType, itemName, itemSource, appendTo, privateLink, possiblePermissions) { - var data = OC.Share.loadItem(itemType, itemName, itemSource); - var html = '