| @@ -109,11 +109,16 @@ | ||
| 109 | 109 | $grid_css = '<style>.wpufTable {display: table; width: 100%; } .wpufTableRow {display: table-row; } .wpufTableRow:nth-child(even) {background-color: #f5f5f5; } .wpufTableHeading {background-color: #eee; display: table-header-group; font-weight: bold; } .wpufTableCell, .wpufTableHead {border: none; display: table-cell; padding: 3px 10px; } .wpufTableFoot {background-color: #eee; display: table-footer-group; font-weight: bold; } .wpufTableBody {display: table-row-group; }</style>'; |
| 110 | 110 | |
| 111 | 111 | $values = []; |
| 112 | 112 | |
| 113 | - $query = "SELECT * FROM {$wpdb->weforms_entries} as entry | |
| 114 | - LEFT JOIN {$wpdb->weforms_entrymeta} AS meta ON entry.id = meta.weforms_entry_id | |
| 115 | - WHERE entry.id = {$this->id}"; | |
| 113 | + $query = $wpdb->prepare( | |
| 114 | + " | |
| 115 | + SELECT * FROM {$wpdb->weforms_entries} as entry | |
| 116 | + LEFT JOIN {$wpdb->weforms_entrymeta} AS meta ON entry.id = meta.weforms_entry_id | |
| 117 | + WHERE entry.id = %d | |
| 118 | + ", | |
| 119 | + $this->id | |
| 120 | + ); | |
| 116 | 121 | |
| 117 | 122 | $results = $wpdb->get_results( $query ); |
| 118 | 123 | |
| 119 | 124 | if ( $results ) { |
| @@ -419,6 +424,36 @@ | ||
| 419 | 424 | return; |
| 420 | 425 | } |
| 421 | 426 | |
| 422 | 427 | return $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}weforms_payments WHERE entry_id = {$this->id} " ); |
| 428 | + } | |
| 429 | + | |
| 430 | + /** | |
| 431 | + * Get Form from entry id. | |
| 432 | + * | |
| 433 | + * @param int $entry_id The entry id. | |
| 434 | + * @global object $wpdb The Wordpress database object. | |
| 435 | + * | |
| 436 | + * @return object The form object. | |
| 437 | + */ | |
| 438 | + public static function get_form( $entry_id ) { | |
| 439 | + $form_id = self::get_form_id( $entry_id ); | |
| 440 | + | |
| 441 | + return ! empty( $form_id ) ? weforms()->form->get( $form_id ) : null; | |
| 442 | + } | |
| 443 | + | |
| 444 | + /** | |
| 445 | + * Get form id from entry id. | |
| 446 | + * | |
| 447 | + * @param int $entry_id The entry id. | |
| 448 | + * @global object $wpdb The Wordpress database object. | |
| 449 | + * | |
| 450 | + * @return int The form id. | |
| 451 | + */ | |
| 452 | + public static function get_form_id( $entry_id ) { | |
| 453 | + global $wpdb; | |
| 454 | + | |
| 455 | + $results = $wpdb->get_results( $wpdb->prepare( "SELECT form_id FROM {$wpdb->prefix}weforms_entries WHERE id = %d ", $entry_id ) ); | |
| 456 | + | |
| 457 | + return ! empty( $results[0]->form_id ) ? $results[0]->form_id : null; | |
| 423 | 458 | } |
| 424 | 459 | } |