| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace FluentBooking\App\Services; |
| 4 | 4 | |
| 5 | -use FluentBooking\Framework\Support\Arr; | |
| 5 | +use FluentBooking\App\Services\PermissionManager; | |
| 6 | 6 | |
| 7 | 7 | class ImportService |
| 8 | 8 | { |
| 9 | 9 | /* |
| @@ -13,8 +13,16 @@ | ||
| 13 | 13 | * @return \FluentBooking\App\Models\Calendar|\WP_Error |
| 14 | 14 | */ |
| 15 | 15 | public function importHostJson($data, $useCurrentUser = true) |
| 16 | 16 | { |
| 17 | + if (!PermissionManager::userCan(['manage_all_data', 'manage_other_calendars'])) { | |
| 18 | + return new \WP_Error('invalid_data', __('You are not authorized to import calendar', 'fluent-booking')); | |
| 19 | + } | |
| 20 | + | |
| 21 | + if (!$useCurrentUser && !PermissionManager::userCan('manage_all_data')) { | |
| 22 | + $useCurrentUser = true; | |
| 23 | + } | |
| 24 | + | |
| 17 | 25 | if (is_string($data)) { |
| 18 | 26 | $data = json_decode($data, true); |
| 19 | 27 | } |
| 20 | 28 | |