Completed
Branch fix-dummy-related-question-qst... (e5efcf)
by
unknown
07:49 queued 03:45
created
core/data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_payments.dmsstage.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -11,44 +11,44 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_payments extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_payment_method_table;
15
-    public function __construct()
16
-    {
17
-        global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
-        $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21
-        parent::__construct();
22
-    }
23
-    protected function _migrate_old_row($payment_row)
24
-    {
25
-        global $wpdb;
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(esc_html__('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
-            $PMD_ID = 0;
31
-        }
32
-        $new_values = array(
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(
39
-            $this->_old_table,
40
-            $new_values,
41
-            $wheres,
42
-            $new_value_datatypes,
43
-            $where_datatypes
44
-        );
45
-        if (! $success) {
46
-            $this->add_error(sprintf(esc_html__('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)));
47
-        }
48
-    }
49
-    /**
50
-     *
51
-     *  array(
14
+	protected $_payment_method_table;
15
+	public function __construct()
16
+	{
17
+		global $wpdb;
18
+		$this->_old_table = $wpdb->prefix . 'esp_payment';
19
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
+		$this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21
+		parent::__construct();
22
+	}
23
+	protected function _migrate_old_row($payment_row)
24
+	{
25
+		global $wpdb;
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(esc_html__('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
+			$PMD_ID = 0;
31
+		}
32
+		$new_values = array(
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(
39
+			$this->_old_table,
40
+			$new_values,
41
+			$wheres,
42
+			$new_value_datatypes,
43
+			$where_datatypes
44
+		);
45
+		if (! $success) {
46
+			$this->add_error(sprintf(esc_html__('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)));
47
+		}
48
+	}
49
+	/**
50
+	 *
51
+	 *  array(
52 52
             'PP' => esc_html__( 'PayPal', 'event_espresso' ),
53 53
             'CC' => esc_html__( 'Credit Card', 'event_espresso' ),
54 54
             'DB'=>  esc_html__("Debit Card", 'event_espresso'),
@@ -57,44 +57,44 @@  discard block
 block discarded – undo
57 57
             'BK'=>  esc_html__("Bank", 'event_espresso'),
58 58
             'IV'=>  esc_html__("Invoice", 'event_espresso'),
59 59
             'MO'=>  esc_html__("Money Order", 'event_espresso'),
60
-     * @global type $wpdb
61
-     * @param int $id
62
-     * @return string
63
-     */
64
-    protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
-    {
66
-        global $wpdb;
67
-        // convert from old known PAY_method values to their corresponding
68
-        // PMD_type or default PMD_name
69
-        switch ($old_pay_method_column) {
70
-            case 'PP':
71
-                $pmd_type = 'Paypal_Standard';
72
-                break;
73
-            case 'CC':
74
-                $pmd_type = 'Credit_Card';
75
-                break;
76
-            case 'DB':
77
-                $pmd_type = 'Debit_Card';
78
-                break;
79
-            case 'CHQ':
80
-                $pmd_type = 'Check';
81
-                break;
82
-            case 'CSH':
83
-                $pmd_type = 'Cash';
84
-                break;
85
-            case 'BK':
86
-                $pmd_type = 'Bank';
87
-                break;
88
-            case 'IV':
89
-                $pmd_type = 'Invoice';
90
-                break;
91
-            case 'MO':
92
-                $pmd_type = 'Money_Order';
93
-                break;
94
-            default:
95
-                $pmd_type = $gateway_name;
96
-        }
97
-        $pmd_name = str_replace("_", " ", $pmd_type);
98
-        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));
99
-    }
60
+	 * @global type $wpdb
61
+	 * @param int $id
62
+	 * @return string
63
+	 */
64
+	protected function _get_payment_method_id_by_gateway_name($gateway_name, $old_pay_method_column)
65
+	{
66
+		global $wpdb;
67
+		// convert from old known PAY_method values to their corresponding
68
+		// PMD_type or default PMD_name
69
+		switch ($old_pay_method_column) {
70
+			case 'PP':
71
+				$pmd_type = 'Paypal_Standard';
72
+				break;
73
+			case 'CC':
74
+				$pmd_type = 'Credit_Card';
75
+				break;
76
+			case 'DB':
77
+				$pmd_type = 'Debit_Card';
78
+				break;
79
+			case 'CHQ':
80
+				$pmd_type = 'Check';
81
+				break;
82
+			case 'CSH':
83
+				$pmd_type = 'Cash';
84
+				break;
85
+			case 'BK':
86
+				$pmd_type = 'Bank';
87
+				break;
88
+			case 'IV':
89
+				$pmd_type = 'Invoice';
90
+				break;
91
+			case 'MO':
92
+				$pmd_type = 'Money_Order';
93
+				break;
94
+			default:
95
+				$pmd_type = $gateway_name;
96
+		}
97
+		$pmd_name = str_replace("_", " ", $pmd_type);
98
+		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));
99
+	}
100 100
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
     public function __construct()
16 16
     {
17 17
         global $wpdb;
18
-        $this->_old_table = $wpdb->prefix . 'esp_payment';
19
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
18
+        $this->_old_table = $wpdb->prefix.'esp_payment';
19
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
20 20
         $this->_pretty_name = esc_html__('Payment-Payment Method Relations', 'event_espresso');
21 21
         parent::__construct();
22 22
     }
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
         global $wpdb;
26 26
         // get the payment method's ID
27 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) {
28
+        if ( ! $PMD_ID) {
29 29
             $this->add_error(sprintf(esc_html__('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' );
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 38
         $success = $wpdb->update(
39 39
             $this->_old_table,
40 40
             $new_values,
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             $new_value_datatypes,
43 43
             $where_datatypes
44 44
         );
45
-        if (! $success) {
45
+        if ( ! $success) {
46 46
             $this->add_error(sprintf(esc_html__('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)));
47 47
         }
48 48
     }
@@ -95,6 +95,6 @@  discard block
 block discarded – undo
95 95
                 $pmd_type = $gateway_name;
96 96
         }
97 97
         $pmd_name = str_replace("_", " ", $pmd_type);
98
-        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));
98
+        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));
99 99
     }
100 100
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_transactions.dmsstage.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    protected $_transaction_table;
15
-    protected $_payment_method_table;
16
-    public function __construct()
17
-    {
18
-        global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
-        $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23
-        $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
-        parent::__construct();
25
-    }
26
-    protected function _migrate_old_row($extra_meta_row)
27
-    {
28
-        global $wpdb;
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(esc_html__('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
-            return;
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(
40
-            $this->_transaction_table,
41
-            $new_values,
42
-            $wheres,
43
-            $new_value_datatypes,
44
-            $where_datatypes
45
-        );
46
-        if (! $success) {
47
-            $this->add_error(sprintf(esc_html__('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)));
48
-        }
49
-    }
50
-    /**
51
-     *
52
-     * @global type $wpdb
53
-     * @param int $id
54
-     * @return string
55
-     */
56
-    protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
-    {
58
-        global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
-    }
14
+	protected $_transaction_table;
15
+	protected $_payment_method_table;
16
+	public function __construct()
17
+	{
18
+		global $wpdb;
19
+		$this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
+		$this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
+		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
22
+		$this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23
+		$this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24
+		parent::__construct();
25
+	}
26
+	protected function _migrate_old_row($extra_meta_row)
27
+	{
28
+		global $wpdb;
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(esc_html__('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
+			return;
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(
40
+			$this->_transaction_table,
41
+			$new_values,
42
+			$wheres,
43
+			$new_value_datatypes,
44
+			$where_datatypes
45
+		);
46
+		if (! $success) {
47
+			$this->add_error(sprintf(esc_html__('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)));
48
+		}
49
+	}
50
+	/**
51
+	 *
52
+	 * @global type $wpdb
53
+	 * @param int $id
54
+	 * @return string
55
+	 */
56
+	protected function _get_payment_method_id_by_gateway_name($gateway_name)
57
+	{
58
+		global $wpdb;
59
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
     public function __construct()
17 17
     {
18 18
         global $wpdb;
19
-        $this->_old_table = $wpdb->prefix . 'esp_extra_meta';
20
-        $this->_transaction_table = $wpdb->prefix . 'esp_transaction';
21
-        $this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
19
+        $this->_old_table = $wpdb->prefix.'esp_extra_meta';
20
+        $this->_transaction_table = $wpdb->prefix.'esp_transaction';
21
+        $this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
22 22
         $this->_pretty_name = esc_html__('Transaction Payment Method Relations', 'event_espresso');
23 23
         $this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
24 24
         parent::__construct();
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
         global $wpdb;
29 29
         // get the payment method's ID
30 30
         $PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
-        if (! $PMD_ID) {
31
+        if ( ! $PMD_ID) {
32 32
             $this->add_error(sprintf(esc_html__('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' );
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 39
         $success = $wpdb->update(
40 40
             $this->_transaction_table,
41 41
             $new_values,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
             $new_value_datatypes,
44 44
             $where_datatypes
45 45
         );
46
-        if (! $success) {
46
+        if ( ! $success) {
47 47
             $this->add_error(sprintf(esc_html__('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)));
48 48
         }
49 49
     }
@@ -56,6 +56,6 @@  discard block
 block discarded – undo
56 56
     protected function _get_payment_method_id_by_gateway_name($gateway_name)
57 57
     {
58 58
         global $wpdb;
59
-        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name));
59
+        return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", $gateway_name));
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_gateways.dmsstage.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
     public function __construct()
42 42
     {
43 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";
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 48
         $this->_pretty_name = esc_html__('Gateways', 'event_espresso');
49 49
         parent::__construct();
50 50
     }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 = esc_html__('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
 block discarded – undo
157 157
                 $extra_meta_key_values = array(
158 158
                     'access_key' => $old_gateway_settings['access_key']
159 159
                 );
160
-                $desc =  esc_html__('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso');
160
+                $desc = esc_html__('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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(esc_html__('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
 block discarded – undo
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
 block discarded – undo
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(esc_html__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error));
287 287
             }
288 288
         }
Please login to merge, or discard this patch.
Indentation   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -13,277 +13,277 @@
 block discarded – undo
13 13
  */
14 14
 class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage
15 15
 {
16
-    protected $_new_table_name;
17
-    protected $_extra_meta_table_name;
18
-    protected $_currency_table_name;
19
-    protected $_currency_payment_method_table_name;
16
+	protected $_new_table_name;
17
+	protected $_extra_meta_table_name;
18
+	protected $_currency_table_name;
19
+	protected $_currency_payment_method_table_name;
20 20
 
21
-    /**
22
-     * each key is the name of a 4.1-style gateway we know how to migrate to 4.6
23
-     * @var array
24
-     */
25
-    protected $_gateway_we_know_to_migrate = array(
26
-        'Aim',
27
-        'Bank',
28
-        'Check',
29
-        'Invoice',
30
-        'Mijireh',
31
-        'Paypal_Pro',
32
-        'Paypal_Standard',
33
-    );
21
+	/**
22
+	 * each key is the name of a 4.1-style gateway we know how to migrate to 4.6
23
+	 * @var array
24
+	 */
25
+	protected $_gateway_we_know_to_migrate = array(
26
+		'Aim',
27
+		'Bank',
28
+		'Check',
29
+		'Invoice',
30
+		'Mijireh',
31
+		'Paypal_Pro',
32
+		'Paypal_Standard',
33
+	);
34 34
 
35 35
 
36 36
 
37
-    /**
38
-     * Just initializes the status of the migration
39
-     */
40
-    public function __construct()
41
-    {
42
-        global $wpdb;
43
-        $this->_new_table_name = $wpdb->prefix . "esp_payment_method";
44
-        $this->_extra_meta_table_name = $wpdb->prefix . "esp_extra_meta";
45
-        $this->_currency_table_name = $wpdb->prefix . "esp_currency";
46
-        $this->_currency_payment_method_table_name = $wpdb->prefix . "esp_currency_payment_method";
47
-        $this->_pretty_name = esc_html__('Gateways', 'event_espresso');
48
-        parent::__construct();
49
-    }
37
+	/**
38
+	 * Just initializes the status of the migration
39
+	 */
40
+	public function __construct()
41
+	{
42
+		global $wpdb;
43
+		$this->_new_table_name = $wpdb->prefix . "esp_payment_method";
44
+		$this->_extra_meta_table_name = $wpdb->prefix . "esp_extra_meta";
45
+		$this->_currency_table_name = $wpdb->prefix . "esp_currency";
46
+		$this->_currency_payment_method_table_name = $wpdb->prefix . "esp_currency_payment_method";
47
+		$this->_pretty_name = esc_html__('Gateways', 'event_espresso');
48
+		parent::__construct();
49
+	}
50 50
 
51 51
 
52 52
 
53
-    /**
54
-     * Counts the records to migrate; the public version may cache it
55
-     * @return int
56
-     */
57
-    protected function _count_records_to_migrate()
58
-    {
59
-        return count(EE_Config::instance()->gateway->payment_settings);
60
-    }
53
+	/**
54
+	 * Counts the records to migrate; the public version may cache it
55
+	 * @return int
56
+	 */
57
+	protected function _count_records_to_migrate()
58
+	{
59
+		return count(EE_Config::instance()->gateway->payment_settings);
60
+	}
61 61
 
62 62
 
63 63
 
64
-    /**
65
-     * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
66
-     * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
67
-     * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
68
-     * 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,
69
-     * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
70
-     * @param int $num_items_to_migrate
71
-     * @return int number of items ACTUALLY migrated
72
-     */
73
-    protected function _migration_step($num_items_to_migrate = 50)
74
-    {
75
-        $items_actually_migrated = 0;
76
-        $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate);
77
-        foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) {
78
-            if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) {
79
-                if (! $old_gateway_settings) {
80
-                    // no settings existed for this gateway anyways... weird...
81
-                    $items_actually_migrated++;
82
-                    continue;
83
-                }
84
-                // now prepare the settings to make sure they're in the 4.1 format
85
-                $success = $this->_convert_gateway_settings(
86
-                    $old_gateway_slug,
87
-                    $old_gateway_settings,
88
-                    isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ])
89
-                );
90
-                if ($success) {
91
-                    EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated';
92
-                }
93
-            }
94
-            $items_actually_migrated++;
95
-        }
64
+	/**
65
+	 * IMPORTANT: if an error is encountered, or everything is finished, this stage should update its status property accordingly.
66
+	 * Note: it should not alter the count of items migrated. That is done in the public function that calls this.
67
+	 * IMPORTANT: The count of items migrated should ONLY be less than $num_items_to_migrate when it's the last migration step, otherwise it
68
+	 * 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,
69
+	 * then we SHOULD actually migrate 50 rows,but at very least we MUST report/return 50 items migrated)
70
+	 * @param int $num_items_to_migrate
71
+	 * @return int number of items ACTUALLY migrated
72
+	 */
73
+	protected function _migration_step($num_items_to_migrate = 50)
74
+	{
75
+		$items_actually_migrated = 0;
76
+		$gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate);
77
+		foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) {
78
+			if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) {
79
+				if (! $old_gateway_settings) {
80
+					// no settings existed for this gateway anyways... weird...
81
+					$items_actually_migrated++;
82
+					continue;
83
+				}
84
+				// now prepare the settings to make sure they're in the 4.1 format
85
+				$success = $this->_convert_gateway_settings(
86
+					$old_gateway_slug,
87
+					$old_gateway_settings,
88
+					isset(EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ])
89
+				);
90
+				if ($success) {
91
+					EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated';
92
+				}
93
+			}
94
+			$items_actually_migrated++;
95
+		}
96 96
 
97
-        EE_Config::instance()->update_espresso_config(false, false);
98
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
99
-            $this->set_completed();
100
-        }
101
-        return $items_actually_migrated;
102
-    }
97
+		EE_Config::instance()->update_espresso_config(false, false);
98
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
99
+			$this->set_completed();
100
+		}
101
+		return $items_actually_migrated;
102
+	}
103 103
 
104
-    /**
105
-     * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB
106
-     * @param string $old_gateway_slug
107
-     * @param array $old_gateway_settings
108
-     * @param boolean $active indicates the gateway is currently active
109
-     * @return boolean success
110
-     */
111
-    protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active)
112
-    {
113
-        switch ($old_gateway_slug) {
114
-            case 'Aim':
115
-                $extra_meta_key_values = array(
116
-                    'login_id' => $old_gateway_settings['authnet_aim_login_id'],
117
-                    'transaction_key' => $old_gateway_settings['authnet_aim_transaction_key'],
118
-                    'test_transactions' => $old_gateway_settings['test_transactions']
119
-                );
120
-                $desc = esc_html__('Please provide the following billing information.', 'event_espresso');
121
-                break;
122
-            case 'Bank':
123
-                $extra_meta_key_values = array(
124
-                    'page_title' => $old_gateway_settings['page_title'],
125
-                    'payment_instructions' =>
126
-                    sprintf(esc_html__('%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']) );
127
-                $desc = esc_html__('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
128
-                break;
129
-            case 'Check':
130
-                $extra_meta_key_values = array(
131
-                    'check_title' => $old_gateway_settings['check_title'],
132
-                    'payment_instructions' => $old_gateway_settings['check_instructions'],
133
-                    'address_to_send_payment' => $old_gateway_settings['payment_address']
134
-                );
135
-                $desc = esc_html__('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso');
136
-                break;
137
-            case 'Invoice':
138
-                $extra_meta_key_values = array(
139
-                    'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'],
140
-                    'pdf_payee_email' => $old_gateway_settings['template_invoice_email'],
141
-                    'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'],
142
-                    'pdf_payee_address' => $old_gateway_settings['template_invoice_address'],
143
-                    'pdf_instructions' => $old_gateway_settings['template_payment_instructions'],
144
-                    'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'],
145
-                    'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '',
146
-                    'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '',
147
-                    'legacy_invoice_css' => $old_gateway_settings['invoice_css']
148
-                );
149
-                // if they didnt want the invoiec gateway to show, pretend it was inactive
150
-                if (! $old_gateway_settings['show']) {
151
-                    $active = false;
152
-                }
153
-                $desc = esc_html__('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso');
154
-                break;
155
-            case 'Mijireh':
156
-                $extra_meta_key_values = array(
157
-                    'access_key' => $old_gateway_settings['access_key']
158
-                );
159
-                $desc =  esc_html__('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso');
160
-                break;
161
-            case 'Paypal_Pro':
162
-                $extra_meta_key_values = array(
163
-                    'username' => $old_gateway_settings['username'],
164
-                    'password' => $old_gateway_settings['password'],
165
-                    'signature' => $old_gateway_settings['signature'],
166
-                    'credit_card_types' => $old_gateway_settings['credit_cards'],
167
-                );
168
-                $desc = esc_html__('Please provide the following billing information.', 'event_espresso');
169
-                break;
170
-            case 'Paypal_Standard':
171
-                $extra_meta_key_values = array(
172
-                    'paypal_id' => $old_gateway_settings['paypal_id'],
173
-                    'image_url' => $old_gateway_settings['image_url'],
174
-                    'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false,
104
+	/**
105
+	 * Converts the 4.1-style gateway to a 4.6-style payment method and saves it to the DB
106
+	 * @param string $old_gateway_slug
107
+	 * @param array $old_gateway_settings
108
+	 * @param boolean $active indicates the gateway is currently active
109
+	 * @return boolean success
110
+	 */
111
+	protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active)
112
+	{
113
+		switch ($old_gateway_slug) {
114
+			case 'Aim':
115
+				$extra_meta_key_values = array(
116
+					'login_id' => $old_gateway_settings['authnet_aim_login_id'],
117
+					'transaction_key' => $old_gateway_settings['authnet_aim_transaction_key'],
118
+					'test_transactions' => $old_gateway_settings['test_transactions']
119
+				);
120
+				$desc = esc_html__('Please provide the following billing information.', 'event_espresso');
121
+				break;
122
+			case 'Bank':
123
+				$extra_meta_key_values = array(
124
+					'page_title' => $old_gateway_settings['page_title'],
125
+					'payment_instructions' =>
126
+					sprintf(esc_html__('%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']) );
127
+				$desc = esc_html__('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
128
+				break;
129
+			case 'Check':
130
+				$extra_meta_key_values = array(
131
+					'check_title' => $old_gateway_settings['check_title'],
132
+					'payment_instructions' => $old_gateway_settings['check_instructions'],
133
+					'address_to_send_payment' => $old_gateway_settings['payment_address']
134
+				);
135
+				$desc = esc_html__('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso');
136
+				break;
137
+			case 'Invoice':
138
+				$extra_meta_key_values = array(
139
+					'pdf_payee_name' => $old_gateway_settings['template_invoice_payee_name'],
140
+					'pdf_payee_email' => $old_gateway_settings['template_invoice_email'],
141
+					'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'],
142
+					'pdf_payee_address' => $old_gateway_settings['template_invoice_address'],
143
+					'pdf_instructions' => $old_gateway_settings['template_payment_instructions'],
144
+					'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'],
145
+					'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '',
146
+					'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '',
147
+					'legacy_invoice_css' => $old_gateway_settings['invoice_css']
148
+				);
149
+				// if they didnt want the invoiec gateway to show, pretend it was inactive
150
+				if (! $old_gateway_settings['show']) {
151
+					$active = false;
152
+				}
153
+				$desc = esc_html__('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso');
154
+				break;
155
+			case 'Mijireh':
156
+				$extra_meta_key_values = array(
157
+					'access_key' => $old_gateway_settings['access_key']
158
+				);
159
+				$desc =  esc_html__('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso');
160
+				break;
161
+			case 'Paypal_Pro':
162
+				$extra_meta_key_values = array(
163
+					'username' => $old_gateway_settings['username'],
164
+					'password' => $old_gateway_settings['password'],
165
+					'signature' => $old_gateway_settings['signature'],
166
+					'credit_card_types' => $old_gateway_settings['credit_cards'],
167
+				);
168
+				$desc = esc_html__('Please provide the following billing information.', 'event_espresso');
169
+				break;
170
+			case 'Paypal_Standard':
171
+				$extra_meta_key_values = array(
172
+					'paypal_id' => $old_gateway_settings['paypal_id'],
173
+					'image_url' => $old_gateway_settings['image_url'],
174
+					'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false,
175 175
 
176
-                );
177
-                $desc = sprintf(esc_html__('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>');
178
-                break;
179
-            default:
180
-                // if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere
181
-                $extra_meta_key_values = $old_gateway_settings;
182
-                $desc = '';
183
-        }
184
-        $pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug;
185
-        $offline_gateways = array( 'Bank', 'Check', 'Invoice' );
186
-        if ($active && in_array($old_gateway_slug, $offline_gateways)) {
187
-            $scope = array( 'CART', 'ADMIN');
188
-        } elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) {
189
-            $scope = array( 'CART' );
190
-        } elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) {
191
-            $scope = array( 'ADMIN' );
192
-        } else {
193
-            $scope = array();
194
-        }
195
-        $payment_method_col_values = array(
196
-            'PMD_type' => $old_gateway_slug,
197
-            'PMD_name' => $pretty_name,
198
-            'PMD_desc' => $desc,
199
-            'PMD_admin_name' => $pretty_name,
200
-            'PMD_slug' => sanitize_key($old_gateway_slug),
201
-            'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : false,
202
-            'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : null,
203
-            'PMD_scope' =>  serialize($scope)
204
-        );
205
-        $db_types = array(
206
-            '%s',// PMD_type
207
-            '%s',// PMD_name
208
-            '%s',// PMD_desc
209
-            '%s',// PMD_admin_name
210
-            '%s',// PMD_slug
211
-            '%d',// PMD_debug_mode
212
-            '%s',// PMD_button_url
213
-            '%s',// PMD_scope
214
-        );
215
-        global $wpdb;
216
-        // first: check if it already exists
217
-        $id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug']));
218
-        if ($id) {
219
-            // just update that payment method instead of creating a new one
220
-            $success = $wpdb->update(
221
-                $this->_new_table_name,
222
-                $payment_method_col_values,
223
-                array(
224
-                        'PMD_ID' => $id
225
-                    ),
226
-                $db_types,
227
-                array(
228
-                        '%d',// PMD_ID
229
-                    )
230
-            );
231
-            if (! $success) {
232
-                $this->add_error(sprintf(esc_html__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error));
233
-            }
234
-        } else {
235
-            $success = $wpdb->insert(
236
-                $this->_new_table_name,
237
-                $payment_method_col_values,
238
-                $db_types
239
-            );
240
-            if (! $success) {
241
-                $this->add_error($wpdb->last_error);
242
-                return false;
243
-            } else {
244
-                $id = $wpdb->insert_id;
245
-            }
246
-        }
176
+				);
177
+				$desc = sprintf(esc_html__('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>');
178
+				break;
179
+			default:
180
+				// if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere
181
+				$extra_meta_key_values = $old_gateway_settings;
182
+				$desc = '';
183
+		}
184
+		$pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug;
185
+		$offline_gateways = array( 'Bank', 'Check', 'Invoice' );
186
+		if ($active && in_array($old_gateway_slug, $offline_gateways)) {
187
+			$scope = array( 'CART', 'ADMIN');
188
+		} elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) {
189
+			$scope = array( 'CART' );
190
+		} elseif (! $active && in_array($old_gateway_slug, $offline_gateways)) {
191
+			$scope = array( 'ADMIN' );
192
+		} else {
193
+			$scope = array();
194
+		}
195
+		$payment_method_col_values = array(
196
+			'PMD_type' => $old_gateway_slug,
197
+			'PMD_name' => $pretty_name,
198
+			'PMD_desc' => $desc,
199
+			'PMD_admin_name' => $pretty_name,
200
+			'PMD_slug' => sanitize_key($old_gateway_slug),
201
+			'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : false,
202
+			'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : null,
203
+			'PMD_scope' =>  serialize($scope)
204
+		);
205
+		$db_types = array(
206
+			'%s',// PMD_type
207
+			'%s',// PMD_name
208
+			'%s',// PMD_desc
209
+			'%s',// PMD_admin_name
210
+			'%s',// PMD_slug
211
+			'%d',// PMD_debug_mode
212
+			'%s',// PMD_button_url
213
+			'%s',// PMD_scope
214
+		);
215
+		global $wpdb;
216
+		// first: check if it already exists
217
+		$id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug']));
218
+		if ($id) {
219
+			// just update that payment method instead of creating a new one
220
+			$success = $wpdb->update(
221
+				$this->_new_table_name,
222
+				$payment_method_col_values,
223
+				array(
224
+						'PMD_ID' => $id
225
+					),
226
+				$db_types,
227
+				array(
228
+						'%d',// PMD_ID
229
+					)
230
+			);
231
+			if (! $success) {
232
+				$this->add_error(sprintf(esc_html__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error));
233
+			}
234
+		} else {
235
+			$success = $wpdb->insert(
236
+				$this->_new_table_name,
237
+				$payment_method_col_values,
238
+				$db_types
239
+			);
240
+			if (! $success) {
241
+				$this->add_error($wpdb->last_error);
242
+				return false;
243
+			} else {
244
+				$id = $wpdb->insert_id;
245
+			}
246
+		}
247 247
 
248
-        if ($id) {
249
-            $this->_convert_extra_meta_values($id, $extra_meta_key_values);
250
-            $this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id);
251
-            return true;
252
-        }
253
-        return false;
254
-    }
248
+		if ($id) {
249
+			$this->_convert_extra_meta_values($id, $extra_meta_key_values);
250
+			$this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id);
251
+			return true;
252
+		}
253
+		return false;
254
+	}
255 255
 
