@@ -192,8 +192,6 @@ public function actionEdit(int $id): Response
192192 */
193193 public function actionSave ()
194194 {
195- PermissionHelper::requirePermission (Freeform::PERMISSION_SUBMISSIONS_MANAGE );
196-
197195 $ post = \Craft::$ app ->request ->post ();
198196
199197 $ submissionId = $ post ['submissionId ' ] ?? null ;
@@ -203,6 +201,13 @@ public function actionSave()
203201 throw new FreeformException (Freeform::t ('Submission not found ' ));
204202 }
205203
204+ PermissionHelper::requirePermission (
205+ PermissionHelper::prepareNestedPermission (
206+ Freeform::PERMISSION_SUBMISSIONS_MANAGE ,
207+ $ model ->formId
208+ )
209+ );
210+
206211 $ model ->title = \Craft::$ app ->request ->post ('title ' , $ model ->title );
207212 $ model ->statusId = $ post ['statusId ' ];
208213 $ model ->setFormFieldValues ($ post );
@@ -234,27 +239,4 @@ public function actionSave()
234239 ]
235240 );
236241 }
237-
238- /**
239- * Deletes a field
240- *
241- * @return Response
242- * @throws \Exception
243- * @throws BadRequestHttpException
244- * @throws ForbiddenHttpException
245- */
246- public function actionDelete (): Response
247- {
248- $ this ->requirePostRequest ();
249- PermissionHelper::requirePermission (Freeform::PERMISSION_SUBMISSIONS_MANAGE );
250-
251- $ submissionId = \Craft::$ app ->request ->post ('id ' );
252- $ submission = $ this ->getSubmissionsService ()->getSubmissionById ($ submissionId );
253-
254- if ($ submission && !$ this ->getSubmissionsService ()->delete ($ submission )) {
255- return $ this ->asErrorJson (implode ('; ' , $ submission ->getErrors ()));
256- }
257-
258- return $ this ->asJson (['success ' => true ]);
259- }
260242}
0 commit comments