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

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