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

Cleanup drafts on ticket processing

Before, the draft was only cleaned up when progress on the ticket was
tracked with the reply box.
parent bbbaba3d
Branches
Tags
No related merge requests found
......@@ -728,6 +728,7 @@ class Ticket {
$this->reload();
$this->logEvent('closed');
$this->deleteDrafts();
return true;
}
......@@ -1676,9 +1677,15 @@ class Ticket {
foreach (DynamicFormEntry::forTicket($this->getId()) as $form)
$form->delete();
$this->deleteDrafts();
return true;
}
function deleteDrafts() {
Draft::deleteForNamespace('ticket.%.' . $this->getId());
}
function update($vars, &$errors) {
global $cfg, $thisstaff;
......
......@@ -70,13 +70,13 @@ if($_POST && !$errors):
$msg='Reply posted successfully';
$ticket->reload();
// Cleanup drafts for the ticket. If not closed, only clean
// for this staff. Else clean all drafts for the ticket.
Draft::deleteForNamespace('ticket.%.' . $ticket->getId(),
$ticket->isClosed() ? false : $thisstaff->getId());
if($ticket->isClosed() && $wasOpen)
$ticket=null;
else
// Still open -- cleanup response draft for this user
Draft::deleteForNamespace(
'ticket.response.' . $ticket->getId(),
$thisstaff->getId());
} elseif(!$errors['err']) {
$errors['err']='Unable to post the reply. Correct the errors below and try again!';
......@@ -174,17 +174,13 @@ if($_POST && !$errors):
$wasOpen = ($ticket->isOpen());
if(($note=$ticket->postNote($vars, $errors, $thisstaff))) {
// Cleanup drafts for the ticket. If not closed, only clean
// note drafts for this staff. Else clean all drafts for the ticket.
Draft::deleteForNamespace(
sprintf('ticket.%s.%d',
$ticket->isClosed() ? '%' : 'note',
$ticket->getId()),
$ticket->isOpen() ? $thisstaff->getId() : false);
$msg='Internal note posted successfully';
if($wasOpen && $ticket->isClosed())
$ticket = null; //Going back to main listing.
else
// Ticket is still open -- clear draft for the note
Draft::deleteForNamespace('ticket.note.'.$ticket->getId(),
$thisstaff->getId());
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment