1 | <?php |
||
37 | class PartialFormSubmission extends SubmittedForm |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private static $table_name = 'PartialFormSubmission'; |
||
|
|||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private static $db = [ |
||
49 | 'IsSend' => 'Boolean(false)', |
||
50 | 'TokenSalt' => 'Varchar(16)', |
||
51 | 'Token' => 'Varchar(16)', |
||
52 | 'Password' => 'Varchar(64)', |
||
53 | ]; |
||
54 | |||
55 | /** |
||
56 | * @var array |
||
57 | */ |
||
58 | private static $has_one = [ |
||
59 | 'UserDefinedForm' => DataObject::class |
||
60 | ]; |
||
61 | |||
62 | /** |
||
63 | * @var array |
||
64 | */ |
||
65 | private static $has_many = [ |
||
66 | 'PartialFields' => PartialFieldSubmission::class, |
||
67 | 1 | 'PartialUploads' => PartialFileFieldSubmission::class |
|
68 | ]; |
||
69 | |||
70 | 1 | private static $cascade_deletes = [ |
|
71 | 1 | 'PartialFields' |
|
72 | 1 | ]; |
|
73 | |||
74 | /** |
||
75 | * @var array |
||
76 | */ |
||
77 | private static $summary_fields = [ |
||
78 | 'ID' => 'ID', |
||
79 | 'PartialLink' => 'Link', |
||
80 | 'Created' => 'Created', |
||
81 | 'LastEdited' => 'Last Edited', |
||
82 | 1 | ]; |
|
83 | 1 | ||
84 | 1 | private static $special_characters = [ |
|
85 | 1 | '!', |
|
86 | 1 | '@', |
|
87 | '#', |
||
88 | 1 | '$', |
|
89 | 1 | '%', |
|
90 | 1 | '^', |
|
91 | 1 | '&', |
|
92 | '*', |
||
93 | '(', |
||
94 | ')', |
||
95 | 1 | '_', |
|
96 | '-', |
||
97 | '=', |
||
98 | '+', |
||
99 | 1 | ';', |
|
100 | 1 | ':', |
|
101 | 1 | ',', |
|
102 | 1 | '.', |
|
103 | 1 | '?' |
|
104 | 1 | ]; |
|
105 | |||
106 | 1 | /** |
|
107 | 1 | * @return FieldList |
|
108 | * @throws Exception |
||
109 | 1 | */ |
|
110 | 1 | public function getCMSFields() |
|
159 | |||
160 | /** |
||
161 | * Get the share link of the form |
||
162 | * |
||
163 | * @return string |
||
164 | * @throws Exception |
||
165 | 3 | */ |
|
166 | public function getPartialLink() |
||
181 | |||
182 | 2 | /** |
|
183 | 1 | * Generate a key based on the share token salt |
|
184 | * |
||
185 | * @param string $token |
||
186 | 2 | * @return mixed |
|
187 | */ |
||
188 | 2 | public function generateKey($token) |
|
192 | 2 | ||
193 | /** |
||
194 | * Generate the partial tokens |
||
195 | * If the submission is password protected, generate a password. |
||
196 | * @throws Exception |
||
197 | */ |
||
198 | public function onBeforeWrite() |
||
206 | 3 | ||
207 | 3 | /** |
|
208 | * Get the unique token for the share link |
||
209 | * |
||
210 | 3 | * @return bool|string|null |
|
211 | * @throws Exception |
||
212 | */ |
||
213 | protected function getPartialToken() |
||
222 | |||
223 | 4 | /** |
|
224 | * Generate a new token |
||
225 | * |
||
226 | * @return bool|string |
||
227 | * @throws Exception |
||
228 | */ |
||
229 | protected function generateToken() |
||
235 | |||
236 | /** |
||
237 | * @return string |
||
238 | * @throws Exception |
||
239 | */ |
||
240 | protected function generatePassword() |
||
252 | |||
253 | /** |
||
254 | * @return DataObject|UserDefinedForm |
||
255 | */ |
||
256 | public function getParent() |
||
260 | |||
261 | /** |
||
262 | * @param Member |
||
263 | * |
||
264 | * @return bool|string|null |
||
265 | * @throws Exception |
||
266 | */ |
||
267 | public function canCreate($member = null, $context = []) |
||
271 | |||
272 | /** |
||
273 | * @param Member $member |
||
274 | * |
||
275 | * @return boolean|string |
||
276 | */ |
||
277 | public function canView($member = null) |
||
285 | |||
286 | /** |
||
287 | * @param Member $member |
||
288 | * |
||
289 | * @throws Exception |
||
290 | * @return boolean|string |
||
291 | */ |
||
292 | public function canEdit($member = null) |
||
300 | |||
301 | /** |
||
302 | * @param Member $member |
||
303 | * |
||
304 | * @return boolean|string |
||
305 | */ |
||
306 | public function canDelete($member = null) |
||
314 | } |
||
315 |