PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.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 All 69 releases
← All changes | app/Hooks/Handlers/ActivityLogger.php +13 -22 2.2.1 → 2.4.5 View file →
@@ -5,29 +5,20 @@
5 5 use FluentSupport\App\Models\Activity;
6 6 use FluentSupport\App\Services\Helper;
7 7
8 8 /**
9 - * ActivityLogger class for Hooks
10 - *
11 - * @package FluentSupport\App\Hooks\Handlers
12 - *
13 - * @version 1.0.0
9 + * Writes ticket lifecycle events to the activity log.
14 10 */
15 11
16 12 class ActivityLogger
17 13 {
18 14
19 - /**
20 - * init method will register all action hooks related to ticket creation, ticket response, response by agent, note by agent, ticket closed or reopen
21 - */
22 15 public function init()
23 16 {
24 - // Check if activity logs are disabled - if so, don't register any hooks
25 17 if (Helper::areLogsDisabled('_activity_settings')) {
26 18 return;
27 19 }
28 20
29 - // Ticket Related activities
30 21 add_action('fluent_support/ticket_created', function ($ticket, $customer) {
31 22
32 23 $customer->last_response_at = current_time('mysql');
33 24 $customer->save();
@@ -60,9 +51,8 @@
60 51
61 52 Activity::create($log);
62 53 }, 20, 2);
63 54
64 - //Response added by customer in a ticket
65 55 add_action('fluent_support/response_added_by_customer', function ($response, $ticket, $person) {
66 56
67 57 $person->last_response_at = current_time('mysql');
68 58 $person->save();
@@ -80,9 +70,8 @@
80 70
81 71 Activity::create($log);
82 72 }, 20, 3);
83 73
84 - //Response added by agent in a ticket
85 74 add_action('fluent_support/response_added_by_agent', function ($response, $ticket, $person) {
86 75 $description = sprintf('%1$s added a response on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source);
87 76
88 77 $log = [
@@ -96,9 +85,8 @@
96 85
97 86 Activity::create($log);
98 87 }, 20, 3);
99 88
100 - //Note added by agent to a ticket
101 89 add_action('fluent_support/note_added_by_agent', function ($response, $ticket, $person) {
102 90 $description = sprintf('%1$s added a note on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source);
103 91
104 92 $log = [
@@ -112,9 +100,8 @@
112 100
113 101 Activity::create($log);
114 102 }, 20, 3);
115 103
116 - //Ticket closed by customer or agent
117 104 add_action('fluent_support/ticket_closed', function ($ticket, $person) {
118 105
119 106 if ($person->person_type == 'customer') {
120 107 $person->last_response_at = current_time('mysql');
@@ -134,9 +121,8 @@
134 121
135 122 Activity::create($log);
136 123 }, 20, 2);
137 124
138 - //Ticket reopen by customer or agent.
139 125 add_action('fluent_support/ticket_reopen', function ($ticket, $person) {
140 126
141 127 if ($person->person_type == 'customer') {
142 128 $person->last_response_at = current_time('mysql');
@@ -156,9 +142,8 @@
156 142
157 143 Activity::create($log);
158 144 }, 20, 2);
159 145
160 - // Ticket Assigned by agent
161 146 add_action('fluent_support/agent_assigned_to_ticket', function ($assignedAgent, $ticket, $assigner) {
162 147
163 148 $description = sprintf('Assign %1$s ticket to %2$s by %3$s', $this->getTicketMarkup($ticket), $this->getPersonMarkup($assignedAgent), $this->getPersonMarkup($assigner));
164 149
@@ -175,9 +160,13 @@
175 160 }
176 161 }, 20, 3);
177 162
178 163 add_action('fluent_support/ticket_deleted', function($agent, $ticketData) {
179 - $description = sprintf('%s deleted %s(#%d) at %s', $this->getPersonMarkup($agent), $ticketData['title'], $ticketData['id'], current_time('mysql'));
164 + if (!$agent || !$agent->id) {
165 + return;
166 + }
167 +
168 + $description = sprintf('%s deleted %s(#%d) at %s', $this->getPersonMarkup($agent), esc_html($ticketData['title']), $ticketData['id'], current_time('mysql'));
180 169 $log = [
181 170 'event_type' => 'fluent_support/ticket_deleted',
182 171 'person_id' => $agent->id,
183 172 'person_type' => 'agent',
@@ -189,11 +178,10 @@
189 178 }, 20, 2);
190 179 }
191 180
192 181 /**
193 - * getTicketMarkup method will generate hyperlink to view the ticket details
194 182 * @param $ticket
195 - * @param false $ticketText
183 + * @param string|false $ticketText
196 184 * @return string
197 185 */
198 186 public function getTicketMarkup($ticket, $ticketText = false)
199 187 {
@@ -198,9 +186,9 @@
198 186 public function getTicketMarkup($ticket, $ticketText = false)
199 187 {
200 188 if (!$ticketText) {
201 189 // translators: %s is the ticket title
202 - $ticketText = sprintf(__('Ticket: %s', 'fluent-support'), $ticket->title);
190 + $ticketText = sprintf(__('Ticket: %s', 'fluent-support'), esc_html($ticket->title));
203 191 }
204 192
205 193 return '<a class="fs_link_trans fs_tk" href="#view_ticket">' . $ticketText . '</a>';
206 194 }
@@ -205,17 +193,20 @@
205 193 return '<a class="fs_link_trans fs_tk" href="#view_ticket">' . $ticketText . '</a>';
206 194 }
207 195
208 196 /**
209 - * getPersonMarkup method will generate hyperlink to view a customer or agent
210 197 * @param $person
211 198 * @return string
212 199 */
213 200 public function getPersonMarkup($person)
214 201 {
202 + if (!$person) {
203 + return '';
204 + }
205 +
215 206 $route = 'view_agent';
216 207 if (isset($person->person_type) && $person->person_type == 'customer') {
217 208 $route = 'view_customer';
218 209 }
219 - return '<a class="fs_link_trans fs_pr" href="#' . $route . '">' . $person->full_name . '</a>';
210 + return '<a class="fs_link_trans fs_pr" href="#' . $route . '">' . esc_html($person->full_name) . '</a>';
220 211 }
221 212 }