PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 1.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v1.4.5
2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 All 68 releases
fluent-support / app / Hooks / Handlers / ActivityLogger.php

ActivityLogger.php in Fluent Support – Helpdesk & Customer Support Ticket System 1.4.5, at app/Hooks/Handlers/ActivityLogger.php

141 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Hooks\Handlers;
4
5 use FluentSupport\App\Models\Activity;
6
7 class ActivityLogger
8 {
9 public function init()
10 {
11 // Ticket Related activities
12 add_action('fluent_support/ticket_created', function ($ticket, $customer) {
13
14 $customer->last_response_at = current_time('mysql');
15 $customer->save();
16
17 $description = sprintf('%1$s created a %2$s via %3$s', $this->getPersonMarkup($customer), $this->getTicketMarkup($ticket), $ticket->source);
18
19 $log = [
20 'event_type' => 'fluent_support/ticket_created',
21 'person_id' => $customer->id,
22 'person_type' => $customer->person_type,
23 'object_id' => $ticket->id,
24 'object_type' => 'ticket',
25 'description' => $description
26 ];
27
28 Activity::create($log);
29 }, 20, 2);
30
31 add_action('fluent_support/response_added_by_customer', function ($response, $ticket, $person) {
32
33 $person->last_response_at = current_time('mysql');
34 $person->save();
35
36 $description = sprintf('Customer %1$s added a response on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source);
37
38 $log = [
39 'event_type' => 'fluent_support/response_added_by_customer',
40 'person_id' => $person->id,
41 'person_type' => $person->person_type,
42 'object_id' => $ticket->id,
43 'object_type' => 'ticket',
44 'description' => $description
45 ];
46
47 Activity::create($log);
48 }, 20, 3);
49
50 add_action('fluent_support/response_added_by_agent', function ($response, $ticket, $person) {
51 $description = sprintf('%1$s added a response on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source);
52
53 $log = [
54 'event_type' => 'fluent_support/response_added_by_agent',
55 'person_id' => $person->id,
56 'person_type' => $person->person_type,
57 'object_id' => $ticket->id,
58 'object_type' => 'ticket',
59 'description' => $description
60 ];
61
62 Activity::create($log);
63 }, 20, 3);
64
65 add_action('fluent_support/note_added_by_agent', function ($response, $ticket, $person) {
66 $description = sprintf('%1$s added a note on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source);
67
68 $log = [
69 'event_type' => 'fluent_support/note_added_by_agent',
70 'person_id' => $person->id,
71 'person_type' => $person->person_type,
72 'object_id' => $ticket->id,
73 'object_type' => 'ticket',
74 'description' => $description
75 ];
76
77 Activity::create($log);
78 }, 20, 3);
79
80 add_action('fluent_support/ticket_closed', function ($ticket, $person) {
81
82 if ($person->person_type == 'customer') {
83 $person->last_response_at = current_time('mysql');
84 $person->save();
85 }
86
87 $description = sprintf('%1$s closed %2$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket));
88
89 $log = [
90 'event_type' => 'fluent_support/ticket_closed',
91 'person_id' => $person->id,
92 'person_type' => $person->person_type,
93 'object_id' => $ticket->id,
94 'object_type' => 'ticket',
95 'description' => $description
96 ];
97
98 Activity::create($log);
99 }, 20, 2);
100
101 add_action('fluent_support/ticket_reopen', function ($ticket, $person) {
102
103 if ($person->person_type == 'customer') {
104 $person->last_response_at = current_time('mysql');
105 $person->save();
106 }
107
108 $description = sprintf('%1$s reopened on %2$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket));
109
110 $log = [
111 'event_type' => 'fluent_support/ticket_reopen',
112 'person_id' => $person->id,
113 'person_type' => $person->person_type,
114 'object_id' => $ticket->id,
115 'object_type' => 'ticket',
116 'description' => $description
117 ];
118
119 Activity::create($log);
120 }, 20, 2);
121 }
122
123 public function getTicketMarkup($ticket, $ticketText = false)
124 {
125 if (!$ticketText) {
126 $ticketText = sprintf(__('Ticket: %s', 'fluent-support'), $ticket->title);
127 }
128
129 return '<a class="fs_link_trans fs_tk" href="#view_ticket">' . $ticketText . '</a>';
130 }
131
132 public function getPersonMarkup($person)
133 {
134 $route = 'view_agent';
135 if ($person->person_type == 'customer') {
136 $route = 'view_customer';
137 }
138 return '<a class="fs_link_trans fs_pr" href="#' . $route . '">' . $person->full_name . '</a>';
139 }
140 }
141