1 | <?php |
||
31 | class PartialFormSubmission extends SubmittedForm |
||
32 | { |
||
33 | private static $table_name = 'PartialFormSubmission'; |
||
|
|||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private static $db = [ |
||
39 | 'IsSend' => 'Boolean(false)', |
||
40 | 'TokenSalt' => 'Varchar(16)', |
||
41 | 'Token' => 'Varchar(16)', |
||
42 | 'Password' => 'Varchar(64)', |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private static $has_one = [ |
||
49 | 'UserDefinedForm' => DataObject::class |
||
50 | ]; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | private static $has_many = [ |
||
56 | 'PartialFields' => PartialFieldSubmission::class |
||
57 | ]; |
||
58 | |||
59 | private static $cascade_deletes = [ |
||
60 | 'PartialFields' |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * @var array |
||
65 | */ |
||
66 | private static $summary_fields = [ |
||
67 | 'ID' => 'ID', |
||
68 | 'PartialLink' => 'Link', |
||
69 | 'Created' => 'Created', |
||
70 | 'LastEdited' => 'Last Edited', |
||
71 | ]; |
||
72 | |||
73 | private static $special_characters = [ |
||
74 | '!', |
||
75 | '@', |
||
76 | '#', |
||
77 | '$', |
||
78 | '%', |
||
79 | '^', |
||
80 | '&', |
||
81 | '*', |
||
82 | '(', |
||
83 | ')', |
||
84 | '_', |
||
85 | '-', |
||
86 | '=', |
||
87 | '+', |
||
88 | ';', |
||
89 | ':', |
||
90 | ',', |
||
91 | '.', |
||
92 | '?' |
||
93 | ]; |
||
94 | |||
95 | /** |
||
96 | * @return FieldList |
||
97 | */ |
||
98 | public function getCMSFields() |
||
132 | |||
133 | /** |
||
134 | * @return DataObject|UserDefinedForm |
||
135 | */ |
||
136 | public function getParent() |
||
140 | |||
141 | /** |
||
142 | * If the submission is password protected, generate a password. |
||
143 | */ |
||
144 | public function onBeforeWrite() |
||
161 | |||
162 | /** |
||
163 | * @param Member |
||
164 | * |
||
165 | * @return boolean|string |
||
166 | */ |
||
167 | public function canCreate($member = null, $context = []) |
||
175 | |||
176 | /** |
||
177 | * @param Member |
||
178 | * |
||
179 | * @return boolean|string |
||
180 | */ |
||
181 | public function canView($member = null) |
||
189 | |||
190 | /** |
||
191 | * @param Member |
||
192 | * |
||
193 | * @return boolean|string |
||
194 | */ |
||
195 | public function canEdit($member = null) |
||
203 | |||
204 | /** |
||
205 | * @param Member |
||
206 | * |
||
207 | * @return boolean|string |
||
208 | */ |
||
209 | public function canDelete($member = null) |
||
217 | |||
218 | /** |
||
219 | * Get the share link of the form |
||
220 | * |
||
221 | * @return string |
||
222 | * @throws \Exception |
||
223 | */ |
||
224 | public function getPartialLink() |
||
239 | |||
240 | /** |
||
241 | * Get the unique token for the share link |
||
242 | * |
||
243 | * @return bool|string|null |
||
244 | * @throws \Exception |
||
245 | */ |
||
246 | protected function getPartialToken() |
||
256 | |||
257 | /** |
||
258 | * Generate a new token |
||
259 | * |
||
260 | * @return bool|string |
||
261 | * @throws \Exception |
||
262 | */ |
||
263 | protected function generateToken() |
||
269 | |||
270 | /** |
||
271 | * Generate a key based on the share token salt |
||
272 | * |
||
273 | * @param string $token |
||
274 | * @return mixed |
||
275 | */ |
||
276 | public function generateKey($token) |
||
280 | } |
||
281 |