PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.8
Booking for Appointments and Events Calendar – Amelia v2.4.8
2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / config / Roles.php
ameliabooking / src / Infrastructure / WP / config Last commit date
Menu.php 7 months ago Roles.php 4 days ago
Roles.php
255 lines
1 <?php
2
3 /**
4 * @author Alexander Gilmanov
5 * Defining the user roles and capabilities
6 */
7
8 namespace AmeliaBooking\Infrastructure\WP\config;
9
10 use AmeliaBooking\Domain\Services\Settings\SettingsService;
11 use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
12 use AmeliaBooking\Infrastructure\WP\UserRoles\SuperAdminRoleService;
13
14 /**
15 * Class Roles
16 *
17 * @package AmeliaBooking\Infrastructure\WP\config
18 */
19 class Roles
20 {
21 /**
22 * Array of all Amelia roles capabilities
23 */
24 public static array $rolesList = [
25 'amelia_read_menu',
26 'amelia_read_dashboard',
27 'amelia_read_whats_new',
28 'amelia_read_lite_vs_premium',
29 'amelia_read_calendar',
30 'amelia_read_appointments',
31 'amelia_read_events',
32 'amelia_read_employees',
33 'amelia_read_services',
34 'amelia_read_packages',
35 'amelia_read_resources',
36 'amelia_read_locations',
37 'amelia_read_taxes',
38 'amelia_read_coupons',
39 'amelia_read_customers',
40 'amelia_read_finance',
41 'amelia_read_notifications',
42 'amelia_read_customize',
43 'amelia_read_custom_fields',
44 'amelia_read_settings',
45 'amelia_super_admin',
46
47 'amelia_read_others_settings',
48 'amelia_read_others_dashboard',
49 'amelia_read_others_calendar',
50 'amelia_read_others_appointments',
51 'amelia_read_others_services',
52 'amelia_read_others_employees',
53 'amelia_read_others_customers',
54
55 'amelia_write_dashboard',
56 'amelia_write_calendar',
57 'amelia_write_appointments',
58 'amelia_write_events',
59 'amelia_write_employees',
60 'amelia_write_services',
61 'amelia_write_packages',
62 'amelia_write_resources',
63 'amelia_write_locations',
64 'amelia_write_taxes',
65 'amelia_write_coupons',
66 'amelia_write_customers',
67 'amelia_write_finance',
68 'amelia_write_notifications',
69 'amelia_write_customize',
70 'amelia_write_custom_fields',
71 'amelia_write_settings',
72 'amelia_write_status',
73
74 'amelia_write_others_settings',
75 'amelia_write_others_calendar',
76 'amelia_write_others_appointments',
77 'amelia_write_others_services',
78 'amelia_write_others_employees',
79 'amelia_write_others_events',
80 'amelia_write_others_finance',
81 'amelia_write_others_dashboard',
82
83 'amelia_delete_dashboard',
84 'amelia_delete_calendar',
85 'amelia_delete_appointments',
86 'amelia_delete_events',
87 'amelia_delete_employees',
88 'amelia_delete_services',
89 'amelia_delete_packages',
90 'amelia_delete_resources',
91 'amelia_delete_locations',
92 'amelia_delete_taxes',
93 'amelia_delete_coupons',
94 'amelia_delete_customers',
95 'amelia_delete_finance',
96 'amelia_delete_notifications',
97 'amelia_delete_customize',
98 'amelia_delete_custom_fields',
99 'amelia_delete_settings',
100
101 'amelia_write_status_appointments',
102 'amelia_write_status_events',
103 'amelia_write_time_appointments',
104 ];
105
106 /**
107 * Array of all amelia roles with capabilities
108 *
109 * @return array
110 */
111 public function __invoke()
112 {
113 $pluginName = $this->getPluginName();
114
115 $roles = [
116 // Customer
117 [
118 'name' => 'wpamelia-customer',
119 'label' => sprintf(\__('%s Customer', 'amelia'), $pluginName),
120 'capabilities' => [
121 'read' => true,
122 'amelia_read_menu' => true,
123 'amelia_read_calendar' => true,
124 'amelia_read_appointments' => true,
125 'amelia_read_events' => true,
126 'amelia_write_time_appointments' => true,
127 ]
128 ],
129
130 // Provider
131 [
132 'name' => 'wpamelia-provider',
133 'label' => sprintf(\__('%s Employee', 'amelia'), $pluginName),
134 'capabilities' => [
135 'read' => true,
136 'amelia_delete_events' => true,
137 'amelia_read_menu' => true,
138 'amelia_read_calendar' => true,
139 'amelia_read_appointments' => true,
140 'amelia_read_events' => true,
141 'amelia_read_employees' => true,
142 'amelia_read_others_customers' => true,
143 'amelia_read_others_services' => false,
144 'amelia_write_employees' => true,
145 'amelia_write_status_appointments' => true,
146 'amelia_write_status_events' => true,
147 'amelia_write_time_appointments' => true,
148 'amelia_write_others_appointments' => false,
149 'amelia_write_others_services' => false,
150 'amelia_write_appointments' => true,
151 'amelia_write_events' => true,
152 'amelia_write_others_events' => false,
153 ]
154 ],
155
156 // Manager
157 [
158 'name' => 'wpamelia-manager',
159 'label' => sprintf(\__('%s Manager', 'amelia'), $pluginName),
160 'capabilities' => [
161 'read' => true,
162
163 'amelia_delete_events' => true,
164 'amelia_read_menu' => true,
165 'amelia_read_dashboard' => true,
166 'amelia_read_whats_new' => true,
167 'amelia_read_lite_vs_premium' => true,
168 'amelia_read_calendar' => true,
169 'amelia_read_appointments' => true,
170 'amelia_read_events' => true,
171 'amelia_read_employees' => true,
172 'amelia_read_services' => true,
173 'amelia_read_resources' => true,
174 'amelia_read_packages' => true,
175 'amelia_read_locations' => true,
176 'amelia_read_taxes' => true,
177 'amelia_read_coupons' => true,
178 'amelia_read_customers' => true,
179 'amelia_read_finance' => true,
180 'amelia_read_notifications' => true,
181 'amelia_read_others_dashboard' => true,
182 'amelia_read_others_calendar' => true,
183 'amelia_read_others_appointments' => true,
184 'amelia_read_others_services' => true,
185 'amelia_read_others_employees' => true,
186 'amelia_read_others_customers' => true,
187 'amelia_write_dashboard' => true,
188 'amelia_write_calendar' => true,
189 'amelia_write_appointments' => true,
190 'amelia_write_events' => true,
191 'amelia_write_employees' => true,
192 'amelia_write_services' => true,
193 'amelia_write_resources' => true,
194 'amelia_write_packages' => true,
195 'amelia_write_locations' => true,
196 'amelia_write_taxes' => true,
197 'amelia_write_coupons' => true,
198 'amelia_write_customers' => true,
199 'amelia_write_finance' => true,
200 'amelia_write_notifications' => true,
201 'amelia_write_others_calendar' => true,
202 'amelia_write_others_appointments' => true,
203 'amelia_write_others_services' => true,
204 'amelia_write_others_employees' => true,
205 'amelia_write_others_events' => true,
206 'amelia_write_others_finance' => true,
207 'amelia_write_others_dashboard' => true,
208 'amelia_write_status_appointments' => true,
209 'amelia_write_status_events' => true,
210 'amelia_write_time_appointments' => true,
211 'upload_files' => true,
212 ]
213 ],
214 ];
215
216 // SuperAdmin is Elite-only (protects White Label / Activation).
217 if (SuperAdminRoleService::isAvailable()) {
218 $roles[] = [
219 'name' => SuperAdminRoleService::ROLE,
220 'label' => sprintf(\__('%s Superadmin', 'amelia'), $pluginName),
221 'capabilities' => [
222 'read' => true,
223 'amelia_read_menu' => true,
224 'amelia_read_settings' => true,
225 'amelia_write_settings' => true,
226 SuperAdminRoleService::CAPABILITY => true,
227 ]
228 ];
229 }
230
231 return $roles;
232 }
233
234 /**
235 * @return string
236 */
237 private function getPluginName()
238 {
239 try {
240 $settingsService = new SettingsService(new SettingsStorage());
241
242 if (!$settingsService->isFeatureEnabled('whiteLabel')) {
243 return 'Amelia';
244 }
245
246 $whiteLabel = $settingsService->getCategorySettings('whiteLabel');
247 $pluginName = !empty($whiteLabel['pluginName']) ? trim($whiteLabel['pluginName']) : '';
248
249 return $pluginName !== '' ? \wp_strip_all_tags($pluginName) : 'Amelia';
250 } catch (\Throwable $e) {
251 return 'Amelia';
252 }
253 }
254 }
255