diff options
Diffstat (limited to 'core/ajax/share.php')
-rw-r--r-- | core/ajax/share.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index efe01dff886..41832a3c659 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -28,13 +28,19 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo case 'share': if (isset($_POST['shareType']) && isset($_POST['shareWith']) && isset($_POST['permissions'])) { try { - if ((int)$_POST['shareType'] === OCP\Share::SHARE_TYPE_LINK && $_POST['shareWith'] == '') { + $shareType = (int)$_POST['shareType']; + $shareWith = $_POST['shareWith']; + if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith == '') { $shareWith = null; + } + + $token = OCP\Share::shareItem($_POST['itemType'], $_POST['itemSource'], $shareType, $shareWith, $_POST['permissions']); + + if (is_string($token)) { + OC_JSON::success(array('data' => array('token' => $token))); } else { - $shareWith = $_POST['shareWith']; + OC_JSON::success(); } - OCP\Share::shareItem($_POST['itemType'], $_POST['itemSource'], (int)$_POST['shareType'], $shareWith, $_POST['permissions']); - OC_JSON::success(); } catch (Exception $exception) { OC_JSON::error(array('data' => array('message' => $exception->getMessage()))); } |