PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.2.0
Fluent Support – Helpdesk & Customer Support Ticket System v2.2.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 1.5.6 All 67 releases
fluent-support / app / Http / Controllers / WidgetsController.php

WidgetsController.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.2.0, at app/Http/Controllers/WidgetsController.php

59 lines 1.7 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\Http\Controllers;
4
5 use FluentSupport\App\Models\Ticket;
6 use FluentSupport\Framework\Http\Request\Request;
7
8 class WidgetsController extends Controller
9 {
10 public function __invoke(Request $request)
11 {
12 $filter = $request->get('filter', '');
13 $filter = sanitize_text_field($filter);
14 $filter = str_replace('fluent_support_', '', $filter);
15
16 // Only allow alphanumeric, underscores, and hyphens in filter names
17 if (!$filter || !preg_match('/^[a-zA-Z0-9_\-]+$/', $filter)) {
18 return $this->sendError([
19 'message' => __('Invalid filter name', 'fluent-support')
20 ]);
21 }
22
23 $data = $request->get('data', []);
24
25 if (!is_array($data)) {
26 $data = [];
27 }
28
29 // Sanitize all scalar values in data
30 $data = array_map(function ($value) {
31 return is_scalar($value) ? sanitize_text_field($value) : $value;
32 }, $data);
33
34 if ($filter === 'ticket_sidebar') {
35 $ticketId = intval($data['ticket_id'] ?? 0);
36 if (!$ticketId) {
37 return $this->sendError([
38 'message' => __('Invalid ticket ID', 'fluent-support')
39 ]);
40 }
41
42 $ticket = Ticket::with('customer')->find($ticketId);
43 if (!$ticket) {
44 return $this->sendError([
45 'message' => __('Ticket not found', 'fluent-support')
46 ]);
47 }
48
49 $this->ensureCanAccessTicket($ticket);
50
51 $data['ticket'] = $ticket;
52 }
53
54 return $this->sendSuccess([
55 'widgets' => apply_filters('fluent_support/widgets/' . $filter, [], $data)
56 ]);
57 }
58 }
59