| @@ -225,5 +225,44 @@ | ||
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | return $locationOptions; |
| 228 | 228 | } |
| 229 | + | |
| 230 | + public static function sanitizePublicLocationSettings($locationSettings) | |
| 231 | + { | |
| 232 | + if (!is_array($locationSettings)) { | |
| 233 | + return []; | |
| 234 | + } | |
| 235 | + | |
| 236 | + $safe = []; | |
| 237 | + foreach ($locationSettings as $location) { | |
| 238 | + if (!is_array($location)) { | |
| 239 | + continue; | |
| 240 | + } | |
| 241 | + | |
| 242 | + $type = Arr::get($location, 'type'); | |
| 243 | + $displayOnBooking = Arr::get($location, 'display_on_booking') === 'yes'; | |
| 244 | + | |
| 245 | + $sanitized = [ | |
| 246 | + 'type' => $type, | |
| 247 | + 'title' => Arr::get($location, 'title'), | |
| 248 | + 'display_on_booking' => Arr::get($location, 'display_on_booking', 'no'), | |
| 249 | + ]; | |
| 250 | + | |
| 251 | + // Only expose host-private fields when the host explicitly opted | |
| 252 | + // in to display them before booking. | |
| 253 | + if ($displayOnBooking) { | |
| 254 | + if ($type === 'online_meeting') { | |
| 255 | + $sanitized['meeting_link'] = Arr::get($location, 'meeting_link'); | |
| 256 | + } elseif ($type === 'phone_organizer') { | |
| 257 | + $sanitized['host_phone_number'] = Arr::get($location, 'host_phone_number'); | |
| 258 | + } elseif (in_array($type, ['in_person_organizer', 'custom'], true)) { | |
| 259 | + $sanitized['description'] = Arr::get($location, 'description'); | |
| 260 | + } | |
| 261 | + } | |
| 262 | + | |
| 263 | + $safe[] = $sanitized; | |
| 264 | + } | |
| 265 | + | |
| 266 | + return $safe; | |
| 267 | + } | |
| 229 | 268 | } |