PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/PermissionManager.php +41 -10 1.7.0 → 2.5.0 View file →
@@ -17,20 +17,21 @@
17 17 'manage_all_bookings' => __('Read & Write Access to All Bookings', 'fluent-booking'),
18 18 'read_other_calendars' => __('Read Access of Other Users Calendars', 'fluent-booking'),
19 19 'manage_other_calendars' => __('Manage Other Users Calendars', 'fluent-booking'),
20 20 'read_and_use_other_availabilities' => __('Read & Use Access of All Availabilities', 'fluent-booking'),
21 - 'manage_other_availabilities' => __('Manage All Availabilities', 'fluent-booking')
21 + 'manage_other_availabilities' => __('Manage All Availabilities', 'fluent-booking'),
22 + 'manage_all_data' => __('Manage All Data and Settings', 'fluent-booking')
22 23 ];
23 24 }
24 25
25 26 public static function hasAllCalendarAccess($readAccess = false)
26 27 {
27 - $hasCalendarAccess = self::userCan('manage_other_calendars');
28 + $hasCalendarAccess = self::userCan(['manage_all_data', 'manage_other_calendars']);
28 29
29 30 if ($readAccess) {
30 31 $hasCalendarAccess = $hasCalendarAccess || self::userCan('read_other_calendars');
31 32 }
32 -
33 +
33 34 return apply_filters('fluent_booking/has_all_calendar_access', current_user_can('manage_options')) || $hasCalendarAccess;
34 35 }
35 36
36 37 public static function canReadCalendar($calendarId)
@@ -52,9 +53,9 @@
52 53 if (CalendarService::isSharedCalendar($calendar)) {
53 54 return true;
54 55 }
55 56
56 - return self::userCan(['read_other_calendars', 'manage_other_calendars']);
57 + return self::userCan(['manage_all_data', 'read_other_calendars', 'manage_other_calendars']);
57 58 }
58 59
59 60 public static function canUpdateCalendarEvent($slotId)
60 61 {
@@ -71,9 +72,9 @@
71 72 if ($calendarSlot->user_id == $userId || in_array($userId, $teamMembers)) {
72 73 return true;
73 74 }
74 75
75 - return current_user_can('manage_options') || self::userCan(['manage_other_calendars']);
76 + return self::userCan(['manage_all_data', 'manage_other_calendars']);
76 77 }
77 78
78 79 public static function canWriteCalendar($calendarId)
79 80 {
@@ -90,19 +91,40 @@
90 91 if ($calendar->user_id == get_current_user_id()) {
91 92 return true;
92 93 }
93 94
94 - return self::userCan('manage_other_calendars');
95 + return self::userCan(['manage_all_data', 'manage_other_calendars']);
95 96 }
96 97
98 + /**
99 + * Whether the current user may make $memberIds hosts. Anyone outside $allowedIds
100 + * is someone new being assigned, which is the same act as creating a calendar
101 + * for another user.
102 + *
103 + * @param int[] $memberIds
104 + * @param int[] $allowedIds
105 + * @return bool
106 + */
107 + public static function canAssignHosts($memberIds, $allowedIds)
108 + {
109 + $memberIds = array_map('intval', (array) $memberIds);
110 + $allowedIds = array_map('intval', (array) $allowedIds);
111 +
112 + if (!array_diff($memberIds, $allowedIds)) {
113 + return true;
114 + }
115 +
116 + return self::canManageOtherHosts();
117 + }
118 +
97 119 public static function hasCalendarAccess($calendar)
98 120 {
99 - $hasAccess = current_user_can('manage_options') || $calendar->user_id == get_current_user_id();
121 + $hasAccess = self::userCan('manage_all_data') || $calendar->user_id == get_current_user_id();
100 122
101 123 return apply_filters('fluent_booking/has_calendar_access', $hasAccess, $calendar);
102 124 }
103 125
104 - public static function currentUserHasAnyPemrmission()
126 + public static function currentUserHasAnyPermission()
105 127 {
106 128 if (current_user_can('manage_options')) {
107 129 return true;
108 130 }
@@ -136,8 +158,18 @@
136 158
137 159 return false;
138 160 }
139 161
162 + /**
163 + * Whether the current user may act for, assign or see the details of other hosts.
164 + *
165 + * @return bool
166 + */
167 + public static function canManageOtherHosts()
168 + {
169 + return self::userCan(['manage_all_data', 'invite_team_members']);
170 + }
171 +
140 172 public static function getUserPermissions($user = null, $formatted = false)
141 173 {
142 174 if ($user === null) {
143 175 $user = wp_get_current_user();
@@ -201,9 +233,8 @@
201 233 }
202 234
203 235 public static function getMetaPermissions($userId = null)
204 236 {
205 -
206 237 if ($userId === null) {
207 238 $userId = get_current_user_id();
208 239 }
209 240
@@ -254,7 +285,7 @@
254 285 }
255 286
256 287 public static function userCanSeeAllBookings()
257 288 {
258 - return self::userCan(['read_all_bookings', 'manage_all_bookings']);
289 + return self::userCan(['manage_all_data', 'read_all_bookings', 'manage_all_bookings']);
259 290 }
260 291 }