1 | <?php |
||
34 | class PartialFormSubmission extends SubmittedForm |
||
35 | { |
||
36 | private static $table_name = 'PartialFormSubmission'; |
||
|
|||
37 | |||
38 | private static $db = [ |
||
39 | 'IsSend' => 'Boolean(false)', |
||
40 | 'TokenSalt' => 'Varchar(16)', |
||
41 | 'Token' => 'Varchar(16)', |
||
42 | ]; |
||
43 | |||
44 | private static $has_one = [ |
||
45 | 'UserDefinedForm' => DataObject::class |
||
46 | ]; |
||
47 | |||
48 | private static $has_many = [ |
||
49 | 'PartialFields' => PartialFieldSubmission::class, |
||
50 | 'PartialUploads' => PartialFileFieldSubmission::class |
||
51 | ]; |
||
52 | |||
53 | private static $cascade_deletes = [ |
||
54 | 'PartialFields' |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | private static $summary_fields = [ |
||
61 | 'ID' => 'ID', |
||
62 | 'PartialLink' => 'Link', |
||
63 | 'Created' => 'Created', |
||
64 | 'LastEdited' => 'Last Edited', |
||
65 | ]; |
||
66 | |||
67 | 1 | public function getCMSFields() |
|
116 | |||
117 | 43 | /** |
|
118 | * Check if this partial form already has entries |
||
119 | 43 | * Used to check if a new form needs to start |
|
120 | * @return bool |
||
121 | */ |
||
122 | public function isStarted() |
||
126 | |||
127 | 1 | /** |
|
128 | * Return this related Form (Elemental or UserDefinedForm |
||
129 | 1 | * @return DataObject |
|
130 | */ |
||
131 | public function getParent() |
||
135 | |||
136 | /** |
||
137 | 40 | * @param Member $member |
|
138 | * @param array $context |
||
139 | 40 | * @return bool |
|
140 | 37 | */ |
|
141 | public function canCreate($member = null, $context = []) |
||
145 | |||
146 | /** |
||
147 | * @param Member |
||
148 | * |
||
149 | * @return boolean|string |
||
150 | */ |
||
151 | 3 | public function canView($member = null) |
|
159 | |||
160 | /** |
||
161 | * @param Member |
||
162 | * |
||
163 | * @return boolean|string |
||
164 | */ |
||
165 | 3 | public function canEdit($member = null) |
|
173 | |||
174 | /** |
||
175 | * @param Member |
||
176 | * |
||
177 | * @return boolean|string |
||
178 | */ |
||
179 | public function canDelete($member = null) |
||
187 | |||
188 | 2 | /** |
|
189 | 2 | * Get the share link of the form |
|
190 | 2 | * |
|
191 | 2 | * @return string |
|
192 | 2 | * @throws Exception |
|
193 | */ |
||
194 | public function getPartialLink() |
||
209 | |||
210 | 3 | /** |
|
211 | * Get the unique token for the share link |
||
212 | * |
||
213 | * @return bool|string|null |
||
214 | * @throws Exception |
||
215 | */ |
||
216 | protected function getPartialToken() |
||
226 | |||
227 | /** |
||
228 | * Generate a new token |
||
229 | * |
||
230 | * @return bool|string |
||
231 | * @throws Exception |
||
232 | 4 | */ |
|
233 | protected function generateToken() |
||
239 | |||
240 | /** |
||
241 | * Generate a key based on the share token salt |
||
242 | * |
||
243 | * @param string $token |
||
244 | * @return string|bool |
||
245 | */ |
||
246 | public function generateKey($token) |
||
250 | } |
||
251 |