| @@ -10,45 +10,44 @@ | ||
| 10 | 10 | * Undocumented class |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | use WP_Error; |
| 14 | -use BitCode\BitForm\Core\Database\Model; | |
| 15 | 14 | |
| 16 | 15 | class FormEntryModel extends Model |
| 17 | 16 | { |
| 18 | - protected static $table = 'bitforms_form_entries'; | |
| 17 | + protected static $table = 'bitforms_form_entries'; | |
| 19 | 18 | |
| 20 | - public function bulkDelete(array $condition = null) | |
| 21 | - { | |
| 22 | - if ( | |
| 23 | - !\is_null($condition) | |
| 24 | - && \is_array($condition) | |
| 25 | - && array_keys($condition) !== range(0, count($condition) - 1) | |
| 26 | - ) { | |
| 27 | - $delete_condition = $condition; | |
| 28 | - } else { | |
| 29 | - return new WP_Error( | |
| 30 | - 'deletion_error', | |
| 31 | - __('At least 1 condition needed', 'bit-form') | |
| 32 | - ); | |
| 33 | - } | |
| 34 | - $formatted_conditions = $this->getFormatedCondition($delete_condition); | |
| 35 | - if ($formatted_conditions) { | |
| 36 | - $condition_to_check = $formatted_conditions['conditions']; | |
| 37 | - $all_values = $formatted_conditions['values']; | |
| 38 | - } else { | |
| 39 | - $condition_to_check = null; | |
| 40 | - return new WP_Error( | |
| 41 | - 'deletion_error', | |
| 42 | - __('At least 1 condition needed', 'bit-form') | |
| 43 | - ); | |
| 44 | - } | |
| 45 | - $prefix = $this->app_db->prefix; | |
| 46 | - $sql = "DELETE `{$prefix}bitforms_form_entries`,`{$prefix}bitforms_form_entrymeta` FROM " | |
| 47 | - . "`{$prefix}bitforms_form_entries` " | |
| 48 | - . " INNER JOIN `{$prefix}bitforms_form_entrymeta` ON " | |
| 49 | - . " `{$prefix}bitforms_form_entries`.`id` " | |
| 50 | - . "= `{$prefix}bitforms_form_entrymeta`.`bitforms_form_entry_id` " | |
| 51 | - . " $condition_to_check"; | |
| 52 | - return $this->execute($sql, $all_values)->getResult(); | |
| 19 | + public function bulkDelete(array $condition = null) | |
| 20 | + { | |
| 21 | + if ( | |
| 22 | + !\is_null($condition) | |
| 23 | + && \is_array($condition) | |
| 24 | + && array_keys($condition) !== range(0, count($condition) - 1) | |
| 25 | + ) { | |
| 26 | + $delete_condition = $condition; | |
| 27 | + } else { | |
| 28 | + return new WP_Error( | |
| 29 | + 'deletion_error', | |
| 30 | + __('At least 1 condition needed', 'bit-form') | |
| 31 | + ); | |
| 53 | 32 | } |
| 33 | + $formatted_conditions = $this->getFormatedCondition($delete_condition); | |
| 34 | + if ($formatted_conditions) { | |
| 35 | + $condition_to_check = $formatted_conditions['conditions']; | |
| 36 | + $all_values = $formatted_conditions['values']; | |
| 37 | + } else { | |
| 38 | + $condition_to_check = null; | |
| 39 | + return new WP_Error( | |
| 40 | + 'deletion_error', | |
| 41 | + __('At least 1 condition needed', 'bit-form') | |
| 42 | + ); | |
| 43 | + } | |
| 44 | + $prefix = $this->app_db->prefix; | |
| 45 | + $sql = "DELETE `{$prefix}bitforms_form_entries`,`{$prefix}bitforms_form_entrymeta` FROM " | |
| 46 | + . "`{$prefix}bitforms_form_entries` " | |
| 47 | + . " INNER JOIN `{$prefix}bitforms_form_entrymeta` ON " | |
| 48 | + . " `{$prefix}bitforms_form_entries`.`id` " | |
| 49 | + . "= `{$prefix}bitforms_form_entrymeta`.`bitforms_form_entry_id` " | |
| 50 | + . " $condition_to_check"; | |
| 51 | + return $this->execute($sql, $all_values)->getResult(); | |
| 52 | + } | |
| 54 | 53 | } |