PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.7.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.7.0
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
← All changes | includes/Core/Database/FormEntryLogModel.php +72 -62 1.22.7.0 View file →
@@ -1,83 +1,93 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Database;
4 4
5 -use BitCode\BitForm\Core\Database\Model;
5 +use WP_Error;
6 +
6 7 /**
7 8 * Undocumented class
8 9 */
9 10
10 -use WP_Error;
11 -
12 11 class FormEntryLogModel extends Model
13 12 {
13 + protected static $table = 'bitforms_form_log_details';
14 14
15 - public function geLogHistory($form_id, $entry_id)
16 - {
17 - $sql = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_entry_log` where form_entry_id=$entry_id AND form_id=$form_id order By created_at DESC";
18 -
19 - $logs = $this->execute($sql)->getResult();
20 - $response = ['success' => true, 'data' => [],'integrations'=>[]];
21 - $ids=[];
22 - foreach($logs as $log){
23 - $ids[] = $log->id;
15 + public function geLogHistory($form_id, $entry_id)
16 + {
17 + $sql = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_entry_log` where form_entry_id=$entry_id AND form_id=$form_id order By created_at DESC";
18 +
19 + $logs = $this->execute($sql)->getResult();
20 + $response = ['success' => true, 'data' => [], 'integrations' => []];
21 + $ids = [];
22 + foreach ($logs as $log) {
23 + $ids[] = $log->id;
24 + }
25 + if (isset($logs->errors['result_empty'])) {
26 + wp_send_json($response);
27 + } else {
28 + $allLogId = preg_replace('/"/', '', implode(',', $ids));
29 + $sql2 = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_log_details` WHERE `log_id` IN ($allLogId)";
30 + $integrations = $this->execute($sql2)->getResult();
31 + foreach ($logs as $key => $log) {
32 + foreach ($integrations as $integration) {
33 + if ($integration->log_id === $log->id) {
34 + $logs[$key]->integration = true;
35 + }
24 36 }
25 - if (isset($logs->errors['result_empty'])) {
26 - wp_send_json($response);
27 - }else{
28 - $allLogId = preg_replace('/"/', '', implode(',',$ids));
29 - $sql2 = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_log_details` WHERE `log_id` IN ($allLogId)";
30 - $integrations = $this->execute($sql2)->getResult();
31 - foreach ($logs as $key => $log) {
32 - foreach ($integrations as $integration) {
33 - if ( $integration->log_id == $log->id ) {
34 - $logs[$key]->integration = true;
35 - }
36 - }
37 - }
38 - if(isset($integrations->errors['result_empty'])){
39 - $integrations=[];
40 - }
41 - wp_send_json(['success' => true, 'data' => $logs,'integrations'=>$integrations]);
42 - }
43 -
37 + }
38 + if (isset($integrations->errors['result_empty'])) {
39 + $integrations = [];
40 + }
41 + wp_send_json(['success' => true, 'data' => $logs, 'integrations' => $integrations]);
44 42 }
43 + }
45 44
46 - public function form_log_insert($data = array())
47 - {
48 - if (is_null($data)) {
49 - return new WP_Error('empty_data', __('Form data is empty', 'bitform'));
50 - }
51 - $result = $this->app_db->insert(
52 - "{$this->app_db->prefix}bitforms_form_entry_log",
53 - $data
54 - );
55 - return $this->getResult($result);
45 + public function entryLogCheck($entry_id, $integ_id)
46 + {
47 + if (is_null($entry_id)) {
48 + return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
56 49 }
50 + $sql = "SELECT api_type, response_obj FROM `{$this->app_db->prefix}bitforms_form_entry_log` as el JOIN `{$this->app_db->prefix}bitforms_form_log_details` as ld ON ld.log_id = el.id WHERE form_entry_id = {$entry_id} AND integration_id = {$integ_id} AND ld.response_type = 'success' ORDER BY el.id DESC LIMIT 1";
57 51
58 - public function log_history_insert($data = array())
59 - {
60 - if (is_null($data)) {
61 - return new WP_Error('empty_data', __('Form data is empty', 'bitform'));
62 - }
63 - $result = $this->app_db->insert(
64 - "{$this->app_db->prefix}bitforms_form_log_details",
65 - $data
66 - );
67 - return $this->getResult($result);
52 + return $this->app_db->get_results($sql);
53 + }
54 +
55 + public function form_log_insert($data = [])
56 + {
57 + if (is_null($data)) {
58 + return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
68 59 }
60 + $result = $this->app_db->insert(
61 + "{$this->app_db->prefix}bitforms_form_entry_log",
62 + $data
63 + );
64 + return $this->getResult($result);
65 + }
69 66
70 - public function get_form_value($form_id = "")
71 - {
72 - $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$form_id";
73 - return $this->execute($sql)->getResult();
67 + public function log_history_insert($data = [])
68 + {
69 + if (is_null($data)) {
70 + return new WP_Error('empty_data', __('Form data is empty', 'bit-form'));
74 71 }
75 - public function logUpdate($updateValue, $logID)
76 - {
77 - if (empty($logID)) {
78 - return false;
79 - }
80 - $sql = "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID";
81 - return $this->execute($sql)->getResult();
72 + $result = $this->app_db->insert(
73 + "{$this->app_db->prefix}bitforms_form_log_details",
74 + $data
75 + );
76 + return $this->getResult($result);
77 + }
78 +
79 + public function get_form_value($form_id = '')
80 + {
81 + $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->app_db->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$form_id";
82 + return $this->execute($sql)->getResult();
83 + }
84 +
85 + public function logUpdate($updateValue, $logID)
86 + {
87 + if (empty($logID)) {
88 + return false;
82 89 }
90 + $sql = "UPDATE `{$this->app_db->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID";
91 + return $this->execute($sql)->getResult();
92 + }
83 93 }