256 256
 
257 257
 
258
-    /**
259
-     * Converts old gateway settings which don't map onto the Payment_Method model
260
-     * to extra meta fields
261
-     * @param int $id
262
-     * @param array $extra_meta_key_values
263
-     */
264
-    private function _convert_extra_meta_values($id, $extra_meta_key_values)
265
-    {
266
-        global $wpdb;
267
-        foreach ($extra_meta_key_values as $key => $value) {
268
-            $exm_args = array(
269
-                'OBJ_ID' => $id,
270
-                'EXM_type' => 'Payment_Method',
271
-                'EXM_key' => $key,
272
-                'EXM_value' => maybe_serialize($value)
273
-            );
274
-            $success = $wpdb->insert(
275
-                $this->_extra_meta_table_name,
276
-                $exm_args,
277
-                array(
278
-                        '%d',// OBJ_ID
279
-                        '%s',// EXM_type
280
-                        '%s',// EXM_key
281
-                        '%s',// EXM_value
282
-                    )
283
-            );
284
-            if (! $success) {
285
-                $this->add_error(sprintf(esc_html__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error));
286
-            }
287
-        }
288
-    }
258
+	/**
259
+	 * Converts old gateway settings which don't map onto the Payment_Method model
260
+	 * to extra meta fields
261
+	 * @param int $id
262
+	 * @param array $extra_meta_key_values
263
+	 */
264
+	private function _convert_extra_meta_values($id, $extra_meta_key_values)
265
+	{
266
+		global $wpdb;
267
+		foreach ($extra_meta_key_values as $key => $value) {
268
+			$exm_args = array(
269
+				'OBJ_ID' => $id,
270
+				'EXM_type' => 'Payment_Method',
271
+				'EXM_key' => $key,
272
+				'EXM_value' => maybe_serialize($value)
273
+			);
274
+			$success = $wpdb->insert(
275
+				$this->_extra_meta_table_name,
276
+				$exm_args,
277
+				array(
278
+						'%d',// OBJ_ID
279
+						'%s',// EXM_type
280
+						'%s',// EXM_key
281
+						'%s',// EXM_value
282
+					)
283
+			);
284
+			if (! $success) {
285
+				$this->add_error(sprintf(esc_html__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error));
286
+			}
287
+		}
288
+	}
289 289
 }
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_payment_method_currencies.dmsstage.php 2 patches
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -12,176 +12,176 @@
 block discarded – undo
