PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.10.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.10.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
fluent-booking / app / Hooks / Handlers / DataImporter.php

DataImporter.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.10.0, at app/Hooks/Handlers/DataImporter.php

61 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\App\Hooks\Handlers;
4
5 use FluentBooking\App\App;
6 use FluentBooking\App\Services\CalendarService;
7 use FluentBooking\App\Services\PermissionManager;
8
9 class DataImporter
10 {
11 public function importCalendar()
12 {
13 if (!PermissionManager::userCan(['invite_team_members', 'manage_other_calendars'])) {
14 wp_send_json_error([
15 'message' => __('You are not authorized to import calendar', 'fluent-booking'),
16 ]);
17 }
18
19 $app = App::getInstance();
20
21 $data = $app->request->all();
22
23 if (empty($data['type'] || empty($data['user_id'] || empty($data['author_timezone'])))) {
24 wp_send_json_error([
25 'message' => __('Please provide all required data', 'fluent-booking'),
26 ]);
27 }
28
29 $file = $app->request->file('file');
30
31 if (empty($file) || $file->getClientOriginalExtension() != 'json') {
32 wp_send_json_error([
33 'message' => __('Invalid file. Please provide a valid JSON file', 'fluent-booking'),
34 ]);
35 }
36
37 $fileContent = $file->getContents();
38
39 $calendarData = wp_parse_args($data, json_decode($fileContent, true));
40
41 if (empty($calendarData)) {
42 wp_send_json_error([
43 'message' => __('Invalid file. Please provide a valid JSON file', 'fluent-booking'),
44 ]);
45 }
46
47 $calendar = CalendarService::createCalendar($calendarData, false, true);
48
49 if (is_wp_error($calendar)) {
50 wp_send_json_error([
51 'message' => $calendar->get_error_message(),
52 ]);
53 }
54
55 wp_send_json([
56 'success' => true,
57 'message' => __('Calendar imported successfully', 'fluent-booking'),
58 ]);
59 }
60 }
61