last_response_at = current_time('mysql'); $customer->save(); $description = sprintf('%1$s created a %2$s via %3$s', $this->getPersonMarkup($customer), $this->getTicketMarkup($ticket), $ticket->source); $log = [ 'event_type' => 'fluent_support/ticket_created', 'person_id' => $customer->id, 'person_type' => $customer->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 2); add_action('fluent_support/response_added_by_customer', function ($response, $ticket, $person) { $person->last_response_at = current_time('mysql'); $person->save(); $description = sprintf('Customer %1$s added a response on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source); $log = [ 'event_type' => 'fluent_support/response_added_by_customer', 'person_id' => $person->id, 'person_type' => $person->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 3); add_action('fluent_support/response_added_by_agent', function ($response, $ticket, $person) { $description = sprintf('%1$s added a response on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source); $log = [ 'event_type' => 'fluent_support/response_added_by_agent', 'person_id' => $person->id, 'person_type' => $person->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 3); add_action('fluent_support/note_added_by_agent', function ($response, $ticket, $person) { $description = sprintf('%1$s added a note on %2$s via %3$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket), $response->source); $log = [ 'event_type' => 'fluent_support/note_added_by_agent', 'person_id' => $person->id, 'person_type' => $person->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 3); add_action('fluent_support/ticket_closed', function ($ticket, $person) { if ($person->person_type == 'customer') { $person->last_response_at = current_time('mysql'); $person->save(); } $description = sprintf('%1$s closed %2$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket)); $log = [ 'event_type' => 'fluent_support/ticket_closed', 'person_id' => $person->id, 'person_type' => $person->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 2); add_action('fluent_support/ticket_reopen', function ($ticket, $person) { if ($person->person_type == 'customer') { $person->last_response_at = current_time('mysql'); $person->save(); } $description = sprintf('%1$s reopened on %2$s', $this->getPersonMarkup($person), $this->getTicketMarkup($ticket)); $log = [ 'event_type' => 'fluent_support/ticket_reopen', 'person_id' => $person->id, 'person_type' => $person->person_type, 'object_id' => $ticket->id, 'object_type' => 'ticket', 'description' => $description ]; Activity::create($log); }, 20, 2); } public function getTicketMarkup($ticket, $ticketText = false) { if (!$ticketText) { $ticketText = sprintf(__('Ticket: %s', 'fluent-support'), $ticket->title); } return '' . $ticketText . ''; } public function getPersonMarkup($person) { $route = 'view_agent'; if ($person->person_type == 'customer') { $route = 'view_customer'; } return '' . $person->full_name . ''; } }