12 12
  */
13 13
 class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage
14 14
 {
15
-    protected $_currency_table_name;
16
-    protected $_currency_payment_method_table_name;
17
-    protected $_payment_method_table_name;
18
-    /**
19
-     * each key is the name of a 4.1-style gateway we know how to migrate to 4.6
20
-     * @var array
21
-     */
22
-    protected $_gateway_currencies = array(
23
-        'Aim' => array(
24
-            'AUD',
25
-            'USD',
26
-            'CAD',
27
-            'EUR',
28
-            'GBP',
29
-            'NZD',
30
-        ),
31
-        'Bank' => 'all',
32
-        'Check' => 'all',
33
-        'Invoice' => 'all',
34
-        'Mijireh' => 'all',
35
-        'Paypal_Pro' => array(
36
-            'USD',
37
-            'GBP',
38
-            'CAD',
39
-            'AUD',
40
-            'BRL',
41
-            'CHF',
42
-            'CZK',
43
-            'DKK',
44
-            'EUR',
45
-            'HKD',
46
-            'HUF',
47
-            'ILS',
48
-            'JPY',
49
-            'MXN',
50
-            'MYR',
51
-            'NOK',
52
-            'NZD',
53
-            'PHP',
54
-            'PLN',
55
-            'SEK',
56
-            'SGD',
57
-            'THB',
58
-            'TRY',
59
-            'TWD',
60
-        ),
61
-        'Paypal_Standard' => array(
62
-            'USD',
63
-            'GBP',
64
-            'CAD',
65
-            'AUD',
66
-            'BRL',
67
-            'CHF',
68
-            'CZK',
69
-            'DKK',
70
-            'EUR',
71
-            'HKD',
72
-            'HUF',
73
-            'ILS',
74
-            'JPY',
75
-            'MXN',
76
-            'MYR',
77
-            'NOK',
78
-            'NZD',
79
-            'PHP',
80
-            'PLN',
81
-            'SEK',
82
-            'SGD',
83
-            'THB',
84
-            'TRY',
85
-            'TWD'
86
-        )
87
-    );
88
-    public function __construct()
89
-    {
90
-        global $wpdb;
91
-        $this->_pretty_name = esc_html__('Payment Method Currencies', 'event_espresso');
92
-        $this->_payment_method_table_name = $wpdb->prefix . 'esp_payment_method';
93
-        $this->_currency_payment_method_table_name = $wpdb->prefix . 'esp_currency_payment_method';
94
-        $this->_currency_table_name = $wpdb->prefix . 'esp_currency';
95
-        parent::__construct();
96
-    }
15
+	protected $_currency_table_name;
16
+	protected $_currency_payment_method_table_name;
17
+	protected $_payment_method_table_name;
18
+	/**
19
+	 * each key is the name of a 4.1-style gateway we know how to migrate to 4.6
20
+	 * @var array
21
+	 */
22
+	protected $_gateway_currencies = array(
23
+		'Aim' => array(
24
+			'AUD',
25
+			'USD',
26
+			'CAD',
27
+			'EUR',
28
+			'GBP',
29
+			'NZD',
30
+		),
31
+		'Bank' => 'all',
32
+		'Check' => 'all',
33
+		'Invoice' => 'all',
34
+		'Mijireh' => 'all',
35
+		'Paypal_Pro' => array(
36
+			'USD',
37
+			'GBP',
38
+			'CAD',
39
+			'AUD',
40
+			'BRL',
41
+			'CHF',
42
+			'CZK',
43
+			'DKK',
44
+			'EUR',
45
+			'HKD',
46
+			'HUF',
47
+			'ILS',
48
+			'JPY',
49
+			'MXN',
50
+			'MYR',
51
+			'NOK',
52
+			'NZD',
53
+			'PHP',
54
+			'PLN',
55
+			'SEK',
56
+			'SGD',
57
+			'THB',
58
+			'TRY',
59
+			'TWD',
60
+		),
61
+		'Paypal_Standard' => array(
62
+			'USD',
63
+			'GBP',
64
+			'CAD',
65
+			'AUD',
66
+			'BRL',
67
+			'CHF',
68
+			'CZK',
69
+			'DKK',
70
+			'EUR',
71
+			'HKD',
72
+			'HUF',
73
+			'ILS',
74
+			'JPY',
75
+			'MXN',
76
+			'MYR',
77
+			'NOK',
78
+			'NZD',
79
+			'PHP',
80
+			'PLN',
81
+			'SEK',
82
+			'SGD',
83
+			'THB',
84
+			'TRY',
85
+			'TWD'
86
+		)
87
+	);
88
+	public function __construct()
89
+	{
90
+		global $wpdb;
91
+		$this->_pretty_name = esc_html__('Payment Method Currencies', 'event_espresso');
92
+		$this->_payment_method_table_name = $wpdb->prefix . 'esp_payment_method';
93
+		$this->_currency_payment_method_table_name = $wpdb->prefix . 'esp_currency_payment_method';
94
+		$this->_currency_table_name = $wpdb->prefix . 'esp_currency';
95
+		parent::__construct();
96
+	}
97 97
 
98
-    protected function _count_records_to_migrate()
99
-    {
100
-        $count = 0;
101
-        foreach ($this->_gateway_currencies as $currencies) {
102
-            if ($currencies == 'all') {
103
-                $currencies = $this->_get_all_currencies();
104
-            }
105
-            $count += count($currencies);
106
-        }
107
-        return $count;
108
-    }
98
+	protected function _count_records_to_migrate()
99
+	{
100
+		$count = 0;
101
+		foreach ($this->_gateway_currencies as $currencies) {
102
+			if ($currencies == 'all') {
103
+				$currencies = $this->_get_all_currencies();
104
+			}
105
+			$count += count($currencies);
106
+		}
107
+		return $count;
108
+	}
109 109
 
110 110
 
111 111
 
112
-    protected function _migration_step($num_items_to_migrate = 50)
113
-    {
114
-        $items_actually_migrated = 0;
115
-        $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate);
116
-        foreach ($relations_to_add_this_step as $pm_slug => $currencies) {
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
-                }
122
-                $items_actually_migrated++;
123
-            }
124
-        }
125
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
126
-            $this->set_completed();
127
-        }
128
-        return $items_actually_migrated;
129
-    }
112
+	protected function _migration_step($num_items_to_migrate = 50)
113
+	{
114
+		$items_actually_migrated = 0;
115
+		$relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate);
116
+		foreach ($relations_to_add_this_step as $pm_slug => $currencies) {
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
+				}
122
+				$items_actually_migrated++;
123
+			}
124
+		}
125
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
126
+			$this->set_completed();
127
+		}
128
+		return $items_actually_migrated;
129
+	}
130 130
 
