PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.4
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Form / FormManager.php

FormManager.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.4, at includes/Core/Form/FormManager.php

648 lines 25.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Get set Form,fields
5 */
6
7 namespace BitCode\BitForm\Core\Form;
8
9 /**
10 * FrontendFormManager class
11 */
12
13 use WP_Error;
14 use BitCode\BitForm\Core\Util\IpTool;
15 use BitCode\BitForm\Core\Form\ApiResponse;
16 use BitCode\BitForm\Core\Util\FileHandler;
17 use BitCode\BitForm\Core\Database\FormModel;
18 use BitCode\BitForm\Core\Database\FormEntryModel;
19 use BitCode\BitForm\Core\Database\FormEntryLogModel;
20 use BitCode\BitForm\Core\WorkFlow\WorkFlowRunHelper;
21 use BitCode\BitForm\Core\Database\FormEntryMetaModel;
22 use BitCode\BitForm\Core\Form\Validator\FormFieldValidator;
23 use BitCode\BitForm\Admin\Form\CustomFieldHandler;
24 use BitCode\BitForm\Core\Integration\IntegrationHandler;
25
26 class FormManager
27 {
28 protected static $form;
29 protected $formModel;
30 protected $form_id;
31 private $_has_upload;
32 private $_field_label;
33 private $_fields;
34 public function __construct($form_id)
35 {
36 $this->form_id = $form_id;
37 $this->formModel = new FormModel();
38
39 static::$form = $this->formModel->get(
40 [
41 "id",
42 "form_content",
43 "form_name",
44 'created_at',
45 'views',
46 'entries',
47 'status'
48 ],
49 array(
50 'id' => $form_id
51 )
52 );
53 }
54
55 public function isExist()
56 {
57 return (!static::$form || is_wp_error(static::$form)) ? false : true;
58 }
59
60 public function checkStatus()
61 {
62 return static::$form[0]->status === '1' ? true : false;
63 }
64
65 public function getFormContentWithValue($defaultValues)
66 {
67 $form_content = \json_decode(static::$form[0]->form_content);
68 if (!is_array($defaultValues)) {
69 return $form_content;
70 }
71 foreach ($form_content->fields as $fieldKey => $fieldDetails) {
72 // $field_name = empty($fieldDetails->lbl) ? null : \preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\!]/', '_', $fieldDetails->lbl);
73 if ((isset($fieldDetails->mul) || $fieldDetails->typ === 'check') && isset($defaultValues[$fieldKey])) {
74 if (is_array($defaultValues[$fieldKey])) {
75 $fieldDetails->val =
76 wp_json_encode(
77 array_map('sanitize_text_field', $defaultValues[$fieldKey])
78 );
79 } else {
80 $fieldDetails->val = sanitize_text_field($defaultValues[$fieldKey]);
81 }
82 } elseif (isset($defaultValues[$fieldKey])) {
83 $fieldDetails->val = is_string($defaultValues[$fieldKey]) ?
84 sanitize_text_field($defaultValues[$fieldKey]) :
85 sanitize_text_field($defaultValues[$fieldKey][count($defaultValues[$fieldKey]) - 1]);
86 }
87 }
88 return $form_content;
89 }
90
91 public function getFormContent()
92 {
93 $formContent = json_decode(static::$form[0]->form_content);
94 $types = ['check', 'radio', 'select'];
95 $filter = false;
96 foreach ($formContent->fields as $field) {
97 if (in_array($field->typ, $types) && property_exists($field, "customType")) {
98 $filter = true;
99 }
100 }
101 if ($filter == true) {
102 $updateFields = apply_filters('bitform_dynamic_field_filter', $formContent->fields);
103 $formContent->fields = $updateFields;
104 }
105 return $formContent;
106 }
107
108 public function getFormName()
109 {
110 return static::$form[0]->form_name;
111 }
112
113 public function getFields()
114 {
115 if (!is_null($this->_fields)) {
116 return $this->_fields;
117 }
118 $form_content = \json_decode(static::$form[0]->form_content);
119 $layout = $form_content->layout;
120 $fields = $form_content->fields;
121 $field_details = array();
122 foreach ($fields as $key => $field) {
123 if ($field->typ === 'recaptcha') {
124 continue;
125 }
126 // $field_name = empty($field->lbl) ? null : \preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\\!]/', '_', $field->lbl);
127 $field_type = $field->typ;
128 $field_details[$key]['label'] = empty($field->lbl) ? null : $field->lbl;
129 $field_details[$key]['type'] = $field_type;
130 $field_details[$key]['key'] = $key;
131 if (isset($field->customType)) {
132 $field_details[$key]['customType'] = $field->customType;
133 }
134
135 if (isset($field->err)) {
136 if (isset($field->err->entryUnique)) {
137 $field_details[$key]['entryUnique'] = $field->err->entryUnique;
138 }
139 if (isset($field->err->userUnique)) {
140 $field_details[$key]['userUnique'] = $field->err->userUnique;
141 }
142 }
143
144 if (isset($field->mul)) {
145 $field_details[$key]['mul'] = $field->mul;
146 }
147 if ($field_type === 'file-up' && isset($field->exts)) {
148 $field_details[$key]['valid']['type'] = $field->exts;
149 }
150 if (isset($field->valid) && !is_null($field->valid)) {
151 if (isset($field->valid->req)) {
152 $field_details[$key]['valid']['req'] = $field->valid->req;
153 }
154 if (isset($field->valid->reqMsg)) {
155 $field_details[$key]['valid']['reqMsg'] = $field->valid->reqMsg;
156 }
157 if (isset($field->valid->typMsg)) {
158 $field_details[$key]['valid']['typMsg'] = $field->valid->typMsg;
159 }
160 }
161 }
162 if ($this->isGCLIDEnabled()) {
163 $field_details['GCLID']['name'] = 'GCLID';
164 $field_details['GCLID']['adminLbl'] = 'GCLID';
165 $field_details['GCLID']['key'] = 'GCLID';
166 $field_details['GCLID']['type'] = 'hidden';
167 }
168 $this->_fields = $field_details;
169 return $field_details;
170 }
171 public function getFieldsKey()
172 {
173 $form_content = \json_decode(static::$form[0]->form_content);
174 $fields = $form_content->fields;
175 $field_details = array();
176 foreach ($fields as $key => $field) {
177 if ($field->typ === 'recaptcha') {
178 continue;
179 }
180 // $field_name = empty($field->lbl) ? null : \preg_replace('/[\`\~\!\@\#\$\'\.\s\?\+\-\*\&\|\/\\\!]/', '_', $field->lbl);
181 $field_details[$key] = $key;
182 }
183 if ($this->isGCLIDEnabled()) {
184 $field_details['GCLID'] = 'GCLID';
185 }
186 return $field_details;
187 }
188
189 public function getFieldLabel($forQuery = false)
190 {
191 if (!is_null($this->_field_label)) {
192 return $this->_field_label;
193 }
194 $form_content = \json_decode(static::$form[0]->form_content);
195 $fields = $form_content->fields;
196 $field_details = array();
197 $fieldCounter = 0;
198 foreach ($fields as $key => $field) {
199 if ($field->typ === 'recaptcha' || $field->typ === 'html' || $field->typ === 'button') {
200 continue;
201 }
202 $field_details[$fieldCounter]['name'] = empty($field->lbl) ? null : $field->lbl;
203 $field_details[$fieldCounter]['adminLbl'] = empty($field->adminLbl) ? $field_details[$fieldCounter]['name'] : $field->adminLbl;
204 $field_details[$fieldCounter]['key'] = $key;
205 $field_details[$fieldCounter]['type'] = $field->typ;
206 $fieldCounter += 1;
207 }
208 if ($this->isGCLIDEnabled()) {
209 $field_details[$fieldCounter]['name'] = 'GCLID';
210 $field_details[$fieldCounter]['adminLbl'] = 'GCLID';
211 $field_details[$fieldCounter]['key'] = 'GCLID';
212 $field_details[$fieldCounter]['type'] = 'hidden';
213 $fieldCounter += 1;
214 }
215 if (!$forQuery) {
216 $field_details = (array) $this->addEntryInfo($field_details, $fieldCounter);
217 }
218 $this->_field_label = $field_details;
219 return $field_details;
220 }
221
222 public function getUploadFields()
223 {
224 if (!is_null($this->_has_upload)) {
225 return $this->_has_upload;
226 }
227 $upload_fields = array();
228 $form_field_details = $this->getFields();
229 foreach ($form_field_details as $field_name => $__field_detail) {
230 if (isset($__field_detail['type']) && $__field_detail['type'] === 'file-up') {
231 $upload_fields[] = $field_name;
232 }
233 }
234 $this->_has_upload = $upload_fields;
235 return $upload_fields;
236 }
237
238 private function entryInsert($user_details)
239 {
240 $formEntryModel = new FormEntryModel();
241 $entryId = $formEntryModel->insert(
242 array(
243 'form_id' => $this->form_id,
244 'user_id' => $user_details['id'],
245 'user_ip' => $user_details['ip'],
246 'user_device' => $user_details['device'],
247 'referer' => $user_details['page'],
248 'status' => 0,
249 'created_at' => $user_details['time']
250 )
251 );
252 return $entryId;
253 }
254
255 private function submisionLog($user_details, $entry_id, $type)
256 {
257 $formEntryLogModel = new FormEntryLogModel();
258 $logId = $formEntryLogModel->form_log_insert(
259 array(
260 "user_id" => $user_details['id'],
261 "action_type" => $type,
262 "log_type" => "entry",
263 "ip" => $user_details['ip'],
264 "form_entry_id" => $entry_id,
265 "content" => null,
266 "form_id" => $this->form_id,
267 "created_at" => $user_details['time'],
268 )
269 );
270 return $logId;
271 }
272
273 private function isArrayAllKeyInt($InputArray)
274 {
275 if (!is_array($InputArray)) {
276 return false;
277 }
278
279 if (count($InputArray) <= 0) {
280 return true;
281 }
282
283 return array_unique(array_map("is_int", array_keys($InputArray))) === array(true);
284 }
285
286 private function saveEntryMeta($submitted_data, $entry_id)
287 {
288 $errorInEntryMetaInsert = false;
289 $entryMeta = new FormEntryMetaModel();
290 foreach ($submitted_data as $key => $value) {
291 $value = $submitted_data[$key];
292 if (is_string($value)) {
293 $value = wp_unslash($value);
294 } elseif ($this->isArrayAllKeyInt($value)) {
295 $value = wp_json_encode(array_values($value));
296 } else {
297 $value = wp_json_encode($value);
298 }
299 $status = $entryMeta->insert(
300 array(
301 'bitforms_form_entry_id' => $entry_id,
302 'meta_key' => $key,
303 'meta_value' => $value
304 )
305 );
306 if (is_wp_error($status)) {
307 $errorInEntryMetaInsert = true;
308 break;
309 }
310 }
311 return $errorInEntryMetaInsert;
312 }
313
314 public function saveFormEntry($submitted_data)
315 {
316 unset($submitted_data[$this->getFormIdentifier()]);
317 $form_content = \json_decode(static::$form[0]->form_content);
318 do_action('bitform_save_entry', $this, $submitted_data);
319 $key = null;
320 $ipTool = new IpTool();
321 $user_details = $ipTool->getUserDetail();
322 $form_fields = $this->getFields();
323 $submitted_data = $this->passwordEncrypted($submitted_data, $form_fields);
324 global $wpdb;
325 $wpdb->query("START TRANSACTION");
326 $entry_id = $this->entryInsert($user_details);
327 $log_id = null;
328 if (is_wp_error($entry_id)) {
329 return new WP_Error('insert_error', __('Sorry, Error occured in saving form entry', 'bitform'));
330 }
331 if ($entry_id) {
332 $log_id = $this->submisionLog($user_details, $entry_id, 'create', $key);
333 if (is_wp_error($log_id)) {
334 $wpdb->query("ROLLBACK");
335 return new WP_Error('error_entry_log', __('Sorry, error occured in logging form entry', 'bitform'));
336 }
337 }
338 if ($entry_id) {
339 $submitted_fields = $this->getFormContentWithValue($submitted_data)->fields;
340 $workFlowRunHelper = new WorkFlowRunHelper($this->form_id);
341 $workFlowreturnedOnSubmit = $workFlowRunHelper->executeOnSubmit(
342 'create',
343 $submitted_fields,
344 $submitted_data,
345 $entry_id,
346 $log_id
347 );
348 if (!empty($workFlowreturnedOnSubmit['fields'])) {
349 $submitted_data = $workFlowreturnedOnSubmit['fields'];
350 }
351
352 $file_fields = $this->getUploadFields();
353 $fileHandler = new FileHandler;
354 foreach ($_FILES as $file_name => $file_details) {
355 if ($file_fields && in_array($file_name, $file_fields)) {
356 $filePath = $fileHandler->moveUploadedFiles($file_details, $this->form_id, $entry_id);
357 if (!empty($filePath)) {
358 $submitted_data[$file_name] = $filePath;
359 }
360 }
361 }
362
363 if (!isset($form_content->additional->enabled->submission)) {
364 $errorInEntryMetaInsert = $this->saveEntryMeta($submitted_data, $entry_id);
365 if ($errorInEntryMetaInsert) {
366 $wpdb->query("ROLLBACK");
367 return new WP_Error('insert_error', __('Sorry, Error occured in saving form entry data', 'bitform'));
368 }
369 }
370 $wpdb->query("COMMIT");
371 $this->setSubmissionCount();
372 $workFlowreturnedOnSubmit['fields'] = $submitted_data;
373
374 return $workFlowreturnedOnSubmit;
375 }
376 }
377
378 public function passwordEncrypted($updatedValue, $form_fields)
379 {
380 $integrationHandler = new IntegrationHandler($this->form_id);
381 $formIntegrations = $integrationHandler->getAllIntegration('wp_user_auth', 'wp_auth', 1);
382 if (!isset($formIntegrations->errors['result_empty'])) {
383 foreach ($form_fields as $field) {
384 if (array_key_exists($field['key'], $updatedValue) && $field['type'] == 'password') {
385 $updatedValue[$field['key']] = '**** (encrypted)';
386 }
387 }
388 }
389 return $updatedValue;
390 }
391
392 public function updateFormEntry($updatedValue, $formID, $entryID)
393 {
394 $formEntryModel = new FormEntryModel();
395 $formEntryLogModel = new FormEntryLogModel();
396 $formOldData = $formEntryLogModel->get_form_value($entryID);
397 $key = null;
398 $entryMeta = new FormEntryMetaModel();
399 $ipTool = new IpTool();
400 $user_details = $ipTool->getUserDetail();
401 $form_fields = $this->getFields();
402 $updatedValue = $this->passwordEncrypted($updatedValue, $form_fields);
403 $field_map = [];
404 foreach ($formOldData as $index => $data) {
405 foreach ($form_fields as $field_key => $field) {
406 if ($data->meta_key == $field['key']) {
407 $field_map[$field_key] = $field['key'];
408 }
409 }
410 }
411 $formFieldValidator = new FormFieldValidator($form_fields, $updatedValue, $_FILES);
412 $validateField = $formFieldValidator->validate('edit', $formID);
413 if (!$validateField) {
414 $errorMessage = count($formFieldValidator->getMessage()) > 0 ?
415 $formFieldValidator->getMessage() : __("Internal error occured!!!", 'bitform');
416 return new WP_Error('validation_error', $errorMessage);
417 }
418 $formEntry = $formEntryModel->update(
419 array(
420 "user_id" => $user_details['id'],
421 "user_ip" => $user_details['ip'],
422 "user_device" => $user_details['device'],
423 "status" => 0,
424 "updated_at" => $user_details['time']
425 ),
426 array(
427 'form_id' => $formID,
428 'id' => $entryID
429 )
430 );
431 $log_id = null;
432 if ($formEntry) {
433 $log_id = $this->submisionLog($user_details, $entryID, 'update');
434 }
435
436 if (is_wp_error($formEntry) || !$formEntry) {
437 return new WP_Error('empty_form', __('provided form entries does not exists', 'bitform'));
438 }
439
440 $file_fields = $this->getUploadFields();
441 if (count($file_fields) > 0) {
442 $fileHandler = new FileHandler();
443 foreach ($file_fields as $file_name) {
444 if (isset($updatedValue[$file_name . '_old'])) {
445 $file_exists = $entryMeta->get(
446 'meta_value',
447 array(
448 'bitforms_form_entry_id' => $entryID,
449 'meta_key' => $file_name
450 )
451 );
452 if (!is_wp_error($file_exists) && count($file_exists) > 0) {
453 $files_in_db = json_decode($file_exists[0]->meta_value);
454 $files_old = empty($updatedValue[$file_name . '_old']) ? [] : explode(',', $updatedValue[$file_name . '_old']);
455 $deleted_file = array_diff($files_in_db, $files_old);
456 if (count($deleted_file) > 0) {
457 $fileHandler->deleteFiles($formID, $entryID, $deleted_file);
458 }
459 $updatedValue[$file_name] = wp_json_encode($files_old);
460 }
461 }
462 if (!empty($_FILES[$file_name]['name'])) {
463 $meta_value = $fileHandler->moveUploadedFiles($_FILES[$file_name], $formID, $entryID);
464 if (!empty($meta_value)) {
465 if (isset($updatedValue[$file_name . '_old']) && !is_wp_error($file_exists) && count($file_exists) > 0) {
466 $meta_value = empty($files_old) ? $meta_value : array_merge($meta_value, $files_old);
467 $updatedValue[$file_name] = wp_json_encode($meta_value);
468 } else {
469 $data = array(
470 'bitforms_form_entry_id' => $entryID,
471 'meta_key' => $file_name,
472 'meta_value' => wp_json_encode($meta_value)
473 );
474 $newFileInsertStatus = $entryMeta->insert(
475 $data
476 );
477 $updatedValue[$file_name] = wp_json_encode($meta_value);
478 }
479 }
480 }
481 }
482 }
483
484
485
486 unset($updatedValue['_ajax_nonce']);
487 unset($_REQUEST['g-recaptcha-response']);
488
489 $workFlowRunHelper = new WorkFlowRunHelper($formID);
490 $workFlowreturnedOnSubmit = $workFlowRunHelper->executeOnSubmit(
491 'edit',
492 $this->getFormContentWithValue($updatedValue)->fields,
493 $updatedValue,
494 $entryID,
495 $log_id
496 );
497 if (!empty($workFlowreturnedOnSubmit['fields'])) {
498 $updatedValue = $workFlowreturnedOnSubmit['fields'];
499 }
500
501
502 $toUpdateValues = [];
503 foreach ($form_fields as $field) {
504 if (isset($updatedValue[$field['key']])) {
505 $toUpdateValues[$field['key']] = $updatedValue[$field['key']];
506 }
507 }
508 $formEntryMetaUpdateStatus = $entryMeta->update(
509 $toUpdateValues,
510 array(
511 'bitforms_form_entry_id' => $entryID
512 )
513 );
514 if (is_wp_error($formEntryMetaUpdateStatus) || isset($newFileInsertStatus) && is_wp_error($newFileInsertStatus)) {
515 return $formEntryMetaUpdateStatus;
516 }
517 $toUpdateValues = array_merge($formEntryMetaUpdateStatus, array('entry_id' => $entryID));
518 if (empty($workFlowreturnedOnSubmit['message'])) {
519 $workFlowreturnedOnSubmit['message'] = __('Entry Updated Successfully', 'bitform');
520 }
521 $customFieldHandler = new CustomFieldHandler();
522 $toUpdateValues = $customFieldHandler->updatedData($form_fields, $toUpdateValues);
523 $workFlowreturnedOnSubmit['updatedData'] = $toUpdateValues;
524 $counter = 0;
525 for ($i = 0; $i < count($formOldData); $i++) {
526 if (array_key_exists($formOldData[$i]->meta_key . '_old', $toUpdateValues)) {
527 unset($toUpdateValues[$formOldData[$i]->meta_key . '_old']);
528 }
529 if (in_array($formOldData[$i]->meta_key, $file_fields)) {
530 if (
531 empty($_FILES[$formOldData[$i]->meta_key]['name'])
532 || (is_array($_FILES[$formOldData[$i]->meta_key]['name'])
533 && count($_FILES[$formOldData[$i]->meta_key]['name']) === 1
534 && empty($_FILES[$formOldData[$i]->meta_key]['name'][0]))
535 ) {
536 unset($toUpdateValues[$formOldData[$i]->meta_key]);
537 continue;
538 }
539 if (is_array($_FILES[$formOldData[$i]->meta_key]['name']) && !in_array($_FILES[$formOldData[$i]->meta_key]['name'], json_decode($formOldData[$i]->meta_value))) {
540 $key[$i] = '${' . $formOldData[$i]->meta_key . '} file was Updated To ' . json_encode($_FILES[$formOldData[$i]->meta_key]['name']);
541 } elseif (!is_array($_FILES[$formOldData[$i]->meta_key]['name']) && !in_array($_FILES[$formOldData[$i]->meta_key]['name'], json_decode($formOldData[$i]->meta_value))) {
542 $key[$i] = '${' . $formOldData[$i]->meta_key . '} file was Updated To ' . $_FILES[$formOldData[$i]->meta_key]['name'];
543 }
544 unset($toUpdateValues[$formOldData[$i]->meta_key]);
545 } elseif (isset($toUpdateValues[$formOldData[$i]->meta_key])) {
546 if (is_array($toUpdateValues[$formOldData[$i]->meta_key])) {
547 if (json_decode($formOldData[$i]->meta_value) !== $toUpdateValues[$formOldData[$i]->meta_key]) {
548 $key[$i] = '${' . $formOldData[$i]->meta_key . '} was Updated From ' . implode(',', json_decode($formOldData[$i]->meta_value)) . ' To ' . implode(",", $toUpdateValues[$formOldData[$i]->meta_key]);
549 }
550 } elseif (is_string($toUpdateValues[$formOldData[$i]->meta_key]) && !empty($toUpdateValues[$formOldData[$i]->meta_key])) {
551 if ($formOldData[$i]->meta_value !== $toUpdateValues[$formOldData[$i]->meta_key]) {
552 $key[$i] = '${' . $formOldData[$i]->meta_key . '} was Updated' . ($formOldData[$i]->meta_value ? ' From ' . $formOldData[$i]->meta_value : '') . ' To ' . $toUpdateValues[$formOldData[$i]->meta_key];
553 }
554 }
555 }
556 $counter++;
557 }
558
559 $newField = array_keys(array_diff_key($formEntryMetaUpdateStatus, $field_map));
560 for ($i = 0; $i < count($newField); $i++) {
561 if (is_array($toUpdateValues[$newField[$i]])) {
562 if (!empty($toUpdateValues[$newField[$i]])) {
563 $key[$counter + $i] = '${' . $newField[$i] . '} Updated To ' . implode(",", $toUpdateValues[$newField[$i]]);
564 }
565 } elseif (is_string($newField[$i])) {
566 if (!empty($toUpdateValues[$newField[$i]])) {
567 $key[$counter + $i] = '${' . $newField[$i] . '} Updated To ' . $toUpdateValues[$newField[$i]];
568 }
569 }
570 }
571 if ($key !== null) {
572 $logUpdate = implode("b::f", (array) $key);
573 $formEntryLogUpdate = $formEntryLogModel->logUpdate($logUpdate, $log_id);
574 }
575 return $workFlowreturnedOnSubmit;
576 }
577
578 public function setSubmissionCount($countStep = 1)
579 {
580 $update_status = $this->formModel->update(
581 array(
582 'entries' => intval(static::$form[0]->entries) + $countStep
583 ),
584 array(
585 'id' => $this->form_id
586 )
587 );
588 }
589 public function resetSubmissionCount($countStep)
590 {
591 $update_status = $this->formModel->update(
592 array(
593 'entries' => intval($countStep)
594 ),
595 array(
596 'id' => $this->form_id
597 )
598 );
599 }
600
601 public function getCaptchaSettings()
602 {
603 $formContents = $this->getFormContent();
604 $fieldStr = wp_json_encode($formContents->fields);
605 if (strpos($fieldStr, '"typ":"recaptcha"') !== false) {
606 return true;
607 }
608 }
609 public function getCaptchaV3Settings()
610 {
611 $formContents = $this->getFormContent();
612 if (!empty($formContents->additional->enabled) && !empty($formContents->additional->enabled->recaptchav3)) {
613 return $formContents->additional->settings->recaptchav3;
614 }
615 return false;
616 }
617
618 public function isGCLIDEnabled()
619 {
620 $formContents = $this->getFormContent();
621 if (isset($formContents->additional->enabled->captureGCLID) && $formContents->additional->enabled->captureGCLID) {
622 return true;
623 }
624 return false;
625 }
626
627 protected function addEntryInfo($field_details, $counter)
628 {
629 $infos = [
630 '__user_id' => __('User'),
631 '__user_ip' => __('IP address'),
632 //'__user_location' => __(''),
633 '__referer' => __('Refer URL'),
634 '__user_device' => __('Device'),
635 '__created_at' => __('Created Time'),
636 '__updated_at' => __('Modified Time'),
637 ];
638 foreach ($infos as $key => $value) {
639 $field_details[$counter]['name'] = $value;
640 $field_details[$counter]['key'] = $key;
641 $field_details[$counter]['type'] = 'sys';
642 $counter = $counter + 1;
643 }
644
645 return $field_details;
646 }
647 }
648