11
11
use OCA \Forms \Db \Form ;
12
12
use OCA \Forms \Db \FormMapper ;
13
13
use OCA \Forms \Db \ShareMapper ;
14
+ use OCA \Forms \Db \Submission ;
15
+ use OCA \Forms \Db \SubmissionMapper ;
14
16
use OCA \Forms \Service \ConfigService ;
15
17
use OCA \Forms \Service \FormsService ;
16
18
@@ -45,6 +47,7 @@ public function __construct(
45
47
IRequest $ request ,
46
48
private FormMapper $ formMapper ,
47
49
private ShareMapper $ shareMapper ,
50
+ private SubmissionMapper $ submissionMapper ,
48
51
private ConfigService $ configService ,
49
52
private FormsService $ formsService ,
50
53
private IAccountManager $ accountManager ,
@@ -63,7 +66,7 @@ public function __construct(
63
66
#[NoAdminRequired()]
64
67
#[NoCSRFRequired()]
65
68
#[FrontpageRoute(verb: 'GET ' , url: '/ ' )]
66
- public function index (?string $ hash = null ): TemplateResponse {
69
+ public function index (?string $ hash = null , ? int $ submissionId = null ): TemplateResponse {
67
70
Util::addScript ($ this ->appName , 'forms-main ' );
68
71
Util::addStyle ($ this ->appName , 'forms ' );
69
72
Util::addStyle ($ this ->appName , 'forms-style ' );
@@ -81,6 +84,16 @@ public function index(?string $hash = null): TemplateResponse {
81
84
}
82
85
}
83
86
87
+ if (isset ($ submissionId )) {
88
+ try {
89
+ $ submission = $ this ->submissionMapper ->findById ($ submissionId );
90
+ $ this ->initialState ->provideInitialState ('submissionId ' , $ submission ->id );
91
+ } catch (DoesNotExistException $ e ) {
92
+ // Provide null to indicate no form was found
93
+ $ this ->initialState ->provideInitialState ('submissionId ' , null );
94
+ }
95
+ }
96
+
84
97
return new TemplateResponse ($ this ->appName , self ::TEMPLATE_MAIN , [
85
98
'id-app-content ' => '#app-content-vue ' ,
86
99
'id-app-navigation ' => '#app-navigation-vue ' ,
@@ -97,6 +110,16 @@ public function views(string $hash): TemplateResponse {
97
110
return $ this ->index ($ hash );
98
111
}
99
112
113
+ /**
114
+ * @return TemplateResponse
115
+ */
116
+ #[NoAdminRequired()]
117
+ #[NoCSRFRequired()]
118
+ #[FrontpageRoute(verb: 'GET ' , url: '/{hash}/submit/{submissionId} ' , requirements: ['hash ' => '[a-zA-Z0-9]{16,} ' , 'submissionId ' => '\d+ ' ])]
119
+ public function submitViewWithSubmission (string $ hash , int $ submissionId ): TemplateResponse {
120
+ return $ this ->formMapper ->findByHash ($ hash )->getAllowEdit () ? $ this ->index ($ hash , $ submissionId ) : $ this ->index ($ hash );
121
+ }
122
+
100
123
/**
101
124
* @param string $hash
102
125
* @return RedirectResponse|TemplateResponse Redirect to login or internal view.
0 commit comments