PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
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/DuplicateFormController.php +16 -12 0.2.1 → 1.5.1 View file →
@@ -1,18 +1,13 @@
1 1 <?php
2 2
3 3 /**
4 - * @copyright © TMS-Plugins. All rights reserved.
4 + * @copyright © Melograno Venture Studio. All rights reserved.
5 5 * @licence See COPYING.md for license details.
6 6 */
7 7
8 8 namespace IvyForms\Controllers\Form;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 10 use IvyForms\Common\Exceptions\ForbiddenException;
16 11 use IvyForms\Common\Exceptions\InvalidArgumentException;
17 12 use IvyForms\Common\Exceptions\NotFoundException;
18 13 use IvyForms\Common\Exceptions\QueryExecutionException;
@@ -23,8 +18,9 @@
23 18 use IvyForms\Services\Confirmation\ConfirmationService;
24 19 use IvyForms\Services\Field\FieldService;
25 20 use IvyForms\Services\Form\FormService;
26 21 use IvyForms\Services\Notification\NotificationService;
22 +use IvyForms\Services\Permissions\AccessRulesFormScopeExtender;
27 23 use IvyForms\Services\Translations\BackendStrings;
28 24 use WP_REST_Request;
29 25 use WP_REST_Response;
30 26
@@ -39,18 +35,22 @@
39 35 private FieldService $fieldService;
40 36 private NotificationService $notificationService;
41 37 private ConfirmationService $confirmationService;
42 38
39 + private AccessRulesFormScopeExtender $accessRulesFormScopeExtender;
40 +
43 41 public function __construct(
44 42 FormService $formService,
45 43 FieldService $fieldService,
46 44 NotificationService $notificationService,
47 - ConfirmationService $confirmationService
45 + ConfirmationService $confirmationService,
46 + AccessRulesFormScopeExtender $accessRulesFormScopeExtender
48 47 ) {
49 - $this->formService = $formService;
50 - $this->fieldService = $fieldService;
51 - $this->notificationService = $notificationService;
52 - $this->confirmationService = $confirmationService;
48 + $this->formService = $formService;
49 + $this->fieldService = $fieldService;
50 + $this->notificationService = $notificationService;
51 + $this->confirmationService = $confirmationService;
52 + $this->accessRulesFormScopeExtender = $accessRulesFormScopeExtender;
53 53 }
54 54
55 55 /**
56 56 * @param WP_REST_Request $data
@@ -69,9 +69,11 @@
69 69 Sanitizer::verifyNonce($data->get_header('X-WP-Nonce'));
70 70
71 71 // Check if the form ID is provided
72 72 if (empty($data->get_params())) {
73 - throw new InvalidArgumentException('Invalid request data.');
73 + throw new InvalidArgumentException(
74 + BackendStrings::getExceptionStrings()['invalid_request_data']
75 + );
74 76 }
75 77
76 78 $formId = Sanitizer::sanitizeId($data->get_param('id')) ;
77 79
@@ -79,8 +81,10 @@
79 81
80 82 $this->fieldService->duplicateFields($formId, $newFormId);
81 83 $this->notificationService->duplicateNotifications($formId, $newFormId);
82 84 $this->confirmationService->duplicateConfirmations($formId, $newFormId);
85 +
86 + $this->accessRulesFormScopeExtender->appendCreatedFormToCurrentUserScope($newFormId);
83 87
84 88 return new WP_REST_Response([
85 89 'message' => BackendStrings::getCommonStrings()['ok'],
86 90 'data' => $this->formService->getFormById($newFormId)->toArray()