1 | <?php |
||
33 | class PartialFormSubmission extends SubmittedForm |
||
34 | { |
||
35 | private static $table_name = 'PartialFormSubmission'; |
||
|
|||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private static $db = [ |
||
41 | 'IsSend' => 'Boolean(false)', |
||
42 | 'TokenSalt' => 'Varchar(16)', |
||
43 | 'Token' => 'Varchar(16)', |
||
44 | 'Password' => 'Varchar(64)', |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * @var array |
||
49 | */ |
||
50 | private static $has_one = [ |
||
51 | 'UserDefinedForm' => DataObject::class |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * @var array |
||
56 | */ |
||
57 | private static $has_many = [ |
||
58 | 'PartialFields' => PartialFieldSubmission::class |
||
59 | ]; |
||
60 | |||
61 | private static $cascade_deletes = [ |
||
62 | 'PartialFields' |
||
63 | ]; |
||
64 | |||
65 | /** |
||
66 | * @var array |
||
67 | */ |
||
68 | private static $summary_fields = [ |
||
69 | 'ID' => 'ID', |
||
70 | 'PartialLink' => 'Link', |
||
71 | 'Created' => 'Created', |
||
72 | 'LastEdited' => 'Last Edited', |
||
73 | ]; |
||
74 | |||
75 | private static $special_characters = [ |
||
76 | '!', |
||
77 | '@', |
||
78 | '#', |
||
79 | '$', |
||
80 | '%', |
||
81 | '^', |
||
82 | '&', |
||
83 | '*', |
||
84 | '(', |
||
85 | ')', |
||
86 | '_', |
||
87 | '-', |
||
88 | '=', |
||
89 | '+', |
||
90 | ';', |
||
91 | ':', |
||
92 | ',', |
||
93 | '.', |
||
94 | '?' |
||
95 | ]; |
||
96 | |||
97 | /** |
||
98 | * @return FieldList |
||
99 | */ |
||
100 | public function getCMSFields() |
||
145 | |||
146 | /** |
||
147 | * @return DataObject|UserDefinedForm |
||
148 | */ |
||
149 | public function getParent() |
||
153 | |||
154 | /** |
||
155 | * Generate the partial tokens |
||
156 | * If the submission is password protected, generate a password. |
||
157 | * @throws \Exception |
||
158 | */ |
||
159 | public function onBeforeWrite() |
||
165 | |||
166 | /** |
||
167 | * @param Member |
||
168 | * |
||
169 | * @return boolean|string |
||
170 | */ |
||
171 | public function canCreate($member = null, $context = []) |
||
179 | |||
180 | /** |
||
181 | * @param Member |
||
182 | * |
||
183 | * @return boolean|string |
||
184 | */ |
||
185 | public function canView($member = null) |
||
193 | |||
194 | /** |
||
195 | * @param Member |
||
196 | * |
||
197 | * @return boolean|string |
||
198 | */ |
||
199 | public function canEdit($member = null) |
||
207 | |||
208 | /** |
||
209 | * @param Member |
||
210 | * |
||
211 | * @return boolean|string |
||
212 | */ |
||
213 | public function canDelete($member = null) |
||
221 | |||
222 | /** |
||
223 | * Get the share link of the form |
||
224 | * |
||
225 | * @return string |
||
226 | * @throws \Exception |
||
227 | */ |
||
228 | public function getPartialLink() |
||
243 | |||
244 | /** |
||
245 | * Get the unique token for the share link |
||
246 | * |
||
247 | * @return bool|string|null |
||
248 | * @throws \Exception |
||
249 | */ |
||
250 | protected function getPartialToken() |
||
259 | |||
260 | /** |
||
261 | * Generate a new token |
||
262 | * |
||
263 | * @return bool|string |
||
264 | * @throws \Exception |
||
265 | */ |
||
266 | protected function generateToken() |
||
272 | |||
273 | /** |
||
274 | * Generate a key based on the share token salt |
||
275 | * |
||
276 | * @param string $token |
||
277 | * @return mixed |
||
278 | */ |
||
279 | public function generateKey($token) |
||
283 | |||
284 | /** |
||
285 | * @return void |
||
286 | */ |
||
287 | protected function generatePassword() |
||
303 | } |
||
304 |