| @@ -13,15 +13,14 @@ | ||
| 13 | 13 | protected static $table = 'bitforms_form_log_details'; |
| 14 | 14 | |
| 15 | 15 | public function geLogHistory($form_id, $entry_id) |
| 16 | 16 | { |
| 17 | - $sql = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_entry_log` where form_entry_id=$entry_id AND form_id=$form_id order By created_at DESC"; | |
| 18 | - | |
| 19 | - $logs = $this->execute($sql)->getResult(); | |
| 17 | + $sql = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_entry_log` where form_entry_id=%d AND form_id=%d order By created_at DESC"; | |
| 18 | + $logs = $this->execute($sql, [$entry_id, $form_id])->getResult(); | |
| 20 | 19 | $response = ['success' => true, 'data' => [], 'integrations' => []]; |
| 21 | 20 | $ids = []; |
| 22 | 21 | foreach ($logs as $log) { |
| 23 | - $ids[] = $log->id; | |
| 22 | + $ids[] = (int) $log->id; | |
| 24 | 23 | } |
| 25 | 24 | if (isset($logs->errors['result_empty'])) { |
| 26 | 25 | wp_send_json($response); |
| 27 | 26 | } else { |
| @@ -27,18 +26,21 @@ | ||
| 27 | 26 | } else { |
| 28 | 27 | $allLogId = preg_replace('/"/', '', implode(',', $ids)); |
| 29 | 28 | $sql2 = "SELECT * FROM `{$this->app_db->prefix}bitforms_form_log_details` WHERE `log_id` IN ($allLogId)"; |
| 30 | 29 | $integrations = $this->execute($sql2)->getResult(); |
| 31 | - foreach ($logs as $key => $log) { | |
| 32 | - foreach ($integrations as $integration) { | |
| 33 | - if ($integration->log_id === $log->id) { | |
| 34 | - $logs[$key]->integration = true; | |
| 30 | + | |
| 31 | + if (isset($integrations->errors['result_empty'])) { | |
| 32 | + $integrations = []; | |
| 33 | + } else { | |
| 34 | + foreach ($logs as $key => $log) { | |
| 35 | + foreach ($integrations as $integration) { | |
| 36 | + if ($integration->log_id === $log->id) { | |
| 37 | + $logs[$key]->integration = true; | |
| 38 | + } | |
| 35 | 39 | } |
| 36 | 40 | } |
| 37 | 41 | } |
| 38 | - if (isset($integrations->errors['result_empty'])) { | |
| 39 | - $integrations = []; | |
| 40 | - } | |
| 42 | + | |
| 41 | 43 | wp_send_json(['success' => true, 'data' => $logs, 'integrations' => $integrations]); |
| 42 | 44 | } |
| 43 | 45 | } |
| 44 | 46 | |