PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.13
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.13
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 / Database / ApiModel.php

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

180 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Database;
4
5 use BitCode\BitForm\Core\Util\IpTool;
6
7 /**
8 * Undocumented class
9 */
10
11 class ApiModel extends Model
12 {
13 public $_wpdb;
14
15 public function __construct()
16 {
17 global $wpdb;
18 $this->_wpdb = $wpdb;
19 }
20
21 public function getForm()
22 {
23 $result = $this->_wpdb->get_results(
24 "
25 SELECT form_name,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 order By created_at DESC
26 "
27 );
28 return $result;
29 }
30
31 public function getField($id)
32 {
33 $result = $this->_wpdb->get_results(
34 $this->_wpdb->prepare(
35 "SELECT form_content,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 AND `id`=%d",
36 $id
37 )
38 );
39 return $result;
40 }
41
42 public function editEntry($entryID)
43 {
44 $result = $this->_wpdb->get_results(
45 $this->_wpdb->prepare(
46 "SELECT bitforms_form_entry_id,meta_key,meta_value FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `bitforms_form_entry_id`=%d",
47 $entryID
48 )
49 );
50 return $result;
51 }
52
53 public function entryDelete($entryID)
54 {
55 $sql = $this->_wpdb->prepare(
56 "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `bitforms_form_entry_id` = %d",
57 $entryID
58 );
59 $result = $this->_wpdb->query($sql);
60 return $result;
61 }
62
63 public function findRecord($table_name, $column, $value)
64 {
65 $result = $this->_wpdb->get_results(
66 "
67 SELECT $column FROM `{$this->_wpdb->prefix}$table_name` WHERE `$column`='$value'
68 "
69 );
70 return $result;
71 }
72
73 public function noteCreate($formID, $entryID, $note_details)
74 {
75 $ipTool = new IpTool();
76 $user_details = $ipTool->getUserDetail();
77 $result = $this->_wpdb->insert(
78 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
79 [
80 'info_type' => 'note',
81 'info_details' => $note_details,
82 'form_id' => $formID,
83 'entry_id' => $entryID,
84 'user_id' => $user_details['id'],
85 'user_ip' => $user_details['ip'],
86 'created_at' => $user_details['time'],
87 ]
88 );
89 return $result;
90 }
91
92 public function noteList()
93 {
94 $result = $this->_wpdb->get_results(
95 "
96 SELECT * FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `status`=1
97 "
98 );
99 return $result;
100 }
101
102 public function getWorkFlow($formID)
103 {
104 $result = $this->_wpdb->get_results(
105 $this->_wpdb->prepare(
106 "SELECT workflow_name,id FROM `{$this->_wpdb->prefix}bitforms_workflows` WHERE `form_id` = %d",
107 $formID
108 )
109 );
110 return $result;
111 }
112
113 public function noteUpdate($noteID, $note_details)
114 {
115 $data = ['info_details' => $note_details];
116 $result = $this->_wpdb->update(
117 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
118 $data,
119 [
120 'id' => $noteID,
121 ]
122 );
123 return $result;
124 }
125
126 public function noteDelete($noteID)
127 {
128 $sql = $this->_wpdb->prepare(
129 "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `id` = %d",
130 $noteID
131 );
132 $result = $this->_wpdb->query($sql);
133 return $result;
134 }
135
136 public function get_form_value($entryID)
137 {
138 $sql = $this->_wpdb->prepare(
139 "SELECT `meta_key`,`meta_value` FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE bitforms_form_entry_id=%d",
140 $entryID
141 );
142 $result = $this->_wpdb->get_results($sql);
143 return $result;
144 }
145
146 public function logUpdate($updateValue, $logID)
147 {
148 if (empty($logID)) {
149 return false;
150 }
151 $sql = $this->_wpdb->prepare(
152 "UPDATE `{$this->_wpdb->prefix}bitforms_form_entry_log` SET content=%s WHERE id=%d",
153 $updateValue,
154 $logID
155 );
156 $result = $this->_wpdb->get_results($sql);
157 return $result;
158 }
159
160 public function getFormId($formID)
161 {
162 $sql = $this->_wpdb->prepare(
163 "SELECT form_id FROM `{$this->_wpdb->prefix}bitforms_form_entries` WHERE id=%d",
164 $formID
165 );
166 $result = $this->_wpdb->get_results($sql);
167 return $result;
168 }
169
170 public function getOnSubmitWorkflow($formID)
171 {
172 $sql = $this->_wpdb->prepare(
173 "SELECT `id`, `workflow_name`, `workflow_type`, `workflow_run`, `workflow_behaviour`, `workflow_status` FROM `{$this->_wpdb->prefix}bitforms_workflows` WHERE `form_id`=%d AND `workflow_type`='onsubmit' ORDER BY id DESC",
174 $formID
175 );
176 $result = $this->_wpdb->get_results($sql);
177 return $result;
178 }
179 }
180