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

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