Skip to content
Snippets Groups Projects
Commit 60b09fa1 authored by Jared Hancock's avatar Jared Hancock
Browse files

draft: Allow clients to delete their draft

parent 209379c9
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ $dispatcher = patterns('',
)),
url('^/draft/', patterns('ajax.draft.php:DraftAjaxAPI',
url_post('^(?P<id>\d+)$', 'updateDraftClient'),
url_delete('^(?P<id>\d+)$', 'deleteDraftClient'),
url_post('^(?P<id>\d+)/attach$', 'uploadInlineImageClient'),
url_get('^(?P<namespace>[\w.]+)$', 'getDraftClient'),
url_post('^(?P<namespace>[\w.]+)$', 'createDraftClient')
......
......@@ -186,6 +186,23 @@ class DraftAjaxAPI extends AjaxController {
return self::_updateDraft($draft);
}
function deleteDraftClient($id) {
global $thisclient;
if (!($draft = Draft::lookup($id)))
Http::response(205, "Draft not found. Create one first");
elseif ($thisclient) {
if ($draft->getStaffId() != $thisclient->getId())
Http::response(404, "Draft not found");
}
else {
if (substr(session_id(), -12) != substr($draft->getNamespace(), -12))
Http::response(404, "Draft not found");
}
$draft->delete();
}
function uploadInlineImageClient($id) {
global $thisclient;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment