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() |
||
134 | |||
135 | /** |
||
136 | * @return DataObject|UserDefinedForm |
||
137 | */ |
||
138 | public function getParent() |
||
142 | |||
143 | /** |
||
144 | * If the submission is password protected, generate a password. |
||
145 | */ |
||
146 | public function onBeforeWrite() |
||
163 | |||
164 | /** |
||
165 | * @param Member |
||
166 | * |
||
167 | * @return boolean|string |
||
168 | */ |
||
169 | public function canCreate($member = null, $context = []) |
||
177 | |||
178 | /** |
||
179 | * @param Member |
||
180 | * |
||
181 | * @return boolean|string |
||
182 | */ |
||
183 | public function canView($member = null) |
||
191 | |||
192 | /** |
||
193 | * @param Member |
||
194 | * |
||
195 | * @return boolean|string |
||
196 | */ |
||
197 | public function canEdit($member = null) |
||
205 | |||
206 | /** |
||
207 | * @param Member |
||
208 | * |
||
209 | * @return boolean|string |
||
210 | */ |
||
211 | public function canDelete($member = null) |
||
219 | |||
220 | /** |
||
221 | * Get the share link of the form |
||
222 | * |
||
223 | * @return string |
||
224 | * @throws \Exception |
||
225 | */ |
||
226 | public function getPartialLink() |
||
241 | |||
242 | /** |
||
243 | * Get the unique token for the share link |
||
244 | * |
||
245 | * @return bool|string|null |
||
246 | * @throws \Exception |
||
247 | */ |
||
248 | protected function getPartialToken() |
||
258 | |||
259 | /** |
||
260 | * Generate a new token |
||
261 | * |
||
262 | * @return bool|string |
||
263 | * @throws \Exception |
||
264 | */ |
||
265 | protected function generateToken() |
||
271 | |||
272 | /** |
||
273 | * Generate a key based on the share token salt |
||
274 | * |
||
275 | * @param string $token |
||
276 | * @return mixed |
||
277 | */ |
||
278 | public function generateKey($token) |
||
282 | } |
||
283 |