PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / trunk
Fluent Support – Helpdesk & Customer Support Ticket System vtrunk
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 / Modules / MCP / Resources / ResourceProvider.php

ResourceProvider.php in Fluent Support – Helpdesk & Customer Support Ticket System trunk, at app/Modules/MCP/Resources/ResourceProvider.php

105 lines 4.1 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\Modules\MCP\Resources;
4
5 use FluentSupport\App\Models\Agent;
6 use FluentSupport\App\Models\MailBox;
7 use FluentSupport\App\Models\Product;
8 use FluentSupport\App\Models\TicketTag;
9 use FluentSupport\App\Modules\PermissionManager;
10 use FluentSupport\App\Services\Helper;
11 use FluentSupport\App\Services\TicketHelper;
12
13 /** @internal Dead class — not wired up. Keep for future WP Resources API integration or remove. */
14 class ResourceProvider
15 {
16 public static function getResourceDefinitions()
17 {
18 return [
19 'fluentsupport://agents' => [
20 'name' => 'Support Agents',
21 'description' => 'List of all support agents with ID, name, and email',
22 'mimeType' => 'application/json',
23 ],
24 'fluentsupport://products' => [
25 'name' => 'Products',
26 'description' => 'List of all products/categories for ticket classification',
27 'mimeType' => 'application/json',
28 ],
29 'fluentsupport://mailboxes' => [
30 'name' => 'Mailboxes',
31 'description' => 'List of all mailboxes with ID, name, and email',
32 'mimeType' => 'application/json',
33 ],
34 'fluentsupport://tags' => [
35 'name' => 'Ticket Tags',
36 'description' => 'List of all ticket tags with ID and title',
37 'mimeType' => 'application/json',
38 ],
39 'fluentsupport://priorities' => [
40 'name' => 'Priorities',
41 'description' => 'Available ticket priority values',
42 'mimeType' => 'application/json',
43 ],
44 'fluentsupport://statuses' => [
45 'name' => 'Statuses',
46 'description' => 'Available ticket status values and groups',
47 'mimeType' => 'application/json',
48 ],
49 'fluentsupport://stats/overview' => [
50 'name' => 'Dashboard Stats',
51 'description' => 'Overview of ticket counts by status',
52 'mimeType' => 'application/json',
53 ],
54 ];
55 }
56
57 public static function readResource($uri)
58 {
59 if (!is_user_logged_in() || !PermissionManager::currentUserCan('fst_view_tickets')) {
60 return new \WP_Error('forbidden', 'You do not have Fluent Support access');
61 }
62
63 switch ($uri) {
64 case 'fluentsupport://agents':
65 return Agent::select(['id', 'first_name', 'last_name', 'email'])
66 ->where('person_type', 'agent')
67 ->get()
68 ->toArray();
69
70 case 'fluentsupport://products':
71 return Product::select(['id', 'title'])->get()->toArray();
72
73 case 'fluentsupport://mailboxes':
74 return MailBox::getAccessibleBoxes(PermissionManager::userCan('fst_sensitive_data'))->toArray();
75
76 case 'fluentsupport://tags':
77 return TicketTag::select(['id', 'title'])->get()->toArray();
78
79 case 'fluentsupport://priorities':
80 return [
81 'admin_priorities' => Helper::adminTicketPriorities(),
82 'client_priorities' => Helper::customerTicketPriorities(),
83 ];
84
85 case 'fluentsupport://statuses':
86 return [
87 'statuses' => Helper::ticketStatuses(),
88 'status_groups' => Helper::ticketStatusGroups(),
89 ];
90
91 case 'fluentsupport://stats/overview':
92 return [
93 'total' => TicketHelper::countAllTickets(),
94 'new' => TicketHelper::countNewTickets(),
95 'active' => TicketHelper::countActiveTickets(),
96 'closed' => TicketHelper::countClosedTickets(),
97 'unassigned' => TicketHelper::countUnassignedTickets(),
98 ];
99
100 default:
101 return new \WP_Error('not_found', 'Resource not found', ['uri' => sanitize_text_field($uri)]);
102 }
103 }
104 }
105