PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
← All changes | WPDataAccess/Plugin_Table_Models/WPDA_App_Model.php +105 -13 5.5.35.5.84 View file →
@@ -10,9 +10,9 @@
10 10
11 11 public static function get_by_id( $app_id ) {
12 12
13 13 global $wpdb;
14 - $dataset = $wpdb->get_results(
14 + $dataset = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
15 15 $wpdb->prepare(
16 16 'SELECT * FROM `%1s` WHERE app_id = %d', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
17 17 array(
18 18 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -19,9 +19,9 @@
19 19 $app_id,
20 20 )
21 21 ), // db call ok; no-cache ok.
22 22 'ARRAY_A'
23 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
23 + );
24 24
25 25 return 1 === $wpdb->num_rows ? $dataset : false;
26 26
27 27 }
@@ -28,9 +28,9 @@
28 28
29 29 public static function get_by_name( $app_name ) {
30 30
31 31 global $wpdb;
32 - $dataset = $wpdb->get_results(
32 + $dataset = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
33 33 $wpdb->prepare(
34 34 'SELECT * FROM `%1s` WHERE app_name = %s', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
35 35 array(
36 36 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -37,9 +37,9 @@
37 37 $app_name,
38 38 )
39 39 ), // db call ok; no-cache ok.
40 40 'ARRAY_A'
41 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
41 + );
42 42
43 43 return 1 === $wpdb->num_rows ? $dataset : false;
44 44
45 45 }
@@ -46,9 +46,9 @@
46 46
47 47 public static function list() {
48 48
49 49 global $wpdb;
50 - return $wpdb->get_results(
50 + return $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
51 51 $wpdb->prepare(
52 52 'SELECT * FROM `%1s` ORDER BY app_name', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
53 53 array(
54 54 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -54,16 +54,33 @@
54 54 WPDA::remove_backticks( self::get_base_table_name() ),
55 55 )
56 56 ), // db call ok; no-cache ok.
57 57 'ARRAY_A'
58 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
58 + );
59 59
60 60 }
61 61
62 - public static function add_to_dashboard_menu() {
62 + public static function has_any() {
63 63
64 + global $wpdb;
65 + $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
66 + $wpdb->prepare(
67 + 'SELECT 1 FROM `%1s` LIMIT 1', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
68 + array(
69 + WPDA::remove_backticks( self::get_base_table_name() ),
70 + )
71 + ), // db call ok; no-cache ok.
72 + 'ARRAY_A'
73 + );
74 +
75 + return 1 === $wpdb->num_rows;
76 +
77 + }
78 +
79 + public static function add_to_dashboard_menu() {
80 +
64 81 global $wpdb;
65 - return $wpdb->get_results(
82 + return $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
66 83 $wpdb->prepare(
67 84 'SELECT * FROM `%1s` WHERE `app_add_to_menu` = 1 ORDER BY app_name', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
68 85 array(
69 86 WPDA::remove_backticks( self::get_base_table_name() ),
@@ -69,9 +86,9 @@
69 86 WPDA::remove_backticks( self::get_base_table_name() ),
70 87 )
71 88 ), // db call ok; no-cache ok.
72 89 'ARRAY_A'
73 - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode
90 + );
74 91
75 92 }
76 93
77 94 public static function create(
@@ -81,9 +98,9 @@
81 98 $app_settings
82 99 ) {
83 100
84 101 global $wpdb;
85 - if ( 1 === $wpdb->insert(
102 + if ( 1 === $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table
86 103 static::get_base_table_name(),
87 104 array(
88 105 'app_name' => $app_name,
89 106 'app_title' => $app_title,
@@ -106,9 +123,9 @@
106 123
107 124 public static function delete( $app_id ) {
108 125
109 126 global $wpdb;
110 - return $wpdb->delete(
127 + return $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
111 128 static::get_base_table_name(),
112 129 array(
113 130 'app_id' => $app_id,
114 131 )
@@ -125,9 +142,9 @@
125 142 $app_add_to_menu
126 143 ) {
127 144
128 145 global $wpdb;
129 - $wpdb->update(
146 + $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
130 147 static::get_base_table_name(),
131 148 array(
132 149 'app_name' => $app_name,
133 150 'app_title' => $app_title,
@@ -143,8 +160,83 @@
143 160 return $wpdb->last_error;
144 161
145 162 }
146 163
164 + public static function copy_all(
165 + $app
166 + ) {
167 +
168 + $app_id = $app[0]['app_id'];
169 + $app_name = $app[0]['app_name'];
170 +
171 + // Determine new app name
172 + $copy_nr = 1;
173 + $new_app_name = "{$app_name}_{$copy_nr} (copy)";
174 + $app_exists = self::get_by_name( $new_app_name );
175 + while ( false !== $app_exists ) {
176 + $copy_nr++;
177 + $new_app_name = "{$app_name}_{$copy_nr} (copy)";
178 + $app_exists = self::get_by_name( $new_app_name );
179 + }
180 +
181 + // Copy app
182 + global $wpdb;
183 + if ( 1 === $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table
184 + static::get_base_table_name(),
185 + array(
186 + 'app_name' => $new_app_name,
187 + 'app_title' => $app[0]['app_title'],
188 + 'app_type' => $app[0]['app_type'],
189 + 'app_settings' => $app[0]['app_settings'],
190 + 'app_theme' => $app[0]['app_theme'],
191 + )
192 + )
193 + ) {
194 + $new_app_id = $wpdb->insert_id;
195 +
196 + // Copy containers
197 + WPDA_App_Container_Model::copy( $app_id, $new_app_id );
198 +
199 + if ( 5 === $app[0]['app_type'] || '5' === $app[0]['app_type'] ) {
200 + // App container, copy details
201 + $apps = WPDA_App_Apps_Model::select_all( $app_id );
202 + foreach ( $apps as $app ) {
203 + $detail_app = self::get_by_id( $app['app_id_detail'] );
204 + if ( false !== $detail_app ) {
205 + $detail_app_ids = static::copy_all($detail_app);
206 + if ( false !== $detail_app_ids['app_id'] ) {
207 + WPDA_App_Apps_Model::create($new_app_id, $detail_app_ids['app_id'], $app['seq_nr']);
208 + }
209 + }
210 + }
211 + }
212 +
213 + return array(
214 + 'app_id' => $new_app_id,
215 + 'msg' => '',
216 + );
217 + } else {
218 + return array(
219 + 'app_id' => false,
220 + 'msg' => $wpdb->last_error,
221 + );
222 + }
223 +
224 + }
225 +
226 + public static function copy(
227 + $app_id
228 + ) {
229 +
230 + $app = self::get_by_id( $app_id );
231 + if ( false === $app ) {
232 + return false;
233 + }
234 +
235 + return static::copy_all( $app );
236 +
237 + }
238 +
147 239 public static function update_theme(
148 240 $app_id,
149 241 $app_theme
150 242 ) {
@@ -149,9 +241,9 @@
149 241 $app_theme
150 242 ) {
151 243
152 244 global $wpdb;
153 - $wpdb->update(
245 + $wpdb->update( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
154 246 static::get_base_table_name(),
155 247 array(
156 248 'app_theme' => $app_theme,
157 249 ),