summaryrefslogtreecommitdiffstats
path: root/core/ajax/share.php
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-20 20:00:29 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-20 21:22:22 -0400
commit09e851a9c4751db6225130bdb6290e65308f8c76 (patch)
treebac3ec01003c49a65b3a8ce7b8bf06e1a11317d7 /core/ajax/share.php
parent49229da0e12ed950288ca5c44bbaf4e7b85e3542 (diff)
downloadnextcloud-server-09e851a9c4751db6225130bdb6290e65308f8c76.tar.gz
nextcloud-server-09e851a9c4751db6225130bdb6290e65308f8c76.zip
Fix share ajax calls to use itemName/itemSource, show who shared a file with you
Diffstat (limited to 'core/ajax/share.php')
-rw-r--r--core/ajax/share.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 4ff12af9eb9..9376f18e8ad 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -21,12 +21,12 @@
require_once '../../lib/base.php';
OC_JSON::checkLoggedIn();
-if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item'])) {
+if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSource'])) {
switch ($_POST['action']) {
case 'share':
- if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) {
+ if (isset($_POST['itemName']) && isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) {
try {
- OCP\Share::shareItem($_POST['itemType'], $_POST['item'], $_POST['item'], (int)$_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
+ OCP\Share::shareItem($_POST['itemType'], $_POST['itemName'], $_POST['itemSource'], (int)$_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
// TODO May need to return private link
OC_JSON::success();
} catch (Exception $exception) {
@@ -36,13 +36,13 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item']
break;
case 'unshare':
if (isset($_POST['shareType']) && isset($_POST['shareWith'])) {
- $return = OCP\Share::unshare($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith']);
+ $return = OCP\Share::unshare($_POST['itemType'], $_POST['itemSource'], $_POST['shareType'], $_POST['shareWith']);
($return) ? OC_JSON::success() : OC_JSON::error();
}
break;
case 'setPermissions':
if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) {
- $return = OCP\Share::setPermissions($_POST['itemType'], $_POST['item'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
+ $return = OCP\Share::setPermissions($_POST['itemType'], $_POST['itemSource'], $_POST['shareType'], $_POST['shareWith'], $_POST['permissions']);
($return) ? OC_JSON::success() : OC_JSON::error();
}
break;
@@ -56,10 +56,14 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['item']
}
break;
case 'getItem':
- // TODO Check if the item was shared to the current user
- if (isset($_GET['itemType']) && isset($_GET['item'])) {
- $return = OCP\Share::getItemShared($_GET['itemType'], $_GET['item']);
- ($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
+ 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) {
+ $shares = OCP\Share::getItemShared($_GET['itemType'], $_GET['itemSource']);
+ } else {
+ $shares = false;
+ }
+ OC_JSON::success(array('data' => array('reshare' => $reshare, 'shares' => $shares)));
}
break;
case 'getShareWith':