PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Controllers/Form/ExportFormController.php +22 -3 1.1 → 1.5 View file →
@@ -6,9 +6,11 @@
6 6 use IvyForms\Common\Exceptions\InvalidArgumentException;
7 7 use IvyForms\Common\Sanitizer\Sanitizer;
8 8 use IvyForms\Controllers\Controller;
9 9 use IvyForms\Services\Form\FormImportExportService;
10 +use IvyForms\Services\Permissions\RoutePermissionService;
10 11 use IvyForms\Services\Translations\BackendStrings;
12 +use IvyForms\ValueObjects\Form\FormExportOptions;
11 13 use WP_REST_Request;
12 14 use WP_REST_Response;
13 15
14 16 class ExportFormController extends Controller
@@ -13,12 +15,16 @@
13 15
14 16 class ExportFormController extends Controller
15 17 {
16 18 private FormImportExportService $importExportService;
19 + private RoutePermissionService $routePermissionService;
17 20
18 - public function __construct(FormImportExportService $importExportService)
19 - {
21 + public function __construct(
22 + FormImportExportService $importExportService,
23 + RoutePermissionService $routePermissionService
24 + ) {
20 25 $this->importExportService = $importExportService;
26 + $this->routePermissionService = $routePermissionService;
21 27 }
22 28
23 29 /**
24 30 * Handle the export request
@@ -53,10 +59,23 @@
53 59 BackendStrings::getExceptionStrings()['no_form_ids_for_export']
54 60 );
55 61 }
56 62
63 + foreach ($formIds as $formId) {
64 + if (!$this->routePermissionService->canExportForms($formId)) {
65 + throw new ForbiddenException(
66 + BackendStrings::getExceptionStrings()['forbidden']
67 + );
68 + }
69 + }
70 +
71 + $exportOptions = FormExportOptions::fromRequestParams(
72 + $data->get_param('includeStyles'),
73 + $data->get_param('includeEntries')
74 + );
75 +
57 76 // Export forms using service
58 - $exportData = $this->importExportService->exportForms($formIds);
77 + $exportData = $this->importExportService->exportForms($formIds, $exportOptions);
59 78
60 79 return new WP_REST_Response([
61 80 'success' => true,
62 81 'data' => $exportData,