131
-    private function _gather_relations_to_add($num_items_to_migrate)
132
-    {
133
-        $relations_to_add_this_step = array();
134
-        $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate;
135
-        $iterator = 0;
136
-        foreach ($this->_gateway_currencies as $pm_slug => $currencies) {
137
-            if ($currencies == 'all') {
138
-                $currencies = $this->_get_all_currencies();
139
-            }
140
-            foreach ($currencies as $currency_code) {
141
-                if (
142
-                    $this->count_records_migrated() <= $iterator &&
143
-                        $iterator < $migrate_up_to_count
144
-                ) {
145
-                    $relations_to_add_this_step[ $pm_slug ] [] = $currency_code;
146
-                }
147
-                $iterator++;
148
-            }
149
-        }
150
-        return $relations_to_add_this_step;
151
-    }
152
-    /**
153
-     * Gets all the currency codes in the database
154
-     * @return array
155
-     */
156
-    private function _get_all_currencies()
157
-    {
158
-        global $wpdb;
159
-        $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}");
160
-        return $currencies;
161
-    }
131
+	private function _gather_relations_to_add($num_items_to_migrate)
132
+	{
133
+		$relations_to_add_this_step = array();
134
+		$migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate;
135
+		$iterator = 0;
136
+		foreach ($this->_gateway_currencies as $pm_slug => $currencies) {
137
+			if ($currencies == 'all') {
138
+				$currencies = $this->_get_all_currencies();
139
+			}
140
+			foreach ($currencies as $currency_code) {
141
+				if (
142
+					$this->count_records_migrated() <= $iterator &&
143
+						$iterator < $migrate_up_to_count
144
+				) {
145
+					$relations_to_add_this_step[ $pm_slug ] [] = $currency_code;
146
+				}
147
+				$iterator++;
148
+			}
149
+		}
150
+		return $relations_to_add_this_step;
151
+	}
152
+	/**
153
+	 * Gets all the currency codes in the database
154
+	 * @return array
155
+	 */
156
+	private function _get_all_currencies()
157
+	{
158
+		global $wpdb;
159
+		$currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}");
160
+		return $currencies;
161
+	}
162 162
 
