Unlinking
This commit is contained in:
51
pagelink.php
51
pagelink.php
@@ -54,6 +54,35 @@ if (auth_quickaclcheck($pageId) < AUTH_EDIT) {
|
||||
luxtools_pagelink_json(403, ['ok' => false, 'error' => 'forbidden']);
|
||||
}
|
||||
|
||||
if ($cmd === 'info') {
|
||||
$depth = (int)$syntax->getConf('pagelink_search_depth');
|
||||
if ($depth < 0) $depth = 0;
|
||||
|
||||
$pageLink = new PageLink((string)$syntax->getConf('paths'), $depth);
|
||||
$uuid = $pageLink->getPageUuid($pageId);
|
||||
if ($uuid === null) {
|
||||
luxtools_pagelink_json(200, [
|
||||
'ok' => true,
|
||||
'uuid' => null,
|
||||
'linked' => false,
|
||||
'folder' => null,
|
||||
'multiple' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
$info = $pageLink->resolveUuid($uuid);
|
||||
$folder = $info['folder'] ?? null;
|
||||
$multiple = !empty($info['multiple']);
|
||||
|
||||
luxtools_pagelink_json(200, [
|
||||
'ok' => true,
|
||||
'uuid' => $uuid,
|
||||
'linked' => is_string($folder) && $folder !== '',
|
||||
'folder' => is_string($folder) ? $folder : null,
|
||||
'multiple' => $multiple,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($cmd === 'ensure') {
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
|
||||
luxtools_pagelink_json(405, ['ok' => false, 'error' => 'method not allowed']);
|
||||
@@ -83,4 +112,26 @@ if ($cmd === 'ensure') {
|
||||
luxtools_pagelink_json(200, ['ok' => true, 'uuid' => $uuid, 'created' => true]);
|
||||
}
|
||||
|
||||
if ($cmd === 'unlink') {
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD'] ?? '') !== 'POST') {
|
||||
luxtools_pagelink_json(405, ['ok' => false, 'error' => 'method not allowed']);
|
||||
}
|
||||
|
||||
if (!checkSecurityToken()) {
|
||||
luxtools_pagelink_json(403, ['ok' => false, 'error' => 'bad token']);
|
||||
}
|
||||
|
||||
$depth = (int)$syntax->getConf('pagelink_search_depth');
|
||||
if ($depth < 0) $depth = 0;
|
||||
|
||||
$pageLink = new PageLink((string)$syntax->getConf('paths'), $depth);
|
||||
$result = $pageLink->unlinkPage($pageId);
|
||||
|
||||
luxtools_pagelink_json(200, [
|
||||
'ok' => true,
|
||||
'uuid' => $result['uuid'] ?? null,
|
||||
'folder' => $result['folder'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
luxtools_pagelink_json(400, ['ok' => false, 'error' => 'unknown command']);
|
||||
|
||||
Reference in New Issue
Block a user