1 | <?php |
||
34 | class PartialFormSubmission extends SubmittedForm |
||
35 | { |
||
36 | private static $table_name = 'PartialFormSubmission'; |
||
|
|||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | private static $db = [ |
||
42 | 'IsSend' => 'Boolean(false)', |
||
43 | 'TokenSalt' => 'Varchar(16)', |
||
44 | 'Token' => 'Varchar(16)', |
||
45 | 'Password' => 'Varchar(64)', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @var array |
||
50 | */ |
||
51 | private static $has_one = [ |
||
52 | 'UserDefinedForm' => DataObject::class |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | private static $has_many = [ |
||
59 | 'PartialFields' => PartialFieldSubmission::class |
||
60 | ]; |
||
61 | |||
62 | private static $cascade_deletes = [ |
||
63 | 'PartialFields' |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | private static $summary_fields = [ |
||
70 | 'ID' => 'ID', |
||
71 | 'PartialLink' => 'Link', |
||
72 | 'Created' => 'Created', |
||
73 | 'LastEdited' => 'Last Edited', |
||
74 | ]; |
||
75 | |||
76 | private static $special_characters = [ |
||
77 | '!', |
||
78 | '@', |
||
79 | '#', |
||
80 | '$', |
||
81 | '%', |
||
82 | '^', |
||
83 | '&', |
||
84 | '*', |
||
85 | '(', |
||
86 | ')', |
||
87 | '_', |
||
88 | '-', |
||
89 | '=', |
||
90 | '+', |
||
91 | ';', |
||
92 | ':', |
||
93 | ',', |
||
94 | '.', |
||
95 | '?' |
||
96 | ]; |
||
97 | |||
98 | /** |
||
99 | * @return FieldList |
||
100 | * @throws Exception |
||
101 | */ |
||
102 | public function getCMSFields() |
||
147 | |||
148 | /** |
||
149 | * Get the share link of the form |
||
150 | * |
||
151 | * @return string |
||
152 | * @throws Exception |
||
153 | */ |
||
154 | public function getPartialLink() |
||
169 | |||
170 | /** |
||
171 | * Generate a key based on the share token salt |
||
172 | * |
||
173 | * @param string $token |
||
174 | * @return mixed |
||
175 | */ |
||
176 | public function generateKey($token) |
||
180 | |||
181 | /** |
||
182 | * Generate the partial tokens |
||
183 | * If the submission is password protected, generate a password. |
||
184 | * @throws Exception |
||
185 | */ |
||
186 | public function onBeforeWrite() |
||
192 | |||
193 | /** |
||
194 | * Get the unique token for the share link |
||
195 | * |
||
196 | * @return bool|string|null |
||
197 | * @throws Exception |
||
198 | */ |
||
199 | protected function getPartialToken() |
||
208 | |||
209 | /** |
||
210 | * Generate a new token |
||
211 | * |
||
212 | * @return bool|string |
||
213 | * @throws Exception |
||
214 | */ |
||
215 | protected function generateToken() |
||
221 | |||
222 | /** |
||
223 | * @return void |
||
224 | */ |
||
225 | protected function generatePassword() |
||
238 | |||
239 | /** |
||
240 | * @return DataObject|UserDefinedForm |
||
241 | */ |
||
242 | public function getParent() |
||
246 | |||
247 | /** |
||
248 | * @param Member |
||
249 | * |
||
250 | * @return boolean|string |
||
251 | */ |
||
252 | public function canCreate($member = null, $context = []) |
||
256 | |||
257 | /** |
||
258 | * @param Member $member |
||
259 | * |
||
260 | * @return boolean|string |
||
261 | */ |
||
262 | public function canView($member = null) |
||
270 | |||
271 | /** |
||
272 | * @param Member $member |
||
273 | * |
||
274 | * @return boolean|string |
||
275 | */ |
||
276 | public function canEdit($member = null) |
||
284 | |||
285 | /** |
||
286 | * @param Member $member |
||
287 | * |
||
288 | * @return boolean|string |
||
289 | */ |
||
290 | public function canDelete($member = null) |
||
298 | } |
||
299 |