163
-    /**
164
-     * Adds teh relation between the payment method and the currencies it can be used for
165
-     * @param int $id
166
-     * @param string $gateway_slug
167
-     */
168
-    private function _add_currency_relations($pm_id, $currency_code)
169
-    {
170
-        global $wpdb;
171
-        $cur_pm_relation = array(
172
-                    'CUR_code' => $currency_code,
173
-                    'PMD_ID' => $pm_id,
174
-                );
175
-        $success = $wpdb->insert(
176
-            $this->_currency_payment_method_table_name,
177
-            $cur_pm_relation,
178
-            array(
179
-                    '%s',// CUR_code
180
-                    '%d',// PMD_ID
181
-                )
182
-        );
183
-        if (! $success) {
184
-            $this->add_error(sprintf(esc_html__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error));
185
-        }
186
-    }
163
+	/**
164
+	 * Adds teh relation between the payment method and the currencies it can be used for
165
+	 * @param int $id
166
+	 * @param string $gateway_slug
167
+	 */
168
+	private function _add_currency_relations($pm_id, $currency_code)
169
+	{
170
+		global $wpdb;
171
+		$cur_pm_relation = array(
172
+					'CUR_code' => $currency_code,
173
+					'PMD_ID' => $pm_id,
174
+				);
175
+		$success = $wpdb->insert(
176
+			$this->_currency_payment_method_table_name,
177
+			$cur_pm_relation,
178
+			array(
179
+					'%s',// CUR_code
180
+					'%d',// PMD_ID
181
+				)
182
+		);
183
+		if (! $success) {
184
+			$this->add_error(sprintf(esc_html__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error));
185
+		}
186
+	}
187 187
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
     {
90 90
         global $wpdb;
91 91
         $this->_pretty_name = esc_html__('Payment Method Currencies', 'event_espresso');
92
-        $this->_payment_method_table_name = $wpdb->prefix . 'esp_payment_method';
93
-        $this->_currency_payment_method_table_name = $wpdb->prefix . 'esp_currency_payment_method';
94
-        $this->_currency_table_name = $wpdb->prefix . 'esp_currency';
92
+        $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method';
93
+        $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method';
94
+        $this->_currency_table_name = $wpdb->prefix.'esp_currency';
95 95
         parent::__construct();
96 96
     }
