| @@ -13,16 +13,9 @@ | ||
| 13 | 13 | $reportMdl = new ReportsModel(); |
| 14 | 14 | global $wpdb; |
| 15 | 15 | $tablename = $wpdb->prefix . 'bitforms_reports'; |
| 16 | 16 | |
| 17 | - // $latestIds = $wpdb->get_results("SELECT MAX(`id`) as latest_id FROM $tablename GROUP BY `context`"); | |
| 18 | - // Direct query: table name from $wpdb->prefix concatenation (no user input). $wpdb->prepare() cannot parameterize table names. | |
| 19 | - $wpdb->query( | |
| 20 | - $wpdb->prepare( | |
| 21 | - "SELECT MAX(`id`) as latest_id FROM `{$tablename}` GROUP BY `context`" | |
| 22 | - ) | |
| 23 | - ); | |
| 24 | - $latestIds = $wpdb->last_result; | |
| 17 | + $latestIds = $wpdb->get_results("SELECT MAX(`id`) as latest_id FROM $tablename GROUP BY `context`"); | |
| 25 | 18 | |
| 26 | 19 | $notDeletedIds = array_column($latestIds, 'latest_id'); |
| 27 | 20 | |
| 28 | 21 | if (!is_wp_error($latestIds) && count($notDeletedIds) > 0) { |
| @@ -38,9 +31,9 @@ | ||
| 38 | 31 | ['id'] |
| 39 | 32 | ); |
| 40 | 33 | |
| 41 | 34 | $details = [ |
| 42 | - 'report_name' => __('All Entries', 'bit-form'), | |
| 35 | + 'report_name' => 'All Entries', | |
| 43 | 36 | 'hiddenColumns' => [], |
| 44 | 37 | 'pageSize' => 10, |
| 45 | 38 | 'sortBy' => [], |
| 46 | 39 | 'filters' => [], |
| @@ -71,38 +64,8 @@ | ||
| 71 | 64 | 'updated_at' => $user_details['time'], |
| 72 | 65 | ]; |
| 73 | 66 | |
| 74 | 67 | $reportMdl->insert($defaultReport); |
| 75 | - } | |
| 76 | - } | |
| 77 | - } | |
| 78 | - | |
| 79 | - public function addHiddenColumns() | |
| 80 | - { | |
| 81 | - $reportMdl = new ReportsModel(); | |
| 82 | - $reports = $reportMdl->get( | |
| 83 | - [ | |
| 84 | - 'id', | |
| 85 | - 'details', | |
| 86 | - ], | |
| 87 | - [ | |
| 88 | - 'category' => 'form', | |
| 89 | - 'type' => 'table', | |
| 90 | - ] | |
| 91 | - ); | |
| 92 | - | |
| 93 | - foreach ($reports as $report) { | |
| 94 | - $reportDetails = json_decode($report->details); | |
| 95 | - if (is_object($reportDetails) && (!property_exists($reportDetails, 'hiddenColumns') || empty($reportDetails->hiddenColumns))) { | |
| 96 | - $reportDetails->hiddenColumns = ['__user_id', '__user_ip', '__referer', '__user_device', '__created_at', '__updated_at']; | |
| 97 | - $reportMdl->update( | |
| 98 | - [ | |
| 99 | - 'details' => wp_json_encode($reportDetails), | |
| 100 | - ], | |
| 101 | - [ | |
| 102 | - 'id' => $report->id, | |
| 103 | - ] | |
| 104 | - ); | |
| 105 | 68 | } |
| 106 | 69 | } |
| 107 | 70 | } |
| 108 | 71 | } |