From a84c681acd27ef0d3172466c96b171d6b2657699 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Tue, 19 Aug 2014 08:46:00 +0000 Subject: [PATCH] Support ticket deletion Delete tickets for realz when set to 'deleted' status. This commit will be partially reverted once data retention plugin is added. --- include/class.ticket.php | 19 ++++++++++++++++++- scp/js/ticket.js | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index 26f3312db..faa95986b 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -837,6 +837,10 @@ class Ticket { if (!$status || !$status instanceof TicketStatus) return false; + // XXX: intercept deleted status and do hard delete + if (!strcasecmp($status->getState(), 'deleted')) + return $this->delete($comments); + if ($this->getStatusId() == $status->getId()) return true; @@ -2025,7 +2029,8 @@ class Ticket { exit; } - function delete() { + function delete($comments='') { + global $ost, $thisstaff; //delete just orphaned ticket thread & associated attachments. // Fetch thread prior to removing ticket entry @@ -2042,6 +2047,18 @@ class Ticket { $this->deleteDrafts(); + // Log delete + $log = sprintf(__('Ticket #%1$s deleted by %2$s'), + $this->getNumber(), + $thisstaff ? $thisstaff->getName() : __('SYSTEM')); + + if ($comments) + $log .= sprintf('<hr>%s', $comments); + + $ost->logDebug( + sprintf( __('Ticket #%s deleted'), $this->getNumber()), + $log); + return true; } diff --git a/scp/js/ticket.js b/scp/js/ticket.js index afbf1ecc9..ca5f3957e 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -396,8 +396,9 @@ var ticket_onload = function($) { var url = 'ajax.php/' +$(this).attr('href').substr(1) +'?_uid='+new Date().getTime(); + var $redirect = $(this).data('href'); $.dialog(url, [201], function (xhr) { - window.location.href = window.location.href; + window.location.href = $redirect ? $redirect : window.location.href; }); return false; -- GitLab