97 97
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     $this->count_records_migrated() <= $iterator &&
143 143
                         $iterator < $migrate_up_to_count
144 144
                 ) {
145
-                    $relations_to_add_this_step[ $pm_slug ] [] = $currency_code;
145
+                    $relations_to_add_this_step[$pm_slug] [] = $currency_code;
146 146
                 }
147 147
                 $iterator++;
148 148
             }
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
             $this->_currency_payment_method_table_name,
177 177
             $cur_pm_relation,
178 178
             array(
179
-                    '%s',// CUR_code
180
-                    '%d',// PMD_ID
179
+                    '%s', // CUR_code
180
+                    '%d', // PMD_ID
181 181
                 )
182 182
         );
183
-        if (! $success) {
183
+        if ( ! $success) {
184 184
             $this->add_error(sprintf(esc_html__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error));
185 185
         }
186 186
     }
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_country_system_question.dmsstage.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
26
-        $this->_old_table = $wpdb->prefix . 'esp_question';
26
+        $this->_old_table = $wpdb->prefix.'esp_question';
27 27
         $this->_extra_where_sql = "WHERE QST_system = 'country'";
28 28
         parent::__construct();
29 29
     }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
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
                         esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    /**
15
-     * Just initializes the status of the migration
16
-     *
17
-     * @return EE_DMS_4_6_0_country_system_question
18
-     */
19
-    public function __construct()
20
-    {
21
-        global $wpdb;
22
-        $this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
23
-        $this->_old_table = $wpdb->prefix . 'esp_question';
24
-        $this->_extra_where_sql = "WHERE QST_system = 'country'";
25
-        parent::__construct();
26
-    }
14
+	/**
15
+	 * Just initializes the status of the migration
16
+	 *
17
+	 * @return EE_DMS_4_6_0_country_system_question
18
+	 */
19
+	public function __construct()
20
+	{
21
+		global $wpdb;
22
+		$this->_pretty_name = esc_html__('Country - System Question', 'event_espresso');
23
+		$this->_old_table = $wpdb->prefix . 'esp_question';
24
+		$this->_extra_where_sql = "WHERE QST_system = 'country'";
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * updates the question with the new question type
32
-     * @param array $question an associative array where keys are column names and values are their values.
33
-     * @return null
34
-     */
35
-    protected function _migrate_old_row($question)
36
-    {
37
-        if ($question['QST_ID'] && $question['QST_system'] == 'country') {
38
-            global $wpdb;
39
-            $success = $wpdb->update(
40
-                $this->_old_table,
41
-                array( 'QST_type' => 'COUNTRY' ),  // data
42
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
43
-                array( '%s' ),   // data format
44
-                array( '%d' )  // where format
45
-            );
46
-            if (! $success) {
47
-                $this->add_error(
48
-                    sprintf(
49
-                        esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
-                        wp_json_encode($question['QST_system']),
51
-                        $question['QST_ID'],
52
-                        $wpdb->last_error
53
-                    )
54
-                );
55
-            }
56
-        }
57
-    }
30
+	/**
31
+	 * updates the question with the new question type
32
+	 * @param array $question an associative array where keys are column names and values are their values.
33
+	 * @return null
34
+	 */
35
+	protected function _migrate_old_row($question)
36
+	{
37
+		if ($question['QST_ID'] && $question['QST_system'] == 'country') {
38
+			global $wpdb;
39
+			$success = $wpdb->update(
40
+				$this->_old_table,
41
+				array( 'QST_type' => 'COUNTRY' ),  // data
42
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
43
+				array( '%s' ),   // data format
44
+				array( '%d' )  // where format
45
+			);
46
+			if (! $success) {
47
+				$this->add_error(
48
+					sprintf(
49
+						esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
+						wp_json_encode($question['QST_system']),
51
+						$question['QST_ID'],
52
+						$wpdb->last_error
53
+					)
54
+				);
55
+			}
56
+		}
57
+	}
58 58
 }
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_question_groups.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 */
10 10
 class EE_DMS_4_5_0_update_wp_user_for_question_groups extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12
