/** * Removes a ticket and all associated records (tags, comments, etc.) * * @return void */ public function deleteTask() { // Incoming $id = Request::getInt('id', 0); // Check for an ID if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=tickets')); return; } // Delete tags $tags = new Tags($id); $tags->removeAll(); // Load the record $ticket = new Ticket($id); // Delete ticket if (!$ticket->delete()) { Notify::error($ticket->getError()); } // Log the activity $recipients = array(['support.tickets', 1]); $creator = User::getInstance($ticket->get('login')); if ($creator && $creator->get('id')) { $recipients[] = ['user', $creator->get('id')]; } if ($ticket->get('owner')) { $recipients[] = ['user', $ticket->owner('id')]; } Event::trigger('system.logActivity', ['activity' => ['action' => 'deleted', 'scope' => 'support.ticket', 'scope_id' => $id, 'description' => Lang::txt('COM_SUPPORT_ACTIVITY_TICKET_DELETED', '<a href="' . Route::url($ticket->link()) . '">#' . $ticket->get('id') . ' - ' . $ticket->get('summary') . '</a>'), 'details' => array('id' => $id)], 'recipients' => $recipients]); // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=tickets')); }