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
fluent-support / app / Http / Policies / CustomerPolicy.php

CustomerPolicy.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.4.5, at app/Http/Policies/CustomerPolicy.php

61 lines 1.9 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\Policies;
4
5 use FluentSupport\App\Modules\PermissionManager;
6 use FluentSupport\Framework\Http\Request\Request;
7 use FluentSupport\Framework\Foundation\Policy;
8
9 /**
10 * Policy for /customers: reads keep the module boundary, deletes are gated below.
11 */
12 class CustomerPolicy extends Policy
13 {
14 /**
15 * @param \FluentSupport\Framework\Http\Request\Request $request
16 * @return Boolean
17 */
18 public function verifyRequest(Request $request)
19 {
20 return PermissionManager::currentUserCan('fst_sensitive_data');
21 }
22
23 public function delete(Request $request)
24 {
25 return $this->guardCustomerDeletion($request);
26 }
27
28 public function bulkDelete(Request $request)
29 {
30 return $this->guardCustomerDeletion($request);
31 }
32
33 /**
34 * Deletion cascades into tickets, conversations and attachments.
35 */
36 protected function guardCustomerDeletion(Request $request)
37 {
38 // The router runs either the per-route method or verifyRequest(), not both,
39 // so re-apply the module boundary. The exception code becomes the HTTP status.
40 if (!$this->verifyRequest($request)) {
41 throw new \Exception(
42 esc_html__('You do not have permission to manage customers.', 'fluent-support'),
43 is_user_logged_in() ? 403 : 401
44 );
45 }
46
47 // manage_options can't be granted by the plugin's own permissions.
48 // Sites can drop this requirement. The boundary above still applies.
49 $requiresAdmin = apply_filters('fluent_support/customer_delete_requires_admin', true);
50
51 if ($requiresAdmin && !current_user_can('manage_options')) {
52 throw new \Exception(
53 esc_html__('Only administrators can delete customers.', 'fluent-support'),
54 403
55 );
56 }
57
58 return true;
59 }
60 }
61