← All changes
|
WPDataAccess/Plugin_Table_Models/WPDA_App_Container_Model.php
+282
-190
5.5.3
→
5.5.84
View file →
| @@ -1,210 +1,302 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace WPDataAccess\Plugin_Table_Models { | |
| 3 | +namespace WPDataAccess\Plugin_Table_Models; | |
| 4 | 4 | |
| 5 | - use WPDataAccess\WPDA; | |
| 5 | +use WPDataAccess\WPDA; | |
| 6 | +class WPDA_App_Container_Model extends WPDA_Plugin_Table_Base_Model { | |
| 7 | + const BASE_TABLE_NAME = 'wpda_app_container'; | |
| 6 | 8 | |
| 7 | - class WPDA_App_Container_Model extends WPDA_Plugin_Table_Base_Model { | |
| 9 | + public static function select( $app_id, $cnt_seq_nr ) { | |
| 10 | + global $wpdb; | |
| 11 | + if ( 0 === $cnt_seq_nr ) { | |
| 12 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 13 | + $dataset = $wpdb->get_results( | |
| 14 | + $wpdb->prepare( 'SELECT * FROM `%1s` WHERE app_id = %d and cnt_seq_nr = 0 order by cnt_id', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id) ), | |
| 15 | + // db call ok; no-cache ok. | |
| 16 | + 'ARRAY_A' | |
| 17 | + ); | |
| 18 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 19 | + return $dataset; | |
| 20 | + } else { | |
| 21 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 22 | + $dataset = $wpdb->get_results( | |
| 23 | + $wpdb->prepare( 'SELECT * FROM `%1s` WHERE app_id = %d and cnt_seq_nr > 0 order by cnt_seq_nr, cnt_id', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id) ), | |
| 24 | + // db call ok; no-cache ok. | |
| 25 | + 'ARRAY_A' | |
| 26 | + ); | |
| 27 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 28 | + return $dataset; | |
| 29 | + } | |
| 30 | + } | |
| 8 | 31 | |
| 9 | - const BASE_TABLE_NAME = 'wpda_app_container'; | |
| 32 | + public static function select_all( $app_id ) { | |
| 33 | + global $wpdb; | |
| 34 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 35 | + $dataset = $wpdb->get_results( | |
| 36 | + $wpdb->prepare( 'SELECT * FROM `%1s` WHERE app_id = %d order by cnt_seq_nr', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id) ), | |
| 37 | + // db call ok; no-cache ok. | |
| 38 | + 'ARRAY_A' | |
| 39 | + ); | |
| 40 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 41 | + return $dataset; | |
| 42 | + } | |
| 10 | 43 | |
| 11 | - public static function select( $app_id, $cnt_seq_nr ) { | |
| 44 | + public static function get_container( $app_id, $cnt_id ) { | |
| 45 | + global $wpdb; | |
| 46 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 47 | + $dataset = $wpdb->get_results( | |
| 48 | + $wpdb->prepare( 'SELECT * FROM `%1s` WHERE app_id = %d AND cnt_id = %d', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id, $cnt_id) ), | |
| 49 | + // db call ok; no-cache ok. | |
| 50 | + 'ARRAY_A' | |
| 51 | + ); | |
| 52 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 53 | + return $dataset; | |
| 54 | + } | |
| 12 | 55 | |
| 13 | - global $wpdb; | |
| 14 | - return $wpdb->get_results( | |
| 15 | - $wpdb->prepare( | |
| 16 | - 'SELECT * FROM `%1s` WHERE app_id = %d and cnt_seq_nr = %d order by cnt_id', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders | |
| 17 | - array( | |
| 18 | - WPDA::remove_backticks( self::get_base_table_name() ), | |
| 19 | - $app_id, | |
| 20 | - $cnt_seq_nr, | |
| 21 | - ) | |
| 22 | - ), // db call ok; no-cache ok. | |
| 23 | - 'ARRAY_A' | |
| 24 | - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode | |
| 56 | + public static function create( | |
| 57 | + $app_id, | |
| 58 | + $app_dbs, | |
| 59 | + $app_tbl, | |
| 60 | + $app_cls, | |
| 61 | + $cnt_title, | |
| 62 | + $cnt_seq_nr, | |
| 63 | + $cnt_table, | |
| 64 | + $cnt_relation = null, | |
| 65 | + $cnt_query = null | |
| 66 | + ) { | |
| 67 | + global $wpdb; | |
| 68 | + if ( 1 === $cnt_seq_nr ) { | |
| 69 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 70 | + $max_seq_nr = $wpdb->get_results( | |
| 71 | + $wpdb->prepare( 'SELECT max(cnt_seq_nr) FROM `%1s` WHERE app_id = %d', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id) ), | |
| 72 | + // db call ok; no-cache ok. | |
| 73 | + 'ARRAY_N' | |
| 74 | + ); | |
| 75 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 76 | + if ( isset( $max_seq_nr[0][0] ) ) { | |
| 77 | + $cnt_seq_nr = $max_seq_nr[0][0] + 1; | |
| 78 | + } | |
| 79 | + } | |
| 80 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table | |
| 81 | + $rows = $wpdb->insert( static::get_base_table_name(), array( | |
| 82 | + 'cnt_dbs' => $app_dbs, | |
| 83 | + 'cnt_tbl' => $app_tbl, | |
| 84 | + 'cnt_cls' => $app_cls, | |
| 85 | + 'cnt_title' => $cnt_title, | |
| 86 | + 'app_id' => $app_id, | |
| 87 | + 'cnt_seq_nr' => $cnt_seq_nr, | |
| 88 | + 'cnt_table' => $cnt_table, | |
| 89 | + 'cnt_relation' => $cnt_relation, | |
| 90 | + 'cnt_query' => $cnt_query, | |
| 91 | + ) ); | |
| 92 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 93 | + if ( 1 === $rows ) { | |
| 94 | + // Return new container | |
| 95 | + $cnt_id = $wpdb->insert_id; | |
| 96 | + return array( | |
| 97 | + 'cnt_id' => $wpdb->insert_id, | |
| 98 | + 'msg' => '', | |
| 99 | + ); | |
| 100 | + } else { | |
| 101 | + return array( | |
| 102 | + 'cnt_id' => false, | |
| 103 | + 'msg' => $wpdb->last_error, | |
| 104 | + ); | |
| 105 | + } | |
| 106 | + } | |
| 25 | 107 | |
| 26 | - } | |
| 108 | + public static function update( | |
| 109 | + $app_id, | |
| 110 | + $app_cnt, | |
| 111 | + $app_dbs, | |
| 112 | + $app_tbl, | |
| 113 | + $app_cls, | |
| 114 | + $cnt_title, | |
| 115 | + $cnt_relation = null | |
| 116 | + ) { | |
| 117 | + global $wpdb; | |
| 118 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 119 | + $wpdb->update( static::get_base_table_name(), array( | |
| 120 | + 'cnt_dbs' => $app_dbs, | |
| 121 | + 'cnt_tbl' => $app_tbl, | |
| 122 | + 'cnt_cls' => $app_cls, | |
| 123 | + 'cnt_title' => $cnt_title, | |
| 124 | + 'cnt_relation' => $cnt_relation, | |
| 125 | + ), array( | |
| 126 | + 'app_id' => $app_id, | |
| 127 | + 'cnt_id' => $app_cnt, | |
| 128 | + ) ); | |
| 129 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 130 | + return $wpdb->last_error; | |
| 131 | + } | |
| 27 | 132 | |
| 28 | - public static function get_container( $cnt_id ) { | |
| 133 | + public static function delete( $app_id ) { | |
| 134 | + global $wpdb; | |
| 135 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 136 | + $delete = $wpdb->delete( static::get_base_table_name(), array( | |
| 137 | + 'app_id' => $app_id, | |
| 138 | + ) ); | |
| 139 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 140 | + return $delete; | |
| 141 | + } | |
| 29 | 142 | |
| 30 | - global $wpdb; | |
| 31 | - return $wpdb->get_results( | |
| 32 | - $wpdb->prepare( | |
| 33 | - 'SELECT * FROM `%1s` WHERE cnt_id = %d', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders | |
| 34 | - array( | |
| 35 | - WPDA::remove_backticks( self::get_base_table_name() ), | |
| 36 | - $cnt_id, | |
| 37 | - ) | |
| 38 | - ), // db call ok; no-cache ok. | |
| 39 | - 'ARRAY_A' | |
| 40 | - ); // phpcs:ignore Standard.Category.SniffName.ErrorCode | |
| 143 | + public static function delete_container( $cnt_id ) { | |
| 144 | + global $wpdb; | |
| 145 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 146 | + $delete = $wpdb->delete( static::get_base_table_name(), array( | |
| 147 | + 'cnt_id' => $cnt_id, | |
| 148 | + ) ); | |
| 149 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 150 | + return $delete; | |
| 151 | + } | |
| 41 | 152 | |
| 42 | - } | |
| 153 | + public static function update_master( | |
| 154 | + $app_id, | |
| 155 | + $app_dbs, | |
| 156 | + $app_tbl, | |
| 157 | + $app_cls, | |
| 158 | + $app_query | |
| 159 | + ) { | |
| 160 | + global $wpdb; | |
| 161 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 162 | + $wpdb->update( static::get_base_table_name(), array( | |
| 163 | + 'cnt_dbs' => $app_dbs, | |
| 164 | + 'cnt_tbl' => $app_tbl, | |
| 165 | + 'cnt_cls' => $app_cls, | |
| 166 | + 'cnt_query' => $app_query, | |
| 167 | + ), array( | |
| 168 | + 'app_id' => $app_id, | |
| 169 | + 'cnt_seq_nr' => 0, | |
| 170 | + ) ); | |
| 171 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 172 | + return $wpdb->last_error; | |
| 173 | + } | |
| 43 | 174 | |
| 44 | - public static function create( | |
| 45 | - $app_id, | |
| 46 | - $app_dbs, | |
| 47 | - $app_tbl, | |
| 48 | - $app_cls, | |
| 49 | - $cnt_title, | |
| 50 | - $cnt_seq_nr, | |
| 51 | - $cnt_table, | |
| 52 | - $cnt_relation = null | |
| 53 | - ) { | |
| 175 | + public static function update_table_settings( $cnt_id, $cnt_table_settings ) { | |
| 176 | + global $wpdb; | |
| 177 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 178 | + $wpdb->update( static::get_base_table_name(), array( | |
| 179 | + 'cnt_table' => $cnt_table_settings, | |
| 180 | + ), array( | |
| 181 | + 'cnt_id' => $cnt_id, | |
| 182 | + ) ); | |
| 183 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 184 | + return $wpdb->last_error; | |
| 185 | + } | |
| 54 | 186 | |
| 55 | - global $wpdb; | |
| 56 | - if ( 1 === $wpdb->insert( | |
| 57 | - static::get_base_table_name(), | |
| 58 | - array( | |
| 59 | - 'cnt_dbs' => $app_dbs, | |
| 60 | - 'cnt_tbl' => $app_tbl, | |
| 61 | - 'cnt_cls' => $app_cls, | |
| 62 | - 'cnt_title' => $cnt_title, | |
| 63 | - 'app_id' => $app_id, | |
| 64 | - 'cnt_seq_nr' => $cnt_seq_nr, | |
| 65 | - 'cnt_table' => $cnt_table, | |
| 66 | - 'cnt_relation' => $cnt_relation, | |
| 67 | - ) | |
| 68 | - ) | |
| 69 | - ) { | |
| 70 | - // Return new container | |
| 71 | - $cnt_id = $wpdb->insert_id; | |
| 72 | - return array( | |
| 73 | - 'cnt_id' => $wpdb->insert_id, | |
| 74 | - 'msg' => '', | |
| 75 | - ); | |
| 76 | - } else { | |
| 77 | - return array( | |
| 78 | - 'cnt_id' => false, | |
| 79 | - 'msg' => $wpdb->last_error, | |
| 80 | - ); | |
| 81 | - } | |
| 187 | + public static function update_rform_settings( $cnt_id, $cnt_form_settings ) { | |
| 188 | + global $wpdb; | |
| 189 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 190 | + $wpdb->update( static::get_base_table_name(), array( | |
| 191 | + 'cnt_rform' => $cnt_form_settings, | |
| 192 | + ), array( | |
| 193 | + 'cnt_id' => $cnt_id, | |
| 194 | + ) ); | |
| 195 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 196 | + return $wpdb->last_error; | |
| 197 | + } | |
| 82 | 198 | |
| 83 | - } | |
| 199 | + public static function update_form_settings( $cnt_id, $cnt_form_settings ) { | |
| 200 | + global $wpdb; | |
| 201 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 202 | + $wpdb->update( static::get_base_table_name(), array( | |
| 203 | + 'cnt_form' => $cnt_form_settings, | |
| 204 | + ), array( | |
| 205 | + 'cnt_id' => $cnt_id, | |
| 206 | + ) ); | |
| 207 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 208 | + return $wpdb->last_error; | |
| 209 | + } | |
| 84 | 210 | |
| 85 | - public static function update( | |
| 86 | - $app_id, | |
| 87 | - $app_cnt, | |
| 88 | - $app_dbs, | |
| 89 | - $app_tbl, | |
| 90 | - $app_cls, | |
| 91 | - $cnt_title, | |
| 92 | - $cnt_seq_nr, | |
| 93 | - $cnt_table, | |
| 94 | - $cnt_relation = null | |
| 95 | - ) { | |
| 211 | + public static function update_chart_settings( $cnt_id, $cnt_chart_settings ) { | |
| 212 | + global $wpdb; | |
| 213 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 214 | + $wpdb->update( static::get_base_table_name(), array( | |
| 215 | + 'cnt_chart' => $cnt_chart_settings, | |
| 216 | + ), array( | |
| 217 | + 'cnt_id' => $cnt_id, | |
| 218 | + ) ); | |
| 219 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 220 | + return $wpdb->last_error; | |
| 221 | + } | |
| 96 | 222 | |
| 97 | - global $wpdb; | |
| 98 | - $wpdb->update( | |
| 99 | - static::get_base_table_name(), | |
| 100 | - array( | |
| 101 | - 'cnt_dbs' => $app_dbs, | |
| 102 | - 'cnt_tbl' => $app_tbl, | |
| 103 | - 'cnt_cls' => $app_cls, | |
| 104 | - 'cnt_title' => $cnt_title, | |
| 105 | - 'cnt_seq_nr' => $cnt_seq_nr, | |
| 106 | - 'cnt_table' => $cnt_table, | |
| 107 | - 'cnt_relation' => $cnt_relation, | |
| 108 | - ), | |
| 109 | - array( | |
| 110 | - 'app_id' => $app_id, | |
| 111 | - 'cnt_id' => $app_cnt, | |
| 112 | - ) | |
| 113 | - ); | |
| 223 | + public static function update_dashboard_settings( $cnt_id, $cnt_dashboard_settings ) { | |
| 224 | + global $wpdb; | |
| 225 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 226 | + $wpdb->update( static::get_base_table_name(), array( | |
| 227 | + 'cnt_dashboard' => $cnt_dashboard_settings, | |
| 228 | + ), array( | |
| 229 | + 'cnt_id' => $cnt_id, | |
| 230 | + ) ); | |
| 231 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 232 | + return $wpdb->last_error; | |
| 233 | + } | |
| 114 | 234 | |
| 115 | - return $wpdb->last_error; | |
| 235 | + public static function update_map_settings( $cnt_id, $cnt_map_settings ) { | |
| 236 | + global $wpdb; | |
| 237 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 238 | + $wpdb->update( static::get_base_table_name(), array( | |
| 239 | + 'cnt_map' => $cnt_map_settings, | |
| 240 | + ), array( | |
| 241 | + 'cnt_id' => $cnt_id, | |
| 242 | + ) ); | |
| 243 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 244 | + return $wpdb->last_error; | |
| 245 | + } | |
| 116 | 246 | |
| 117 | - } | |
| 247 | + public static function container_move( $app_id, $cnt_id_from, $cnt_id_to ) { | |
| 248 | + // This is a premium feature. | |
| 249 | + return ''; | |
| 250 | + } | |
| 118 | 251 | |
| 119 | - public static function delete( $app_id ) { | |
| 252 | + public static function copy( $app_id_old, $app_id_new ) { | |
| 253 | + global $wpdb; | |
| 254 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders -- plugin table | |
| 255 | + $containers = $wpdb->get_results( | |
| 256 | + $wpdb->prepare( 'SELECT * FROM `%1s` WHERE app_id = %d order by cnt_seq_nr', array(WPDA::remove_backticks( self::get_base_table_name() ), $app_id_old) ), | |
| 257 | + // db call ok; no-cache ok. | |
| 258 | + 'ARRAY_A' | |
| 259 | + ); | |
| 260 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders | |
| 261 | + $cnt_id_conversion = array(); | |
| 262 | + foreach ( $containers as $container ) { | |
| 263 | + $cnt_id = $container['cnt_id']; | |
| 264 | + $container['app_id'] = $app_id_new; | |
| 265 | + unset($container['cnt_id']); | |
| 266 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- plugin table | |
| 267 | + $wpdb->insert( static::get_base_table_name(), $container ); | |
| 268 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 269 | + $cnt_id_conversion[$cnt_id] = $wpdb->insert_id; | |
| 270 | + } | |
| 271 | + foreach ( $cnt_id_conversion as $cnt_id_old => $cnt_id_new ) { | |
| 272 | + $container = self::get_container( $app_id_new, $cnt_id_new ); | |
| 273 | + if ( isset( $container[0]['cnt_relation'] ) ) { | |
| 274 | + $relation = $container[0]['cnt_relation']; | |
| 275 | + if ( null !== $relation && '' !== $relation ) { | |
| 276 | + $json = json_decode( $relation, true ); | |
| 277 | + if ( isset( $json['cnt_id_master'] ) ) { | |
| 278 | + $cnt_id_master_old = $json['cnt_id_master']; | |
| 279 | + if ( isset( $cnt_id_conversion[$cnt_id_master_old] ) ) { | |
| 280 | + // Update relationship master id | |
| 281 | + $cnt_id_master_new = $cnt_id_conversion[$cnt_id_master_old]; | |
| 282 | + $json['cnt_id_master'] = strval( $cnt_id_master_new ); | |
| 283 | + $relation = json_encode( $json ); | |
| 284 | + } else { | |
| 285 | + // Master no longer available | |
| 286 | + $relation = null; | |
| 287 | + } | |
| 288 | + // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table | |
| 289 | + $wpdb->update( static::get_base_table_name(), array( | |
| 290 | + 'cnt_relation' => $relation, | |
| 291 | + ), array( | |
| 292 | + 'app_id' => $app_id_new, | |
| 293 | + 'cnt_id' => $cnt_id_new, | |
| 294 | + ) ); | |
| 295 | + // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching | |
| 296 | + } | |
| 297 | + } | |
| 298 | + } | |
| 299 | + } | |
| 300 | + } | |
| 120 | 301 | |
| 121 | - global $wpdb; | |
| 122 | - return $wpdb->delete( | |
| 123 | - static::get_base_table_name(), | |
| 124 | - array( | |
| 125 | - 'app_id' => $app_id, | |
| 126 | - ) | |
| 127 | - ); | |
| 128 | - | |
| 129 | - } | |
| 130 | - | |
| 131 | - public static function delete_container( $cnt_id ) { | |
| 132 | - | |
| 133 | - global $wpdb; | |
| 134 | - return $wpdb->delete( | |
| 135 | - static::get_base_table_name(), | |
| 136 | - array( | |
| 137 | - 'cnt_id' => $cnt_id, | |
| 138 | - ) | |
| 139 | - ); | |
| 140 | - | |
| 141 | - } | |
| 142 | - | |
| 143 | - public static function update_master( | |
| 144 | - $app_id, | |
| 145 | - $app_dbs, | |
| 146 | - $app_tbl, | |
| 147 | - $app_cls | |
| 148 | - ) { | |
| 149 | - | |
| 150 | - global $wpdb; | |
| 151 | - $wpdb->update( | |
| 152 | - static::get_base_table_name(), | |
| 153 | - array( | |
| 154 | - 'cnt_dbs' => $app_dbs, | |
| 155 | - 'cnt_tbl' => $app_tbl, | |
| 156 | - 'cnt_cls' => $app_cls, | |
| 157 | - ), | |
| 158 | - array( | |
| 159 | - 'app_id' => $app_id, | |
| 160 | - 'cnt_seq_nr' => 0, | |
| 161 | - ) | |
| 162 | - ); | |
| 163 | - | |
| 164 | - return $wpdb->last_error; | |
| 165 | - | |
| 166 | - } | |
| 167 | - | |
| 168 | - public static function update_table_settings( | |
| 169 | - $cnt_id, | |
| 170 | - $cnt_table_settings | |
| 171 | - ) { | |
| 172 | - | |
| 173 | - global $wpdb; | |
| 174 | - $wpdb->update( | |
| 175 | - static::get_base_table_name(), | |
| 176 | - array( | |
| 177 | - 'cnt_table' => $cnt_table_settings, | |
| 178 | - ), | |
| 179 | - array( | |
| 180 | - 'cnt_id' => $cnt_id, | |
| 181 | - ) | |
| 182 | - ); | |
| 183 | - | |
| 184 | - return $wpdb->last_error; | |
| 185 | - | |
| 186 | - } | |
| 187 | - | |
| 188 | - public static function update_form_settings( | |
| 189 | - $cnt_id, | |
| 190 | - $cnt_form_settings | |
| 191 | - ) { | |
| 192 | - | |
| 193 | - global $wpdb; | |
| 194 | - $wpdb->update( | |
| 195 | - static::get_base_table_name(), | |
| 196 | - array( | |
| 197 | - 'cnt_form' => $cnt_form_settings, | |
| 198 | - ), | |
| 199 | - array( | |
| 200 | - 'cnt_id' => $cnt_id, | |
| 201 | - ) | |
| 202 | - ); | |
| 203 | - | |
| 204 | - return $wpdb->last_error; | |
| 205 | - | |
| 206 | - } | |
| 207 | - | |
| 208 | - } | |
| 209 | - | |
| 210 | -} | |
| 302 | +} | |