Skip to content
Snippets Groups Projects
Commit 7a554bf7 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #1392 from greezybacon/issue/1363


draft: Allow clients to delete their draft

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents b6c9d9bb 60b09fa1
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,7 @@ $dispatcher = patterns('', ...@@ -31,6 +31,7 @@ $dispatcher = patterns('',
)), )),
url('^/draft/', patterns('ajax.draft.php:DraftAjaxAPI', url('^/draft/', patterns('ajax.draft.php:DraftAjaxAPI',
url_post('^(?P<id>\d+)$', 'updateDraftClient'), url_post('^(?P<id>\d+)$', 'updateDraftClient'),
url_delete('^(?P<id>\d+)$', 'deleteDraftClient'),
url_post('^(?P<id>\d+)/attach$', 'uploadInlineImageClient'), url_post('^(?P<id>\d+)/attach$', 'uploadInlineImageClient'),
url_get('^(?P<namespace>[\w.]+)$', 'getDraftClient'), url_get('^(?P<namespace>[\w.]+)$', 'getDraftClient'),
url_post('^(?P<namespace>[\w.]+)$', 'createDraftClient') url_post('^(?P<namespace>[\w.]+)$', 'createDraftClient')
......
...@@ -186,6 +186,23 @@ class DraftAjaxAPI extends AjaxController { ...@@ -186,6 +186,23 @@ class DraftAjaxAPI extends AjaxController {
return self::_updateDraft($draft); 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) { function uploadInlineImageClient($id) {
global $thisclient; 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