-    public function __construct()
13
-    {
14
-        global $wpdb;
15
-        $this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_question_group";
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('QSG_wp_user' => $user_id),
27
-            array('QSG_ID' => $old_row['QSG_ID']),
28
-            array('%d',// QSG_wp_user
29
-                    ),
30
-            array('%d',// QSG_ID
31
-                    )
32
-        );
33
-        if (false === $updated) {
34
-            $this->add_error(
35
-                sprintf(
36
-                    esc_html__(
37
-                        "Error in updating table %s setting QSG_wp_user = %d where QSG_ID = %d",
38
-                        'event_espresso'
39
-                    ),
40
-                    $this->_old_table,
41
-                    $user_id,
42
-                    $old_row['QSG_ID']
43
-                )
44
-            );
45
-        }
46
-    }
12
+	public function __construct()
13
+	{
14
+		global $wpdb;
15
+		$this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
+		$this->_old_table = $wpdb->prefix . "esp_question_group";
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('QSG_wp_user' => $user_id),
27
+			array('QSG_ID' => $old_row['QSG_ID']),
28
+			array('%d',// QSG_wp_user
29
+					),
30
+			array('%d',// QSG_ID
31
+					)
32
+		);
33
+		if (false === $updated) {
34
+			$this->add_error(
35
+				sprintf(
36
+					esc_html__(
37
+						"Error in updating table %s setting QSG_wp_user = %d where QSG_ID = %d",
38
+						'event_espresso'
39
+					),
40
+					$this->_old_table,
41
+					$user_id,
42
+					$old_row['QSG_ID']
43
+				)
44
+			);
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_question_group";
16
+        $this->_old_table = $wpdb->prefix."esp_question_group";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
             $this->_old_table,
26 26
             array('QSG_wp_user' => $user_id),
27 27
             array('QSG_ID' => $old_row['QSG_ID']),
28
-            array('%d',// QSG_wp_user
28
+            array('%d', // QSG_wp_user
29 29
                     ),
30
-            array('%d',// QSG_ID
30
+            array('%d', // QSG_ID
31 31
                     )
32 32
         );
33 33
         if (false === $updated) {
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_invoice_settings.dmsstage.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
     protected function _migration_step($num_items = 1)
55 55
     {
56 56
         // if this isn't set then something is really wrong
57
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
+        if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
58 58
             throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
59 59
         }
60 60
         $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
61
-        if (! $invoice_settings) {
61
+        if ( ! $invoice_settings) {
62 62
             $this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
63 63
         } else {
64 64
             $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                 );
94 94
             }
95 95
             $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
96
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
97
-            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
96
+            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true);
97
+            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true);
98 98
             if ($overridden_invoice_body || $overridden_receipt_body) {
99 99
                 new PersistentAdminNotice(
100 100
                     'invoice_overriding_templates',
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,97 +16,97 @@
 block discarded – undo
16 16
  */
17 17
 class EE_DMS_4_5_0_invoice_settings extends EE_Data_Migration_Script_Stage
18 18
 {
19
-    /**
20
-     * Just initializes the status of the migration
21
-     */
22
-    public function __construct()
23
-    {
24
-        $this->_pretty_name = esc_html__('Update Invoice Gateway Settings', 'event_espresso');
25
-        parent::__construct();
26
-    }
19
+	/**
20
+	 * Just initializes the status of the migration
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$this->_pretty_name = esc_html__('Update Invoice Gateway Settings', 'event_espresso');
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * _count_records_to_migrate
32
-     * Counts the records to migrate; the public version may cache it
33
-     *
34
-     * @access protected
35
-     * @return int
36
-     */
37
-    protected function _count_records_to_migrate()
38
-    {
39
-        return 1;
40
-    }
30
+	/**
31
+	 * _count_records_to_migrate
32
+	 * Counts the records to migrate; the public version may cache it
33
+	 *
34
+	 * @access protected
35
+	 * @return int
36
+	 */
37
+	protected function _count_records_to_migrate()
38
+	{
39
+		return 1;
40
+	}
41 41
 
42 42
 
43 43
 
44
-    /**
45
-     *    _migration_step
46
-     *
47
-     * @access protected
48
-     * @param int $num_items
49
-     * @throws EE_Error
50
-     * @return int number of items ACTUALLY migrated
51
-     * @throws InvalidDataTypeException
52
-     */
53
-    protected function _migration_step($num_items = 1)
54
-    {
55
-        // if this isn't set then something is really wrong
56
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
-            throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
58
-        }
59
-        $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
60
-        if (! $invoice_settings) {
61
-            $this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
62
-        } else {
63
-            $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
64
-            $invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
65
-            $invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
66
-            $invoice_settings['template_invoice_email'] = '';
67
-            $invoice_settings['template_invoice_tax_number'] = '';
68
-            unset($invoice_settings['pdf_instructions']);
69
-            unset($invoice_settings['payable_to']);
70
-            unset($invoice_settings['payment_address']);
71
-            EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
72
-            EE_Config::instance()->update_espresso_config(false, false);
44
+	/**
45
+	 *    _migration_step
46
+	 *
47
+	 * @access protected
48
+	 * @param int $num_items
49
+	 * @throws EE_Error
50
+	 * @return int number of items ACTUALLY migrated
51
+	 * @throws InvalidDataTypeException
52
+	 */
53
+	protected function _migration_step($num_items = 1)
54
+	{
55
+		// if this isn't set then something is really wrong
56
+		if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
+			throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
58
+		}
59
+		$invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
60
+		if (! $invoice_settings) {
61
+			$this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
62
+		} else {
63
+			$invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
64
+			$invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
65
+			$invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
66
+			$invoice_settings['template_invoice_email'] = '';
67
+			$invoice_settings['template_invoice_tax_number'] = '';
68
+			unset($invoice_settings['pdf_instructions']);
69
+			unset($invoice_settings['payable_to']);
70
+			unset($invoice_settings['payment_address']);
71
+			EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
72
+			EE_Config::instance()->update_espresso_config(false, false);
73 73
 
74
-            // @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
75
-            // (why is it tough to change? because we want to update the receipt and invoice message template, but
76
-            // message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
77
-            // update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
78
-            // also we don't want to build a dependency on the messages code because it is likely to change soon
79
-            if (
80
-                isset($invoice_settings['invoice_css'])
81
-                && ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])
82
-            ) {
83
-                new PersistentAdminNotice(
84
-                    'invoice_css_not_updated',
85
-                    sprintf(
86
-                        esc_html__(
87
-                            'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
88
-                            'event_espresso'
89
-                        ),
90
-                        $invoice_settings['invoice_css']
91
-                    )
92
-                );
93
-            }
94
-            $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
95
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
96
-            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
97
-            if ($overridden_invoice_body || $overridden_receipt_body) {
98
-                new PersistentAdminNotice(
99
-                    'invoice_overriding_templates',
100
-                    esc_html__(
101
-                        '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. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
102
-                        'event_espresso'
103
-                    ),
104
-                    true
105
-                );
106
-            }
107
-        }
108
-        // regardless of whether it worked or not, we ought to continue the migration
109
-        $this->set_completed();
110
-        return 1;
111
-    }
74
+			// @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
75
+			// (why is it tough to change? because we want to update the receipt and invoice message template, but
76
+			// message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
77
+			// update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
78
+			// also we don't want to build a dependency on the messages code because it is likely to change soon
79
+			if (
80
+				isset($invoice_settings['invoice_css'])
81
+				&& ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])
82
+			) {
83
+				new PersistentAdminNotice(
84
+					'invoice_css_not_updated',
85
+					sprintf(
86
+						esc_html__(
87
+							'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
88
+							'event_espresso'
89
+						),
90
+						$invoice_settings['invoice_css']
91
+					)
92
+				);
93
+			}
94
+			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
95
+			$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
96
+			$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
97
+			if ($overridden_invoice_body || $overridden_receipt_body) {
98
+				new PersistentAdminNotice(
99
+					'invoice_overriding_templates',
100
+					esc_html__(
101
+						'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. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
102
+						'event_espresso'
103
+					),
104
+					true
105
+				);
106
+			}
107
+		}
108
+		// regardless of whether it worked or not, we ought to continue the migration
109
+		$this->set_completed();
110
+		return 1;
111
+	}
112 112
 }
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_tickets.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
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 = esc_html__("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
-                    esc_html__(
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 = esc_html__("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
+					esc_html__(
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Tickets", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_ticket";
16
+        $this->_old_table = $wpdb->prefix."esp_ticket";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
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) {
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_price_types.dmsstage.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@
 block discarded – undo
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 = esc_html__("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
-                    esc_html__("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 = esc_html__("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
+					esc_html__("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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Price Types", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_price_type";
16
+        $this->_old_table = $wpdb->prefix."esp_price_type";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
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) {
Please login to merge, or discard this patch.