User Support
Ticket system for communicating with users
Extending the Plugin
Another plugin can add to the support system without changing its files. The models and controllers extend as described in Extending Plugins, and the events below cover the places that the usual extension methods cannot reach.
Ticket Page
The ticket page in the admin panel fires two view events, so a plugin can add its own buttons and details. Each listener receives the Tickets controller and the ticket, and returns the HTML to add.
| Event | Where the HTML goes |
|---|---|
responsiv.support.tickets.extendPreviewToolbar |
The toolbar, before the Delete button. It fires for open and closed tickets, so check closed_at when a button only suits one of them. |
responsiv.support.tickets.extendPreviewScoreboard |
The end of the scoreboard at the top of the page. |
The following example adds a scoreboard item and a toolbar button that opens a popup. The handlers it calls are added to the controller with addDynamicMethod.
Event::listen('responsiv.support.tickets.extendPreviewScoreboard', function ($controller, $ticket) {
return $controller->makePartial('$/acme/helpdesk/partials/_ticket_score.php', ['ticket' => $ticket]);
});
Event::listen('responsiv.support.tickets.extendPreviewToolbar', function ($controller, $ticket) {
if ($ticket->closed_at) {
return '';
}
return Ui::popupButton(
label: "Escalate",
handler: 'onLoadEscalateForm',
icon: 'ph ph-arrow-fat-up',
secondary: true
);
});
Closing Expired Tickets
The support worker fires the responsiv.support.extendExpiredTicketQuery event with the query that finds the next expired ticket. Narrow the query to keep tickets open. Tickets left out of the query are skipped, so the worker closes the next expired ticket instead.
Event::listen('responsiv.support.extendExpiredTicketQuery', function ($query) {
$query->where('is_on_hold', false);
});
Notifications
The notifyUser and notifyStaff methods of the ticket model are public, so a plugin can send its own mail templates about a ticket. Both pass the ticket, its user and its assignee to the template, and log a failed send instead of throwing.
| Method | Recipients |
|---|---|
notifyUser($template) |
The ticket's user. The template also receives ticketUrl, the address of the ticket on your site. |
notifyStaff($template, $participants = false) |
The assignee, or every support member when nobody is assigned. Pass true as the second argument to mail every staff member who took part in the ticket. The template also receives staff, the administrator being mailed, and previewUrl, the address of the ticket in the admin panel. |
$ticket->notifyStaff('acme.helpdesk::mail.ticket-escalated');
Register the template with the registerMailTemplates method of your plugin, see Sending Mail.
Previous: Theming Next: Upgrade Guide