@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | /** |
| 485 | 485 | * Inserts the CPT |
| 486 | - * @param array $old_venue keys are cols, values are col values |
|
| 486 | + * @param array $old_event keys are cols, values are col values |
|
| 487 | 487 | * @return int |
| 488 | 488 | */ |
| 489 | 489 | private function _insert_venue_into_posts($old_event){ |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | |
| 529 | 529 | /** |
| 530 | 530 | * Inserts into the venue_meta table |
| 531 | - * @param type $cpt_id |
|
| 531 | + * @param integer $cpt_id |
|
| 532 | 532 | * @param type $old_event |
| 533 | 533 | * @return int |
| 534 | 534 | */ |
@@ -596,6 +596,9 @@ discard block |
||
| 596 | 596 | return $wpdb->insert_id; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | + /** |
|
| 600 | + * @param integer $new_venue_id |
|
| 601 | + */ |
|
| 599 | 602 | private function _insert_new_venue_to_event($new_event_id,$new_venue_id){ |
| 600 | 603 | global $wpdb; |
| 601 | 604 | if( ! $new_event_id){ |
@@ -654,7 +657,7 @@ discard block |
||
| 654 | 657 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
| 655 | 658 | * @param type $start_end_time_row |
| 656 | 659 | * @param type $old_event_row |
| 657 | - * @param type $new_cpt_id |
|
| 660 | + * @param integer $new_cpt_id |
|
| 658 | 661 | * @return int ID of new datetime |
| 659 | 662 | */ |
| 660 | 663 | private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
@@ -84,8 +84,6 @@ discard block |
||
| 84 | 84 | KEY `submitted` (`submitted`), |
| 85 | 85 | KEY `likes` (`likes`) |
| 86 | 86 | ) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8$$ |
| 87 | - |
|
| 88 | - |
|
| 89 | 87 | * |
| 90 | 88 | * 4.1 Event model: |
| 91 | 89 | * $this->_tables = array( |
@@ -124,7 +122,6 @@ discard block |
||
| 124 | 122 | 'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __("Accept Donations?", "event_espresso"), false, false) |
| 125 | 123 | |
| 126 | 124 | )); |
| 127 | - |
|
| 128 | 125 | * |
| 129 | 126 | * 3.1's start end table |
| 130 | 127 | * |
@@ -137,8 +134,6 @@ discard block |
||
| 137 | 134 | PRIMARY KEY (`id`), |
| 138 | 135 | KEY `event_id` (`event_id`) |
| 139 | 136 | ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8$$ |
| 140 | - |
|
| 141 | - |
|
| 142 | 137 | * |
| 143 | 138 | * and 4.1 Datetime model's tables and fields: |
| 144 | 139 | * $this->_tables = array( |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
| 159 | 159 | )); |
| 160 | 160 | */ |
| 161 | -class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage{ |
|
| 161 | +class EE_DMS_4_1_0_events extends EE_Data_Migration_Script_Stage { |
|
| 162 | 162 | private $_old_table; |
| 163 | 163 | private $_old_start_end_table; |
| 164 | 164 | private $_new_table; |
@@ -184,41 +184,41 @@ discard block |
||
| 184 | 184 | protected function _migration_step($num_items_to_migrate = 50) { |
| 185 | 185 | global $wpdb; |
| 186 | 186 | //because the migration of each event can be a LOT more work, make each step smaller |
| 187 | - $num_items_to_migrate = max(1,$num_items_to_migrate/5); |
|
| 188 | - $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$this->count_records_migrated(),$num_items_to_migrate),ARRAY_A); |
|
| 187 | + $num_items_to_migrate = max(1, $num_items_to_migrate / 5); |
|
| 188 | + $events = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $this->count_records_migrated(), $num_items_to_migrate), ARRAY_A); |
|
| 189 | 189 | $items_migrated_this_step = 0; |
| 190 | 190 | |
| 191 | - foreach($events as $event_row){ |
|
| 191 | + foreach ($events as $event_row) { |
|
| 192 | 192 | $created_attachment_post = false; |
| 193 | 193 | //insert new 4.1 Attendee object using $wpdb |
| 194 | 194 | $post_id = $this->_insert_cpt($event_row); |
| 195 | - if($post_id){ |
|
| 195 | + if ($post_id) { |
|
| 196 | 196 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_table, $post_id); |
| 197 | 197 | $meta_id = $this->_insert_event_meta($event_row, $post_id); |
| 198 | - if($meta_id){ |
|
| 198 | + if ($meta_id) { |
|
| 199 | 199 | $this->get_migration_script()->set_mapping($this->_old_table, $event_row['id'], $this->_new_meta_table, $meta_id); |
| 200 | 200 | } |
| 201 | - $this->_convert_start_end_times($event_row,$post_id); |
|
| 201 | + $this->_convert_start_end_times($event_row, $post_id); |
|
| 202 | 202 | $event_meta = maybe_unserialize($event_row['event_meta']); |
| 203 | 203 | $guid = isset($event_meta['event_thumbnail_url']) ? $event_meta['event_thumbnail_url'] : null; |
| 204 | - $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$post_id,$this); |
|
| 204 | + $created_attachment_post = $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $post_id, $this); |
|
| 205 | 205 | |
| 206 | 206 | //maybe create a venue from info on the event? |
| 207 | 207 | $new_venue_id = $this->_maybe_create_venue($event_row); |
| 208 | - if($new_venue_id){ |
|
| 209 | - $this->_insert_new_venue_to_event($post_id,$new_venue_id); |
|
| 208 | + if ($new_venue_id) { |
|
| 209 | + $this->_insert_new_venue_to_event($post_id, $new_venue_id); |
|
| 210 | 210 | } |
| 211 | 211 | $this->_add_post_metas($event_row, $post_id); |
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | $items_migrated_this_step++; |
| 215 | - if($guid){ |
|
| 215 | + if ($guid) { |
|
| 216 | 216 | //if we had to check for an image attachment |
| 217 | 217 | //then let's call it a day (avoid timing out, because this took a long time) |
| 218 | 218 | break; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - if($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()){ |
|
| 221 | + if ($this->count_records_migrated() + $items_migrated_this_step >= $this->count_records_to_migrate()) { |
|
| 222 | 222 | $this->set_status(EE_Data_Migration_Manager::status_completed); |
| 223 | 223 | } |
| 224 | 224 | return $items_migrated_this_step; |
@@ -230,28 +230,28 @@ discard block |
||
| 230 | 230 | * @param type $post_id |
| 231 | 231 | * @return void |
| 232 | 232 | */ |
| 233 | - private function _add_post_metas($old_event,$post_id){ |
|
| 233 | + private function _add_post_metas($old_event, $post_id) { |
|
| 234 | 234 | $event_meta = maybe_unserialize($old_event['event_meta']); |
| 235 | - if( ! $event_meta || ! is_array( $event_meta ) ){ |
|
| 235 | + if ( ! $event_meta || ! is_array($event_meta)) { |
|
| 236 | 236 | return; |
| 237 | 237 | } |
| 238 | - unset($event_meta['date_submitted']);//factored into CPT |
|
| 239 | - unset($event_meta['additional_attendee_reg_info']);//facotred into event meta table |
|
| 240 | - unset($event_meta['default_payment_status']);//dido |
|
| 241 | - unset($event_meta['event_thumbnail_url']);//used to find post featured image |
|
| 242 | - foreach($event_meta as $meta_key => $meta_value){ |
|
| 243 | - if ($meta_key){//if th emeta key is just an empty string, ignore it |
|
| 244 | - $success = add_post_meta($post_id,$meta_key,$meta_value,true); |
|
| 245 | - if( ! $success ){ |
|
| 246 | - $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"),$post_id,$meta_key,$meta_value,implode(",",$old_event))); |
|
| 238 | + unset($event_meta['date_submitted']); //factored into CPT |
|
| 239 | + unset($event_meta['additional_attendee_reg_info']); //facotred into event meta table |
|
| 240 | + unset($event_meta['default_payment_status']); //dido |
|
| 241 | + unset($event_meta['event_thumbnail_url']); //used to find post featured image |
|
| 242 | + foreach ($event_meta as $meta_key => $meta_value) { |
|
| 243 | + if ($meta_key) {//if th emeta key is just an empty string, ignore it |
|
| 244 | + $success = add_post_meta($post_id, $meta_key, $meta_value, true); |
|
| 245 | + if ( ! $success) { |
|
| 246 | + $this->add_error(sprintf(__("Could not add post meta for CPT with ID #%d. Meta key: '%s',meta value:'%d' for 3.1 event: %s", "event_espresso"), $post_id, $meta_key, $meta_value, implode(",", $old_event))); |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | - if($old_event['alt_email']){ |
|
| 251 | - add_post_meta($post_id,'alt_email',$old_event['alt_email']); |
|
| 250 | + if ($old_event['alt_email']) { |
|
| 251 | + add_post_meta($post_id, 'alt_email', $old_event['alt_email']); |
|
| 252 | 252 | } |
| 253 | - if($old_event['recurrence_id']){ |
|
| 254 | - add_post_meta($post_id,'recurrence_id',$old_event['recurrence_id']); |
|
| 253 | + if ($old_event['recurrence_id']) { |
|
| 254 | + add_post_meta($post_id, 'recurrence_id', $old_event['recurrence_id']); |
|
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | /** |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | * @param string $event_name |
| 262 | 262 | * @return string |
| 263 | 263 | */ |
| 264 | - private function _find_unique_slug($event_name, $old_identifier = ''){ |
|
| 264 | + private function _find_unique_slug($event_name, $old_identifier = '') { |
|
| 265 | 265 | $count = 0; |
| 266 | 266 | $original_name = $event_name ? sanitize_title($event_name) : $old_identifier; |
| 267 | 267 | $event_slug = $original_name; |
| 268 | - while( $this->_other_post_exists_with_that_slug($event_slug) && $count<50){ |
|
| 268 | + while ($this->_other_post_exists_with_that_slug($event_slug) && $count < 50) { |
|
| 269 | 269 | $event_slug = sanitize_title($original_name."-".++$count); |
| 270 | 270 | } |
| 271 | 271 | return $event_slug; |
@@ -277,13 +277,13 @@ discard block |
||
| 277 | 277 | * @param type $slug |
| 278 | 278 | * @return boolean |
| 279 | 279 | */ |
| 280 | - private function _other_post_exists_with_that_slug($slug){ |
|
| 280 | + private function _other_post_exists_with_that_slug($slug) { |
|
| 281 | 281 | global $wpdb; |
| 282 | - $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s",$slug); |
|
| 282 | + $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug); |
|
| 283 | 283 | $count = $wpdb->get_var($query); |
| 284 | - return (boolean)intval($count); |
|
| 284 | + return (boolean) intval($count); |
|
| 285 | 285 | } |
| 286 | - private function _insert_cpt($old_event){ |
|
| 286 | + private function _insert_cpt($old_event) { |
|
| 287 | 287 | global $wpdb; |
| 288 | 288 | //convert 3.1 event status to 4.1 CPT status |
| 289 | 289 | //for refrence, 3.1 event stati available for setting are: |
@@ -302,55 +302,55 @@ discard block |
||
| 302 | 302 | // and 3 custom ones: cancelled,postponed,sold_out |
| 303 | 303 | $status_conversions = array( |
| 304 | 304 | 'R'=>'draft', |
| 305 | - 'X'=>'draft',//4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
| 305 | + 'X'=>'draft', //4.1 doesn't have a "not approved for publishing" status. this is what posts are set to that aren't approved |
|
| 306 | 306 | 'P'=>'pending', |
| 307 | - 'IA'=>'draft',//draft and in the past |
|
| 307 | + 'IA'=>'draft', //draft and in the past |
|
| 308 | 308 | //IA=inactive in 3.1: events were switched to this when they expired. in 4.1 that's just calculated |
| 309 | - 'O'=>'publish',//@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
| 309 | + 'O'=>'publish', //@todo: will be an event type later; if this is the status, set the end date WAAAY later; and add term for 'ongoing' |
|
| 310 | 310 | 'A'=>'publish', |
| 311 | - 'S'=>'draft',//@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
| 311 | + 'S'=>'draft', //@todo: is it ok to just mark secondary/waitlist events as DRAFTS? |
|
| 312 | 312 | 'D'=>'trash', |
| 313 | 313 | ); |
| 314 | 314 | $post_status = $status_conversions[$old_event['event_status']]; |
| 315 | 315 | //check if we've sold out |
| 316 | - if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])){ |
|
| 316 | + if (intval($old_event['reg_limit']) <= self::count_registrations($old_event['id'])) { |
|
| 317 | 317 | $post_status = 'sold_out'; |
| 318 | 318 | } |
| 319 | 319 | // FYI postponed and cancelled don't exist in 3.1 |
| 320 | 320 | $cols_n_values = array( |
| 321 | - 'post_title'=>stripslashes($old_event['event_name']),//EVT_name |
|
| 322 | - 'post_content'=>stripslashes($old_event['event_desc']),//EVT_desc |
|
| 323 | - 'post_name'=>$this->_find_unique_slug($old_event['event_name']),//$old_event['event_identifier'],//EVT_slug |
|
| 324 | - 'post_date'=>$old_event['submitted'],//EVT_created NOT |
|
| 321 | + 'post_title'=>stripslashes($old_event['event_name']), //EVT_name |
|
| 322 | + 'post_content'=>stripslashes($old_event['event_desc']), //EVT_desc |
|
| 323 | + 'post_name'=>$this->_find_unique_slug($old_event['event_name']), //$old_event['event_identifier'],//EVT_slug |
|
| 324 | + 'post_date'=>$old_event['submitted'], //EVT_created NOT |
|
| 325 | 325 | 'post_date_gmt'=>get_gmt_from_date($old_event['submitted']), |
| 326 | - 'post_excerpt'=>'',//EVT_short_desc |
|
| 327 | - 'post_modified'=>$old_event['submitted'],//EVT_modified |
|
| 326 | + 'post_excerpt'=>'', //EVT_short_desc |
|
| 327 | + 'post_modified'=>$old_event['submitted'], //EVT_modified |
|
| 328 | 328 | 'post_modified_gmt'=>get_gmt_from_date($old_event['submitted']), |
| 329 | - 'post_author'=>$old_event['wp_user'],//EVT_wp_user |
|
| 330 | - 'post_parent'=>null,//parent maybe get this from some REM field? |
|
| 331 | - 'menu_order'=>null,//EVT_order |
|
| 332 | - 'post_type'=>'espresso_events',//post_type |
|
| 333 | - 'post_status'=>$post_status,//status |
|
| 329 | + 'post_author'=>$old_event['wp_user'], //EVT_wp_user |
|
| 330 | + 'post_parent'=>null, //parent maybe get this from some REM field? |
|
| 331 | + 'menu_order'=>null, //EVT_order |
|
| 332 | + 'post_type'=>'espresso_events', //post_type |
|
| 333 | + 'post_status'=>$post_status, //status |
|
| 334 | 334 | ); |
| 335 | 335 | $datatypes = array( |
| 336 | - '%s',//EVT_name |
|
| 337 | - '%s',//EVT_desc |
|
| 338 | - '%s',//EVT_slug |
|
| 339 | - '%s',//EVT_created |
|
| 336 | + '%s', //EVT_name |
|
| 337 | + '%s', //EVT_desc |
|
| 338 | + '%s', //EVT_slug |
|
| 339 | + '%s', //EVT_created |
|
| 340 | 340 | '%s', |
| 341 | - '%s',//EVT_short_desc |
|
| 342 | - '%s',//EVT_modified |
|
| 341 | + '%s', //EVT_short_desc |
|
| 342 | + '%s', //EVT_modified |
|
| 343 | 343 | '%s', |
| 344 | - '%s',//EVT_wp_user |
|
| 345 | - '%d',//post_parent |
|
| 346 | - '%d',//EVT_order |
|
| 347 | - '%s',//post_type |
|
| 348 | - '%s',//status |
|
| 344 | + '%s', //EVT_wp_user |
|
| 345 | + '%d', //post_parent |
|
| 346 | + '%d', //EVT_order |
|
| 347 | + '%s', //post_type |
|
| 348 | + '%s', //status |
|
| 349 | 349 | ); |
| 350 | 350 | $success = $wpdb->insert($this->_new_table, |
| 351 | 351 | $cols_n_values, |
| 352 | 352 | $datatypes); |
| 353 | - if( ! $success ){ |
|
| 353 | + if ( ! $success) { |
|
| 354 | 354 | $this->add_error($this->get_migration_script->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_table, $cols_n_values, $datatypes)); |
| 355 | 355 | return 0; |
| 356 | 356 | } |
@@ -363,13 +363,13 @@ discard block |
||
| 363 | 363 | * @param type $event_id |
| 364 | 364 | * @return int |
| 365 | 365 | */ |
| 366 | - public static function count_registrations($event_id){ |
|
| 366 | + public static function count_registrations($event_id) { |
|
| 367 | 367 | global $wpdb; |
| 368 | - $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d",$event_id)); |
|
| 368 | + $count = $wpdb->get_var($wpdb->prepare("SELECT sum(quantity) FROM {$wpdb->prefix}events_attendee WHERE event_id=%d", $event_id)); |
|
| 369 | 369 | return intval($count); |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - private function _insert_event_meta($old_event,$new_cpt_id){ |
|
| 372 | + private function _insert_event_meta($old_event, $new_cpt_id) { |
|
| 373 | 373 | global $wpdb; |
| 374 | 374 | $event_meta = maybe_unserialize($old_event['event_meta']); |
| 375 | 375 | // for reference, 3.1 'default_payment_status' are: $default_payment_status = array( |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | //); |
| 381 | 381 | $default_reg_status = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(isset($event_meta['default_payment_status']) ? $event_meta['default_payment_status'] : '', intval($old_event['require_pre_approval'])); |
| 382 | 382 | $cols_n_values = array( |
| 383 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID_fk |
|
| 383 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID_fk |
|
| 384 | 384 | 'EVT_display_desc'=> 'Y' == $old_event['display_desc'], |
| 385 | - 'EVT_display_ticket_selector'=> 'Y'== $old_event['display_reg_form'], |
|
| 386 | - 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this,$old_event,current_time('mysql'),$old_event['timezone_string']),//don't use the old 'visible_on', as it wasnt ever used |
|
| 385 | + 'EVT_display_ticket_selector'=> 'Y' == $old_event['display_reg_form'], |
|
| 386 | + 'EVT_visible_on'=> $this->get_migration_script()->convert_date_string_to_utc($this, $old_event, current_time('mysql'), $old_event['timezone_string']), //don't use the old 'visible_on', as it wasnt ever used |
|
| 387 | 387 | 'EVT_additional_limit'=> $old_event['allow_multiple'] == 'N' ? 1 : $old_event['additional_limit'], |
| 388 | 388 | 'EVT_default_registration_status' => $default_reg_status, |
| 389 | 389 | 'EVT_member_only'=>$old_event['member_only'], |
@@ -395,31 +395,31 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | ); |
| 397 | 397 | $datatypes = array( |
| 398 | - '%s',//EVT_ID |
|
| 399 | - '%d',//EVT_display_desc |
|
| 400 | - '%d',//EVT_display_ticket_selector |
|
| 401 | - '%s',//EVT_visible_on |
|
| 402 | - '%d',//EVT_additional_limit |
|
| 403 | - '%s',//EVT_default_registration_status |
|
| 404 | - '%d',//EVT_member_only |
|
| 405 | - '%s',//EVT_phone |
|
| 406 | - '%d',//EVT_allow_overflow |
|
| 407 | - '%s',//EVT_timezone_string |
|
| 408 | - '%s',//EVT_external_URL |
|
| 409 | - '%d',//EVT_donations |
|
| 398 | + '%s', //EVT_ID |
|
| 399 | + '%d', //EVT_display_desc |
|
| 400 | + '%d', //EVT_display_ticket_selector |
|
| 401 | + '%s', //EVT_visible_on |
|
| 402 | + '%d', //EVT_additional_limit |
|
| 403 | + '%s', //EVT_default_registration_status |
|
| 404 | + '%d', //EVT_member_only |
|
| 405 | + '%s', //EVT_phone |
|
| 406 | + '%d', //EVT_allow_overflow |
|
| 407 | + '%s', //EVT_timezone_string |
|
| 408 | + '%s', //EVT_external_URL |
|
| 409 | + '%d', //EVT_donations |
|
| 410 | 410 | ); |
| 411 | 411 | $success = $wpdb->insert($this->_new_meta_table, |
| 412 | 412 | $cols_n_values, |
| 413 | 413 | $datatypes); |
| 414 | - if( ! $success ){ |
|
| 414 | + if ( ! $success) { |
|
| 415 | 415 | $this->add_error($this->get_migration_script->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $cols_n_values, $datatypes)); |
| 416 | 416 | return 0; |
| 417 | 417 | } |
| 418 | 418 | return $wpdb->insert_id; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - private function _maybe_create_venue($old_event){ |
|
| 422 | - if( $old_event['address'] || |
|
| 421 | + private function _maybe_create_venue($old_event) { |
|
| 422 | + if ($old_event['address'] || |
|
| 423 | 423 | $old_event['address2'] || |
| 424 | 424 | $old_event['city'] || |
| 425 | 425 | $old_event['state'] || |
@@ -430,21 +430,21 @@ discard block |
||
| 430 | 430 | $old_event['venue_phone'] || |
| 431 | 431 | $old_event['virtual_url'] || |
| 432 | 432 | $old_event['virtual_phone'] |
| 433 | - ){ |
|
| 434 | - $old_id = $this->_duplicate_venue_exists( $old_event ); |
|
| 435 | - if( $old_id ){ |
|
| 433 | + ) { |
|
| 434 | + $old_id = $this->_duplicate_venue_exists($old_event); |
|
| 435 | + if ($old_id) { |
|
| 436 | 436 | return $old_id; |
| 437 | 437 | } |
| 438 | 438 | $new_id = $this->_insert_venue_into_posts($old_event); |
| 439 | - if( $new_id ){ |
|
| 439 | + if ($new_id) { |
|
| 440 | 440 | $this->_insert_venue_into_meta_table($new_id, $old_event); |
| 441 | - $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
| 442 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id,$this); |
|
| 441 | + $guid = isset($old_event['venue_image']) ? $old_event['venue_image'] : null; |
|
| 442 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
| 443 | 443 | } |
| 444 | 444 | //we don't bother recording the conversion from old events to venues as that |
| 445 | 445 | //will complicate finding the conversion from old venues to new events |
| 446 | 446 | return $new_id; |
| 447 | - }else{ |
|
| 447 | + } else { |
|
| 448 | 448 | return 0; |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -455,29 +455,29 @@ discard block |
||
| 455 | 455 | * @param array $old_event |
| 456 | 456 | * @return int duplicate venue id |
| 457 | 457 | */ |
| 458 | - private function _duplicate_venue_exists($old_event){ |
|
| 458 | + private function _duplicate_venue_exists($old_event) { |
|
| 459 | 459 | global $wpdb; |
| 460 | 460 | $conditions = array( |
| 461 | - 'VNU_address' => $old_event [ 'address' ], |
|
| 462 | - 'VNU_address2' => $old_event[ 'address2' ], |
|
| 463 | - 'VNU_city' => $old_event[ 'city' ], |
|
| 464 | - 'VNU_zip' => $old_event[ 'zip' ], |
|
| 461 | + 'VNU_address' => $old_event ['address'], |
|
| 462 | + 'VNU_address2' => $old_event['address2'], |
|
| 463 | + 'VNU_city' => $old_event['city'], |
|
| 464 | + 'VNU_zip' => $old_event['zip'], |
|
| 465 | 465 | 'post_title'=> stripslashes($old_event['venue_title']), |
| 466 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
| 467 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
| 468 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
| 469 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
| 466 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
| 467 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
| 468 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
| 469 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
| 470 | 470 | ); |
| 471 | 471 | $sql_conditions = array(); |
| 472 | - foreach($conditions as $column => $value){ |
|
| 472 | + foreach ($conditions as $column => $value) { |
|
| 473 | 473 | $sql_conditions [] = "$column = '$value'"; |
| 474 | 474 | } |
| 475 | 475 | $query = "SELECT VNU_ID |
| 476 | 476 | FROM |
| 477 | 477 | {$wpdb->posts} as p INNER JOIN |
| 478 | 478 | {$wpdb->prefix}esp_venue_meta as v ON p.ID = v.VNU_ID |
| 479 | - WHERE " . implode( " AND ",$sql_conditions ) . " LIMIT 1"; |
|
| 480 | - $id = $wpdb->get_var( $query ); |
|
| 479 | + WHERE ".implode(" AND ", $sql_conditions)." LIMIT 1"; |
|
| 480 | + $id = $wpdb->get_var($query); |
|
| 481 | 481 | return $id; |
| 482 | 482 | } |
| 483 | 483 | |
@@ -486,40 +486,40 @@ discard block |
||
| 486 | 486 | * @param array $old_venue keys are cols, values are col values |
| 487 | 487 | * @return int |
| 488 | 488 | */ |
| 489 | - private function _insert_venue_into_posts($old_event){ |
|
| 489 | + private function _insert_venue_into_posts($old_event) { |
|
| 490 | 490 | global $wpdb; |
| 491 | 491 | $insertion_array = array( |
| 492 | - 'post_title'=>$old_event['venue_title'] ? stripslashes($old_event['venue_title']) : stripslashes( sprintf( __( 'Venue of %s', 'event_espresso' ), $old_event['event_name'])),//VNU_name |
|
| 493 | - 'post_content'=>'',//VNU_desc |
|
| 494 | - 'post_name'=> $this->_find_unique_slug( $old_event['venue_title'], sanitize_title( 'venue-of-' . $old_event['event_name'] ) ),//VNU_identifier |
|
| 495 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
| 492 | + 'post_title'=>$old_event['venue_title'] ? stripslashes($old_event['venue_title']) : stripslashes(sprintf(__('Venue of %s', 'event_espresso'), $old_event['event_name'])), //VNU_name |
|
| 493 | + 'post_content'=>'', //VNU_desc |
|
| 494 | + 'post_name'=> $this->_find_unique_slug($old_event['venue_title'], sanitize_title('venue-of-'.$old_event['event_name'])), //VNU_identifier |
|
| 495 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
| 496 | 496 | 'post_date_gmt'=>get_gmt_from_date(current_time('mysql')), |
| 497 | - 'post_excerpt'=>'',//VNU_short_desc arbitraty only 50 characters |
|
| 498 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
| 497 | + 'post_excerpt'=>'', //VNU_short_desc arbitraty only 50 characters |
|
| 498 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
| 499 | 499 | 'post_modified_gmt'=>get_gmt_from_date(current_time('mysql')), |
| 500 | - 'post_author'=>$old_event['wp_user'],//VNU_wp_user |
|
| 501 | - 'post_parent'=>null,//parent |
|
| 502 | - 'menu_order'=>0,//VNU_order |
|
| 500 | + 'post_author'=>$old_event['wp_user'], //VNU_wp_user |
|
| 501 | + 'post_parent'=>null, //parent |
|
| 502 | + 'menu_order'=>0, //VNU_order |
|
| 503 | 503 | 'post_type'=>'espresso_venues'//post_type |
| 504 | 504 | ); |
| 505 | 505 | $datatypes_array = array( |
| 506 | - '%s',//VNU_name |
|
| 507 | - '%s',//VNU_desc |
|
| 508 | - '%s',//VNU_identifier |
|
| 509 | - '%s',//VNU_created |
|
| 506 | + '%s', //VNU_name |
|
| 507 | + '%s', //VNU_desc |
|
| 508 | + '%s', //VNU_identifier |
|
| 509 | + '%s', //VNU_created |
|
| 510 | 510 | '%s', |
| 511 | - '%s',//VNU_short_desc |
|
| 512 | - '%s',//VNU_modified |
|
| 511 | + '%s', //VNU_short_desc |
|
| 512 | + '%s', //VNU_modified |
|
| 513 | 513 | '%s', |
| 514 | - '%d',//VNU_wp_user |
|
| 515 | - '%d',//parent |
|
| 516 | - '%d',//VNU_order |
|
| 517 | - '%s',//post_type |
|
| 514 | + '%d', //VNU_wp_user |
|
| 515 | + '%d', //parent |
|
| 516 | + '%d', //VNU_order |
|
| 517 | + '%s', //post_type |
|
| 518 | 518 | ); |
| 519 | 519 | $success = $wpdb->insert($wpdb->posts, |
| 520 | 520 | $insertion_array, |
| 521 | 521 | $datatypes_array); |
| 522 | - if( ! $success ){ |
|
| 522 | + if ( ! $success) { |
|
| 523 | 523 | $this->add_error($this->get_migration_script->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
| 524 | 524 | return 0; |
| 525 | 525 | } |
@@ -532,78 +532,78 @@ discard block |
||
| 532 | 532 | * @param type $old_event |
| 533 | 533 | * @return int |
| 534 | 534 | */ |
| 535 | - private function _insert_venue_into_meta_table($cpt_id,$old_event){ |
|
| 535 | + private function _insert_venue_into_meta_table($cpt_id, $old_event) { |
|
| 536 | 536 | global $wpdb; |
| 537 | 537 | |
| 538 | 538 | //assume the country is the same as the organization's old settings |
| 539 | 539 | $country_iso = $this->get_migration_script()->get_default_country_iso(); |
| 540 | 540 | //find the state from the venue, or the organization, or just guess california |
| 541 | - if( ! $old_event['state']){ |
|
| 541 | + if ( ! $old_event['state']) { |
|
| 542 | 542 | $old_org_options = get_option('events_organization_settings'); |
| 543 | 543 | $state_name = stripslashes($old_org_options['organization_state']); |
| 544 | - }else{ |
|
| 544 | + } else { |
|
| 545 | 545 | $state_name = $old_event['state']; |
| 546 | 546 | } |
| 547 | - if ( ! $state_name ){ |
|
| 547 | + if ( ! $state_name) { |
|
| 548 | 548 | $state_name = 'CA'; |
| 549 | 549 | } |
| 550 | 550 | //get a state ID with the same name, if possible |
| 551 | - try{ |
|
| 552 | - $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
|
| 551 | + try { |
|
| 552 | + $state = $this->get_migration_script()->get_or_create_state($state_name, $country_iso); |
|
| 553 | 553 | $state_id = $state['STA_ID']; |
| 554 | - }catch(EE_Error $e){ |
|
| 554 | + } catch (EE_Error $e) { |
|
| 555 | 555 | $this->add_error($e->getMessage()); |
| 556 | 556 | $state_id = 0; |
| 557 | 557 | } |
| 558 | 558 | //now insert into meta table |
| 559 | 559 | $insertion_array = array( |
| 560 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
| 561 | - 'VNU_address'=>stripslashes($old_event['address']),//VNU_address |
|
| 562 | - 'VNU_address2'=>stripslashes($old_event['address2']),//VNU_address2 |
|
| 563 | - 'VNU_city'=>stripslashes($old_event['city']),//VNU_city |
|
| 564 | - 'STA_ID'=>$state_id,//STA_ID |
|
| 565 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
| 566 | - 'VNU_zip'=>$old_event['zip'],//VNU_zip |
|
| 567 | - 'VNU_phone'=>$old_event['venue_phone'],//VNU_phone |
|
| 568 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
| 569 | - 'VNU_url'=>$old_event['venue_url'],//VNU_url |
|
| 570 | - 'VNU_virtual_phone'=>$old_event['virtual_phone'],//VNU_virtual_phone |
|
| 571 | - 'VNU_virtual_url'=>$old_event['virtual_url'],//VNU_virtual_url |
|
| 572 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
| 560 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
| 561 | + 'VNU_address'=>stripslashes($old_event['address']), //VNU_address |
|
| 562 | + 'VNU_address2'=>stripslashes($old_event['address2']), //VNU_address2 |
|
| 563 | + 'VNU_city'=>stripslashes($old_event['city']), //VNU_city |
|
| 564 | + 'STA_ID'=>$state_id, //STA_ID |
|
| 565 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
| 566 | + 'VNU_zip'=>$old_event['zip'], //VNU_zip |
|
| 567 | + 'VNU_phone'=>$old_event['venue_phone'], //VNU_phone |
|
| 568 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
| 569 | + 'VNU_url'=>$old_event['venue_url'], //VNU_url |
|
| 570 | + 'VNU_virtual_phone'=>$old_event['virtual_phone'], //VNU_virtual_phone |
|
| 571 | + 'VNU_virtual_url'=>$old_event['virtual_url'], //VNU_virtual_url |
|
| 572 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
| 573 | 573 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
| 574 | 574 | ); |
| 575 | 575 | $datatypes = array( |
| 576 | - '%d',//VNU_ID_fk |
|
| 577 | - '%s',//VNU_address |
|
| 578 | - '%s',//VNU_address2 |
|
| 579 | - '%s',//VNU_city |
|
| 580 | - '%d',//STA_ID |
|
| 581 | - '%s',//CNT_ISO |
|
| 582 | - '%s',//VNU_zip |
|
| 583 | - '%s',//VNU_phone |
|
| 584 | - '%d',//VNU_capacity |
|
| 585 | - '%s',//VNU_url |
|
| 586 | - '%s',//VNU_virtual_phone |
|
| 587 | - '%s',//VNU_virtual_url |
|
| 588 | - '%s',//VNU_google_map_link |
|
| 589 | - '%d',//VNU_enable_for_gmap |
|
| 576 | + '%d', //VNU_ID_fk |
|
| 577 | + '%s', //VNU_address |
|
| 578 | + '%s', //VNU_address2 |
|
| 579 | + '%s', //VNU_city |
|
| 580 | + '%d', //STA_ID |
|
| 581 | + '%s', //CNT_ISO |
|
| 582 | + '%s', //VNU_zip |
|
| 583 | + '%s', //VNU_phone |
|
| 584 | + '%d', //VNU_capacity |
|
| 585 | + '%s', //VNU_url |
|
| 586 | + '%s', //VNU_virtual_phone |
|
| 587 | + '%s', //VNU_virtual_url |
|
| 588 | + '%s', //VNU_google_map_link |
|
| 589 | + '%d', //VNU_enable_for_gmap |
|
| 590 | 590 | ); |
| 591 | - $success = $wpdb->insert($wpdb->prefix."esp_venue_meta",$insertion_array,$datatypes); |
|
| 592 | - if( ! $success ){ |
|
| 591 | + $success = $wpdb->insert($wpdb->prefix."esp_venue_meta", $insertion_array, $datatypes); |
|
| 592 | + if ( ! $success) { |
|
| 593 | 593 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event, $this->_new_meta_table, $insertion_array, $datatypes)); |
| 594 | 594 | return 0; |
| 595 | 595 | } |
| 596 | 596 | return $wpdb->insert_id; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - private function _insert_new_venue_to_event($new_event_id,$new_venue_id){ |
|
| 599 | + private function _insert_new_venue_to_event($new_event_id, $new_venue_id) { |
|
| 600 | 600 | global $wpdb; |
| 601 | - if( ! $new_event_id){ |
|
| 602 | - $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"),$new_event_id)); |
|
| 601 | + if ( ! $new_event_id) { |
|
| 602 | + $this->add_error(sprintf(__("Could not find 4.1 event id for 3.1 event #%d.", "event_espresso"), $new_event_id)); |
|
| 603 | 603 | return 0; |
| 604 | 604 | } |
| 605 | - if( ! $new_venue_id){ |
|
| 606 | - $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"),$new_venue_id)); |
|
| 605 | + if ( ! $new_venue_id) { |
|
| 606 | + $this->add_error(sprintf(__("Could not find 4.1 venue id for 3.1 venue #%d.", "event_espresso"), $new_venue_id)); |
|
| 607 | 607 | return 0; |
| 608 | 608 | } |
| 609 | 609 | $cols_n_values = array( |
@@ -612,12 +612,12 @@ discard block |
||
| 612 | 612 | 'EVV_primary'=>true |
| 613 | 613 | ); |
| 614 | 614 | $datatypes = array( |
| 615 | - '%d',//EVT_ID |
|
| 616 | - '%d',//VNU_ID |
|
| 617 | - '%d',//EVT_primary |
|
| 615 | + '%d', //EVT_ID |
|
| 616 | + '%d', //VNU_ID |
|
| 617 | + '%d', //EVT_primary |
|
| 618 | 618 | ); |
| 619 | - $success = $wpdb->insert($wpdb->prefix."esp_event_venue",$cols_n_values,$datatypes); |
|
| 620 | - if ( ! $success){ |
|
| 619 | + $success = $wpdb->insert($wpdb->prefix."esp_event_venue", $cols_n_values, $datatypes); |
|
| 620 | + if ( ! $success) { |
|
| 621 | 621 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_event_venue_rel, $this->_new_table, $cols_n_values, $datatypes)); |
| 622 | 622 | return 0; |
| 623 | 623 | } |
@@ -631,11 +631,11 @@ discard block |
||
| 631 | 631 | * @param int $new_cpt_id new post ID |
| 632 | 632 | * @return void (if there are errors though, adds them to the stage's error list |
| 633 | 633 | */ |
| 634 | - private function _convert_start_end_times($old_event,$new_cpt_id){ |
|
| 634 | + private function _convert_start_end_times($old_event, $new_cpt_id) { |
|
| 635 | 635 | $start_end_times = $this->_get_old_start_end_times($old_event['id']); |
| 636 | - foreach($start_end_times as $start_end_time){ |
|
| 637 | - $datetime_id = $this->_insert_new_datetime($start_end_time,$old_event,$new_cpt_id); |
|
| 638 | - if($datetime_id){ |
|
| 636 | + foreach ($start_end_times as $start_end_time) { |
|
| 637 | + $datetime_id = $this->_insert_new_datetime($start_end_time, $old_event, $new_cpt_id); |
|
| 638 | + if ($datetime_id) { |
|
| 639 | 639 | $this->get_migration_script()->set_mapping($this->_old_start_end_table, $start_end_time['id'], $this->_new_datetime_table, $datetime_id); |
| 640 | 640 | } |
| 641 | 641 | } |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | * @param type $old_event_id |
| 647 | 647 | * @return type |
| 648 | 648 | */ |
| 649 | - private function _get_old_start_end_times($old_event_id){ |
|
| 649 | + private function _get_old_start_end_times($old_event_id) { |
|
| 650 | 650 | global $wpdb; |
| 651 | - return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d",$old_event_id),ARRAY_A); |
|
| 651 | + return $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_start_end_table WHERE event_id=%d", $old_event_id), ARRAY_A); |
|
| 652 | 652 | } |
| 653 | 653 | /** |
| 654 | 654 | * Inserts a 4.1 datetime given the 3.1 start_end db row and event_details row |
@@ -657,40 +657,40 @@ discard block |
||
| 657 | 657 | * @param type $new_cpt_id |
| 658 | 658 | * @return int ID of new datetime |
| 659 | 659 | */ |
| 660 | - private function _insert_new_datetime($start_end_time_row,$old_event_row,$new_cpt_id){ |
|
| 660 | + private function _insert_new_datetime($start_end_time_row, $old_event_row, $new_cpt_id) { |
|
| 661 | 661 | global $wpdb; |
| 662 | 662 | $start_date = $old_event_row['start_date']; |
| 663 | 663 | $start_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['start_time']); |
| 664 | 664 | $end_date = $old_event_row['end_date']; |
| 665 | 665 | $end_time = $this->get_migration_script()->convertTimeFromAMPM($start_end_time_row['end_time']); |
| 666 | 666 | $existing_datetimes = $this->_count_other_datetimes_exist_for_new_event($new_cpt_id); |
| 667 | - $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$start_date $start_time:00",$old_event_row['timezone_string']); |
|
| 668 | - $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$start_end_time_row,"$end_date $end_time:00",$old_event_row['timezone_string']); |
|
| 667 | + $start_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$start_date $start_time:00", $old_event_row['timezone_string']); |
|
| 668 | + $end_datetime_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $start_end_time_row, "$end_date $end_time:00", $old_event_row['timezone_string']); |
|
| 669 | 669 | $cols_n_values = array( |
| 670 | - 'EVT_ID'=>$new_cpt_id,//EVT_ID |
|
| 671 | - 'DTT_EVT_start'=>$start_datetime_utc,//DTT_EVT_start |
|
| 672 | - 'DTT_EVT_end'=> $end_datetime_utc,//DTT_EVT_end |
|
| 673 | - 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'],//DTT_reg_limit |
|
| 674 | - 'DTT_sold'=>0,//note: we will increment this as registrations are added during the migration |
|
| 670 | + 'EVT_ID'=>$new_cpt_id, //EVT_ID |
|
| 671 | + 'DTT_EVT_start'=>$start_datetime_utc, //DTT_EVT_start |
|
| 672 | + 'DTT_EVT_end'=> $end_datetime_utc, //DTT_EVT_end |
|
| 673 | + 'DTT_reg_limit'=>intval($start_end_time_row['reg_limit']) ? $start_end_time_row['reg_limit'] : $old_event_row['reg_limit'], //DTT_reg_limit |
|
| 674 | + 'DTT_sold'=>0, //note: we will increment this as registrations are added during the migration |
|
| 675 | 675 | // 'DTT_is_primary'=> 0 == $existing_datetimes ,//DTT_is_primary... if count==0, then we'll call it the 'primary' |
| 676 | - 'DTT_order'=> $existing_datetimes,//DTT_order, just give it the same order as the count of how many datetimes already exist |
|
| 676 | + 'DTT_order'=> $existing_datetimes, //DTT_order, just give it the same order as the count of how many datetimes already exist |
|
| 677 | 677 | 'DTT_parent'=>0, |
| 678 | 678 | 'DTT_deleted'=>false |
| 679 | 679 | ); |
| 680 | 680 | $datatypes = array( |
| 681 | - '%d',//EVT_Id |
|
| 682 | - '%s',//DTT_EVT_start |
|
| 683 | - '%s',//DTT_EVT_end |
|
| 684 | - '%d',//DTT_reg_limit |
|
| 685 | - '%d',//DTT_sold |
|
| 681 | + '%d', //EVT_Id |
|
| 682 | + '%s', //DTT_EVT_start |
|
| 683 | + '%s', //DTT_EVT_end |
|
| 684 | + '%d', //DTT_reg_limit |
|
| 685 | + '%d', //DTT_sold |
|
| 686 | 686 | // '%d',//DTT_is_primary |
| 687 | - '%d',//DTT_order |
|
| 688 | - '%d',//DTT_parent |
|
| 689 | - '%d',//DTT_deleted |
|
| 687 | + '%d', //DTT_order |
|
| 688 | + '%d', //DTT_parent |
|
| 689 | + '%d', //DTT_deleted |
|
| 690 | 690 | ); |
| 691 | - $success = $wpdb->insert($this->_new_datetime_table,$cols_n_values,$datatypes); |
|
| 692 | - if ( ! $success){ |
|
| 693 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row,$start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
| 691 | + $success = $wpdb->insert($this->_new_datetime_table, $cols_n_values, $datatypes); |
|
| 692 | + if ( ! $success) { |
|
| 693 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_start_end_table, array_merge($old_event_row, $start_end_time_row), $this->_new_datetime_table, $cols_n_values, $datatypes)); |
|
| 694 | 694 | return 0; |
| 695 | 695 | } |
| 696 | 696 | return $wpdb->insert_id; |
@@ -703,9 +703,9 @@ discard block |
||
| 703 | 703 | * @param type $cpt_event_id |
| 704 | 704 | * @return int |
| 705 | 705 | */ |
| 706 | - private function _count_other_datetimes_exist_for_new_event($cpt_event_id){ |
|
| 706 | + private function _count_other_datetimes_exist_for_new_event($cpt_event_id) { |
|
| 707 | 707 | global $wpdb; |
| 708 | - $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d",$cpt_event_id)); |
|
| 708 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $this->_new_datetime_table WHERE EVT_ID=%d", $cpt_event_id)); |
|
| 709 | 709 | return intval($count); |
| 710 | 710 | } |
| 711 | 711 | |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | //we don't bother recording the conversion from old events to venues as that |
| 445 | 445 | //will complicate finding the conversion from old venues to new events |
| 446 | 446 | return $new_id; |
| 447 | - }else{ |
|
| 447 | + } else{ |
|
| 448 | 448 | return 0; |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | if( ! $old_event['state']){ |
| 542 | 542 | $old_org_options = get_option('events_organization_settings'); |
| 543 | 543 | $state_name = stripslashes($old_org_options['organization_state']); |
| 544 | - }else{ |
|
| 544 | + } else{ |
|
| 545 | 545 | $state_name = $old_event['state']; |
| 546 | 546 | } |
| 547 | 547 | if ( ! $state_name ){ |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | try{ |
| 552 | 552 | $state = $this->get_migration_script()->get_or_create_state($state_name,$country_iso); |
| 553 | 553 | $state_id = $state['STA_ID']; |
| 554 | - }catch(EE_Error $e){ |
|
| 554 | + } catch(EE_Error $e){ |
|
| 555 | 555 | $this->add_error($e->getMessage()); |
| 556 | 556 | $state_id = 0; |
| 557 | 557 | } |
@@ -77,7 +77,7 @@ |
||
| 77 | 77 | * Takes the old array of 3.1 gateway settings for this gateway and converts it |
| 78 | 78 | * into an array with all the 4.1 gateway setting array keys (often the keys were |
| 79 | 79 | * changed from 3.1 to 4.1) |
| 80 | - * @param array $old_gateway_settings |
|
| 80 | + * @param string $old_gateway_settings |
|
| 81 | 81 | * @param string $new_gateway_slug |
| 82 | 82 | * @return array |
| 83 | 83 | */ |
@@ -11,52 +11,52 @@ discard block |
||
| 11 | 11 | * which are both arrays |
| 12 | 12 | * -a function named update_espresso_config() which saves the EE_Config object to the database |
| 13 | 13 | */ |
| 14 | -class EE_DMS_4_1_0_gateways extends EE_Data_Migration_Script_Stage{ |
|
| 14 | +class EE_DMS_4_1_0_gateways extends EE_Data_Migration_Script_Stage { |
|
| 15 | 15 | |
| 16 | 16 | private $_converted_active_gateways = false; |
| 17 | 17 | |
| 18 | -function _migration_step($num_items=50){ |
|
| 18 | +function _migration_step($num_items = 50) { |
|
| 19 | 19 | //loads existing EE_CONfig from DB, if it exists |
| 20 | 20 | $new_gateway_config_obj = EE_Config::instance()->gateway; |
| 21 | 21 | $items_actually_migrated = 0; |
| 22 | 22 | //convert settings |
| 23 | - $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate,$this->_gateways_we_leave_alone); |
|
| 23 | + $gateways_to_deal_with = array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone); |
|
| 24 | 24 | //just do a part of them on this request |
| 25 | - $gateways_to_deal_with = array_slice($gateways_to_deal_with,$this->count_records_migrated(),$num_items);// $this->_gateways_we_know_how_to_migrate; |
|
| 26 | - foreach($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug){ |
|
| 25 | + $gateways_to_deal_with = array_slice($gateways_to_deal_with, $this->count_records_migrated(), $num_items); // $this->_gateways_we_know_how_to_migrate; |
|
| 26 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $new_gateway_slug) { |
|
| 27 | 27 | $old_gateway_wp_option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
| 28 | - if(isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])){ |
|
| 28 | + if (isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
| 29 | 29 | //determine the old option's name |
| 30 | 30 | $old_gateway_settings = $this->_get_old_gateway_option($new_gateway_slug); |
| 31 | - if( ! $old_gateway_settings){ |
|
| 31 | + if ( ! $old_gateway_settings) { |
|
| 32 | 32 | //no settings existed for this gateway anyways... weird... |
| 33 | 33 | $items_actually_migrated++; |
| 34 | 34 | continue; |
| 35 | 35 | } |
| 36 | 36 | //now prepare the settings to make sure they're in the 4.1 format |
| 37 | - $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings,$new_gateway_slug); |
|
| 37 | + $new_gateway_settings = $this->_convert_gateway_settings($old_gateway_settings, $new_gateway_slug); |
|
| 38 | 38 | $new_gateway_config_obj->payment_settings[$new_gateway_slug] = $new_gateway_settings; |
| 39 | 39 | //and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
| 40 | 40 | //I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
| 41 | 41 | delete_option($old_gateway_wp_option_name); |
| 42 | - }else{//it must be one of the ones we mostly leave alone |
|
| 42 | + } else {//it must be one of the ones we mostly leave alone |
|
| 43 | 43 | global $wpdb; |
| 44 | 44 | //yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
| 45 | 45 | //only be saving users 50 milliseconds the one time this runs... |
| 46 | - $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s",$old_gateway_wp_option_name)); |
|
| 46 | + $wpdb->query($wpdb->prepare("UPDATE ".$wpdb->options." SET autoload='no' WHERE option_name=%s", $old_gateway_wp_option_name)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $items_actually_migrated++; |
| 50 | 50 | } |
| 51 | 51 | //if we can keep going, and it hasn' tbeen done yet, convert active gateways |
| 52 | - if($items_actually_migrated < $num_items && ! $this->_converted_active_gateways){ |
|
| 52 | + if ($items_actually_migrated < $num_items && ! $this->_converted_active_gateways) { |
|
| 53 | 53 | $this->_convert_active_gateways(); |
| 54 | 54 | $this->_converted_active_gateways = true; |
| 55 | 55 | $items_actually_migrated++; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - EE_Config::instance()->update_espresso_config(false,false); |
|
| 59 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 58 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 59 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 60 | 60 | $this->set_completed(); |
| 61 | 61 | } |
| 62 | 62 | return $items_actually_migrated; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $step_of_setting_active_gateways = 1; |
| 67 | 67 | $count_of_gateways_to_leave_alone = count($this->_gateways_we_leave_alone); |
| 68 | 68 | // $button_images_to_update = |
| 69 | - return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
| 69 | + return $count_of_gateways_to_convert + $step_of_setting_active_gateways + $count_of_gateways_to_leave_alone; |
|
| 70 | 70 | } |
| 71 | 71 | function __construct() { |
| 72 | 72 | $this->_pretty_name = __("Gateways", "event_espresso"); |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | * @param string $new_gateway_slug |
| 82 | 82 | * @return array |
| 83 | 83 | */ |
| 84 | -private function _convert_gateway_settings($old_gateway_settings,$new_gateway_slug){ |
|
| 84 | +private function _convert_gateway_settings($old_gateway_settings, $new_gateway_slug) { |
|
| 85 | 85 | $new_gateway_settings = $old_gateway_settings; |
| 86 | - switch($new_gateway_slug){ |
|
| 86 | + switch ($new_gateway_slug) { |
|
| 87 | 87 | case 'Bank': |
| 88 | 88 | $new_gateway_settings['account_number'] = $old_gateway_settings['bank_account']; |
| 89 | 89 | $new_gateway_settings['page_title'] = $old_gateway_settings['bank_title']; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $new_gateway_settings['username'] = $old_gateway_settings['paypal_api_username']; |
| 97 | 97 | $new_gateway_settings['password'] = $old_gateway_settings['paypal_api_password']; |
| 98 | 98 | $new_gateway_settings['signature'] = $old_gateway_settings['paypal_api_signature']; |
| 99 | - $new_gateway_settings['credit_cards'] = explode(",",$old_gateway_settings['paypal_api_credit_cards']); |
|
| 99 | + $new_gateway_settings['credit_cards'] = explode(",", $old_gateway_settings['paypal_api_credit_cards']); |
|
| 100 | 100 | $new_gateway_settings['use_sandbox'] = $old_gateway_settings['paypal_pro_use_sandbox']; |
| 101 | 101 | break; |
| 102 | 102 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | * @param string $new_gateway_slug |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | -private function _get_old_gateway_option($new_gateway_slug){ |
|
| 110 | +private function _get_old_gateway_option($new_gateway_slug) { |
|
| 111 | 111 | $option_name = $this->_get_old_gateway_option_name($new_gateway_slug); |
| 112 | - $settings = get_option($option_name, NULL); |
|
| 112 | + $settings = get_option($option_name, NULL); |
|
| 113 | 113 | // if( ! $settings){ |
| 114 | 114 | // $this->add_error(sprintf(__("There is no wordpress option named %s for gateway %s", "event_espresso"),$option_name,$new_gateway_slug)); |
| 115 | 115 | // } |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | * @param string $new_gateway_slug |
| 122 | 122 | * @return string |
| 123 | 123 | */ |
| 124 | -private function _get_old_gateway_option_name($new_gateway_slug){ |
|
| 125 | - $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate,$this->_gateways_we_leave_alone)); |
|
| 124 | +private function _get_old_gateway_option_name($new_gateway_slug) { |
|
| 125 | + $new_gateway_slugs_to_new = array_flip(array_merge($this->_gateways_we_know_how_to_migrate, $this->_gateways_we_leave_alone)); |
|
| 126 | 126 | $old_gateway_slug = $new_gateway_slugs_to_new[$new_gateway_slug]; |
| 127 | 127 | $normal_option_prefix = 'event_espresso_'; |
| 128 | 128 | $normal_option_postfix = '_settings'; |
| 129 | - switch($new_gateway_slug){ |
|
| 129 | + switch ($new_gateway_slug) { |
|
| 130 | 130 | case 'Bank': |
| 131 | 131 | $option_name = $normal_option_prefix.'bank_deposit'.$normal_option_postfix; |
| 132 | 132 | break; |
@@ -152,18 +152,18 @@ discard block |
||
| 152 | 152 | $option_name = 'espresso_usaepay_onsite'.$normal_option_postfix; |
| 153 | 153 | break; |
| 154 | 154 | default: |
| 155 | - $option_name = apply_filters( 'FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option',$normal_option_prefix.$old_gateway_slug.$normal_option_postfix ); |
|
| 155 | + $option_name = apply_filters('FHEE__EE_DMS_4_1_0_gateways__get_old_gateway_option', $normal_option_prefix.$old_gateway_slug.$normal_option_postfix); |
|
| 156 | 156 | } |
| 157 | 157 | return $option_name; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | -private function _convert_active_gateways(){ |
|
| 160 | +private function _convert_active_gateways() { |
|
| 161 | 161 | //just does it all one big swoop |
| 162 | 162 | $old_active_gateways = get_option('event_espresso_active_gateways'); |
| 163 | 163 | $new_active_gateways = EE_Config::instance()->gateway->active_gateways; |
| 164 | - foreach($old_active_gateways as $old_gateway_slug => $filepath){ |
|
| 165 | - if( ! isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])){ |
|
| 166 | - $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"),$old_gateway_slug)); |
|
| 164 | + foreach ($old_active_gateways as $old_gateway_slug => $filepath) { |
|
| 165 | + if ( ! isset($this->_gateways_we_know_how_to_migrate[$old_gateway_slug])) { |
|
| 166 | + $this->add_error(sprintf(__("The %s gateway does not exist in EE 4.1", "event_espresso"), $old_gateway_slug)); |
|
| 167 | 167 | continue; |
| 168 | 168 | } |
| 169 | 169 | $new_gateway_slug = $this->_gateways_we_know_how_to_migrate[$old_gateway_slug]; |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | //and when we're done, remove the old option. Sometimes we'd prefer to do this in a different stage, but |
| 40 | 40 | //I think it's ok to do right away this time (we wont need gateway settings elsewhere) |
| 41 | 41 | delete_option($old_gateway_wp_option_name); |
| 42 | - }else{//it must be one of the ones we mostly leave alone |
|
| 42 | + } else{//it must be one of the ones we mostly leave alone |
|
| 43 | 43 | global $wpdb; |
| 44 | 44 | //yeah we could do this all in one query... and if you're reading this and would liek to, go ahead. Although you'll |
| 45 | 45 | //only be saving users 50 milliseconds the one time this runs... |
@@ -245,7 +245,6 @@ |
||
| 245 | 245 | /** |
| 246 | 246 | * Creates a 4.1 member price discount |
| 247 | 247 | * @global type $wpdb |
| 248 | - * @param type $old_price |
|
| 249 | 248 | * @return int |
| 250 | 249 | */ |
| 251 | 250 | private function _insert_new_global_surcharge_price($org_options){ |
@@ -191,7 +191,7 @@ |
||
| 191 | 191 | $c->organization->logo_url = $value;break; |
| 192 | 192 | case 'event_page_id': |
| 193 | 193 | |
| 194 | - //also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 194 | + //also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
|
| 195 | 195 | //to ESPRESSO_THANK_YOU |
| 196 | 196 | $reg_page_post = get_post($value); |
| 197 | 197 | $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]","[ESPRESSO_CHECKOUT]",$reg_page_post->post_content); |
@@ -100,30 +100,30 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @todo: inform clients that messages have COMPLETELY changed in 4.1; themeroller isn't in there; event list page is no more; |
| 102 | 102 | */ |
| 103 | -class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage{ |
|
| 103 | +class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage { |
|
| 104 | 104 | |
| 105 | - function _migration_step($num_items=50){ |
|
| 105 | + function _migration_step($num_items = 50) { |
|
| 106 | 106 | |
| 107 | 107 | $items_actually_migrated = 0; |
| 108 | 108 | $old_org_options = get_option('events_organization_settings'); |
| 109 | - foreach($this->_org_options_we_know_how_to_migrate as $option_name){ |
|
| 109 | + foreach ($this->_org_options_we_know_how_to_migrate as $option_name) { |
|
| 110 | 110 | //only bother migrating if there's a setting to migrate. Otherwise we'll just use the default |
| 111 | - if(isset($old_org_options[$option_name])){ |
|
| 111 | + if (isset($old_org_options[$option_name])) { |
|
| 112 | 112 | $this->_handle_org_option($option_name, $old_org_options[$option_name]); |
| 113 | 113 | } |
| 114 | - if($option_name=='surcharge'){ |
|
| 114 | + if ($option_name == 'surcharge') { |
|
| 115 | 115 | $this->_insert_new_global_surcharge_price($old_org_options); |
| 116 | 116 | } |
| 117 | 117 | $items_actually_migrated++; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - $success = EE_Config::instance()->update_espresso_config(FALSE,TRUE); |
|
| 121 | - if( ! $success ) { |
|
| 122 | - $this->add_error( sprintf( __( 'Could not save EE Config during org options stage. Reason: %s', 'event_espresso' ), EE_Error::get_notices( FALSE )) ); |
|
| 120 | + $success = EE_Config::instance()->update_espresso_config(FALSE, TRUE); |
|
| 121 | + if ( ! $success) { |
|
| 122 | + $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(FALSE))); |
|
| 123 | 123 | EE_Error::overwrite_errors(); |
| 124 | 124 | } |
| 125 | - EE_Network_Config::instance()->update_config(FALSE,FALSE); |
|
| 126 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 125 | + EE_Network_Config::instance()->update_config(FALSE, FALSE); |
|
| 126 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 127 | 127 | //we may have added new pages and this might be necessary |
| 128 | 128 | flush_rewrite_rules(); |
| 129 | 129 | $this->set_completed(); |
@@ -136,65 +136,65 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | function __construct() { |
| 138 | 138 | $this->_pretty_name = __("Organization Options/Config", "event_espresso"); |
| 139 | - $this->_org_options_we_know_how_to_migrate = apply_filters( 'FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate',$this->_org_options_we_know_how_to_migrate ); |
|
| 139 | + $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate); |
|
| 140 | 140 | parent::__construct(); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - private function _handle_org_option($option_name,$value){ |
|
| 143 | + private function _handle_org_option($option_name, $value) { |
|
| 144 | 144 | $c = EE_Config::instance(); |
| 145 | 145 | $cn = EE_Network_Config::instance(); |
| 146 | - switch($option_name){ |
|
| 146 | + switch ($option_name) { |
|
| 147 | 147 | case 'organization': |
| 148 | - $c->organization->name = $value;break; |
|
| 148 | + $c->organization->name = $value; break; |
|
| 149 | 149 | case 'organization_street1': |
| 150 | - $c->organization->address_1 = $value;break; |
|
| 150 | + $c->organization->address_1 = $value; break; |
|
| 151 | 151 | case 'organization_street2': |
| 152 | - $c->organization->address_2 = $value;break; |
|
| 152 | + $c->organization->address_2 = $value; break; |
|
| 153 | 153 | case 'organization_city': |
| 154 | - $c->organization->city = $value;break; |
|
| 154 | + $c->organization->city = $value; break; |
|
| 155 | 155 | case 'organization_state': |
| 156 | - try{ |
|
| 156 | + try { |
|
| 157 | 157 | $state = $this->get_migration_script()->get_or_create_state($value); |
| 158 | 158 | $state_id = $state['STA_ID']; |
| 159 | 159 | $c->organization->STA_ID = $state_id; |
| 160 | - }catch(EE_Error $e){}break; |
|
| 160 | + } catch (EE_Error $e) {}break; |
|
| 161 | 161 | case 'organization_zip': |
| 162 | - $c->organization->zip = $value;break; |
|
| 162 | + $c->organization->zip = $value; break; |
|
| 163 | 163 | case 'contact_email': |
| 164 | - $c->organization->email = $value;break; |
|
| 164 | + $c->organization->email = $value; break; |
|
| 165 | 165 | case 'default_payment_status': |
| 166 | - $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);break; |
|
| 166 | + $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value); break; |
|
| 167 | 167 | case 'organization_country': |
| 168 | - $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 168 | + $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value); |
|
| 169 | 169 | $c->organization->CNT_ISO = $iso; |
| 170 | 170 | $country_row = $this->get_migration_script()->get_or_create_country($iso); |
| 171 | - if( ! $country_row){ |
|
| 172 | - $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"),$iso)); |
|
| 171 | + if ( ! $country_row) { |
|
| 172 | + $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso)); |
|
| 173 | 173 | } |
| 174 | 174 | //can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them) |
| 175 | - $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 176 | - $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 177 | - $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 178 | - $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 179 | - $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
| 180 | - $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 181 | - $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 182 | - $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 175 | + $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR |
|
| 176 | + $c->currency->name = $country_row['CNT_cur_single']; // Dollar |
|
| 177 | + $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars |
|
| 178 | + $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $ |
|
| 179 | + $c->currency->sign_b4 = intval($country_row['CNT_cur_sign_b4']); // currency sign before or after: $TRUE or FALSE$ |
|
| 180 | + $c->currency->dec_plc = intval($country_row['CNT_cur_dec_plc']); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 181 | + $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 182 | + $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 183 | 183 | // $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break; |
| 184 | 184 | // case 'currency_symbol': ignore the currency symbol. we'll just go by their country. |
| 185 | 185 | // $c->currency->sign = $value;break; |
| 186 | 186 | case 'show_pending_payment_options': |
| 187 | - $c->registration->show_pending_payment_options = ($value == 'Y');break; |
|
| 187 | + $c->registration->show_pending_payment_options = ($value == 'Y'); break; |
|
| 188 | 188 | case 'display_address_in_regform': |
| 189 | - $c->template_settings->display_address_in_regform = ($value == 'Y');break; |
|
| 189 | + $c->template_settings->display_address_in_regform = ($value == 'Y'); break; |
|
| 190 | 190 | case 'default_logo_url': |
| 191 | - $c->organization->logo_url = $value;break; |
|
| 191 | + $c->organization->logo_url = $value; break; |
|
| 192 | 192 | case 'event_page_id': |
| 193 | 193 | |
| 194 | 194 | //also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
| 195 | 195 | //to ESPRESSO_THANK_YOU |
| 196 | 196 | $reg_page_post = get_post($value); |
| 197 | - $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]","[ESPRESSO_CHECKOUT]",$reg_page_post->post_content); |
|
| 197 | + $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content); |
|
| 198 | 198 | wp_update_post($reg_page_post); |
| 199 | 199 | $c->core->reg_page_id = $value; |
| 200 | 200 | break; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | //also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS |
| 203 | 203 | //to ESPRESSO_THANK_YOU |
| 204 | 204 | $thank_you_page_post = get_post($value); |
| 205 | - $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]","[ESPRESSO_THANK_YOU]",$thank_you_page_post->post_content); |
|
| 205 | + $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content); |
|
| 206 | 206 | wp_update_post($thank_you_page_post); |
| 207 | 207 | $c->core->thank_you_page_id = $value; |
| 208 | 208 | break; |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | case 'use_captcha': |
| 217 | 217 | $c->registration->use_captcha = ($value == 'Y'); break; |
| 218 | 218 | case 'recaptcha_publickey': |
| 219 | - $c->registration->recaptcha_publickey = $value;break; |
|
| 219 | + $c->registration->recaptcha_publickey = $value; break; |
|
| 220 | 220 | case 'recaptcha_privatekey': |
| 221 | - $c->registration->recaptcha_privatekey = $value;break; |
|
| 221 | + $c->registration->recaptcha_privatekey = $value; break; |
|
| 222 | 222 | case 'recaptcha_theme': |
| 223 | - $c->registration->recaptcha_theme = $value;break; |
|
| 223 | + $c->registration->recaptcha_theme = $value; break; |
|
| 224 | 224 | case 'recaptcha_width': |
| 225 | - $c->registration->recaptcha_width = $value;break; |
|
| 225 | + $c->registration->recaptcha_width = $value; break; |
|
| 226 | 226 | case 'recaptcha_language': |
| 227 | - $c->registration->recaptcha_language = $value;break; |
|
| 227 | + $c->registration->recaptcha_language = $value; break; |
|
| 228 | 228 | case 'espresso_dashboard_widget': |
| 229 | 229 | $c->admin->use_dashboard_widget = ($value == 'Y'); break; |
| 230 | 230 | case 'use_personnel_manager': |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | case 'use_event_timezones': |
| 233 | 233 | $c->admin->use_event_timezones = ($value == 'Y'); break; |
| 234 | 234 | case 'full_logging': |
| 235 | - $c->admin->use_full_logging = ($value == 'Y');break; |
|
| 235 | + $c->admin->use_full_logging = ($value == 'Y'); break; |
|
| 236 | 236 | case 'affiliate_id': |
| 237 | - $c->admin->affiliate_id = $value;break; |
|
| 237 | + $c->admin->affiliate_id = $value; break; |
|
| 238 | 238 | case 'site_license_key': |
| 239 | - $cn->core->site_license_key = $value;break; |
|
| 239 | + $cn->core->site_license_key = $value; break; |
|
| 240 | 240 | default: |
| 241 | - do_action( 'AHEE__EE_DMS_4_1_0__handle_org_option',$option_name,$value ); |
|
| 241 | + do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value); |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
@@ -248,15 +248,15 @@ discard block |
||
| 248 | 248 | * @param type $old_price |
| 249 | 249 | * @return int |
| 250 | 250 | */ |
| 251 | - private function _insert_new_global_surcharge_price($org_options){ |
|
| 251 | + private function _insert_new_global_surcharge_price($org_options) { |
|
| 252 | 252 | $amount = floatval($org_options['surcharge']); |
| 253 | 253 | //dont createa a price if the surcharge is 0 |
| 254 | - if($amount <=.01){ |
|
| 254 | + if ($amount <= .01) { |
|
| 255 | 255 | return 0; |
| 256 | 256 | } |
| 257 | - if($org_options['surcharge_type'] == 'flat_rate'){ |
|
| 257 | + if ($org_options['surcharge_type'] == 'flat_rate') { |
|
| 258 | 258 | $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
| 259 | - }else{ |
|
| 259 | + } else { |
|
| 260 | 260 | $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
| 261 | 261 | } |
| 262 | 262 | global $wpdb; |
@@ -272,18 +272,18 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | ); |
| 274 | 274 | $datatypes = array( |
| 275 | - '%d',//PRT_ID |
|
| 276 | - '%f',//PRT_amount |
|
| 277 | - '%s',//PRC_name |
|
| 278 | - '%d',//PRC_is_default |
|
| 279 | - '%d',//PRC_overrides |
|
| 280 | - '%d',//PRC_order |
|
| 281 | - '%d',//PRC_deleted |
|
| 282 | - '%d',//PRC_parent |
|
| 275 | + '%d', //PRT_ID |
|
| 276 | + '%f', //PRT_amount |
|
| 277 | + '%s', //PRC_name |
|
| 278 | + '%d', //PRC_is_default |
|
| 279 | + '%d', //PRC_overrides |
|
| 280 | + '%d', //PRC_order |
|
| 281 | + '%d', //PRC_deleted |
|
| 282 | + '%d', //PRC_parent |
|
| 283 | 283 | ); |
| 284 | 284 | $price_table = $wpdb->prefix."esp_price"; |
| 285 | - $success = $wpdb->insert($price_table,$cols_n_values,$datatypes); |
|
| 286 | - if ( ! $success){ |
|
| 285 | + $success = $wpdb->insert($price_table, $cols_n_values, $datatypes); |
|
| 286 | + if ( ! $success) { |
|
| 287 | 287 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion('org_options', |
| 288 | 288 | array( |
| 289 | 289 | 'surcharge'=>$org_options['surcharge'], |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | 'payment_message', |
| 309 | 309 | 'message', |
| 310 | 310 | 'default_payment_status', |
| 311 | - 'surcharge',//unused? |
|
| 312 | - 'country_id',//unused? |
|
| 311 | + 'surcharge', //unused? |
|
| 312 | + 'country_id', //unused? |
|
| 313 | 313 | 'organization_country', |
| 314 | 314 | // 'currency_symbol', |
| 315 | 315 | 'expire_on_registration_end', |
@@ -321,13 +321,13 @@ discard block |
||
| 321 | 321 | 'show_pending_payment_options', |
| 322 | 322 | 'show_reg_footer', |
| 323 | 323 | 'skip_confirmation_page', |
| 324 | - 'allow_mer_discounts',//no equiv |
|
| 325 | - 'allow_mer_vouchers',//no equiv |
|
| 324 | + 'allow_mer_discounts', //no equiv |
|
| 325 | + 'allow_mer_vouchers', //no equiv |
|
| 326 | 326 | 'display_short_description_in_event_list', |
| 327 | 327 | 'display_description_on_multi_reg_page', |
| 328 | 328 | 'display_address_in_event_list', |
| 329 | 329 | 'display_address_in_regform', |
| 330 | - 'use_custom_post_types',//no equiv |
|
| 330 | + 'use_custom_post_types', //no equiv |
|
| 331 | 331 | 'display_ical_download', |
| 332 | 332 | 'display_featured_image', |
| 333 | 333 | 'themeroller', |
@@ -346,11 +346,11 @@ discard block |
||
| 346 | 346 | 'espresso_dashboard_widget', |
| 347 | 347 | 'time_reg_limit', |
| 348 | 348 | // 'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status |
| 349 | - 'use_personnel_manager',//no equiv |
|
| 349 | + 'use_personnel_manager', //no equiv |
|
| 350 | 350 | 'use_event_timezones', |
| 351 | 351 | 'full_logging', |
| 352 | - 'surcharge_type',//unused |
|
| 353 | - 'surcharge_text',//unused |
|
| 352 | + 'surcharge_type', //unused |
|
| 353 | + 'surcharge_text', //unused |
|
| 354 | 354 | 'affiliate_id', |
| 355 | 355 | 'site_license_key', |
| 356 | 356 | ); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $state = $this->get_migration_script()->get_or_create_state($value); |
| 158 | 158 | $state_id = $state['STA_ID']; |
| 159 | 159 | $c->organization->STA_ID = $state_id; |
| 160 | - }catch(EE_Error $e){}break; |
|
| 160 | + } catch(EE_Error $e){}break; |
|
| 161 | 161 | case 'organization_zip': |
| 162 | 162 | $c->organization->zip = $value;break; |
| 163 | 163 | case 'contact_email': |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | if($org_options['surcharge_type'] == 'flat_rate'){ |
| 258 | 258 | $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge; |
| 259 | - }else{ |
|
| 259 | + } else{ |
|
| 260 | 260 | $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge; |
| 261 | 261 | } |
| 262 | 262 | global $wpdb; |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | /** |
| 346 | 346 | * Adds a join between a ticket and a price |
| 347 | 347 | * @global type $wpdb |
| 348 | - * @param type $new_ticket_id |
|
| 349 | - * @param type $new_price_id |
|
| 348 | + * @param integer $new_ticket_id |
|
| 349 | + * @param integer $new_price_id |
|
| 350 | 350 | * @return int |
| 351 | 351 | */ |
| 352 | 352 | private function _insert_ticket_price_relation($new_ticket_id,$new_price_id){ |
@@ -371,8 +371,7 @@ discard block |
||
| 371 | 371 | /** |
| 372 | 372 | * Adds a join between a ticket and a datetime |
| 373 | 373 | * @global type $wpdb |
| 374 | - * @param type $new_ticket_id |
|
| 375 | - * @param type $new_price_id |
|
| 374 | + * @param integer $new_ticket_id |
|
| 376 | 375 | * @return int |
| 377 | 376 | */ |
| 378 | 377 | private function _insert_datetime_ticket_relation($new_datetime_id,$new_ticket_id){ |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | if(floatval($old_row['surcharge']) >= 0.01){ |
| 126 | 126 | $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
| 127 | 127 | $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id,$surcharge_price_id)); |
| 128 | - }else{ |
|
| 128 | + } else{ |
|
| 129 | 129 | $surcharge_price_id = 0; |
| 130 | 130 | $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id)); |
| 131 | 131 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | if($old_price['surcharge_type'] == 'flat_rate'){ |
| 243 | 243 | $price_type = self::price_type_flat_surcharge; |
| 244 | - }else{ |
|
| 244 | + } else{ |
|
| 245 | 245 | $price_type = self::price_type_percent_surcharge; |
| 246 | 246 | } |
| 247 | 247 | global $wpdb; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | $event_row = $this->_get_event_row($old_price_row['event_id']); |
| 288 | 288 | if($old_price_row['surcharge_type'] == 'flat_rate'){ |
| 289 | 289 | $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
| 290 | - }else{//percent surcharge |
|
| 290 | + } else{//percent surcharge |
|
| 291 | 291 | $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge'])/100); |
| 292 | 292 | } |
| 293 | 293 | $start_date = $event_row['registration_start']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | )); |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | -class EE_DMS_4_1_0_prices extends EE_Data_Migration_Script_Stage_Table{ |
|
| 89 | +class EE_DMS_4_1_0_prices extends EE_Data_Migration_Script_Stage_Table { |
|
| 90 | 90 | private $_new_price_table; |
| 91 | 91 | private $_new_ticket_table; |
| 92 | 92 | private $_new_ticket_price_table; |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | // $member_price_discount_id = 0; |
| 123 | 123 | // } |
| 124 | 124 | //create the surcharge if there is any |
| 125 | - if(floatval($old_row['surcharge']) >= 0.01){ |
|
| 125 | + if (floatval($old_row['surcharge']) >= 0.01) { |
|
| 126 | 126 | $surcharge_price_id = $this->_insert_new_surcharge_price($old_row); |
| 127 | - $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id,$surcharge_price_id)); |
|
| 128 | - }else{ |
|
| 127 | + $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id, $surcharge_price_id)); |
|
| 128 | + } else { |
|
| 129 | 129 | $surcharge_price_id = 0; |
| 130 | 130 | $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_price_table, array($new_price_id)); |
| 131 | 131 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | // } |
| 146 | 146 | //create a ticket for each old price -old datetime combo |
| 147 | 147 | $tickets_for_old_price = array(); |
| 148 | - foreach($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id){ |
|
| 148 | + foreach ($this->_get_datetime_ids_for_old_event_id($old_row['event_id']) as $new_datetime_id) { |
|
| 149 | 149 | $ticket_id = $this->_insert_new_ticket($old_row); |
| 150 | 150 | $tickets_for_old_price[] = $ticket_id; |
| 151 | 151 | //associate to old prices |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param type $old_price |
| 163 | 163 | * @return int |
| 164 | 164 | */ |
| 165 | - private function _insert_new_price($old_price){ |
|
| 165 | + private function _insert_new_price($old_price) { |
|
| 166 | 166 | global $wpdb; |
| 167 | 167 | $cols_n_values = array( |
| 168 | 168 | 'PRT_ID'=>self::price_type_base, |
@@ -176,17 +176,17 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | ); |
| 178 | 178 | $datatypes = array( |
| 179 | - '%d',//PRT_ID |
|
| 180 | - '%f',//PRT_amount |
|
| 181 | - '%s',//PRC_name |
|
| 182 | - '%d',//PRC_is_default |
|
| 183 | - '%d',//PRC_overrides |
|
| 184 | - '%d',//PRC_order |
|
| 185 | - '%d',//PRC_deleted |
|
| 186 | - '%d',//PRC_parent |
|
| 179 | + '%d', //PRT_ID |
|
| 180 | + '%f', //PRT_amount |
|
| 181 | + '%s', //PRC_name |
|
| 182 | + '%d', //PRC_is_default |
|
| 183 | + '%d', //PRC_overrides |
|
| 184 | + '%d', //PRC_order |
|
| 185 | + '%d', //PRC_deleted |
|
| 186 | + '%d', //PRC_parent |
|
| 187 | 187 | ); |
| 188 | - $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$datatypes); |
|
| 189 | - if ( ! $success){ |
|
| 188 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes); |
|
| 189 | + if ( ! $success) { |
|
| 190 | 190 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes)); |
| 191 | 191 | return 0; |
| 192 | 192 | } |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | * @param type $old_price |
| 238 | 238 | * @return int |
| 239 | 239 | */ |
| 240 | - private function _insert_new_surcharge_price($old_price){ |
|
| 240 | + private function _insert_new_surcharge_price($old_price) { |
|
| 241 | 241 | |
| 242 | - if($old_price['surcharge_type'] == 'flat_rate'){ |
|
| 242 | + if ($old_price['surcharge_type'] == 'flat_rate') { |
|
| 243 | 243 | $price_type = self::price_type_flat_surcharge; |
| 244 | - }else{ |
|
| 244 | + } else { |
|
| 245 | 245 | $price_type = self::price_type_percent_surcharge; |
| 246 | 246 | } |
| 247 | 247 | global $wpdb; |
@@ -257,17 +257,17 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | ); |
| 259 | 259 | $datatypes = array( |
| 260 | - '%d',//PRT_ID |
|
| 261 | - '%f',//PRT_amount |
|
| 262 | - '%s',//PRC_name |
|
| 263 | - '%d',//PRC_is_default |
|
| 264 | - '%d',//PRC_overrides |
|
| 265 | - '%d',//PRC_order |
|
| 266 | - '%d',//PRC_deleted |
|
| 267 | - '%d',//PRC_parent |
|
| 260 | + '%d', //PRT_ID |
|
| 261 | + '%f', //PRT_amount |
|
| 262 | + '%s', //PRC_name |
|
| 263 | + '%d', //PRC_is_default |
|
| 264 | + '%d', //PRC_overrides |
|
| 265 | + '%d', //PRC_order |
|
| 266 | + '%d', //PRC_deleted |
|
| 267 | + '%d', //PRC_parent |
|
| 268 | 268 | ); |
| 269 | - $success = $wpdb->insert($this->_new_price_table,$cols_n_values,$datatypes); |
|
| 270 | - if ( ! $success){ |
|
| 269 | + $success = $wpdb->insert($this->_new_price_table, $cols_n_values, $datatypes); |
|
| 270 | + if ( ! $success) { |
|
| 271 | 271 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price, $this->_new_price_table, $cols_n_values, $datatypes)); |
| 272 | 272 | return 0; |
| 273 | 273 | } |
@@ -282,18 +282,18 @@ discard block |
||
| 282 | 282 | * @param $new_surcharge_id int |
| 283 | 283 | * @return int new ticket id |
| 284 | 284 | */ |
| 285 | - private function _insert_new_ticket($old_price_row){ |
|
| 285 | + private function _insert_new_ticket($old_price_row) { |
|
| 286 | 286 | global $wpdb; |
| 287 | 287 | $event_row = $this->_get_event_row($old_price_row['event_id']); |
| 288 | - if($old_price_row['surcharge_type'] == 'flat_rate'){ |
|
| 288 | + if ($old_price_row['surcharge_type'] == 'flat_rate') { |
|
| 289 | 289 | $final_ticket_price = floatval($old_price_row['event_cost']) + floatval($old_price_row['surcharge']); |
| 290 | - }else{//percent surcharge |
|
| 291 | - $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge'])/100); |
|
| 290 | + } else {//percent surcharge |
|
| 291 | + $final_ticket_price = floatval($old_price_row['event_cost']) * (1 + floatval($old_price_row['surcharge']) / 100); |
|
| 292 | 292 | } |
| 293 | 293 | $start_date = $event_row['registration_start']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_startT']); |
| 294 | - $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$old_price_row,$start_date,$event_row['timezone_string']); |
|
| 294 | + $start_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $start_date, $event_row['timezone_string']); |
|
| 295 | 295 | $end_date = $event_row['registration_end']." ".$this->get_migration_script()->convertTimeFromAMPM($event_row['registration_endT']); |
| 296 | - $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this,$old_price_row,$end_date,$event_row['timezone_string']); |
|
| 296 | + $end_date_utc = $this->get_migration_script()->convert_date_string_to_utc($this, $old_price_row, $end_date, $event_row['timezone_string']); |
|
| 297 | 297 | $cols_n_values = array( |
| 298 | 298 | 'TTM_ID'=>0, |
| 299 | 299 | 'TKT_name'=>$old_price_row['price_type'], |
@@ -303,38 +303,38 @@ discard block |
||
| 303 | 303 | 'TKT_min'=>0, |
| 304 | 304 | 'TKT_max'=>-1, |
| 305 | 305 | 'TKT_price'=>$final_ticket_price, |
| 306 | - 'TKT_sold'=> 0,//note: this will get calculated as we actually add registrations during the migration |
|
| 306 | + 'TKT_sold'=> 0, //note: this will get calculated as we actually add registrations during the migration |
|
| 307 | 307 | 'TKT_qty'=> -1, |
| 308 | 308 | 'TKT_uses'=> 1, |
| 309 | - 'TKT_taxable'=>false,//so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
| 309 | + 'TKT_taxable'=>false, //so by default, old prices are NOT taxable. This way they don't suddenly have a sudden spike in prices |
|
| 310 | 310 | 'TKT_is_default'=>false, |
| 311 | 311 | 'TKT_order'=>$this->_get_ticket_count(), |
| 312 | - 'TKT_row'=>0,//doesn't matter because UI reset this on first save anyways |
|
| 312 | + 'TKT_row'=>0, //doesn't matter because UI reset this on first save anyways |
|
| 313 | 313 | 'TKT_deleted'=>false, |
| 314 | 314 | 'TKT_parent'=>0 |
| 315 | 315 | |
| 316 | 316 | ); |
| 317 | 317 | $datatypes = array( |
| 318 | - '%d',//TTM_ID |
|
| 319 | - '%s',//TKT_name |
|
| 320 | - '%s',//TKT_description |
|
| 321 | - '%s',//TKT_start_date |
|
| 322 | - '%s',//TKT_end_date |
|
| 323 | - '%d',//TKT_min |
|
| 324 | - '%d',//TKT_max |
|
| 325 | - '%f',//TKT_price |
|
| 326 | - '%d',//TKT_sold |
|
| 327 | - '%d',//TKT_qty |
|
| 328 | - '%d',//TKT_uses |
|
| 329 | - '%d',//TKT_taxable |
|
| 330 | - '%d',//TKT_is_default |
|
| 331 | - '%d',//TKT_order |
|
| 332 | - '%d',//TKT_row |
|
| 333 | - '%d',//TKT_deleted |
|
| 334 | - '%d',//TKT_parent |
|
| 318 | + '%d', //TTM_ID |
|
| 319 | + '%s', //TKT_name |
|
| 320 | + '%s', //TKT_description |
|
| 321 | + '%s', //TKT_start_date |
|
| 322 | + '%s', //TKT_end_date |
|
| 323 | + '%d', //TKT_min |
|
| 324 | + '%d', //TKT_max |
|
| 325 | + '%f', //TKT_price |
|
| 326 | + '%d', //TKT_sold |
|
| 327 | + '%d', //TKT_qty |
|
| 328 | + '%d', //TKT_uses |
|
| 329 | + '%d', //TKT_taxable |
|
| 330 | + '%d', //TKT_is_default |
|
| 331 | + '%d', //TKT_order |
|
| 332 | + '%d', //TKT_row |
|
| 333 | + '%d', //TKT_deleted |
|
| 334 | + '%d', //TKT_parent |
|
| 335 | 335 | ); |
| 336 | - $success = $wpdb->insert($this->_new_ticket_table,$cols_n_values,$datatypes); |
|
| 337 | - if ( ! $success){ |
|
| 336 | + $success = $wpdb->insert($this->_new_ticket_table, $cols_n_values, $datatypes); |
|
| 337 | + if ( ! $success) { |
|
| 338 | 338 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_price_row, $this->_new_ticket_table, $cols_n_values, $datatypes)); |
| 339 | 339 | return 0; |
| 340 | 340 | } |
@@ -349,19 +349,19 @@ discard block |
||
| 349 | 349 | * @param type $new_price_id |
| 350 | 350 | * @return int |
| 351 | 351 | */ |
| 352 | - private function _insert_ticket_price_relation($new_ticket_id,$new_price_id){ |
|
| 352 | + private function _insert_ticket_price_relation($new_ticket_id, $new_price_id) { |
|
| 353 | 353 | global $wpdb; |
| 354 | 354 | $cols_n_values = array( |
| 355 | 355 | 'TKT_ID'=>$new_ticket_id, |
| 356 | 356 | 'PRC_ID'=>$new_price_id, |
| 357 | 357 | ); |
| 358 | 358 | $datatypes = array( |
| 359 | - '%d',//TKT_ID |
|
| 360 | - '%d',//PRC_ID |
|
| 359 | + '%d', //TKT_ID |
|
| 360 | + '%d', //PRC_ID |
|
| 361 | 361 | ); |
| 362 | - $success = $wpdb->insert($this->_new_ticket_price_table,$cols_n_values,$datatypes); |
|
| 363 | - if ( ! $success){ |
|
| 364 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes)); |
|
| 362 | + $success = $wpdb->insert($this->_new_ticket_price_table, $cols_n_values, $datatypes); |
|
| 363 | + if ( ! $success) { |
|
| 364 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id, 'price id'=>$new_price_id), $this->_new_ticket_price_table, $cols_n_values, $datatypes)); |
|
| 365 | 365 | return 0; |
| 366 | 366 | } |
| 367 | 367 | $new_id = $wpdb->insert_id; |
@@ -375,19 +375,19 @@ discard block |
||
| 375 | 375 | * @param type $new_price_id |
| 376 | 376 | * @return int |
| 377 | 377 | */ |
| 378 | - private function _insert_datetime_ticket_relation($new_datetime_id,$new_ticket_id){ |
|
| 378 | + private function _insert_datetime_ticket_relation($new_datetime_id, $new_ticket_id) { |
|
| 379 | 379 | global $wpdb; |
| 380 | 380 | $cols_n_values = array( |
| 381 | 381 | 'TKT_ID'=>$new_ticket_id, |
| 382 | 382 | 'DTT_ID'=>$new_datetime_id, |
| 383 | 383 | ); |
| 384 | 384 | $datatypes = array( |
| 385 | - '%d',//TKT_ID |
|
| 386 | - '%d',//DTT_ID |
|
| 385 | + '%d', //TKT_ID |
|
| 386 | + '%d', //DTT_ID |
|
| 387 | 387 | ); |
| 388 | - $success = $wpdb->insert($this->_new_datetime_ticket_table,$cols_n_values,$datatypes); |
|
| 389 | - if ( ! $success){ |
|
| 390 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id,'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes)); |
|
| 388 | + $success = $wpdb->insert($this->_new_datetime_ticket_table, $cols_n_values, $datatypes); |
|
| 389 | + if ( ! $success) { |
|
| 390 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('ticket id'=>$new_ticket_id, 'datetime id'=>$new_datetime_id), $this->_new_datetime_ticket_table, $cols_n_values, $datatypes)); |
|
| 391 | 391 | return 0; |
| 392 | 392 | } |
| 393 | 393 | $new_id = $wpdb->insert_id; |
@@ -400,17 +400,17 @@ discard block |
||
| 400 | 400 | * @param type $event_id |
| 401 | 401 | * @return array |
| 402 | 402 | */ |
| 403 | - private function _get_event_row($event_id){ |
|
| 403 | + private function _get_event_row($event_id) { |
|
| 404 | 404 | global $wpdb; |
| 405 | 405 | $old_event_table = $wpdb->prefix."events_detail"; |
| 406 | - return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d",$event_id),ARRAY_A); |
|
| 406 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $old_event_table WHERE id=%d", $event_id), ARRAY_A); |
|
| 407 | 407 | } |
| 408 | 408 | /** |
| 409 | 409 | * Gets a higher ticket count than last time it was called (and is persisted between HTTP requests). |
| 410 | 410 | * Yes we COULD run a query joining events->datetimes->ticket_datetimes->tickets, but this should work fine too |
| 411 | 411 | * @return int |
| 412 | 412 | */ |
| 413 | - private function _get_ticket_count(){ |
|
| 413 | + private function _get_ticket_count() { |
|
| 414 | 414 | return $this->_ticket_count++; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -419,10 +419,10 @@ discard block |
||
| 419 | 419 | * @param int $old_event_id |
| 420 | 420 | * @return array where values are datetime ids |
| 421 | 421 | */ |
| 422 | - private function _get_datetime_ids_for_old_event_id($old_event_id){ |
|
| 422 | + private function _get_datetime_ids_for_old_event_id($old_event_id) { |
|
| 423 | 423 | global $wpdb; |
| 424 | 424 | $new_cpt_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_event_id, $wpdb->posts); |
| 425 | - $datetime_ids = $wpdb->get_col($wpdb->prepare("SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d",$new_cpt_id)); |
|
| 425 | + $datetime_ids = $wpdb->get_col($wpdb->prepare("SELECT DTT_ID FROM {$wpdb->prefix}esp_datetime WHERE EVT_ID=%d", $new_cpt_id)); |
|
| 426 | 426 | return $datetime_ids; |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -126,7 +126,7 @@ |
||
| 126 | 126 | * being address info, and 0 being neither) |
| 127 | 127 | * @global type $wpdb |
| 128 | 128 | * @param type $new_question_group_id |
| 129 | - * @return boolean |
|
| 129 | + * @return integer |
|
| 130 | 130 | */ |
| 131 | 131 | private function _is_system_question_group($new_question_group_id){ |
| 132 | 132 | global $wpdb; |
@@ -12,8 +12,6 @@ |
||
| 12 | 12 | KEY `group_id` (`group_id`), |
| 13 | 13 | KEY `question_id` (`question_id`) |
| 14 | 14 | ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8$$ |
| 15 | - |
|
| 16 | - |
|
| 17 | 15 | * 4.1 question group question model's tables and fields: |
| 18 | 16 | $this->_tables = array( |
| 19 | 17 | 'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID') |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | ); |
| 28 | 28 | * |
| 29 | 29 | */ |
| 30 | -class EE_DMS_4_1_0_question_group_question extends EE_Data_Migration_Script_Stage{ |
|
| 30 | +class EE_DMS_4_1_0_question_group_question extends EE_Data_Migration_Script_Stage { |
|
| 31 | 31 | private $_old_table; |
| 32 | 32 | private $_new_table; |
| 33 | - function _migration_step($num_items=50){ |
|
| 33 | + function _migration_step($num_items = 50) { |
|
| 34 | 34 | |
| 35 | 35 | global $wpdb; |
| 36 | 36 | $start_at_record = $this->count_records_migrated(); |
| 37 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$start_at_record,$num_items),ARRAY_A); |
|
| 37 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
| 38 | 38 | $items_actually_migrated = 0; |
| 39 | - foreach($rows as $question_group_question){ |
|
| 39 | + foreach ($rows as $question_group_question) { |
|
| 40 | 40 | $this->_insert_new_question_group_question($question_group_question); |
| 41 | 41 | $items_actually_migrated++; |
| 42 | 42 | } |
| 43 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 43 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 44 | 44 | $this->set_completed(); |
| 45 | 45 | } |
| 46 | 46 | return $items_actually_migrated; |
@@ -64,39 +64,39 @@ discard block |
||
| 64 | 64 | * @param array $old_question_group_question |
| 65 | 65 | * @return int |
| 66 | 66 | */ |
| 67 | - private function _insert_new_question_group_question($old_question_group_question){ |
|
| 67 | + private function _insert_new_question_group_question($old_question_group_question) { |
|
| 68 | 68 | global $wpdb; |
| 69 | 69 | $new_question_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_question", $old_question_group_question['question_id'], $wpdb->prefix."esp_question"); |
| 70 | 70 | $new_question_group_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_qst_group", $old_question_group_question['group_id'], $wpdb->prefix."esp_question_group"); |
| 71 | - if( ! $new_question_id){ |
|
| 72 | - $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"),$old_question_group_question['question_id'])); |
|
| 71 | + if ( ! $new_question_id) { |
|
| 72 | + $this->add_error(sprintf(__("Could not find 4.1 question id for 3.1 question #%d.", "event_espresso"), $old_question_group_question['question_id'])); |
|
| 73 | 73 | return 0; |
| 74 | 74 | } |
| 75 | - if( ! $new_question_group_id){ |
|
| 76 | - $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"),$old_question_group_question['group_id'])); |
|
| 75 | + if ( ! $new_question_group_id) { |
|
| 76 | + $this->add_error(sprintf(__("Could not find 4.1 question group id for 3.1 question group #%d.", "event_espresso"), $old_question_group_question['group_id'])); |
|
| 77 | 77 | return 0; |
| 78 | 78 | } |
| 79 | 79 | //if it's a system question, it needs to be in the right system group. otherwise no dice! |
| 80 | - if( |
|
| 81 | - ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id) ) |
|
| 80 | + if ( |
|
| 81 | + ($this->_is_system_question_group($new_question_group_id) == $this->_is_system_question_for_question_group($new_question_id)) |
|
| 82 | 82 | || |
| 83 | 83 | ! $this->_is_system_question_for_question_group($new_question_id) |
| 84 | - ){ |
|
| 84 | + ) { |
|
| 85 | 85 | $cols_n_values = array( |
| 86 | 86 | 'QSG_ID'=>$new_question_group_id, |
| 87 | 87 | 'QST_ID'=>$new_question_id |
| 88 | 88 | ); |
| 89 | 89 | $datatypes = array( |
| 90 | - '%d',//QSG_ID |
|
| 91 | - '%d',//QST_ID |
|
| 90 | + '%d', //QSG_ID |
|
| 91 | + '%d', //QST_ID |
|
| 92 | 92 | ); |
| 93 | - $success = $wpdb->insert($this->_new_table,$cols_n_values,$datatypes); |
|
| 94 | - if ( ! $success){ |
|
| 93 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
| 94 | + if ( ! $success) { |
|
| 95 | 95 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question_group_question, $this->_new_table, $cols_n_values, $datatypes)); |
| 96 | 96 | return 0; |
| 97 | 97 | } |
| 98 | 98 | return $wpdb->insert_id; |
| 99 | - }else{ |
|
| 99 | + } else { |
|
| 100 | 100 | return false; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | * @param type $new_question_id |
| 110 | 110 | * @return int |
| 111 | 111 | */ |
| 112 | - private function _is_system_question_for_question_group($new_question_id){ |
|
| 112 | + private function _is_system_question_for_question_group($new_question_id) { |
|
| 113 | 113 | global $wpdb; |
| 114 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d",$new_question_id)); |
|
| 115 | - if(in_array($system_id, array('fname','lname','email'))){ |
|
| 114 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d", $new_question_id)); |
|
| 115 | + if (in_array($system_id, array('fname', 'lname', 'email'))) { |
|
| 116 | 116 | return 1; |
| 117 | - }elseif($system_id!='' && $system_id){ |
|
| 117 | + }elseif ($system_id != '' && $system_id) { |
|
| 118 | 118 | return 2; |
| 119 | - }else{ |
|
| 119 | + } else { |
|
| 120 | 120 | return 0; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @param type $new_question_group_id |
| 129 | 129 | * @return boolean |
| 130 | 130 | */ |
| 131 | - private function _is_system_question_group($new_question_group_id){ |
|
| 131 | + private function _is_system_question_group($new_question_group_id) { |
|
| 132 | 132 | global $wpdb; |
| 133 | - $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d",$new_question_group_id)); |
|
| 133 | + $system_id = $wpdb->get_var($wpdb->prepare("SELECT QSG_system FROM ".$wpdb->prefix."esp_question_group WHERE QSG_ID=%d", $new_question_group_id)); |
|
| 134 | 134 | return intval($system_id); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | return 0; |
| 97 | 97 | } |
| 98 | 98 | return $wpdb->insert_id; |
| 99 | - }else{ |
|
| 99 | + } else{ |
|
| 100 | 100 | return false; |
| 101 | 101 | } |
| 102 | 102 | |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | $system_id = $wpdb->get_var($wpdb->prepare("SELECT QST_system FROM ".$wpdb->prefix."esp_question WHERE QST_ID=%d",$new_question_id)); |
| 115 | 115 | if(in_array($system_id, array('fname','lname','email'))){ |
| 116 | 116 | return 1; |
| 117 | - }elseif($system_id!='' && $system_id){ |
|
| 117 | + } elseif($system_id!='' && $system_id){ |
|
| 118 | 118 | return 2; |
| 119 | - }else{ |
|
| 119 | + } else{ |
|
| 120 | 120 | return 0; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -196,7 +196,7 @@ |
||
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | 198 | * Inserts into the venue_meta table |
| 199 | - * @param type $cpt_id |
|
| 199 | + * @param integer $cpt_id |
|
| 200 | 200 | * @param type $old_venue |
| 201 | 201 | * @return int |
| 202 | 202 | */ |
@@ -61,44 +61,44 @@ discard block |
||
| 61 | 61 | // )); |
| 62 | 62 | * |
| 63 | 63 | */ |
| 64 | -class EE_DMS_4_1_0_venues extends EE_Data_Migration_Script_Stage{ |
|
| 64 | +class EE_DMS_4_1_0_venues extends EE_Data_Migration_Script_Stage { |
|
| 65 | 65 | private $_old_table; |
| 66 | 66 | private $_new_table; |
| 67 | 67 | private $_new_meta_table; |
| 68 | -function _migration_step($num_items=50){ |
|
| 68 | +function _migration_step($num_items = 50) { |
|
| 69 | 69 | global $wpdb; |
| 70 | 70 | $start_at_record = $this->count_records_migrated(); |
| 71 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d",$start_at_record,$num_items),ARRAY_A); |
|
| 71 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".$this->_old_table." LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
| 72 | 72 | $items_actually_migrated = 0; |
| 73 | - foreach($rows as $old_venue){ |
|
| 74 | - if ( ! $new_id = $this->_insert_into_posts($old_venue)){ |
|
| 73 | + foreach ($rows as $old_venue) { |
|
| 74 | + if ( ! $new_id = $this->_insert_into_posts($old_venue)) { |
|
| 75 | 75 | $items_actually_migrated++; |
| 76 | 76 | continue; |
| 77 | 77 | } |
| 78 | 78 | $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_table, $new_id); |
| 79 | - if( ! $new_meta_id = $this->_insert_into_meta_table($new_id,$old_venue)){ |
|
| 79 | + if ( ! $new_meta_id = $this->_insert_into_meta_table($new_id, $old_venue)) { |
|
| 80 | 80 | $items_actually_migrated++; |
| 81 | 81 | continue; |
| 82 | 82 | } |
| 83 | 83 | $this->get_migration_script()->set_mapping($this->_old_table, $old_venue['id'], $this->_new_meta_table, $new_meta_id); |
| 84 | 84 | //lastly, save the 'contact' as post meta, because it doesn't exist anywhere else but someone may still want it |
| 85 | 85 | $venue_meta = maybe_unserialize($old_venue['meta']); |
| 86 | - if(isset($venue_meta['contact']) && $venue_meta['contact']){ |
|
| 87 | - add_post_meta($new_id,'contact',$venue_meta['contact']); |
|
| 86 | + if (isset($venue_meta['contact']) && $venue_meta['contact']) { |
|
| 87 | + add_post_meta($new_id, 'contact', $venue_meta['contact']); |
|
| 88 | 88 | } |
| 89 | 89 | //is there an image on this venue? |
| 90 | 90 | $guid = isset($venue_meta['image']) && $venue_meta['image'] ? $venue_meta['image'] : NULL; |
| 91 | - if($guid){ |
|
| 92 | - $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid,$new_id,$this); |
|
| 91 | + if ($guid) { |
|
| 92 | + $this->get_migration_script()->convert_image_url_to_attachment_and_attach_to_post($guid, $new_id, $this); |
|
| 93 | 93 | } |
| 94 | 94 | $items_actually_migrated++; |
| 95 | - if($guid){ |
|
| 95 | + if ($guid) { |
|
| 96 | 96 | //if there was an image, we may have had to download it etc and it may have taken |
| 97 | 97 | //longer, then let's not bother migrating anymore on this step |
| 98 | 98 | break; |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 101 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 102 | 102 | $this->set_completed(); |
| 103 | 103 | } |
| 104 | 104 | return $items_actually_migrated; |
@@ -122,42 +122,42 @@ discard block |
||
| 122 | 122 | * @param array $old_venue keys are cols, values are col values |
| 123 | 123 | * @return int |
| 124 | 124 | */ |
| 125 | - private function _insert_into_posts($old_venue){ |
|
| 125 | + private function _insert_into_posts($old_venue) { |
|
| 126 | 126 | global $wpdb; |
| 127 | 127 | $meta = maybe_unserialize($old_venue['meta']); |
| 128 | - $slug = $this->_find_unique_slug( $old_venue[ 'name' ], $old_venue[ 'identifier' ] ); |
|
| 128 | + $slug = $this->_find_unique_slug($old_venue['name'], $old_venue['identifier']); |
|
| 129 | 129 | $insertion_array = array( |
| 130 | - 'post_title'=>stripslashes($old_venue['name']),//VNU_name |
|
| 131 | - 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '',//VNU_desc |
|
| 132 | - 'post_name'=> $slug,//VNU_identifier |
|
| 133 | - 'post_date'=>current_time('mysql'),//VNU_created |
|
| 134 | - 'post_date_gmt'=> current_time('mysql',true), |
|
| 135 | - 'post_excerpt'=>'',//wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
| 136 | - 'post_modified'=>current_time('mysql'),//VNU_modified |
|
| 137 | - 'post_modified_gmt'=>current_time('mysql',true), |
|
| 138 | - 'post_author'=>$old_venue['wp_user'],//VNU_wp_user |
|
| 139 | - 'post_parent'=>null,//parent |
|
| 140 | - 'menu_order'=>0,//VNU_order |
|
| 130 | + 'post_title'=>stripslashes($old_venue['name']), //VNU_name |
|
| 131 | + 'post_content'=>isset($meta['description']) ? stripslashes(strip_tags($meta['description'])) : '', //VNU_desc |
|
| 132 | + 'post_name'=> $slug, //VNU_identifier |
|
| 133 | + 'post_date'=>current_time('mysql'), //VNU_created |
|
| 134 | + 'post_date_gmt'=> current_time('mysql', true), |
|
| 135 | + 'post_excerpt'=>'', //wp_trim_words($meta['description'] ? $meta['description'] : '',50),//VNU_short_desc arbitraty only 50 characters |
|
| 136 | + 'post_modified'=>current_time('mysql'), //VNU_modified |
|
| 137 | + 'post_modified_gmt'=>current_time('mysql', true), |
|
| 138 | + 'post_author'=>$old_venue['wp_user'], //VNU_wp_user |
|
| 139 | + 'post_parent'=>null, //parent |
|
| 140 | + 'menu_order'=>0, //VNU_order |
|
| 141 | 141 | 'post_type'=>'espresso_venues'//post_type |
| 142 | 142 | ); |
| 143 | 143 | $datatypes_array = array( |
| 144 | - '%s',//VNU_name |
|
| 145 | - '%s',//VNU_desc |
|
| 146 | - '%s',//VNU_identifier |
|
| 147 | - '%s',//VNU_created |
|
| 144 | + '%s', //VNU_name |
|
| 145 | + '%s', //VNU_desc |
|
| 146 | + '%s', //VNU_identifier |
|
| 147 | + '%s', //VNU_created |
|
| 148 | 148 | '%s', |
| 149 | - '%s',//VNU_short_desc |
|
| 150 | - '%s',//VNU_modified |
|
| 149 | + '%s', //VNU_short_desc |
|
| 150 | + '%s', //VNU_modified |
|
| 151 | 151 | '%s', |
| 152 | - '%d',//VNU_wp_user |
|
| 153 | - '%d',//parent |
|
| 154 | - '%d',//VNU_order |
|
| 155 | - '%s',//post_type |
|
| 152 | + '%d', //VNU_wp_user |
|
| 153 | + '%d', //parent |
|
| 154 | + '%d', //VNU_order |
|
| 155 | + '%s', //post_type |
|
| 156 | 156 | ); |
| 157 | 157 | $success = $wpdb->insert($this->_new_table, |
| 158 | 158 | $insertion_array, |
| 159 | 159 | $datatypes_array); |
| 160 | - if( ! $success ){ |
|
| 160 | + if ( ! $success) { |
|
| 161 | 161 | $this->add_error($this->get_migration_script->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_table, $insertion_array, $datatypes_array)); |
| 162 | 162 | return 0; |
| 163 | 163 | } |
@@ -171,11 +171,11 @@ discard block |
||
| 171 | 171 | * @param string $post_name |
| 172 | 172 | * @return string |
| 173 | 173 | */ |
| 174 | - private function _find_unique_slug($post_name, $old_identifier = '' ){ |
|
| 174 | + private function _find_unique_slug($post_name, $old_identifier = '') { |
|
| 175 | 175 | $count = 0; |
| 176 | - $original_name = $post_name ? sanitize_title( $post_name ) : $old_identifier; |
|
| 176 | + $original_name = $post_name ? sanitize_title($post_name) : $old_identifier; |
|
| 177 | 177 | $event_slug = $original_name; |
| 178 | - while( $this->_other_post_exists_with_that_slug($event_slug) && $count<50){ |
|
| 178 | + while ($this->_other_post_exists_with_that_slug($event_slug) && $count < 50) { |
|
| 179 | 179 | $event_slug = sanitize_title($original_name."-".++$count); |
| 180 | 180 | } |
| 181 | 181 | return $event_slug; |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | * @param type $slug |
| 188 | 188 | * @return boolean |
| 189 | 189 | */ |
| 190 | - private function _other_post_exists_with_that_slug($slug){ |
|
| 190 | + private function _other_post_exists_with_that_slug($slug) { |
|
| 191 | 191 | global $wpdb; |
| 192 | - $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s",$slug); |
|
| 192 | + $query = $wpdb->prepare("SELECT COUNT(ID) FROM ".$this->_new_table." WHERE post_name = %s", $slug); |
|
| 193 | 193 | $count = $wpdb->get_var($query); |
| 194 | - return (boolean)intval($count); |
|
| 194 | + return (boolean) intval($count); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -200,60 +200,60 @@ discard block |
||
| 200 | 200 | * @param type $old_venue |
| 201 | 201 | * @return int |
| 202 | 202 | */ |
| 203 | - private function _insert_into_meta_table($cpt_id,$old_venue){ |
|
| 203 | + private function _insert_into_meta_table($cpt_id, $old_venue) { |
|
| 204 | 204 | global $wpdb; |
| 205 | 205 | //get a country with the same name, or insert one |
| 206 | - try{ |
|
| 206 | + try { |
|
| 207 | 207 | $country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country'])); |
| 208 | 208 | $country_iso = $country['CNT_ISO']; |
| 209 | - }catch(EE_Error $e){ |
|
| 210 | - $this->add_error(sprintf(__("%s for venue %s", "event_espresso"),$e->getMessage(),$this->_json_encode($old_venue))); |
|
| 209 | + } catch (EE_Error $e) { |
|
| 210 | + $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
| 211 | 211 | $country_iso = null; |
| 212 | 212 | } |
| 213 | 213 | //get a state with the same name, if possible |
| 214 | - try{ |
|
| 215 | - $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']),isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country'])); |
|
| 214 | + try { |
|
| 215 | + $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']), isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country'])); |
|
| 216 | 216 | $state_id = $state['STA_ID']; |
| 217 | - }catch(EE_Error $e){ |
|
| 218 | - $this->add_error(sprintf(__("%s for venue %s", "event_espresso"),$e->getMessage(),$this->_json_encode($old_venue))); |
|
| 217 | + } catch (EE_Error $e) { |
|
| 218 | + $this->add_error(sprintf(__("%s for venue %s", "event_espresso"), $e->getMessage(), $this->_json_encode($old_venue))); |
|
| 219 | 219 | $state_id = 0; |
| 220 | 220 | } |
| 221 | 221 | $meta = maybe_unserialize($old_venue['meta']); |
| 222 | 222 | //now insert into meta table |
| 223 | 223 | $insertion_array = array( |
| 224 | - 'VNU_ID'=>$cpt_id,//VNU_ID_fk |
|
| 225 | - 'VNU_address'=>stripslashes($old_venue['address']),//VNU_address |
|
| 226 | - 'VNU_address2'=>stripslashes($old_venue['address2']),//VNU_address2 |
|
| 227 | - 'VNU_city'=>stripslashes($old_venue['city']),//VNU_city |
|
| 228 | - 'STA_ID'=>$state_id,//STA_ID |
|
| 229 | - 'CNT_ISO'=>$country_iso,//CNT_ISO |
|
| 230 | - 'VNU_zip'=>stripslashes($old_venue['zip']),//VNU_zip |
|
| 231 | - 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '',//VNU_phone |
|
| 232 | - 'VNU_capacity'=>-1,//VNU_capacity |
|
| 233 | - 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '',//VNU_url |
|
| 234 | - 'VNU_virtual_phone'=>'',//VNU_virtual_phone |
|
| 235 | - 'VNU_virtual_url'=>'',//VNU_virtual_url |
|
| 236 | - 'VNU_google_map_link'=>'',//VNU_google_map_link |
|
| 224 | + 'VNU_ID'=>$cpt_id, //VNU_ID_fk |
|
| 225 | + 'VNU_address'=>stripslashes($old_venue['address']), //VNU_address |
|
| 226 | + 'VNU_address2'=>stripslashes($old_venue['address2']), //VNU_address2 |
|
| 227 | + 'VNU_city'=>stripslashes($old_venue['city']), //VNU_city |
|
| 228 | + 'STA_ID'=>$state_id, //STA_ID |
|
| 229 | + 'CNT_ISO'=>$country_iso, //CNT_ISO |
|
| 230 | + 'VNU_zip'=>stripslashes($old_venue['zip']), //VNU_zip |
|
| 231 | + 'VNU_phone'=>isset($meta['phone']) ? stripslashes($meta['phone']) : '', //VNU_phone |
|
| 232 | + 'VNU_capacity'=>-1, //VNU_capacity |
|
| 233 | + 'VNU_url'=>isset($meta['website']) ? stripslashes($meta['website']) : '', //VNU_url |
|
| 234 | + 'VNU_virtual_phone'=>'', //VNU_virtual_phone |
|
| 235 | + 'VNU_virtual_url'=>'', //VNU_virtual_url |
|
| 236 | + 'VNU_google_map_link'=>'', //VNU_google_map_link |
|
| 237 | 237 | 'VNU_enable_for_gmap'=>true //VNU_enable_for_gmap |
| 238 | 238 | ); |
| 239 | 239 | $datatypes = array( |
| 240 | - '%d',//VNU_ID_fk |
|
| 241 | - '%s',//VNU_address |
|
| 242 | - '%s',//VNU_address2 |
|
| 243 | - '%s',//VNU_city |
|
| 244 | - '%d',//STA_ID |
|
| 245 | - '%s',//CNT_ISO |
|
| 246 | - '%s',//VNU_zip |
|
| 247 | - '%s',//VNU_phone |
|
| 248 | - '%d',//VNU_capacity |
|
| 249 | - '%s',//VNU_url |
|
| 250 | - '%s',//VNU_virtual_phone |
|
| 251 | - '%s',//VNU_virtual_url |
|
| 252 | - '%s',//VNU_google_map_link |
|
| 253 | - '%d',//VNU_enable_for_gmap |
|
| 240 | + '%d', //VNU_ID_fk |
|
| 241 | + '%s', //VNU_address |
|
| 242 | + '%s', //VNU_address2 |
|
| 243 | + '%s', //VNU_city |
|
| 244 | + '%d', //STA_ID |
|
| 245 | + '%s', //CNT_ISO |
|
| 246 | + '%s', //VNU_zip |
|
| 247 | + '%s', //VNU_phone |
|
| 248 | + '%d', //VNU_capacity |
|
| 249 | + '%s', //VNU_url |
|
| 250 | + '%s', //VNU_virtual_phone |
|
| 251 | + '%s', //VNU_virtual_url |
|
| 252 | + '%s', //VNU_google_map_link |
|
| 253 | + '%d', //VNU_enable_for_gmap |
|
| 254 | 254 | ); |
| 255 | - $success = $wpdb->insert($this->_new_meta_table,$insertion_array,$datatypes); |
|
| 256 | - if( ! $success ){ |
|
| 255 | + $success = $wpdb->insert($this->_new_meta_table, $insertion_array, $datatypes); |
|
| 256 | + if ( ! $success) { |
|
| 257 | 257 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_venue, $this->_new_meta_table, $insertion_array, $datatypes)); |
| 258 | 258 | return 0; |
| 259 | 259 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | try{ |
| 207 | 207 | $country = $this->get_migration_script()->get_or_create_country(stripslashes($old_venue['country'])); |
| 208 | 208 | $country_iso = $country['CNT_ISO']; |
| 209 | - }catch(EE_Error $e){ |
|
| 209 | + } catch(EE_Error $e){ |
|
| 210 | 210 | $this->add_error(sprintf(__("%s for venue %s", "event_espresso"),$e->getMessage(),$this->_json_encode($old_venue))); |
| 211 | 211 | $country_iso = null; |
| 212 | 212 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | try{ |
| 215 | 215 | $state = $this->get_migration_script()->get_or_create_state(stripslashes($old_venue['state']),isset($country['CNT_name']) ? $country['CNT_name'] : strip_tags($old_venue['country'])); |
| 216 | 216 | $state_id = $state['STA_ID']; |
| 217 | - }catch(EE_Error $e){ |
|
| 217 | + } catch(EE_Error $e){ |
|
| 218 | 218 | $this->add_error(sprintf(__("%s for venue %s", "event_espresso"),$e->getMessage(),$this->_json_encode($old_venue))); |
| 219 | 219 | $state_id = 0; |
| 220 | 220 | } |
@@ -128,6 +128,9 @@ discard block |
||
| 128 | 128 | return $items_actually_migrated; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | + /** |
|
| 132 | + * @param integer $num_items_to_migrate |
|
| 133 | + */ |
|
| 131 | 134 | private function _gather_relations_to_add($num_items_to_migrate) { |
| 132 | 135 | $relations_to_add_this_step = array(); |
| 133 | 136 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
@@ -158,8 +161,6 @@ discard block |
||
| 158 | 161 | |
| 159 | 162 | /** |
| 160 | 163 | * Adds teh relation between the payment method and the currencies it can be used for |
| 161 | - * @param int $id |
|
| 162 | - * @param string $gateway_slug |
|
| 163 | 164 | */ |
| 164 | 165 | private function _add_currency_relations($pm_id,$currency_code){ |
| 165 | 166 | global $wpdb; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Mike Nelson |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{ |
|
| 16 | +class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage { |
|
| 17 | 17 | protected $_currency_table_name; |
| 18 | 18 | protected $_currency_payment_method_table_name; |
| 19 | 19 | protected $_payment_method_table_name; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | public function __construct() { |
| 91 | 91 | global $wpdb; |
| 92 | - $this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' ); |
|
| 92 | + $this->_pretty_name = __('Payment Method Currencies', 'event_espresso'); |
|
| 93 | 93 | $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method'; |
| 94 | 94 | $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method'; |
| 95 | 95 | $this->_currency_table_name = $wpdb->prefix.'esp_currency'; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | protected function _count_records_to_migrate() { |
| 100 | 100 | $count = 0; |
| 101 | - foreach($this->_gateway_currencies as $currencies){ |
|
| 102 | - if( $currencies == 'all'){ |
|
| 101 | + foreach ($this->_gateway_currencies as $currencies) { |
|
| 102 | + if ($currencies == 'all') { |
|
| 103 | 103 | $currencies = $this->_get_all_currencies(); |
| 104 | 104 | } |
| 105 | 105 | $count += count($currencies); |
@@ -109,20 +109,20 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - protected function _migration_step( $num_items_to_migrate = 50 ) { |
|
| 112 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
| 113 | 113 | $items_actually_migrated = 0; |
| 114 | 114 | $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate); |
| 115 | - foreach($relations_to_add_this_step as $pm_slug => $currencies){ |
|
| 115 | + foreach ($relations_to_add_this_step as $pm_slug => $currencies) { |
|
| 116 | 116 | |
| 117 | - $id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name ); |
|
| 118 | - foreach( $currencies as $currency ){ |
|
| 119 | - if( $id ){ |
|
| 120 | - $this->_add_currency_relations( $id, $currency ); |
|
| 117 | + $id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name); |
|
| 118 | + foreach ($currencies as $currency) { |
|
| 119 | + if ($id) { |
|
| 120 | + $this->_add_currency_relations($id, $currency); |
|
| 121 | 121 | } |
| 122 | 122 | $items_actually_migrated++; |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 125 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 126 | 126 | $this->set_completed(); |
| 127 | 127 | } |
| 128 | 128 | return $items_actually_migrated; |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | $relations_to_add_this_step = array(); |
| 133 | 133 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
| 134 | 134 | $iterator = 0; |
| 135 | - foreach($this->_gateway_currencies as $pm_slug => $currencies){ |
|
| 136 | - if( $currencies == 'all' ){ |
|
| 135 | + foreach ($this->_gateway_currencies as $pm_slug => $currencies) { |
|
| 136 | + if ($currencies == 'all') { |
|
| 137 | 137 | $currencies = $this->_get_all_currencies(); |
| 138 | 138 | } |
| 139 | - foreach($currencies as $currency_code){ |
|
| 140 | - if( $this->count_records_migrated() <= $iterator && |
|
| 141 | - $iterator < $migrate_up_to_count ){ |
|
| 142 | - $relations_to_add_this_step[ $pm_slug ] [] = $currency_code; |
|
| 139 | + foreach ($currencies as $currency_code) { |
|
| 140 | + if ($this->count_records_migrated() <= $iterator && |
|
| 141 | + $iterator < $migrate_up_to_count) { |
|
| 142 | + $relations_to_add_this_step[$pm_slug] [] = $currency_code; |
|
| 143 | 143 | } |
| 144 | 144 | $iterator++; |
| 145 | 145 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * Gets all the currency codes in the database |
| 151 | 151 | * @return array |
| 152 | 152 | */ |
| 153 | - private function _get_all_currencies(){ |
|
| 153 | + private function _get_all_currencies() { |
|
| 154 | 154 | global $wpdb; |
| 155 | 155 | $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}"); |
| 156 | 156 | return $currencies; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param int $id |
| 162 | 162 | * @param string $gateway_slug |
| 163 | 163 | */ |
| 164 | - private function _add_currency_relations($pm_id,$currency_code){ |
|
| 164 | + private function _add_currency_relations($pm_id, $currency_code) { |
|
| 165 | 165 | global $wpdb; |
| 166 | 166 | $cur_pm_relation = array( |
| 167 | 167 | 'CUR_code'=>$currency_code, |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | $success = $wpdb->insert($this->_currency_payment_method_table_name, |
| 171 | 171 | $cur_pm_relation, |
| 172 | 172 | array( |
| 173 | - '%s',//CUR_code |
|
| 174 | - '%d',//PMD_ID |
|
| 173 | + '%s', //CUR_code |
|
| 174 | + '%d', //PMD_ID |
|
| 175 | 175 | )); |
| 176 | - if( ! $success ){ |
|
| 177 | - $this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), json_encode( $cur_pm_relation ), $wpdb->last_error ) ); |
|
| 176 | + if ( ! $success) { |
|
| 177 | + $this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), json_encode($cur_pm_relation), $wpdb->last_error)); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -57,7 +57,6 @@ |
||
| 57 | 57 | 'IV'=> __("Invoice", 'event_espresso'), |
| 58 | 58 | 'MO'=> __("Money Order", 'event_espresso'), |
| 59 | 59 | * @global type $wpdb |
| 60 | - * @param int $id |
|
| 61 | 60 | * @return string |
| 62 | 61 | */ |
| 63 | 62 | protected function _get_payment_method_id_by_gateway_name( $gateway_name, $old_pay_method_column ){ |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -12,37 +12,37 @@ discard block |
||
| 12 | 12 | * @author Mike Nelson |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table{ |
|
| 15 | +class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table { |
|
| 16 | 16 | protected $_payment_method_table; |
| 17 | - function __construct(){ |
|
| 17 | + function __construct() { |
|
| 18 | 18 | global $wpdb; |
| 19 | - $this->_old_table = $wpdb->prefix . 'esp_payment'; |
|
| 20 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
| 19 | + $this->_old_table = $wpdb->prefix.'esp_payment'; |
|
| 20 | + $this->_payment_method_table = $wpdb->prefix.'esp_payment_method'; |
|
| 21 | 21 | $this->_pretty_name = __('Payment-Payment Method Relations', 'event_espresso'); |
| 22 | 22 | parent::__construct(); |
| 23 | 23 | } |
| 24 | - protected function _migrate_old_row( $payment_row ) { |
|
| 24 | + protected function _migrate_old_row($payment_row) { |
|
| 25 | 25 | global $wpdb; |
| 26 | 26 | //get the payment method's ID |
| 27 | - $PMD_ID = apply_filters( 'FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name( $payment_row[ 'PAY_gateway' ], $payment_row[ 'PAY_method'] ) ); |
|
| 28 | - if( ! $PMD_ID ){ |
|
| 29 | - $this->add_error( sprintf( __( 'Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso' ), $payment_row[ 'PAY_gateway' ], $this->_json_encode( $payment_row ) ) ); |
|
| 27 | + $PMD_ID = apply_filters('FHEE__EE_DMS_4_6_0_payments__migrate_old_row__PMD_ID', $this->_get_payment_method_id_by_gateway_name($payment_row['PAY_gateway'], $payment_row['PAY_method'])); |
|
| 28 | + if ( ! $PMD_ID) { |
|
| 29 | + $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating payment row %2$s so just assigned it an unknown payment method', 'event_espresso'), $payment_row['PAY_gateway'], $this->_json_encode($payment_row))); |
|
| 30 | 30 | $PMD_ID = 0; |
| 31 | 31 | } |
| 32 | 32 | $new_values = array( |
| 33 | 33 | 'PMD_ID' => $PMD_ID, |
| 34 | - 'PAY_source' => ( $payment_row[ 'PAY_via_admin' ] ? 'ADMIN' : 'CART' ) ); |
|
| 35 | - $wheres = array( 'PAY_ID' => $payment_row[ 'PAY_ID' ] ); |
|
| 36 | - $new_value_datatypes = array( '%d', '%s' ); |
|
| 37 | - $where_datatypes = array( '%d' ); |
|
| 38 | - $success = $wpdb->update( $this->_old_table, |
|
| 34 | + 'PAY_source' => ($payment_row['PAY_via_admin'] ? 'ADMIN' : 'CART') ); |
|
| 35 | + $wheres = array('PAY_ID' => $payment_row['PAY_ID']); |
|
| 36 | + $new_value_datatypes = array('%d', '%s'); |
|
| 37 | + $where_datatypes = array('%d'); |
|
| 38 | + $success = $wpdb->update($this->_old_table, |
|
| 39 | 39 | $new_values, |
| 40 | 40 | $wheres, |
| 41 | 41 | $new_value_datatypes, |
| 42 | 42 | $where_datatypes |
| 43 | 43 | ); |
| 44 | - if( ! $success ){ |
|
| 45 | - $this->add_error( sprintf( __( 'Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso' ), $this->_json_encode( $new_values ), $this->_old_table, $this->_json_encode( $wheres ) ) ); |
|
| 44 | + if ( ! $success) { |
|
| 45 | + $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_old_table, $this->_json_encode($wheres))); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | /** |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * @param int $id |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - protected function _get_payment_method_id_by_gateway_name( $gateway_name, $old_pay_method_column ){ |
|
| 63 | + protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column) { |
|
| 64 | 64 | global $wpdb; |
| 65 | 65 | //convert from old known PAY_method values to their corresponding |
| 66 | 66 | //PMD_type or default PMD_name |
| 67 | - switch( $old_pay_method_column ) { |
|
| 67 | + switch ($old_pay_method_column) { |
|
| 68 | 68 | case 'PP': |
| 69 | 69 | $pmd_type = 'Paypal_Standard'; |
| 70 | 70 | break; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | default: |
| 93 | 93 | $pmd_type = $gateway_name; |
| 94 | 94 | } |
| 95 | - $pmd_name = str_replace( "_", " ", $pmd_type ); |
|
| 96 | - return $wpdb->get_var( $wpdb->prepare( "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name ) ); |
|
| 95 | + $pmd_name = str_replace("_", " ", $pmd_type); |
|
| 96 | + return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s OR PMD_name = %s", $pmd_type, $pmd_name)); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -49,7 +49,6 @@ |
||
| 49 | 49 | /** |
| 50 | 50 | * |
| 51 | 51 | * @global type $wpdb |
| 52 | - * @param int $id |
|
| 53 | 52 | * @return string |
| 54 | 53 | */ |
| 55 | 54 | protected function _get_payment_method_id_by_gateway_name( $gateway_name ){ |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -12,38 +12,38 @@ discard block |
||
| 12 | 12 | * @author Mike Nelson |
| 13 | 13 | * |
| 14 | 14 | */ |
| 15 | -class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table{ |
|
| 15 | +class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table { |
|
| 16 | 16 | protected $_transaction_table; |
| 17 | 17 | protected $_payment_method_table; |
| 18 | - function __construct(){ |
|
| 18 | + function __construct() { |
|
| 19 | 19 | global $wpdb; |
| 20 | - $this->_old_table = $wpdb->prefix . 'esp_extra_meta'; |
|
| 21 | - $this->_transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
| 22 | - $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method'; |
|
| 20 | + $this->_old_table = $wpdb->prefix.'esp_extra_meta'; |
|
| 21 | + $this->_transaction_table = $wpdb->prefix.'esp_transaction'; |
|
| 22 | + $this->_payment_method_table = $wpdb->prefix.'esp_payment_method'; |
|
| 23 | 23 | $this->_pretty_name = __('Transaction Payment Method Relations', 'event_espresso'); |
| 24 | 24 | $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'"; |
| 25 | 25 | parent::__construct(); |
| 26 | 26 | } |
| 27 | - protected function _migrate_old_row( $extra_meta_row ) { |
|
| 27 | + protected function _migrate_old_row($extra_meta_row) { |
|
| 28 | 28 | global $wpdb; |
| 29 | 29 | //get the payment method's ID |
| 30 | - $PMD_ID = $this->_get_payment_method_id_by_gateway_name( $extra_meta_row[ 'EXM_value' ] ); |
|
| 31 | - if( ! $PMD_ID ){ |
|
| 32 | - $this->add_error( sprintf( __( 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso' ), $extra_meta_row[ 'EXM_value' ], $this->_json_encode( $extra_meta_row ) ) ); |
|
| 30 | + $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']); |
|
| 31 | + if ( ! $PMD_ID) { |
|
| 32 | + $this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row))); |
|
| 33 | 33 | return; |
| 34 | 34 | } |
| 35 | - $new_values = array( 'PMD_ID' => $PMD_ID ); |
|
| 36 | - $wheres = array( 'TXN_ID' => $extra_meta_row[ 'OBJ_ID' ] ); |
|
| 37 | - $new_value_datatypes = array( '%d' ); |
|
| 38 | - $where_datatypes = array( '%d' ); |
|
| 39 | - $success = $wpdb->update( $this->_transaction_table, |
|
| 35 | + $new_values = array('PMD_ID' => $PMD_ID); |
|
| 36 | + $wheres = array('TXN_ID' => $extra_meta_row['OBJ_ID']); |
|
| 37 | + $new_value_datatypes = array('%d'); |
|
| 38 | + $where_datatypes = array('%d'); |
|
| 39 | + $success = $wpdb->update($this->_transaction_table, |
|
| 40 | 40 | $new_values, |
| 41 | 41 | $wheres, |
| 42 | 42 | $new_value_datatypes, |
| 43 | 43 | $where_datatypes |
| 44 | 44 | ); |
| 45 | - if( ! $success ){ |
|
| 46 | - $this->add_error( sprintf( __( 'Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso' ), $this->_json_encode( $new_values ), $this->_transaction_table, $this->_json_encode( $wheres ) ) ); |
|
| 45 | + if ( ! $success) { |
|
| 46 | + $this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres))); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | /** |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @param int $id |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - protected function _get_payment_method_id_by_gateway_name( $gateway_name ){ |
|
| 55 | + protected function _get_payment_method_id_by_gateway_name($gateway_name) { |
|
| 56 | 56 | global $wpdb; |
| 57 | - return $wpdb->get_var( $wpdb->prepare( "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name ) ); |
|
| 57 | + return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", $gateway_name)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |