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

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

149 lines 4.2 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\Database\Model;
6 use BitCode\BitForm\Core\Util\IpTool;
7
8 /**
9 * Undocumented class
10 */
11
12 class ApiModel extends Model
13 {
14 public function __construct()
15 {
16 global $wpdb;
17 $this->_wpdb = $wpdb;
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 array(
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 $result = $this->_wpdb->get_results(
97 "
98 SELECT workflow_name,id FROM `{$this->_wpdb->prefix}bitforms_workflows` WHERE `form_id`= $formID
99 "
100 );
101 return $result;
102 }
103
104 public function noteUpdate($noteID, $note_details)
105 {
106 $data = array('info_details' => $note_details,);
107 $result = $this->_wpdb->update(
108 "{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo",
109 $data,
110 array(
111 'id' => $noteID,
112 )
113 );
114 return $result;
115 }
116
117 public function noteDelete($noteID)
118 {
119 $sql = "DELETE FROM `{$this->_wpdb->prefix}bitforms_form_entry_relatedinfo` WHERE `id` = $noteID";
120 $result = $this->_wpdb->query($sql);
121 return $result;
122 }
123
124 public function get_form_value($entryID){
125
126 $sql = "SELECT `meta_key`,`meta_value` FROM `{$this->_wpdb->prefix}bitforms_form_entrymeta` where bitforms_form_entry_id=$entryID";
127 $result = $this->_wpdb->get_results($sql);
128 return $result;
129
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 $sql = "SELECT form_id FROM `{$this->_wpdb->prefix}bitforms_form_entries` WHERE id=$formID";
144 $result = $this->_wpdb->get_results($sql);
145 return $result;
146 }
147
148 }
149