PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
← All changes | WPDataAccess/API/WPDA_QB.php +81 -26 5.5.425.5.84 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace WPDataAccess\API;
4 4
5 +use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists;
5 6 use WPDataAccess\Query_Builder\WPDA_Query_Builder;
6 7 use WPDataAccess\Query_Builder\WPDA_Query_Builder_Scheduler;
7 8 use WPDataAccess\Utilities\WPDA_Mail;
8 9 use WPDataAccess\WPDA;
@@ -46,21 +47,28 @@
46 47 'methods' => array('POST'),
47 48 'callback' => array($this, 'save'),
48 49 'permission_callback' => '__return_true',
49 50 'args' => array(
50 - 'access' => $this->get_param( 'access' ),
51 - 'dbs' => $this->get_param( 'dbs' ),
52 - 'name' => $this->get_param( 'name' ),
53 - 'query' => $this->get_param( 'query' ),
54 - 'vqb' => $this->get_param( 'vqb' ),
55 - 'old_name' => array(
51 + 'access' => $this->get_param( 'access' ),
52 + 'dbs' => $this->get_param( 'dbs' ),
53 + 'name' => $this->get_param( 'name' ),
54 + 'query' => $this->get_param( 'query' ),
55 + 'is_visual' => array(
56 56 'required' => false,
57 + 'type' => 'boolean',
58 + 'description' => __( 'Is Visual Query?', 'wp-data-access' ),
59 + 'sanitize_callback' => 'sanitize_text_field',
60 + 'validate_callback' => 'rest_validate_request_arg',
61 + ),
62 + 'vqb' => $this->get_param( 'vqb' ),
63 + 'old_name' => array(
64 + 'required' => false,
57 65 'type' => 'string',
58 66 'description' => __( 'Old query name', 'wp-data-access' ),
59 67 'sanitize_callback' => 'sanitize_text_field',
60 68 'validate_callback' => 'rest_validate_request_arg',
61 69 ),
62 - 'insert' => array(
70 + 'insert' => array(
63 71 'required' => false,
64 72 'type' => 'boolean',
65 73 'description' => __( 'Perform insert', 'wp-data-access' ),
66 74 'sanitize_callback' => 'sanitize_text_field',
@@ -65,9 +73,9 @@
65 73 'description' => __( 'Perform insert', 'wp-data-access' ),
66 74 'sanitize_callback' => 'sanitize_text_field',
67 75 'validate_callback' => 'rest_validate_request_arg',
68 76 ),
69 - 'params' => $this->get_param( 'params' ),
77 + 'params' => $this->get_param( 'params' ),
70 78 ),
71 79 ) );
72 80 register_rest_route( WPDA_API::WPDA_NAMESPACE, 'qb/delete', array(
73 81 'methods' => array('POST'),
@@ -150,10 +158,59 @@
150 158 'name' => $this->get_param( 'name' ),
151 159 'params' => $this->get_param( 'params' ),
152 160 ),
153 161 ) );
162 + register_rest_route( WPDA_API::WPDA_NAMESPACE, 'qb/vqb/get', array(
163 + 'methods' => array('POST'),
164 + 'callback' => array($this, 'vqb_get'),
165 + 'permission_callback' => '__return_true',
166 + 'args' => array(
167 + 'access' => $this->get_param( 'access' ),
168 + 'name' => $this->get_param( 'name' ),
169 + ),
170 + ) );
171 + register_rest_route( WPDA_API::WPDA_NAMESPACE, 'qb/vqb/tbl', array(
172 + 'methods' => array('POST'),
173 + 'callback' => array($this, 'vqb_tbl'),
174 + 'permission_callback' => '__return_true',
175 + 'args' => array(
176 + 'dbs' => $this->get_param( 'dbs' ),
177 + 'tbl' => $this->get_param( 'tbl' ),
178 + ),
179 + ) );
154 180 }
155 181
182 + public function vqb_tbl( $request ) {
183 + if ( !$this->current_user_can_access() ) {
184 + return $this->unauthorized();
185 + }
186 + if ( !$this->current_user_token_valid( $request ) ) {
187 + return $this->invalid_nonce();
188 + }
189 + $dbs = $request->get_param( 'dbs' );
190 + $tbl = $request->get_param( 'tbl' );
191 + $cols = WPDA_Dictionary_Lists::get_table_widget_info( $dbs, $tbl );
192 + return $this->WPDA_Rest_Response( '', $cols );
193 + }
194 +
195 + public function vqb_get( $request ) {
196 + if ( !$this->current_user_can_access() ) {
197 + return $this->unauthorized();
198 + }
199 + if ( !$this->current_user_token_valid( $request ) ) {
200 + return $this->invalid_nonce();
201 + }
202 + $access = $request->get_param( 'access' );
203 + $name = $request->get_param( 'name' );
204 + $qb = new WPDA_Query_Builder();
205 + if ( 'user' === $access ) {
206 + $query = $qb->get_visual_query( $name );
207 + } else {
208 + $query = maybe_unserialize( $qb->get_visual_query_global( $name ) );
209 + }
210 + return $this->WPDA_Rest_Response( '', $query );
211 + }
212 +
156 213 public function open( $request ) {
157 214 if ( !$this->current_user_can_access() ) {
158 215 return $this->unauthorized();
159 216 }
@@ -205,8 +262,9 @@
205 262 $access = $request->get_param( 'access' );
206 263 $dbs = $request->get_param( 'dbs' );
207 264 $name = $request->get_param( 'name' );
208 265 $query = $request->get_param( 'query' );
266 + $is_visual = '1' === $request->get_param( 'is_visual' );
209 267 $vqb = $request->get_param( 'vqb' );
210 268 $old_name = $request->get_param( 'old_name' ) ?? '';
211 269 $insert = '1' === $request->get_param( 'insert' );
212 270 $params = $request->get_param( 'params' );
@@ -222,8 +280,9 @@
222 280 $dbs,
223 281 $name,
224 282 $query,
225 283 $old_name,
284 + $is_visual,
226 285 $vqb,
227 286 $params
228 287 );
229 288 }
@@ -237,8 +296,9 @@
237 296 $dbs,
238 297 $name,
239 298 $query,
240 299 $old_name,
300 + $is_visual,
241 301 $vqb,
242 302 $params
243 303 );
244 304 }
@@ -282,8 +342,9 @@
282 342 $access_to = $request->get_param( 'access_to' );
283 343 $to_name = $request->get_param( 'to' );
284 344 $qb = new WPDA_Query_Builder();
285 345 $source = ( 'user' === $access_from ? $qb->get_query( $from_name ) : $qb->get_query_global( $from_name ) );
346 + $visual = ( 'user' === $access_from ? $qb->get_visual_query( $from_name ) : maybe_unserialize( $qb->get_visual_query_global( $from_name ) ) );
286 347 if ( 0 === count( $source ) ) {
287 348 return new \WP_Error('error', 'Source query not found', array(
288 349 'status' => 403,
289 350 ));
@@ -291,13 +352,19 @@
291 352 if ( 'user' === $access_to ) {
292 353 $saved = $qb->get_query( $to_name );
293 354 if ( 0 === count( $saved ) ) {
294 355 $qb->add_query( $to_name, $source );
356 + if ( !empty( $visual ) ) {
357 + $qb->upd_visual_query( $to_name, $visual );
358 + }
295 359 }
296 360 } else {
297 361 $saved = $qb->get_query_global( $to_name );
298 362 if ( 0 === count( $saved ) ) {
299 363 $qb->add_query_global( $to_name, $source );
364 + if ( !empty( $visual ) ) {
365 + $qb->upd_visual_query_global( $to_name, $visual );
366 + }
300 367 }
301 368 }
302 369 if ( 0 === count( $saved ) ) {
303 370 return $this->WPDA_Rest_Response( '' );
@@ -342,31 +409,19 @@
342 409 }
343 410 }
344 411
345 412 public function cron_schedules( $request ) {
346 - if ( !$this->current_user_can_access() ) {
347 - return $this->unauthorized();
348 - }
349 - if ( !$this->current_user_token_valid( $request ) ) {
350 - return $this->invalid_nonce();
351 - }
413 + // This feature is implemented in the premium version
414 + return $this->unauthorized();
352 415 }
353 416
354 417 public function cron_add( $request ) {
355 - if ( !$this->current_user_can_access() ) {
356 - return $this->unauthorized();
357 - }
358 - if ( !$this->current_user_token_valid( $request ) ) {
359 - return $this->invalid_nonce();
360 - }
418 + // This feature is implemented in the premium version
419 + return $this->unauthorized();
361 420 }
362 421
363 422 public function cron_delete( $request ) {
364 - if ( !$this->current_user_can_access() ) {
365 - return $this->unauthorized();
366 - }
367 - if ( !$this->current_user_token_valid( $request ) ) {
368 - return $this->invalid_nonce();
369 - }
423 + // This feature is implemented in the premium version
424 + return $this->unauthorized();
370 425 }
371 426
372 427 }