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
bit-form / includes / Core / Database / ApiModel.php

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

149 lines 3.7 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 function __construct()
14 {
15 global $wpdb;
16 $this->_wpdb = $wpdb;
17 }
18
19 public function getForm()
20 {
21 $result = $this->_wpdb->get_results(
22 "
23 SELECT form_name,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 order By created_at DESC
24 "
25 );
26 return $result;
27 }
28
29 public function getField($id)
30 {
31 $result = $this->_wpdb->get_results(
32 "
33 SELECT form_content,id FROM `{$this->_wpdb->prefix}bitforms_form` WHERE `status`=1 AND `id`='$id'
34 "
35 );
36 return $result;
37 }
38
39 public function editEntry($entryID)
40 {
41 $result = $this->_wpdb->get_results(
42 "
43 SELECT bitforms_form_entry_id,meta_key,meta_value FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `bitforms_form_entry_id`='$entryID'
44 "
45 );
46 return $result;
47 }
48
49 public function entryDelete($entryID)
50 {
51 $sql = "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` WHERE `bitforms_form_entry_id` = $entryID";
52 $result = $this->_wpdb->query($sql);
53 return $result;
54 }
55
56 public function findRecord($table_name, $column, $value)
57 {
58 $result = $this->_wpdb->get_results(
59 "
60 SELECT $column FROM `{$this->_wpdb->prefix}$table_name` WHERE `$column`='$value'
61 "
62 );
63 return $result;
64 }
65
66 public function noteCreate($formID, $entryID, $note_details)
67 {
68 $ipTool = new IpTool();
69 $user_details = $ipTool->getUserDetail();
70 $result = $this->_wpdb->insert(
71 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
72 [
73 'info_type' => 'note',
74 'info_details' => $note_details,
75 'form_id' => $formID,
76 'entry_id' => $entryID,
77 'user_id' => $user_details['id'],
78 'user_ip' => $user_details['ip'],
79 'created_at' => $user_details['time'],
80 ]
81 );
82 return $result;
83 }
84
85 public function noteList()
86 {
87 $result = $this->_wpdb->get_results(
88 "
89 SELECT * FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `status`=1
90 "
91 );
92 return $result;
93 }
94
95 public function getWorkFlow($formID)
96 {
97 $result = $this->_wpdb->get_results(
98 "
99 SELECT workflow_name,id FROM `{$this->_wpdb->prefix}bitforms_workflows` WHERE `form_id`= $formID
100 "
101 );
102 return $result;
103 }
104
105 public function noteUpdate($noteID, $note_details)
106 {
107 $data = ['info_details' => $note_details];
108 $result = $this->_wpdb->update(
109 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
110 $data,
111 [
112 'id' => $noteID,
113 ]
114 );
115 return $result;
116 }
117
118 public function noteDelete($noteID)
119 {
120 $sql = "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `id` = $noteID";
121 $result = $this->_wpdb->query($sql);
122 return $result;
123 }
124
125 public function get_form_value($entryID)
126 {
127 $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$entryID";
128 $result = $this->_wpdb->get_results($sql);
129 return $result;
130 }
131
132 public function logUpdate($updateValue, $logID)
133 {
134 if (empty($logID)) {
135 return false;
136 }
137 $sql = "UPDATE `{$this->_wpdb->prefix}bitforms_form_entry_log` SET content='$updateValue' WHERE id=$logID";
138 $result = $this->_wpdb->get_results($sql);
139 return $result;
140 }
141
142 public function getFormId($formID)
143 {
144 $sql = "SELECT form_id FROM `{$this->_wpdb->prefix}bitforms_form_entries` WHERE id=$formID";
145 $result = $this->_wpdb->get_results($sql);
146 return $result;
147 }
148 }
149