@@ -9,39 +9,39 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_DMS_4_5_0_update_wp_user_for_prices extends EE_Data_Migration_Script_Stage_Table |
| 11 | 11 | { |
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->_pretty_name = __("Prices", "event_espresso"); |
|
| 16 | - $this->_old_table = $wpdb->prefix."esp_price"; |
|
| 17 | - parent::__construct(); |
|
| 18 | - } |
|
| 19 | - protected function _migrate_old_row($old_row) |
|
| 20 | - { |
|
| 21 | - // foreach ticket row we add the id for the current logged in user. |
|
| 22 | - global $wpdb; |
|
| 23 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | - $updated = $wpdb->update( |
|
| 25 | - $this->_old_table, |
|
| 26 | - array('PRC_wp_user'=>$user_id), |
|
| 27 | - array('PRC_ID'=>$old_row['PRC_ID']), |
|
| 28 | - array('%d',// PRC_wp_user |
|
| 29 | - ), |
|
| 30 | - array('%d',// PRC_ID |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - if (false === $updated) { |
|
| 34 | - $this->add_error( |
|
| 35 | - sprintf( |
|
| 36 | - __( |
|
| 37 | - "Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d", |
|
| 38 | - 'event_espresso' |
|
| 39 | - ), |
|
| 40 | - $this->_old_table, |
|
| 41 | - $user_id, |
|
| 42 | - $old_row['PRC_ID'] |
|
| 43 | - ) |
|
| 44 | - ); |
|
| 45 | - } |
|
| 46 | - } |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->_pretty_name = __("Prices", "event_espresso"); |
|
| 16 | + $this->_old_table = $wpdb->prefix."esp_price"; |
|
| 17 | + parent::__construct(); |
|
| 18 | + } |
|
| 19 | + protected function _migrate_old_row($old_row) |
|
| 20 | + { |
|
| 21 | + // foreach ticket row we add the id for the current logged in user. |
|
| 22 | + global $wpdb; |
|
| 23 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | + $updated = $wpdb->update( |
|
| 25 | + $this->_old_table, |
|
| 26 | + array('PRC_wp_user'=>$user_id), |
|
| 27 | + array('PRC_ID'=>$old_row['PRC_ID']), |
|
| 28 | + array('%d',// PRC_wp_user |
|
| 29 | + ), |
|
| 30 | + array('%d',// PRC_ID |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + if (false === $updated) { |
|
| 34 | + $this->add_error( |
|
| 35 | + sprintf( |
|
| 36 | + __( |
|
| 37 | + "Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d", |
|
| 38 | + 'event_espresso' |
|
| 39 | + ), |
|
| 40 | + $this->_old_table, |
|
| 41 | + $user_id, |
|
| 42 | + $old_row['PRC_ID'] |
|
| 43 | + ) |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | $this->_old_table, |
| 26 | 26 | array('PRC_wp_user'=>$user_id), |
| 27 | 27 | array('PRC_ID'=>$old_row['PRC_ID']), |
| 28 | - array('%d',// PRC_wp_user |
|
| 28 | + array('%d', // PRC_wp_user |
|
| 29 | 29 | ), |
| 30 | - array('%d',// PRC_ID |
|
| 30 | + array('%d', // PRC_ID |
|
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | 33 | if (false === $updated) { |
@@ -9,39 +9,39 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_DMS_4_5_0_update_wp_user_for_tickets extends EE_Data_Migration_Script_Stage_Table |
| 11 | 11 | { |
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->_pretty_name = __("Tickets", "event_espresso"); |
|
| 16 | - $this->_old_table = $wpdb->prefix."esp_ticket"; |
|
| 17 | - parent::__construct(); |
|
| 18 | - } |
|
| 19 | - protected function _migrate_old_row($old_row) |
|
| 20 | - { |
|
| 21 | - // foreach ticket row we add the id for the current logged in user. |
|
| 22 | - global $wpdb; |
|
| 23 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | - $updated = $wpdb->update( |
|
| 25 | - $this->_old_table, |
|
| 26 | - array('TKT_wp_user'=>$user_id), |
|
| 27 | - array('TKT_ID'=>$old_row['TKT_ID']), |
|
| 28 | - array('%d',// TKT_wp_user |
|
| 29 | - ), |
|
| 30 | - array('%d',// TKT_ID |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - if (false === $updated) { |
|
| 34 | - $this->add_error( |
|
| 35 | - sprintf( |
|
| 36 | - __( |
|
| 37 | - "Error in updating table %s setting TKT_wp_user = %d where TKT_ID = %d", |
|
| 38 | - 'event_espresso' |
|
| 39 | - ), |
|
| 40 | - $this->_old_table, |
|
| 41 | - $user_id, |
|
| 42 | - $old_row['TKT_ID'] |
|
| 43 | - ) |
|
| 44 | - ); |
|
| 45 | - } |
|
| 46 | - } |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->_pretty_name = __("Tickets", "event_espresso"); |
|
| 16 | + $this->_old_table = $wpdb->prefix."esp_ticket"; |
|
| 17 | + parent::__construct(); |
|
| 18 | + } |
|
| 19 | + protected function _migrate_old_row($old_row) |
|
| 20 | + { |
|
| 21 | + // foreach ticket row we add the id for the current logged in user. |
|
| 22 | + global $wpdb; |
|
| 23 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | + $updated = $wpdb->update( |
|
| 25 | + $this->_old_table, |
|
| 26 | + array('TKT_wp_user'=>$user_id), |
|
| 27 | + array('TKT_ID'=>$old_row['TKT_ID']), |
|
| 28 | + array('%d',// TKT_wp_user |
|
| 29 | + ), |
|
| 30 | + array('%d',// TKT_ID |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + if (false === $updated) { |
|
| 34 | + $this->add_error( |
|
| 35 | + sprintf( |
|
| 36 | + __( |
|
| 37 | + "Error in updating table %s setting TKT_wp_user = %d where TKT_ID = %d", |
|
| 38 | + 'event_espresso' |
|
| 39 | + ), |
|
| 40 | + $this->_old_table, |
|
| 41 | + $user_id, |
|
| 42 | + $old_row['TKT_ID'] |
|
| 43 | + ) |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | $this->_old_table, |
| 26 | 26 | array('TKT_wp_user'=>$user_id), |
| 27 | 27 | array('TKT_ID'=>$old_row['TKT_ID']), |
| 28 | - array('%d',// TKT_wp_user |
|
| 28 | + array('%d', // TKT_wp_user |
|
| 29 | 29 | ), |
| 30 | - array('%d',// TKT_ID |
|
| 30 | + array('%d', // TKT_ID |
|
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | 33 | if (false === $updated) { |
@@ -9,36 +9,36 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class EE_DMS_4_5_0_update_wp_user_for_price_types extends EE_Data_Migration_Script_Stage_Table |
| 11 | 11 | { |
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->_pretty_name = __("Price Types", "event_espresso"); |
|
| 16 | - $this->_old_table = $wpdb->prefix."esp_price_type"; |
|
| 17 | - parent::__construct(); |
|
| 18 | - } |
|
| 19 | - protected function _migrate_old_row($old_row) |
|
| 20 | - { |
|
| 21 | - // foreach ticket row we add the id for the current logged in user. |
|
| 22 | - global $wpdb; |
|
| 23 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | - $updated = $wpdb->update( |
|
| 25 | - $this->_old_table, |
|
| 26 | - array('PRT_wp_user'=>$user_id), |
|
| 27 | - array('PRT_ID'=>$old_row['PRT_ID']), |
|
| 28 | - array('%d',// PRT_wp_user |
|
| 29 | - ), |
|
| 30 | - array('%d',// PRT_ID |
|
| 31 | - ) |
|
| 32 | - ); |
|
| 33 | - if (false === $updated) { |
|
| 34 | - $this->add_error( |
|
| 35 | - sprintf( |
|
| 36 | - __("Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", 'event_espresso'), |
|
| 37 | - $this->_old_table, |
|
| 38 | - $user_id, |
|
| 39 | - $old_row['PRT_ID'] |
|
| 40 | - ) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 43 | - } |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->_pretty_name = __("Price Types", "event_espresso"); |
|
| 16 | + $this->_old_table = $wpdb->prefix."esp_price_type"; |
|
| 17 | + parent::__construct(); |
|
| 18 | + } |
|
| 19 | + protected function _migrate_old_row($old_row) |
|
| 20 | + { |
|
| 21 | + // foreach ticket row we add the id for the current logged in user. |
|
| 22 | + global $wpdb; |
|
| 23 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
| 24 | + $updated = $wpdb->update( |
|
| 25 | + $this->_old_table, |
|
| 26 | + array('PRT_wp_user'=>$user_id), |
|
| 27 | + array('PRT_ID'=>$old_row['PRT_ID']), |
|
| 28 | + array('%d',// PRT_wp_user |
|
| 29 | + ), |
|
| 30 | + array('%d',// PRT_ID |
|
| 31 | + ) |
|
| 32 | + ); |
|
| 33 | + if (false === $updated) { |
|
| 34 | + $this->add_error( |
|
| 35 | + sprintf( |
|
| 36 | + __("Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", 'event_espresso'), |
|
| 37 | + $this->_old_table, |
|
| 38 | + $user_id, |
|
| 39 | + $old_row['PRT_ID'] |
|
| 40 | + ) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | } |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | $this->_old_table, |
| 26 | 26 | array('PRT_wp_user'=>$user_id), |
| 27 | 27 | array('PRT_ID'=>$old_row['PRT_ID']), |
| 28 | - array('%d',// PRT_wp_user |
|
| 28 | + array('%d', // PRT_wp_user |
|
| 29 | 29 | ), |
| 30 | - array('%d',// PRT_ID |
|
| 30 | + array('%d', // PRT_ID |
|
| 31 | 31 | ) |
| 32 | 32 | ); |
| 33 | 33 | if (false === $updated) { |
@@ -14,48 +14,48 @@ |
||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Just initializes the status of the migration |
|
| 19 | - * |
|
| 20 | - * @return EE_DMS_4_6_0_country_system_question |
|
| 21 | - */ |
|
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 24 | - global $wpdb; |
|
| 25 | - $this->_pretty_name = __('Country - System Question', 'event_espresso'); |
|
| 26 | - $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 27 | - $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
| 28 | - parent::__construct(); |
|
| 29 | - } |
|
| 17 | + /** |
|
| 18 | + * Just initializes the status of the migration |
|
| 19 | + * |
|
| 20 | + * @return EE_DMS_4_6_0_country_system_question |
|
| 21 | + */ |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 24 | + global $wpdb; |
|
| 25 | + $this->_pretty_name = __('Country - System Question', 'event_espresso'); |
|
| 26 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 27 | + $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
|
| 28 | + parent::__construct(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * updates the question with the new question type |
|
| 35 | - * @param array $question an associative array where keys are column names and values are their values. |
|
| 36 | - * @return null |
|
| 37 | - */ |
|
| 38 | - protected function _migrate_old_row($question) |
|
| 39 | - { |
|
| 40 | - if ($question['QST_ID'] && $question['QST_system'] == 'country') { |
|
| 41 | - global $wpdb; |
|
| 42 | - $success = $wpdb->update( |
|
| 43 | - $this->_old_table, |
|
| 44 | - array( 'QST_type' => 'COUNTRY' ), // data |
|
| 45 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | - array( '%s' ), // data format |
|
| 47 | - array( '%d' ) // where format |
|
| 48 | - ); |
|
| 49 | - if (! $success) { |
|
| 50 | - $this->add_error( |
|
| 51 | - sprintf( |
|
| 52 | - __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 53 | - wp_json_encode($question['QST_system']), |
|
| 54 | - $question['QST_ID'], |
|
| 55 | - $wpdb->last_error |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 33 | + /** |
|
| 34 | + * updates the question with the new question type |
|
| 35 | + * @param array $question an associative array where keys are column names and values are their values. |
|
| 36 | + * @return null |
|
| 37 | + */ |
|
| 38 | + protected function _migrate_old_row($question) |
|
| 39 | + { |
|
| 40 | + if ($question['QST_ID'] && $question['QST_system'] == 'country') { |
|
| 41 | + global $wpdb; |
|
| 42 | + $success = $wpdb->update( |
|
| 43 | + $this->_old_table, |
|
| 44 | + array( 'QST_type' => 'COUNTRY' ), // data |
|
| 45 | + array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | + array( '%s' ), // data format |
|
| 47 | + array( '%d' ) // where format |
|
| 48 | + ); |
|
| 49 | + if (! $success) { |
|
| 50 | + $this->add_error( |
|
| 51 | + sprintf( |
|
| 52 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 53 | + wp_json_encode($question['QST_system']), |
|
| 54 | + $question['QST_ID'], |
|
| 55 | + $wpdb->last_error |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -41,12 +41,12 @@ |
||
| 41 | 41 | global $wpdb; |
| 42 | 42 | $success = $wpdb->update( |
| 43 | 43 | $this->_old_table, |
| 44 | - array( 'QST_type' => 'COUNTRY' ), // data |
|
| 45 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | - array( '%s' ), // data format |
|
| 47 | - array( '%d' ) // where format |
|
| 44 | + array('QST_type' => 'COUNTRY'), // data |
|
| 45 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 46 | + array('%s'), // data format |
|
| 47 | + array('%d') // where format |
|
| 48 | 48 | ); |
| 49 | - if (! $success) { |
|
| 49 | + if ( ! $success) { |
|
| 50 | 50 | $this->add_error( |
| 51 | 51 | sprintf( |
| 52 | 52 | __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
@@ -14,48 +14,48 @@ |
||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Just initializes the status of the migration |
|
| 19 | - * |
|
| 20 | - * @return EE_DMS_4_6_0_state_system_question |
|
| 21 | - */ |
|
| 22 | - public function __construct() |
|
| 23 | - { |
|
| 24 | - global $wpdb; |
|
| 25 | - $this->_pretty_name = __('State - System Question', 'event_espresso'); |
|
| 26 | - $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 27 | - $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
| 28 | - parent::__construct(); |
|
| 29 | - } |
|
| 17 | + /** |
|
| 18 | + * Just initializes the status of the migration |
|
| 19 | + * |
|
| 20 | + * @return EE_DMS_4_6_0_state_system_question |
|
| 21 | + */ |
|
| 22 | + public function __construct() |
|
| 23 | + { |
|
| 24 | + global $wpdb; |
|
| 25 | + $this->_pretty_name = __('State - System Question', 'event_espresso'); |
|
| 26 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 27 | + $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
|
| 28 | + parent::__construct(); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * updates the question with the new question type |
|
| 35 | - * @param array $question an associative array where keys are column names and values are their values. |
|
| 36 | - * @return null |
|
| 37 | - */ |
|
| 38 | - protected function _migrate_old_row($question) |
|
| 39 | - { |
|
| 40 | - if ($question['QST_ID'] && $question['QST_system'] == 'state') { |
|
| 41 | - global $wpdb; |
|
| 42 | - $success = $wpdb->update( |
|
| 43 | - $this->_old_table, |
|
| 44 | - array( 'QST_type' => 'STATE' ), // data |
|
| 45 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | - array( '%s' ), // data format |
|
| 47 | - array( '%d' ) // where format |
|
| 48 | - ); |
|
| 49 | - if (! $success) { |
|
| 50 | - $this->add_error( |
|
| 51 | - sprintf( |
|
| 52 | - __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 53 | - wp_json_encode($question['QST_system']), |
|
| 54 | - $question['QST_ID'], |
|
| 55 | - $wpdb->last_error |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 33 | + /** |
|
| 34 | + * updates the question with the new question type |
|
| 35 | + * @param array $question an associative array where keys are column names and values are their values. |
|
| 36 | + * @return null |
|
| 37 | + */ |
|
| 38 | + protected function _migrate_old_row($question) |
|
| 39 | + { |
|
| 40 | + if ($question['QST_ID'] && $question['QST_system'] == 'state') { |
|
| 41 | + global $wpdb; |
|
| 42 | + $success = $wpdb->update( |
|
| 43 | + $this->_old_table, |
|
| 44 | + array( 'QST_type' => 'STATE' ), // data |
|
| 45 | + array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | + array( '%s' ), // data format |
|
| 47 | + array( '%d' ) // where format |
|
| 48 | + ); |
|
| 49 | + if (! $success) { |
|
| 50 | + $this->add_error( |
|
| 51 | + sprintf( |
|
| 52 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 53 | + wp_json_encode($question['QST_system']), |
|
| 54 | + $question['QST_ID'], |
|
| 55 | + $wpdb->last_error |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -41,12 +41,12 @@ |
||
| 41 | 41 | global $wpdb; |
| 42 | 42 | $success = $wpdb->update( |
| 43 | 43 | $this->_old_table, |
| 44 | - array( 'QST_type' => 'STATE' ), // data |
|
| 45 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 46 | - array( '%s' ), // data format |
|
| 47 | - array( '%d' ) // where format |
|
| 44 | + array('QST_type' => 'STATE'), // data |
|
| 45 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 46 | + array('%s'), // data format |
|
| 47 | + array('%d') // where format |
|
| 48 | 48 | ); |
| 49 | - if (! $success) { |
|
| 49 | + if ( ! $success) { |
|
| 50 | 50 | $this->add_error( |
| 51 | 51 | sprintf( |
| 52 | 52 | __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
@@ -28,59 +28,59 @@ |
||
| 28 | 28 | class EE_DMS_4_6_0_invoice_settings extends EE_Data_Migration_Script_Stage |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Just initializes the status of the migration |
|
| 33 | - */ |
|
| 34 | - public function __construct() |
|
| 35 | - { |
|
| 36 | - $this->_pretty_name = __('Update Invoice Settings', 'event_espresso'); |
|
| 37 | - parent::__construct(); |
|
| 38 | - } |
|
| 31 | + /** |
|
| 32 | + * Just initializes the status of the migration |
|
| 33 | + */ |
|
| 34 | + public function __construct() |
|
| 35 | + { |
|
| 36 | + $this->_pretty_name = __('Update Invoice Settings', 'event_espresso'); |
|
| 37 | + parent::__construct(); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * _count_records_to_migrate |
|
| 44 | - * Counts the records to migrate; the public version may cache it |
|
| 45 | - * |
|
| 46 | - * @access protected |
|
| 47 | - * @return int |
|
| 48 | - */ |
|
| 49 | - protected function _count_records_to_migrate() |
|
| 50 | - { |
|
| 51 | - return 1; |
|
| 52 | - } |
|
| 42 | + /** |
|
| 43 | + * _count_records_to_migrate |
|
| 44 | + * Counts the records to migrate; the public version may cache it |
|
| 45 | + * |
|
| 46 | + * @access protected |
|
| 47 | + * @return int |
|
| 48 | + */ |
|
| 49 | + protected function _count_records_to_migrate() |
|
| 50 | + { |
|
| 51 | + return 1; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * _migration_step |
|
| 58 | - * |
|
| 59 | - * @access protected |
|
| 60 | - * @param int $num_items |
|
| 61 | - * @throws EE_Error |
|
| 62 | - * @return int number of items ACTUALLY migrated |
|
| 63 | - * @throws InvalidDataTypeException |
|
| 64 | - */ |
|
| 65 | - protected function _migration_step($num_items = 1) |
|
| 66 | - { |
|
| 56 | + /** |
|
| 57 | + * _migration_step |
|
| 58 | + * |
|
| 59 | + * @access protected |
|
| 60 | + * @param int $num_items |
|
| 61 | + * @throws EE_Error |
|
| 62 | + * @return int number of items ACTUALLY migrated |
|
| 63 | + * @throws InvalidDataTypeException |
|
| 64 | + */ |
|
| 65 | + protected function _migration_step($num_items = 1) |
|
| 66 | + { |
|
| 67 | 67 | |
| 68 | - $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
| 69 | - $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
| 70 | - $overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
| 71 | - if ($overridden_invoice_body || $overridden_receipt_body) { |
|
| 72 | - new PersistentAdminNotice( |
|
| 73 | - 'invoice_overriding_templates', |
|
| 74 | - esc_html__( |
|
| 75 | - 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
| 76 | - 'event_espresso' |
|
| 77 | - ), |
|
| 78 | - true |
|
| 79 | - ); |
|
| 80 | - } |
|
| 68 | + $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
|
| 69 | + $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
| 70 | + $overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
| 71 | + if ($overridden_invoice_body || $overridden_receipt_body) { |
|
| 72 | + new PersistentAdminNotice( |
|
| 73 | + 'invoice_overriding_templates', |
|
| 74 | + esc_html__( |
|
| 75 | + 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
| 76 | + 'event_espresso' |
|
| 77 | + ), |
|
| 78 | + true |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // regardless of whether it worked or not, we ought to continue the migration |
|
| 83 | - $this->set_completed(); |
|
| 84 | - return 1; |
|
| 85 | - } |
|
| 82 | + // regardless of whether it worked or not, we ought to continue the migration |
|
| 83 | + $this->set_completed(); |
|
| 84 | + return 1; |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -66,8 +66,8 @@ |
||
| 66 | 66 | { |
| 67 | 67 | |
| 68 | 68 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
| 69 | - $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true); |
|
| 70 | - $overridden_receipt_body= EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true); |
|
| 69 | + $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true); |
|
| 70 | + $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true); |
|
| 71 | 71 | if ($overridden_invoice_body || $overridden_receipt_body) { |
| 72 | 72 | new PersistentAdminNotice( |
| 73 | 73 | 'invoice_overriding_templates', |
@@ -11,69 +11,69 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_DMS_4_6_0_billing_info extends EE_Data_Migration_Script_Stage_Table |
| 13 | 13 | { |
| 14 | - public function __construct() |
|
| 15 | - { |
|
| 16 | - global $wpdb; |
|
| 17 | - $this->_old_table = $wpdb->postmeta; |
|
| 18 | - $this->_pretty_name = __('Billing Info', 'event_espresso'); |
|
| 19 | - $this->_extra_where_sql = "WHERE meta_key LIKE 'billing_info_%'"; |
|
| 20 | - parent::__construct(); |
|
| 21 | - } |
|
| 22 | - protected function _migrate_old_row($old_row) |
|
| 23 | - { |
|
| 24 | - $new_billing_info = array(); |
|
| 25 | - $old_billing_info = maybe_unserialize($old_row['meta_value']); |
|
| 26 | - $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']); |
|
| 27 | - $repetitive_prefix = '_reg-page-billing-'; |
|
| 28 | - $repetitive_suffix = "-" . $gateway_name; |
|
| 29 | - foreach ($old_billing_info as $old_input_name => $input_value) { |
|
| 30 | - $old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name); |
|
| 14 | + public function __construct() |
|
| 15 | + { |
|
| 16 | + global $wpdb; |
|
| 17 | + $this->_old_table = $wpdb->postmeta; |
|
| 18 | + $this->_pretty_name = __('Billing Info', 'event_espresso'); |
|
| 19 | + $this->_extra_where_sql = "WHERE meta_key LIKE 'billing_info_%'"; |
|
| 20 | + parent::__construct(); |
|
| 21 | + } |
|
| 22 | + protected function _migrate_old_row($old_row) |
|
| 23 | + { |
|
| 24 | + $new_billing_info = array(); |
|
| 25 | + $old_billing_info = maybe_unserialize($old_row['meta_value']); |
|
| 26 | + $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']); |
|
| 27 | + $repetitive_prefix = '_reg-page-billing-'; |
|
| 28 | + $repetitive_suffix = "-" . $gateway_name; |
|
| 29 | + foreach ($old_billing_info as $old_input_name => $input_value) { |
|
| 30 | + $old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name); |
|
| 31 | 31 | |
| 32 | - switch ($old_input_name_important_part) { |
|
| 33 | - case 'fname': |
|
| 34 | - $new_input_name = 'first_name'; |
|
| 35 | - break; |
|
| 36 | - case 'lname': |
|
| 37 | - $new_input_name = 'last_name'; |
|
| 38 | - break; |
|
| 39 | - case 'state': |
|
| 40 | - // we used to store the state's id ,but now we just store the name |
|
| 41 | - $new_input_name = $old_input_name_important_part; |
|
| 42 | - $input_value = $this->_get_state_name_by_ID($input_value); |
|
| 43 | - break; |
|
| 44 | - case 'card-nmbr': |
|
| 45 | - $new_input_name = 'credit_card'; |
|
| 46 | - break; |
|
| 47 | - case 'card-type':// paypal pro only |
|
| 48 | - $new_input_name = 'credit_card_type'; |
|
| 49 | - break; |
|
| 50 | - case 'card-exp-date-mnth': |
|
| 51 | - $new_input_name = 'exp_month'; |
|
| 52 | - $input_value = ''; |
|
| 53 | - break; |
|
| 54 | - case 'card-exp-date-year': |
|
| 55 | - $new_input_name = 'exp_year'; |
|
| 56 | - $input_value = 0; |
|
| 57 | - break; |
|
| 58 | - case 'ccv-code': |
|
| 59 | - $new_input_name = 'cvv'; |
|
| 60 | - break; |
|
| 61 | - default: |
|
| 62 | - $new_input_name = $old_input_name_important_part; |
|
| 63 | - } |
|
| 64 | - $new_billing_info[ $new_input_name ] = $input_value; |
|
| 65 | - } |
|
| 66 | - update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info); |
|
| 67 | - } |
|
| 68 | - /** |
|
| 69 | - * |
|
| 70 | - * @global type $wpdb |
|
| 71 | - * @param int $id |
|
| 72 | - * @return string |
|
| 73 | - */ |
|
| 74 | - protected function _get_state_name_by_ID($id) |
|
| 75 | - { |
|
| 76 | - global $wpdb; |
|
| 77 | - return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id)); |
|
| 78 | - } |
|
| 32 | + switch ($old_input_name_important_part) { |
|
| 33 | + case 'fname': |
|
| 34 | + $new_input_name = 'first_name'; |
|
| 35 | + break; |
|
| 36 | + case 'lname': |
|
| 37 | + $new_input_name = 'last_name'; |
|
| 38 | + break; |
|
| 39 | + case 'state': |
|
| 40 | + // we used to store the state's id ,but now we just store the name |
|
| 41 | + $new_input_name = $old_input_name_important_part; |
|
| 42 | + $input_value = $this->_get_state_name_by_ID($input_value); |
|
| 43 | + break; |
|
| 44 | + case 'card-nmbr': |
|
| 45 | + $new_input_name = 'credit_card'; |
|
| 46 | + break; |
|
| 47 | + case 'card-type':// paypal pro only |
|
| 48 | + $new_input_name = 'credit_card_type'; |
|
| 49 | + break; |
|
| 50 | + case 'card-exp-date-mnth': |
|
| 51 | + $new_input_name = 'exp_month'; |
|
| 52 | + $input_value = ''; |
|
| 53 | + break; |
|
| 54 | + case 'card-exp-date-year': |
|
| 55 | + $new_input_name = 'exp_year'; |
|
| 56 | + $input_value = 0; |
|
| 57 | + break; |
|
| 58 | + case 'ccv-code': |
|
| 59 | + $new_input_name = 'cvv'; |
|
| 60 | + break; |
|
| 61 | + default: |
|
| 62 | + $new_input_name = $old_input_name_important_part; |
|
| 63 | + } |
|
| 64 | + $new_billing_info[ $new_input_name ] = $input_value; |
|
| 65 | + } |
|
| 66 | + update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info); |
|
| 67 | + } |
|
| 68 | + /** |
|
| 69 | + * |
|
| 70 | + * @global type $wpdb |
|
| 71 | + * @param int $id |
|
| 72 | + * @return string |
|
| 73 | + */ |
|
| 74 | + protected function _get_state_name_by_ID($id) |
|
| 75 | + { |
|
| 76 | + global $wpdb; |
|
| 77 | + return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id)); |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | $old_billing_info = maybe_unserialize($old_row['meta_value']); |
| 26 | 26 | $gateway_name = str_replace("billing_info_", '', $old_row['meta_key']); |
| 27 | 27 | $repetitive_prefix = '_reg-page-billing-'; |
| 28 | - $repetitive_suffix = "-" . $gateway_name; |
|
| 28 | + $repetitive_suffix = "-".$gateway_name; |
|
| 29 | 29 | foreach ($old_billing_info as $old_input_name => $input_value) { |
| 30 | - $old_input_name_important_part = str_replace(array( $repetitive_prefix, $repetitive_suffix ), array( '', ''), $old_input_name); |
|
| 30 | + $old_input_name_important_part = str_replace(array($repetitive_prefix, $repetitive_suffix), array('', ''), $old_input_name); |
|
| 31 | 31 | |
| 32 | 32 | switch ($old_input_name_important_part) { |
| 33 | 33 | case 'fname': |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | default: |
| 62 | 62 | $new_input_name = $old_input_name_important_part; |
| 63 | 63 | } |
| 64 | - $new_billing_info[ $new_input_name ] = $input_value; |
|
| 64 | + $new_billing_info[$new_input_name] = $input_value; |
|
| 65 | 65 | } |
| 66 | 66 | update_post_meta($old_row['post_id'], $old_row['meta_key'], $new_billing_info); |
| 67 | 67 | } |
@@ -74,6 +74,6 @@ discard block |
||
| 74 | 74 | protected function _get_state_name_by_ID($id) |
| 75 | 75 | { |
| 76 | 76 | global $wpdb; |
| 77 | - return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM " . $wpdb->prefix . "esp_state WHERE STA_ID = %d", $id)); |
|
| 77 | + return $wpdb->get_var($wpdb->prepare("SELECT STA_name FROM ".$wpdb->prefix."esp_state WHERE STA_ID = %d", $id)); |
|
| 78 | 78 | } |
| 79 | 79 | } |
@@ -12,57 +12,57 @@ |
||
| 12 | 12 | class EE_DMS_4_6_0_question_types extends EE_Data_Migration_Script_Stage_Table |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - protected $_question_type_conversions = array(); |
|
| 15 | + protected $_question_type_conversions = array(); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Just initializes the status of the migration |
|
| 21 | - * |
|
| 22 | - * @return EE_DMS_4_6_0_question_types |
|
| 23 | - */ |
|
| 24 | - public function __construct() |
|
| 25 | - { |
|
| 26 | - global $wpdb; |
|
| 27 | - $this->_pretty_name = __('Question Types', 'event_espresso'); |
|
| 28 | - $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 29 | - $this->_question_type_conversions = array( |
|
| 30 | - 'MULTIPLE' => 'CHECKBOX', |
|
| 31 | - 'SINGLE' => 'RADIO_BTN' |
|
| 32 | - ); |
|
| 33 | - // when fetching rows, because we automatically use a limit and offset |
|
| 34 | - // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
| 35 | - // so we need to include both the migrated rows as well as the non-migrated rows |
|
| 36 | - $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions); |
|
| 37 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ; |
|
| 38 | - parent::__construct(); |
|
| 39 | - } |
|
| 19 | + /** |
|
| 20 | + * Just initializes the status of the migration |
|
| 21 | + * |
|
| 22 | + * @return EE_DMS_4_6_0_question_types |
|
| 23 | + */ |
|
| 24 | + public function __construct() |
|
| 25 | + { |
|
| 26 | + global $wpdb; |
|
| 27 | + $this->_pretty_name = __('Question Types', 'event_espresso'); |
|
| 28 | + $this->_old_table = $wpdb->prefix.'esp_question'; |
|
| 29 | + $this->_question_type_conversions = array( |
|
| 30 | + 'MULTIPLE' => 'CHECKBOX', |
|
| 31 | + 'SINGLE' => 'RADIO_BTN' |
|
| 32 | + ); |
|
| 33 | + // when fetching rows, because we automatically use a limit and offset |
|
| 34 | + // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
|
| 35 | + // so we need to include both the migrated rows as well as the non-migrated rows |
|
| 36 | + $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions); |
|
| 37 | + $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ; |
|
| 38 | + parent::__construct(); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param array $question an associative array where keys are column names and values are their values. |
|
| 43 | - * @return null |
|
| 44 | - */ |
|
| 45 | - protected function _migrate_old_row($question) |
|
| 46 | - { |
|
| 47 | - global $wpdb; |
|
| 48 | - if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) { |
|
| 49 | - $success = $wpdb->update( |
|
| 50 | - $this->_old_table, |
|
| 51 | - array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ), // data |
|
| 52 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 53 | - array( '%s' ), // data format |
|
| 54 | - array( '%d' ) // where format |
|
| 55 | - ); |
|
| 56 | - if (! $success) { |
|
| 57 | - $this->add_error( |
|
| 58 | - sprintf( |
|
| 59 | - __('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 60 | - wp_json_encode($question['QST_type']), |
|
| 61 | - $question['QST_ID'], |
|
| 62 | - $wpdb->last_error |
|
| 63 | - ) |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 41 | + /** |
|
| 42 | + * @param array $question an associative array where keys are column names and values are their values. |
|
| 43 | + * @return null |
|
| 44 | + */ |
|
| 45 | + protected function _migrate_old_row($question) |
|
| 46 | + { |
|
| 47 | + global $wpdb; |
|
| 48 | + if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) { |
|
| 49 | + $success = $wpdb->update( |
|
| 50 | + $this->_old_table, |
|
| 51 | + array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ), // data |
|
| 52 | + array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 53 | + array( '%s' ), // data format |
|
| 54 | + array( '%d' ) // where format |
|
| 55 | + ); |
|
| 56 | + if (! $success) { |
|
| 57 | + $this->add_error( |
|
| 58 | + sprintf( |
|
| 59 | + __('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 60 | + wp_json_encode($question['QST_type']), |
|
| 61 | + $question['QST_ID'], |
|
| 62 | + $wpdb->last_error |
|
| 63 | + ) |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | // rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
| 35 | 35 | // so we need to include both the migrated rows as well as the non-migrated rows |
| 36 | 36 | $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions); |
| 37 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode("', '", $QST_types_to_count) . "')" ; |
|
| 37 | + $this->_extra_where_sql = "WHERE QST_type IN ('".implode("', '", $QST_types_to_count)."')"; |
|
| 38 | 38 | parent::__construct(); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | protected function _migrate_old_row($question) |
| 46 | 46 | { |
| 47 | 47 | global $wpdb; |
| 48 | - if ($question['QST_ID'] && isset($this->_question_type_conversions[ $question['QST_type'] ])) { |
|
| 48 | + if ($question['QST_ID'] && isset($this->_question_type_conversions[$question['QST_type']])) { |
|
| 49 | 49 | $success = $wpdb->update( |
| 50 | 50 | $this->_old_table, |
| 51 | - array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ), // data |
|
| 52 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 53 | - array( '%s' ), // data format |
|
| 54 | - array( '%d' ) // where format |
|
| 51 | + array('QST_type' => $this->_question_type_conversions[$question['QST_type']]), // data |
|
| 52 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 53 | + array('%s'), // data format |
|
| 54 | + array('%d') // where format |
|
| 55 | 55 | ); |
| 56 | - if (! $success) { |
|
| 56 | + if ( ! $success) { |
|
| 57 | 57 | $this->add_error( |
| 58 | 58 | sprintf( |
| 59 | 59 | __('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'), |
@@ -14,277 +14,277 @@ |
||
| 14 | 14 | class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - protected $_new_table_name; |
|
| 18 | - protected $_extra_meta_table_name; |
|
| 19 | - protected $_currency_table_name; |
|
| 20 | - protected $_currency_payment_method_table_name; |
|
| 17 | + protected $_new_table_name; |
|
| 18 | + protected $_extra_meta_table_name; |
|
| 19 | + protected $_currency_table_name; |
|
| 20 | + protected $_currency_payment_method_table_name; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * each key is the name of a 4.1-style gateway we know how to migrate to 4.6 |
|
| 24 | - * @var array |
|
| 25 | - */ |
|
| 26 | - protected $_gateway_we_know_to_migrate = array( |
|
| 27 | - 'Aim', |
|
| 28 | - 'Bank', |
|
| 29 | - 'Check', |
|
| 30 | - 'Invoice', |
|
| 31 | - 'Mijireh', |
|
| 32 | - 'Paypal_Pro', |
|
| 33 | - 'Paypal_Standard', |
|
| 34 | - ); |
|
| 22 | + /** |
|
| 23 | + * each key is the name of a 4.1-style gateway we know how to migrate to 4.6 |
|
| 24 | + * @var array |
|
| 25 | + */ |
|
| 26 | + protected $_gateway_we_know_to_migrate = array( |
|
| 27 | + 'Aim', |
|
| 28 | + 'Bank', |
|
| 29 | + 'Check', |
|
| 30 | + 'Invoice', |
|
| 31 | + 'Mijireh', |
|
| 32 | + 'Paypal_Pro', |
|
| 33 | + 'Paypal_Standard', |
|
| 34 | + ); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Just initializes the status of the migration |
|
| 40 | - */ |
|
| 41 | - public function __construct() |
|
| 42 | - { |
|
| 43 | - global $wpdb; |
|
| 44 | - $this->_new_table_name = $wpdb->prefix."esp_payment_method"; |
|
| 45 | - $this->_extra_meta_table_name = $wpdb->prefix."esp_extra_meta"; |
|
| 46 | - $this->_currency_table_name = $wpdb->prefix."esp_currency"; |
|
| 47 | - $this->_currency_payment_method_table_name = $wpdb->prefix."esp_currency_payment_method"; |
|
| 48 | - $this->_pretty_name = __('Gateways', 'event_espresso'); |
|
| 49 | - parent::__construct(); |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * Just initializes the status of the migration |
|
| 40 | + */ |
|
| 41 | + public function __construct() |
|
| 42 | + { |
|
| 43 | + global $wpdb; |
|
| 44 | + $this->_new_table_name = $wpdb->prefix."esp_payment_method"; |
|
| 45 | + $this->_extra_meta_table_name = $wpdb->prefix."esp_extra_meta"; |
|
| 46 | + $this->_currency_table_name = $wpdb->prefix."esp_currency"; |
|
| 47 | + $this->_currency_payment_method_table_name = $wpdb->prefix."esp_currency_payment_method"; |
|
| 48 | + $this->_pretty_name = __('Gateways', 'event_espresso'); |
|
| 49 | + parent::__construct(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Counts the records to migrate; the public version may cache it |
|
| 56 | - * @return int |
|
| 57 | - */ |
|
| 58 | - protected function _count_records_to_migrate() |
|
| 59 | - { |
|
| 60 | - return count(EE_Config::instance()->gateway->payment_settings); |
|
| 61 | - } |
|
| 54 | + /** |
|
| 55 | + * Counts the records to migrate; the public version may cache it |
|
| 56 | + * @return int |
|
| 57 | + */ |
|
| 58 | + protected function _count_records_to_migrate() |
|
| 59 | + { |
|
| 60 | + return count(EE_Config::instance()->gateway->payment_settings); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
| 67 | - * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
| 68 | - * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
| 69 | - * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
| 70 | - * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
| 71 | - * @param int $num_items_to_migrate |
|
| 72 | - * @return int number of items ACTUALLY migrated |
|
| 73 | - */ |
|
| 74 | - protected function _migration_step($num_items_to_migrate = 50) |
|
| 75 | - { |
|
| 76 | - $items_actually_migrated = 0; |
|
| 77 | - $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate); |
|
| 78 | - foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
|
| 79 | - if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
|
| 80 | - if (! $old_gateway_settings) { |
|
| 81 | - // no settings existed for this gateway anyways... weird... |
|
| 82 | - $items_actually_migrated++; |
|
| 83 | - continue; |
|
| 84 | - } |
|
| 85 | - // now prepare the settings to make sure they're in the 4.1 format |
|
| 86 | - $success = $this->_convert_gateway_settings( |
|
| 87 | - $old_gateway_slug, |
|
| 88 | - $old_gateway_settings, |
|
| 89 | - isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ]) |
|
| 90 | - ); |
|
| 91 | - if ($success) { |
|
| 92 | - EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - $items_actually_migrated++; |
|
| 96 | - } |
|
| 65 | + /** |
|
| 66 | + * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly. |
|
| 67 | + * Note: it should not alter the count of items migrated. That is done in the public function that calls this. |
|
| 68 | + * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it |
|
| 69 | + * should always return $num_items_to_migrate. (Eg, if we're migrating attendees rows from the database, and $num_items_to_migrate is set to 50, |
|
| 70 | + * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated) |
|
| 71 | + * @param int $num_items_to_migrate |
|
| 72 | + * @return int number of items ACTUALLY migrated |
|
| 73 | + */ |
|
| 74 | + protected function _migration_step($num_items_to_migrate = 50) |
|
| 75 | + { |
|
| 76 | + $items_actually_migrated = 0; |
|
| 77 | + $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate); |
|
| 78 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
|
| 79 | + if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
|
| 80 | + if (! $old_gateway_settings) { |
|
| 81 | + // no settings existed for this gateway anyways... weird... |
|
| 82 | + $items_actually_migrated++; |
|
| 83 | + continue; |
|
| 84 | + } |
|
| 85 | + // now prepare the settings to make sure they're in the 4.1 format |
|
| 86 | + $success = $this->_convert_gateway_settings( |
|
| 87 | + $old_gateway_slug, |
|
| 88 | + $old_gateway_settings, |
|
| 89 | + isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ]) |
|
| 90 | + ); |
|
| 91 | + if ($success) { |
|
| 92 | + EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + $items_actually_migrated++; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 99 | - if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 100 | - $this->set_completed(); |
|
| 101 | - } |
|
| 102 | - return $items_actually_migrated; |
|
| 103 | - } |
|
| 98 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 99 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 100 | + $this->set_completed(); |
|
| 101 | + } |
|
| 102 | + return $items_actually_migrated; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB |
|
| 107 | - * @param string $old_gateway_slug |
|
| 108 | - * @param array $old_gateway_settings |
|
| 109 | - * @param boolean $active indicates the gateway is currently active |
|
| 110 | - * @return boolean success |
|
| 111 | - */ |
|
| 112 | - protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active) |
|
| 113 | - { |
|
| 114 | - switch ($old_gateway_slug) { |
|
| 115 | - case 'Aim': |
|
| 116 | - $extra_meta_key_values = array( |
|
| 117 | - 'login_id'=>$old_gateway_settings['authnet_aim_login_id'], |
|
| 118 | - 'transaction_key'=>$old_gateway_settings['authnet_aim_transaction_key'], |
|
| 119 | - 'test_transactions'=>$old_gateway_settings['test_transactions'] |
|
| 120 | - ); |
|
| 121 | - $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 122 | - break; |
|
| 123 | - case 'Bank': |
|
| 124 | - $extra_meta_key_values = array( |
|
| 125 | - 'page_title'=>$old_gateway_settings['page_title'], |
|
| 126 | - 'payment_instructions'=> |
|
| 127 | - sprintf(__('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'], $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address']) ); |
|
| 128 | - $desc = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
| 129 | - break; |
|
| 130 | - case 'Check': |
|
| 131 | - $extra_meta_key_values = array( |
|
| 132 | - 'check_title'=> $old_gateway_settings['check_title'], |
|
| 133 | - 'payment_instructions'=>$old_gateway_settings['check_instructions'], |
|
| 134 | - 'address_to_send_payment'=>$old_gateway_settings['payment_address'] |
|
| 135 | - ); |
|
| 136 | - $desc = __('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso'); |
|
| 137 | - break; |
|
| 138 | - case 'Invoice': |
|
| 139 | - $extra_meta_key_values = array( |
|
| 140 | - 'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'], |
|
| 141 | - 'pdf_payee_email' => $old_gateway_settings['template_invoice_email'], |
|
| 142 | - 'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'], |
|
| 143 | - 'pdf_payee_address' => $old_gateway_settings['template_invoice_address'], |
|
| 144 | - 'pdf_instructions' => $old_gateway_settings['template_payment_instructions'], |
|
| 145 | - 'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'], |
|
| 146 | - 'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '', |
|
| 147 | - 'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '', |
|
| 148 | - 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] |
|
| 149 | - ); |
|
| 150 | - // if they didnt want the invoiec gateway to show, pretend it was inactive |
|
| 151 | - if (! $old_gateway_settings['show']) { |
|
| 152 | - $active = false; |
|
| 153 | - } |
|
| 154 | - $desc = __('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso'); |
|
| 155 | - break; |
|
| 156 | - case 'Mijireh': |
|
| 157 | - $extra_meta_key_values = array( |
|
| 158 | - 'access_key' => $old_gateway_settings['access_key'] |
|
| 159 | - ); |
|
| 160 | - $desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso'); |
|
| 161 | - break; |
|
| 162 | - case 'Paypal_Pro': |
|
| 163 | - $extra_meta_key_values = array( |
|
| 164 | - 'username'=>$old_gateway_settings['username'], |
|
| 165 | - 'password'=>$old_gateway_settings['password'], |
|
| 166 | - 'signature'=>$old_gateway_settings['signature'], |
|
| 167 | - 'credit_card_types'=>$old_gateway_settings['credit_cards'], |
|
| 168 | - ); |
|
| 169 | - $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 170 | - break; |
|
| 171 | - case 'Paypal_Standard': |
|
| 172 | - $extra_meta_key_values = array( |
|
| 173 | - 'paypal_id' => $old_gateway_settings['paypal_id'], |
|
| 174 | - 'image_url' => $old_gateway_settings['image_url'], |
|
| 175 | - 'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false, |
|
| 105 | + /** |
|
| 106 | + * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB |
|
| 107 | + * @param string $old_gateway_slug |
|
| 108 | + * @param array $old_gateway_settings |
|
| 109 | + * @param boolean $active indicates the gateway is currently active |
|
| 110 | + * @return boolean success |
|
| 111 | + */ |
|
| 112 | + protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active) |
|
| 113 | + { |
|
| 114 | + switch ($old_gateway_slug) { |
|
| 115 | + case 'Aim': |
|
| 116 | + $extra_meta_key_values = array( |
|
| 117 | + 'login_id'=>$old_gateway_settings['authnet_aim_login_id'], |
|
| 118 | + 'transaction_key'=>$old_gateway_settings['authnet_aim_transaction_key'], |
|
| 119 | + 'test_transactions'=>$old_gateway_settings['test_transactions'] |
|
| 120 | + ); |
|
| 121 | + $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 122 | + break; |
|
| 123 | + case 'Bank': |
|
| 124 | + $extra_meta_key_values = array( |
|
| 125 | + 'page_title'=>$old_gateway_settings['page_title'], |
|
| 126 | + 'payment_instructions'=> |
|
| 127 | + sprintf(__('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'], $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address']) ); |
|
| 128 | + $desc = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
| 129 | + break; |
|
| 130 | + case 'Check': |
|
| 131 | + $extra_meta_key_values = array( |
|
| 132 | + 'check_title'=> $old_gateway_settings['check_title'], |
|
| 133 | + 'payment_instructions'=>$old_gateway_settings['check_instructions'], |
|
| 134 | + 'address_to_send_payment'=>$old_gateway_settings['payment_address'] |
|
| 135 | + ); |
|
| 136 | + $desc = __('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso'); |
|
| 137 | + break; |
|
| 138 | + case 'Invoice': |
|
| 139 | + $extra_meta_key_values = array( |
|
| 140 | + 'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'], |
|
| 141 | + 'pdf_payee_email' => $old_gateway_settings['template_invoice_email'], |
|
| 142 | + 'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'], |
|
| 143 | + 'pdf_payee_address' => $old_gateway_settings['template_invoice_address'], |
|
| 144 | + 'pdf_instructions' => $old_gateway_settings['template_payment_instructions'], |
|
| 145 | + 'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'], |
|
| 146 | + 'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '', |
|
| 147 | + 'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '', |
|
| 148 | + 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] |
|
| 149 | + ); |
|
| 150 | + // if they didnt want the invoiec gateway to show, pretend it was inactive |
|
| 151 | + if (! $old_gateway_settings['show']) { |
|
| 152 | + $active = false; |
|
| 153 | + } |
|
| 154 | + $desc = __('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso'); |
|
| 155 | + break; |
|
| 156 | + case 'Mijireh': |
|
| 157 | + $extra_meta_key_values = array( |
|
| 158 | + 'access_key' => $old_gateway_settings['access_key'] |
|
| 159 | + ); |
|
| 160 | + $desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso'); |
|
| 161 | + break; |
|
| 162 | + case 'Paypal_Pro': |
|
| 163 | + $extra_meta_key_values = array( |
|
| 164 | + 'username'=>$old_gateway_settings['username'], |
|
| 165 | + 'password'=>$old_gateway_settings['password'], |
|
| 166 | + 'signature'=>$old_gateway_settings['signature'], |
|
| 167 | + 'credit_card_types'=>$old_gateway_settings['credit_cards'], |
|
| 168 | + ); |
|
| 169 | + $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 170 | + break; |
|
| 171 | + case 'Paypal_Standard': |
|
| 172 | + $extra_meta_key_values = array( |
|
| 173 | + 'paypal_id' => $old_gateway_settings['paypal_id'], |
|
| 174 | + 'image_url' => $old_gateway_settings['image_url'], |
|
| 175 | + 'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false, |
|
| 176 | 176 | |
| 177 | - ); |
|
| 178 | - $desc = sprintf(__('After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso'), '<strong>', '</strong>'); |
|
| 179 | - break; |
|
| 180 | - default: |
|
| 181 | - // if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere |
|
| 182 | - $extra_meta_key_values = $old_gateway_settings; |
|
| 183 | - $desc = ''; |
|
| 184 | - } |
|
| 185 | - $pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug; |
|
| 186 | - $offline_gateways = array( 'Bank', 'Check', 'Invoice' ); |
|
| 187 | - if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 188 | - $scope = array( 'CART', 'ADMIN'); |
|
| 189 | - } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
|
| 190 | - $scope = array( 'CART' ); |
|
| 191 | - } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 192 | - $scope = array( 'ADMIN' ); |
|
| 193 | - } else { |
|
| 194 | - $scope = array(); |
|
| 195 | - } |
|
| 196 | - $payment_method_col_values = array( |
|
| 197 | - 'PMD_type' => $old_gateway_slug, |
|
| 198 | - 'PMD_name' => $pretty_name, |
|
| 199 | - 'PMD_desc' => $desc, |
|
| 200 | - 'PMD_admin_name' => $pretty_name, |
|
| 201 | - 'PMD_slug' => sanitize_key($old_gateway_slug), |
|
| 202 | - 'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : false, |
|
| 203 | - 'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : null, |
|
| 204 | - 'PMD_scope' => serialize($scope) |
|
| 205 | - ); |
|
| 206 | - $db_types = array( |
|
| 207 | - '%s',// PMD_type |
|
| 208 | - '%s',// PMD_name |
|
| 209 | - '%s',// PMD_desc |
|
| 210 | - '%s',// PMD_admin_name |
|
| 211 | - '%s',// PMD_slug |
|
| 212 | - '%d',// PMD_debug_mode |
|
| 213 | - '%s',// PMD_button_url |
|
| 214 | - '%s',// PMD_scope |
|
| 215 | - ); |
|
| 216 | - global $wpdb; |
|
| 217 | - // first: check if it already exists |
|
| 218 | - $id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug'])); |
|
| 219 | - if ($id) { |
|
| 220 | - // just update that payment method instead of creating a new one |
|
| 221 | - $success = $wpdb->update( |
|
| 222 | - $this->_new_table_name, |
|
| 223 | - $payment_method_col_values, |
|
| 224 | - array( |
|
| 225 | - 'PMD_ID'=>$id |
|
| 226 | - ), |
|
| 227 | - $db_types, |
|
| 228 | - array( |
|
| 229 | - '%d',// PMD_ID |
|
| 230 | - ) |
|
| 231 | - ); |
|
| 232 | - if (! $success) { |
|
| 233 | - $this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error)); |
|
| 234 | - } |
|
| 235 | - } else { |
|
| 236 | - $success = $wpdb->insert( |
|
| 237 | - $this->_new_table_name, |
|
| 238 | - $payment_method_col_values, |
|
| 239 | - $db_types |
|
| 240 | - ); |
|
| 241 | - if (! $success) { |
|
| 242 | - $this->add_error($wpdb->last_error); |
|
| 243 | - return false; |
|
| 244 | - } else { |
|
| 245 | - $id = $wpdb->insert_id; |
|
| 246 | - } |
|
| 247 | - } |
|
| 177 | + ); |
|
| 178 | + $desc = sprintf(__('After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso'), '<strong>', '</strong>'); |
|
| 179 | + break; |
|
| 180 | + default: |
|
| 181 | + // if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere |
|
| 182 | + $extra_meta_key_values = $old_gateway_settings; |
|
| 183 | + $desc = ''; |
|
| 184 | + } |
|
| 185 | + $pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug; |
|
| 186 | + $offline_gateways = array( 'Bank', 'Check', 'Invoice' ); |
|
| 187 | + if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 188 | + $scope = array( 'CART', 'ADMIN'); |
|
| 189 | + } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
|
| 190 | + $scope = array( 'CART' ); |
|
| 191 | + } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 192 | + $scope = array( 'ADMIN' ); |
|
| 193 | + } else { |
|
| 194 | + $scope = array(); |
|
| 195 | + } |
|
| 196 | + $payment_method_col_values = array( |
|
| 197 | + 'PMD_type' => $old_gateway_slug, |
|
| 198 | + 'PMD_name' => $pretty_name, |
|
| 199 | + 'PMD_desc' => $desc, |
|
| 200 | + 'PMD_admin_name' => $pretty_name, |
|
| 201 | + 'PMD_slug' => sanitize_key($old_gateway_slug), |
|
| 202 | + 'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : false, |
|
| 203 | + 'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : null, |
|
| 204 | + 'PMD_scope' => serialize($scope) |
|
| 205 | + ); |
|
| 206 | + $db_types = array( |
|
| 207 | + '%s',// PMD_type |
|
| 208 | + '%s',// PMD_name |
|
| 209 | + '%s',// PMD_desc |
|
| 210 | + '%s',// PMD_admin_name |
|
| 211 | + '%s',// PMD_slug |
|
| 212 | + '%d',// PMD_debug_mode |
|
| 213 | + '%s',// PMD_button_url |
|
| 214 | + '%s',// PMD_scope |
|
| 215 | + ); |
|
| 216 | + global $wpdb; |
|
| 217 | + // first: check if it already exists |
|
| 218 | + $id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug'])); |
|
| 219 | + if ($id) { |
|
| 220 | + // just update that payment method instead of creating a new one |
|
| 221 | + $success = $wpdb->update( |
|
| 222 | + $this->_new_table_name, |
|
| 223 | + $payment_method_col_values, |
|
| 224 | + array( |
|
| 225 | + 'PMD_ID'=>$id |
|
| 226 | + ), |
|
| 227 | + $db_types, |
|
| 228 | + array( |
|
| 229 | + '%d',// PMD_ID |
|
| 230 | + ) |
|
| 231 | + ); |
|
| 232 | + if (! $success) { |
|
| 233 | + $this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error)); |
|
| 234 | + } |
|
| 235 | + } else { |
|
| 236 | + $success = $wpdb->insert( |
|
| 237 | + $this->_new_table_name, |
|
| 238 | + $payment_method_col_values, |
|
| 239 | + $db_types |
|
| 240 | + ); |
|
| 241 | + if (! $success) { |
|
| 242 | + $this->add_error($wpdb->last_error); |
|
| 243 | + return false; |
|
| 244 | + } else { |
|
| 245 | + $id = $wpdb->insert_id; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - if ($id) { |
|
| 250 | - $this->_convert_extra_meta_values($id, $extra_meta_key_values); |
|
| 251 | - $this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id); |
|
| 252 | - return true; |
|
| 253 | - } |
|
| 254 | - return false; |
|
| 255 | - } |
|
| 249 | + if ($id) { |
|
| 250 | + $this->_convert_extra_meta_values($id, $extra_meta_key_values); |
|
| 251 | + $this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id); |
|
| 252 | + return true; |
|
| 253 | + } |
|
| 254 | + return false; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | |
| 259 | - /** |
|
| 260 | - * Converts old gateway settings which don't map onto the Payment_Method model |
|
| 261 | - * to extra meta fields |
|
| 262 | - * @param int $id |
|
| 263 | - * @param array $extra_meta_key_values |
|
| 264 | - */ |
|
| 265 | - private function _convert_extra_meta_values($id, $extra_meta_key_values) |
|
| 266 | - { |
|
| 267 | - global $wpdb; |
|
| 268 | - foreach ($extra_meta_key_values as $key => $value) { |
|
| 269 | - $exm_args = array( |
|
| 270 | - 'OBJ_ID'=>$id, |
|
| 271 | - 'EXM_type'=>'Payment_Method', |
|
| 272 | - 'EXM_key'=>$key, |
|
| 273 | - 'EXM_value'=> maybe_serialize($value) |
|
| 274 | - ); |
|
| 275 | - $success = $wpdb->insert( |
|
| 276 | - $this->_extra_meta_table_name, |
|
| 277 | - $exm_args, |
|
| 278 | - array( |
|
| 279 | - '%d',// OBJ_ID |
|
| 280 | - '%s',// EXM_type |
|
| 281 | - '%s',// EXM_key |
|
| 282 | - '%s',// EXM_value |
|
| 283 | - ) |
|
| 284 | - ); |
|
| 285 | - if (! $success) { |
|
| 286 | - $this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error)); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 259 | + /** |
|
| 260 | + * Converts old gateway settings which don't map onto the Payment_Method model |
|
| 261 | + * to extra meta fields |
|
| 262 | + * @param int $id |
|
| 263 | + * @param array $extra_meta_key_values |
|
| 264 | + */ |
|
| 265 | + private function _convert_extra_meta_values($id, $extra_meta_key_values) |
|
| 266 | + { |
|
| 267 | + global $wpdb; |
|
| 268 | + foreach ($extra_meta_key_values as $key => $value) { |
|
| 269 | + $exm_args = array( |
|
| 270 | + 'OBJ_ID'=>$id, |
|
| 271 | + 'EXM_type'=>'Payment_Method', |
|
| 272 | + 'EXM_key'=>$key, |
|
| 273 | + 'EXM_value'=> maybe_serialize($value) |
|
| 274 | + ); |
|
| 275 | + $success = $wpdb->insert( |
|
| 276 | + $this->_extra_meta_table_name, |
|
| 277 | + $exm_args, |
|
| 278 | + array( |
|
| 279 | + '%d',// OBJ_ID |
|
| 280 | + '%s',// EXM_type |
|
| 281 | + '%s',// EXM_key |
|
| 282 | + '%s',// EXM_value |
|
| 283 | + ) |
|
| 284 | + ); |
|
| 285 | + if (! $success) { |
|
| 286 | + $this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error)); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | 290 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate); |
| 78 | 78 | foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
| 79 | 79 | if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
| 80 | - if (! $old_gateway_settings) { |
|
| 80 | + if ( ! $old_gateway_settings) { |
|
| 81 | 81 | // no settings existed for this gateway anyways... weird... |
| 82 | 82 | $items_actually_migrated++; |
| 83 | 83 | continue; |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | $success = $this->_convert_gateway_settings( |
| 87 | 87 | $old_gateway_slug, |
| 88 | 88 | $old_gateway_settings, |
| 89 | - isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ]) |
|
| 89 | + isset(EE_Config::instance()->gateway->active_gateways[$old_gateway_slug]) |
|
| 90 | 90 | ); |
| 91 | 91 | if ($success) { |
| 92 | - EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
| 92 | + EE_Config::instance()->gateway->payment_settings[$old_gateway_slug] = 'Deprecated'; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | $items_actually_migrated++; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] |
| 149 | 149 | ); |
| 150 | 150 | // if they didnt want the invoiec gateway to show, pretend it was inactive |
| 151 | - if (! $old_gateway_settings['show']) { |
|
| 151 | + if ( ! $old_gateway_settings['show']) { |
|
| 152 | 152 | $active = false; |
| 153 | 153 | } |
| 154 | 154 | $desc = __('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso'); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $extra_meta_key_values = array( |
| 158 | 158 | 'access_key' => $old_gateway_settings['access_key'] |
| 159 | 159 | ); |
| 160 | - $desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso'); |
|
| 160 | + $desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso'); |
|
| 161 | 161 | break; |
| 162 | 162 | case 'Paypal_Pro': |
| 163 | 163 | $extra_meta_key_values = array( |
@@ -183,13 +183,13 @@ discard block |
||
| 183 | 183 | $desc = ''; |
| 184 | 184 | } |
| 185 | 185 | $pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug; |
| 186 | - $offline_gateways = array( 'Bank', 'Check', 'Invoice' ); |
|
| 186 | + $offline_gateways = array('Bank', 'Check', 'Invoice'); |
|
| 187 | 187 | if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
| 188 | - $scope = array( 'CART', 'ADMIN'); |
|
| 188 | + $scope = array('CART', 'ADMIN'); |
|
| 189 | 189 | } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
| 190 | - $scope = array( 'CART' ); |
|
| 191 | - } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 192 | - $scope = array( 'ADMIN' ); |
|
| 190 | + $scope = array('CART'); |
|
| 191 | + } elseif ( ! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 192 | + $scope = array('ADMIN'); |
|
| 193 | 193 | } else { |
| 194 | 194 | $scope = array(); |
| 195 | 195 | } |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | 'PMD_scope' => serialize($scope) |
| 205 | 205 | ); |
| 206 | 206 | $db_types = array( |
| 207 | - '%s',// PMD_type |
|
| 208 | - '%s',// PMD_name |
|
| 209 | - '%s',// PMD_desc |
|
| 210 | - '%s',// PMD_admin_name |
|
| 211 | - '%s',// PMD_slug |
|
| 212 | - '%d',// PMD_debug_mode |
|
| 213 | - '%s',// PMD_button_url |
|
| 214 | - '%s',// PMD_scope |
|
| 207 | + '%s', // PMD_type |
|
| 208 | + '%s', // PMD_name |
|
| 209 | + '%s', // PMD_desc |
|
| 210 | + '%s', // PMD_admin_name |
|
| 211 | + '%s', // PMD_slug |
|
| 212 | + '%d', // PMD_debug_mode |
|
| 213 | + '%s', // PMD_button_url |
|
| 214 | + '%s', // PMD_scope |
|
| 215 | 215 | ); |
| 216 | 216 | global $wpdb; |
| 217 | 217 | // first: check if it already exists |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | ), |
| 227 | 227 | $db_types, |
| 228 | 228 | array( |
| 229 | - '%d',// PMD_ID |
|
| 229 | + '%d', // PMD_ID |
|
| 230 | 230 | ) |
| 231 | 231 | ); |
| 232 | - if (! $success) { |
|
| 232 | + if ( ! $success) { |
|
| 233 | 233 | $this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error)); |
| 234 | 234 | } |
| 235 | 235 | } else { |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $payment_method_col_values, |
| 239 | 239 | $db_types |
| 240 | 240 | ); |
| 241 | - if (! $success) { |
|
| 241 | + if ( ! $success) { |
|
| 242 | 242 | $this->add_error($wpdb->last_error); |
| 243 | 243 | return false; |
| 244 | 244 | } else { |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | $this->_extra_meta_table_name, |
| 277 | 277 | $exm_args, |
| 278 | 278 | array( |
| 279 | - '%d',// OBJ_ID |
|
| 280 | - '%s',// EXM_type |
|
| 281 | - '%s',// EXM_key |
|
| 282 | - '%s',// EXM_value |
|
| 279 | + '%d', // OBJ_ID |
|
| 280 | + '%s', // EXM_type |
|
| 281 | + '%s', // EXM_key |
|
| 282 | + '%s', // EXM_value |
|
| 283 | 283 | ) |
| 284 | 284 | ); |
| 285 | - if (! $success) { |
|
| 285 | + if ( ! $success) { |
|
| 286 | 286 | $this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error)); |
| 287 | 287 | } |
| 288 | 288 | } |