Remove modifying calls in ajax/share.php
Those calls used the old sharing endpoint that created incompatible shares. Which eventually would lead to some weird bugs.
This commit is contained in:
parent
75bbd4f8b6
commit
5f3a91536d
|
@ -43,92 +43,6 @@ $defaults = new \OCP\Defaults();
|
|||
|
||||
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'])) {
|
||||
try {
|
||||
$shareType = (int)$_POST['shareType'];
|
||||
$shareWith = $_POST['shareWith'];
|
||||
$itemSourceName = isset($_POST['itemSourceName']) ? (string)$_POST['itemSourceName'] : null;
|
||||
|
||||
/*
|
||||
* Nasty nasty fix for https://github.com/owncloud/core/issues/19950
|
||||
*/
|
||||
$passwordChanged = null;
|
||||
if (is_array($shareWith)) {
|
||||
$passwordChanged = ($shareWith['passwordChanged'] === 'true');
|
||||
if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith['password'] === '') {
|
||||
$shareWith = null;
|
||||
} else {
|
||||
$shareWith = $shareWith['password'];
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* We need this branch since the calendar and contacts also use this
|
||||
* endpoint
|
||||
*/
|
||||
if ($shareType === OCP\Share::SHARE_TYPE_LINK && $shareWith === '') {
|
||||
$shareWith = null;
|
||||
}
|
||||
}
|
||||
|
||||
$itemSourceName=(isset($_POST['itemSourceName'])) ? (string)$_POST['itemSourceName']:'';
|
||||
|
||||
$token = OCP\Share::shareItem(
|
||||
$_POST['itemType'],
|
||||
$_POST['itemSource'],
|
||||
$shareType,
|
||||
$shareWith,
|
||||
$_POST['permissions'],
|
||||
$itemSourceName,
|
||||
(!empty($_POST['expirationDate']) ? new \DateTime((string)$_POST['expirationDate']) : null),
|
||||
$passwordChanged
|
||||
);
|
||||
|
||||
if (is_string($token)) {
|
||||
OC_JSON::success(array('data' => array('token' => $token)));
|
||||
} else {
|
||||
OC_JSON::success();
|
||||
}
|
||||
} catch (\OC\HintException $exception) {
|
||||
OC_JSON::error(array('data' => array('message' => $exception->getHint())));
|
||||
} catch (Exception $exception) {
|
||||
OC_JSON::error(array('data' => array('message' => $exception->getMessage())));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'unshare':
|
||||
if (isset($_POST['shareType']) && isset($_POST['shareWith'])) {
|
||||
if ((int)$_POST['shareType'] === OCP\Share::SHARE_TYPE_LINK && $_POST['shareWith'] == '') {
|
||||
$shareWith = null;
|
||||
} else {
|
||||
$shareWith = (string)$_POST['shareWith'];
|
||||
}
|
||||
$return = OCP\Share::unshare((string)$_POST['itemType'],(string) $_POST['itemSource'], (int)$_POST['shareType'], $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(
|
||||
(string)$_POST['itemType'],
|
||||
(string)$_POST['itemSource'],
|
||||
(int)$_POST['shareType'],
|
||||
(string)$_POST['shareWith'],
|
||||
(int)$_POST['permissions']
|
||||
);
|
||||
($return) ? OC_JSON::success() : OC_JSON::error();
|
||||
}
|
||||
break;
|
||||
case 'setExpirationDate':
|
||||
if (isset($_POST['date'])) {
|
||||
try {
|
||||
$return = OCP\Share::setExpirationDate((string)$_POST['itemType'], (string)$_POST['itemSource'], (string)$_POST['date']);
|
||||
($return) ? OC_JSON::success() : OC_JSON::error();
|
||||
} catch (\Exception $e) {
|
||||
OC_JSON::error(array('data' => array('message' => $e->getMessage())));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'informRecipients':
|
||||
$l = \OC::$server->getL10N('core');
|
||||
$shareType = (int) $_POST['shareType'];
|
||||
|
|
Loading…
Reference in New Issue