PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / v1 / includes / Core / Database / ReportsModel.php

ReportsModel.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.9.1, at v1/includes/Core/Database/ReportsModel.php

94 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Provides Report Model Class
4 */
5 namespace BitCode\BitForm\Core\Database;
6
7 use BitCode\BitForm\Core\Database\Model;
8 use WP_Error;
9
10 /**
11 *
12 */
13 class ReportsModel extends Model
14 {
15 protected static $table = 'bitforms_reports';
16
17 public function validateReportFields($reportData, $fieldNames)
18 {
19 $reportDetails = [];
20 switch ($reportData->type) {
21 case 'table':
22 $tableAction = "table_ac";
23 $reportDetails = !is_string($reportData->details)? $reportData->details : json_decode($reportData->details);
24 if (!empty($reportDetails->order)) {
25 $initialOrder = $fieldNames;
26 $columnOrder = $reportDetails->order;
27 foreach ($reportDetails->order as $key => $value) {
28 if (isset($initialOrder[$value])) {
29 unset($initialOrder[$value]);
30 } elseif (!isset($initialOrder[$value])) {
31 unset($columnOrder[$key]);
32 }
33 }
34 $columnOrder = array_values($columnOrder);
35 if (!empty($initialOrder)) {
36 foreach ($initialOrder as $name => $label) {
37 $columnOrder[] = $name;
38 }
39 }
40 $columnOrder[] = $tableAction;
41 array_unshift($columnOrder, 'selection', 'sl');
42 $reportDetails->order = $columnOrder;
43 }
44 if (!empty($reportDetails->hiddenColumns)) {
45 $hiddenColumns = $reportDetails->hiddenColumns;
46 foreach ($reportDetails->hiddenColumns as $key => $value) {
47 if (!isset($fieldNames[$value]) && ($value !== 'sl' && $value !== 'selection' && $value !== 'table_ac')) {
48 unset($hiddenColumns[$key]);
49 }
50 }
51 $reportDetails->hiddenColumns = array_values($hiddenColumns);
52 }
53 break;
54
55 default:
56 break;
57 }
58 return $reportDetails;
59 }
60
61 public function bulkDelete(array $condition = null, $check_operator=null){
62 if (
63 !\is_null($condition)
64 && \is_array($condition)
65 && array_keys($condition) !== range(0, count($condition) - 1)
66 ) {
67 $delete_condition = $condition;
68 } else {
69 return new WP_Error(
70 'deletion_error',
71 __('At least 1 condition needed', 'bitform')
72 );
73 }
74 $formatted_conditions = $this->getFormatedCondition($delete_condition, $check_operator);
75 if ($formatted_conditions) {
76 $condition_to_check = $formatted_conditions['conditions'];
77 $all_values = $formatted_conditions['values'];
78 } else {
79 $condition_to_check = null;
80 return new WP_Error(
81 'deletion_error',
82 __('At least 1 condition needed', 'bitform')
83 );
84 }
85 $result = $this->app_db->query(
86 $this->app_db->prepare(
87 "DELETE FROM $this->table_name $condition_to_check",
88 $all_values
89 )
90 );
91 return $this->getResult($result);
92 }
93 }
94