PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.9
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.9
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 / API / Controller / NoteController.php

NoteController.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 1.9, at includes/API/Controller/NoteController.php

140 lines 4.0 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\API\Controller;
4
5 use WP_REST_Controller;
6 use BitCode\BitForm\Core\Database\ApiModel;
7 use WP_Error;
8 class NoteController extends WP_REST_Controller
9 {
10 public function __construct(){
11 global $wpdb;
12 $this->_wpdb = $wpdb;
13 }
14 public function get_notes(){
15 $db = new ApiModel();
16 $notes = $db->noteList();
17 if($notes){
18 return rest_ensure_response(['data'=>$notes,'success'=>true,'status'=>200]);
19 }else{
20 return new WP_Error(
21 'empty',
22 __( 'Internal Server Error' ),
23 [
24 'status' => 500,
25 'success'=>false,
26 ]
27 );
28 }
29 }
30
31 public function create_note( $request ){
32 $form_id = $_POST['form_id'];
33 $entry_id = $_POST['entry_id'];
34 $info_details = $_POST['info_details'];
35
36 if(empty($form_id) || empty($entry_id)){
37 return new WP_Error(
38 'empty',
39 __( 'Form ID Or Entry ID is Empty ' ),
40 [
41 'status' => 422,
42 'success'=>false,
43 ]
44 );
45 }
46 $db = new ApiModel();
47 $create = $db->noteCreate( $form_id,$entry_id,$info_details );
48 if($create){
49 return rest_ensure_response(['messsage'=>'successfully note created','success'=>true,'status'=>200]);
50 }else{
51 return new WP_Error(
52 'empty',
53 __( 'Internal Server Error' ),
54 [
55 'status' => 500,
56 'success' => false,
57 ]
58 );
59 }
60 }
61
62 public function note_edit( $request ){
63 $db = new ApiModel();
64 $id = $request['id'];
65 $existData = $db->findRecord("bitforms_form_entry_relatedinfo",'id',$id);
66 if(count($existData)===0){
67 return new WP_Error(
68 'empty',
69 __( 'Record Not Found' ),
70 [
71 'status' => 404,
72 'success'=>false,
73 ]
74 );
75 }
76 return $existData;
77 }
78
79 public function note_update( $request ){
80 $info_details = $_POST['info_details'];
81 $note_id = $request['id'];
82 $db = new ApiModel();
83 $existData = $db->findRecord("bitforms_form_entry_relatedinfo",'id',$note_id);
84 if(count($existData)===0){
85 return new WP_Error(
86 'empty',
87 __( 'Record Not Found' ),
88 [
89 'status' => 404,
90 'success'=>false,
91 ]
92 );
93 }
94 $update = $db->noteUpdate( $note_id,$info_details );
95 if($update){
96 return rest_ensure_response(['messsage'=>'successfully note updated','success'=>true,'status'=>200]);
97 }else{
98 return new WP_Error(
99 'empty',
100 __( 'Internal Server Error' ),
101 [
102 'status' => 500,
103 'success'=>false,
104 ]
105 );
106 }
107
108 }
109
110 public function note_delete( $request ){
111
112 $note_id = $request['id'];
113 $db = new ApiModel();
114 $existData = $db->findRecord("bitforms_form_entry_relatedinfo",'id',$note_id);
115 if(count($existData)===0){
116 return new WP_Error(
117 'empty',
118 __( 'Record Not Found' ),
119 [
120 'status' => 404,
121 'success'=>false,
122 ]
123 );
124 }
125 $delete = $db->noteDelete( $note_id );
126
127 if($delete){
128 return rest_ensure_response(['messsage'=>'successfully note deleted','success'=>true,'status'=>200]);
129 }else{
130 return new WP_Error(
131 'empty',
132 __( 'Internal Server Error' ),
133 [
134 'status' => 500,
135 'success'=>false,
136 ]
137 );
138 }
139 }
140 }