Completed
Branch models-cleanup/model-relations (db5ca7)
by
unknown
13:03 queued 08:35
created
caffeinated/modules/recaptcha_invisible/InvisibleRecaptcha.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
         static $previous_recaptcha_response = array();
136 136
         $grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
137 137
         // if this token has already been verified, then return previous response
138
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
139
-            return $previous_recaptcha_response[ $grecaptcha_response ];
138
+        if (isset($previous_recaptcha_response[$grecaptcha_response])) {
139
+            return $previous_recaptcha_response[$grecaptcha_response];
140 140
         }
141 141
         // still here but no g-recaptcha-response ? - verification failed
142
-        if (! $grecaptcha_response) {
142
+        if ( ! $grecaptcha_response) {
143 143
             EE_Error::add_error(
144 144
                 sprintf(
145 145
                     /* translators: 1: missing parameter */
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             return false;
159 159
         }
160 160
         // will update to true if everything passes
161
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
161
+        $previous_recaptcha_response[$grecaptcha_response] = false;
162 162
         $response                                            = wp_safe_remote_post(
163 163
             InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
164 164
             array(
@@ -175,16 +175,16 @@  discard block
 block discarded – undo
175 175
         }
176 176
         $results = json_decode(wp_remote_retrieve_body($response), true);
177 177
         if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
178
-            $errors   = array_map(
178
+            $errors = array_map(
179 179
                 array($this, 'getErrorCode'),
180 180
                 $results['error-codes']
181 181
             );
182 182
             if (isset($results['challenge_ts'])) {
183
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
183
+                $errors[] = 'challenge timestamp: '.$results['challenge_ts'].'.';
184 184
             }
185 185
             $this->generateError(implode(' ', $errors), true);
186 186
         }
187
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
187
+        $previous_recaptcha_response[$grecaptcha_response] = true;
188 188
         add_action('shutdown', array($this, 'setSessionData'));
189 189
         return true;
190 190
     }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
             'bad-request'            => 'The request is invalid or malformed.',
226 226
             'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
227 227
         );
228
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
228
+        return isset($error_codes[$error_code]) ? $error_codes[$error_code] : '';
229 229
     }
230 230
 
231 231
 
Please login to merge, or discard this patch.
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -27,270 +27,270 @@
 block discarded – undo
27 27
 class InvisibleRecaptcha
28 28
 {
29 29
 
30
-    const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
30
+	const URL_GOOGLE_RECAPTCHA_API          = 'https://www.google.com/recaptcha/api/siteverify';
31 31
 
32
-    const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
32
+	const SESSION_DATA_KEY_RECAPTCHA_PASSED = 'recaptcha_passed';
33 33
 
34
-    /**
35
-     * @var EE_Registration_Config $config
36
-     */
37
-    private $config;
34
+	/**
35
+	 * @var EE_Registration_Config $config
36
+	 */
37
+	private $config;
38 38
 
39
-    /**
40
-     * @var EE_Session $session
41
-     */
42
-    private $session;
39
+	/**
40
+	 * @var EE_Session $session
41
+	 */
42
+	private $session;
43 43
 
44
-    /**
45
-     * @var boolean $recaptcha_passed
46
-     */
47
-    private $recaptcha_passed;
44
+	/**
45
+	 * @var boolean $recaptcha_passed
46
+	 */
47
+	private $recaptcha_passed;
48 48
 
49 49
 
50
-    /**
51
-     * InvisibleRecaptcha constructor.
52
-     *
53
-     * @param EE_Registration_Config $registration_config
54
-     * @param EE_Session             $session
55
-     */
56
-    public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null)
57
-    {
58
-        $this->config = $registration_config;
59
-        $this->session = $session;
60
-    }
50
+	/**
51
+	 * InvisibleRecaptcha constructor.
52
+	 *
53
+	 * @param EE_Registration_Config $registration_config
54
+	 * @param EE_Session             $session
55
+	 */
56
+	public function __construct(EE_Registration_Config $registration_config, EE_Session $session = null)
57
+	{
58
+		$this->config = $registration_config;
59
+		$this->session = $session;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return boolean
65
-     */
66
-    public function useInvisibleRecaptcha()
67
-    {
68
-        return $this->session instanceof EE_Session
69
-               && $this->config->use_captcha
70
-               && $this->config->recaptcha_theme === 'invisible';
71
-    }
63
+	/**
64
+	 * @return boolean
65
+	 */
66
+	public function useInvisibleRecaptcha()
67
+	{
68
+		return $this->session instanceof EE_Session
69
+			   && $this->config->use_captcha
70
+			   && $this->config->recaptcha_theme === 'invisible';
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @param array $input_settings
76
-     * @return EE_Invisible_Recaptcha_Input
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidInterfaceException
79
-     * @throws InvalidArgumentException
80
-     * @throws DomainException
81
-     */
82
-    public function getInput(array $input_settings = array())
83
-    {
84
-        return new EE_Invisible_Recaptcha_Input(
85
-            $input_settings,
86
-            $this->config
87
-        );
88
-    }
74
+	/**
75
+	 * @param array $input_settings
76
+	 * @return EE_Invisible_Recaptcha_Input
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidInterfaceException
79
+	 * @throws InvalidArgumentException
80
+	 * @throws DomainException
81
+	 */
82
+	public function getInput(array $input_settings = array())
83
+	{
84
+		return new EE_Invisible_Recaptcha_Input(
85
+			$input_settings,
86
+			$this->config
87
+		);
88
+	}
89 89
 
90 90
 
91
-    /**
92
-     * @param array $input_settings
93
-     * @return string
94
-     * @throws EE_Error
95
-     * @throws InvalidDataTypeException
96
-     * @throws InvalidInterfaceException
97
-     * @throws InvalidArgumentException
98
-     * @throws DomainException
99
-     */
100
-    public function getInputHtml(array $input_settings = array())
101
-    {
102
-        return $this->getInput($input_settings)->get_html_for_input();
103
-    }
91
+	/**
92
+	 * @param array $input_settings
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 * @throws InvalidDataTypeException
96
+	 * @throws InvalidInterfaceException
97
+	 * @throws InvalidArgumentException
98
+	 * @throws DomainException
99
+	 */
100
+	public function getInputHtml(array $input_settings = array())
101
+	{
102
+		return $this->getInput($input_settings)->get_html_for_input();
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * @param EE_Form_Section_Proper $form
108
-     * @param array                  $input_settings
109
-     * @throws EE_Error
110
-     * @throws InvalidArgumentException
111
-     * @throws InvalidDataTypeException
112
-     * @throws InvalidInterfaceException
113
-     * @throws DomainException
114
-     */
115
-    public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
116
-    {
117
-        $form->add_subsections(
118
-            array(
119
-                'espresso_recaptcha' => $this->getInput($input_settings),
120
-            ),
121
-            null,
122
-            false
123
-        );
124
-    }
106
+	/**
107
+	 * @param EE_Form_Section_Proper $form
108
+	 * @param array                  $input_settings
109
+	 * @throws EE_Error
110
+	 * @throws InvalidArgumentException
111
+	 * @throws InvalidDataTypeException
112
+	 * @throws InvalidInterfaceException
113
+	 * @throws DomainException
114
+	 */
115
+	public function addToFormSection(EE_Form_Section_Proper $form, array $input_settings = array())
116
+	{
117
+		$form->add_subsections(
118
+			array(
119
+				'espresso_recaptcha' => $this->getInput($input_settings),
120
+			),
121
+			null,
122
+			false
123
+		);
124
+	}
125 125
 
126 126
 
127
-    /**
128
-     * @param RequestInterface $request
129
-     * @return boolean
130
-     * @throws InvalidArgumentException
131
-     * @throws InvalidDataTypeException
132
-     * @throws InvalidInterfaceException
133
-     * @throws RuntimeException
134
-     */
135
-    public function verifyToken(RequestInterface $request)
136
-    {
137
-        static $previous_recaptcha_response = array();
138
-        $grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
139
-        // if this token has already been verified, then return previous response
140
-        if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
141
-            return $previous_recaptcha_response[ $grecaptcha_response ];
142
-        }
143
-        // still here but no g-recaptcha-response ? - verification failed
144
-        if (! $grecaptcha_response) {
145
-            EE_Error::add_error(
146
-                sprintf(
147
-                    /* translators: 1: missing parameter */
148
-                    esc_html__(
149
-                        // @codingStandardsIgnoreStart
150
-                        'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.',
151
-                        // @codingStandardsIgnoreEnd
152
-                        'event_espresso'
153
-                    ),
154
-                    'g-recaptcha-response'
155
-                ),
156
-                __FILE__,
157
-                __FUNCTION__,
158
-                __LINE__
159
-            );
160
-            return false;
161
-        }
162
-        // will update to true if everything passes
163
-        $previous_recaptcha_response[ $grecaptcha_response ] = false;
164
-        $response                                            = wp_safe_remote_post(
165
-            InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
166
-            array(
167
-                'body' => array(
168
-                    'secret'   => $this->config->recaptcha_privatekey,
169
-                    'response' => $grecaptcha_response,
170
-                    'remoteip' => $request->ipAddress(),
171
-                ),
172
-            )
173
-        );
174
-        if ($response instanceof WP_Error) {
175
-            $this->generateError($response->get_error_messages());
176
-            return false;
177
-        }
178
-        $results = json_decode(wp_remote_retrieve_body($response), true);
179
-        if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
180
-            $errors   = array_map(
181
-                array($this, 'getErrorCode'),
182
-                $results['error-codes']
183
-            );
184
-            if (isset($results['challenge_ts'])) {
185
-                $errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
186
-            }
187
-            $this->generateError(implode(' ', $errors), true);
188
-        }
189
-        $previous_recaptcha_response[ $grecaptcha_response ] = true;
190
-        add_action('shutdown', array($this, 'setSessionData'));
191
-        return true;
192
-    }
127
+	/**
128
+	 * @param RequestInterface $request
129
+	 * @return boolean
130
+	 * @throws InvalidArgumentException
131
+	 * @throws InvalidDataTypeException
132
+	 * @throws InvalidInterfaceException
133
+	 * @throws RuntimeException
134
+	 */
135
+	public function verifyToken(RequestInterface $request)
136
+	{
137
+		static $previous_recaptcha_response = array();
138
+		$grecaptcha_response = $request->getRequestParam('g-recaptcha-response');
139
+		// if this token has already been verified, then return previous response
140
+		if (isset($previous_recaptcha_response[ $grecaptcha_response ])) {
141
+			return $previous_recaptcha_response[ $grecaptcha_response ];
142
+		}
143
+		// still here but no g-recaptcha-response ? - verification failed
144
+		if (! $grecaptcha_response) {
145
+			EE_Error::add_error(
146
+				sprintf(
147
+					/* translators: 1: missing parameter */
148
+					esc_html__(
149
+						// @codingStandardsIgnoreStart
150
+						'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Missing "%1$s". Please try again.',
151
+						// @codingStandardsIgnoreEnd
152
+						'event_espresso'
153
+					),
154
+					'g-recaptcha-response'
155
+				),
156
+				__FILE__,
157
+				__FUNCTION__,
158
+				__LINE__
159
+			);
160
+			return false;
161
+		}
162
+		// will update to true if everything passes
163
+		$previous_recaptcha_response[ $grecaptcha_response ] = false;
164
+		$response                                            = wp_safe_remote_post(
165
+			InvisibleRecaptcha::URL_GOOGLE_RECAPTCHA_API,
166
+			array(
167
+				'body' => array(
168
+					'secret'   => $this->config->recaptcha_privatekey,
169
+					'response' => $grecaptcha_response,
170
+					'remoteip' => $request->ipAddress(),
171
+				),
172
+			)
173
+		);
174
+		if ($response instanceof WP_Error) {
175
+			$this->generateError($response->get_error_messages());
176
+			return false;
177
+		}
178
+		$results = json_decode(wp_remote_retrieve_body($response), true);
179
+		if (filter_var($results['success'], FILTER_VALIDATE_BOOLEAN) !== true) {
180
+			$errors   = array_map(
181
+				array($this, 'getErrorCode'),
182
+				$results['error-codes']
183
+			);
184
+			if (isset($results['challenge_ts'])) {
185
+				$errors[] = 'challenge timestamp: ' . $results['challenge_ts'] . '.';
186
+			}
187
+			$this->generateError(implode(' ', $errors), true);
188
+		}
189
+		$previous_recaptcha_response[ $grecaptcha_response ] = true;
190
+		add_action('shutdown', array($this, 'setSessionData'));
191
+		return true;
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * @param string $error_response
197
-     * @param bool   $show_errors
198
-     * @return void
199
-     * @throws RuntimeException
200
-     */
201
-    public function generateError($error_response = '', $show_errors = false)
202
-    {
203
-        throw new RuntimeException(
204
-            sprintf(
205
-                esc_html__(
206
-                    'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
207
-                    'event_espresso'
208
-                ),
209
-                '<br />',
210
-                $show_errors || current_user_can('manage_options') ? $error_response : ''
211
-            )
212
-        );
213
-    }
195
+	/**
196
+	 * @param string $error_response
197
+	 * @param bool   $show_errors
198
+	 * @return void
199
+	 * @throws RuntimeException
200
+	 */
201
+	public function generateError($error_response = '', $show_errors = false)
202
+	{
203
+		throw new RuntimeException(
204
+			sprintf(
205
+				esc_html__(
206
+					'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. %1$s %2$s Please try again.',
207
+					'event_espresso'
208
+				),
209
+				'<br />',
210
+				$show_errors || current_user_can('manage_options') ? $error_response : ''
211
+			)
212
+		);
213
+	}
214 214
 
215 215
 
216
-    /**
217
-     * @param string $error_code
218
-     * @return string
219
-     */
220
-    public function getErrorCode(&$error_code)
221
-    {
222
-        $error_codes = array(
223
-            'missing-input-secret'   => 'The secret parameter is missing.',
224
-            'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
225
-            'missing-input-response' => 'The response parameter is missing.',
226
-            'invalid-input-response' => 'The response parameter is invalid or malformed.',
227
-            'bad-request'            => 'The request is invalid or malformed.',
228
-            'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
229
-        );
230
-        return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
231
-    }
216
+	/**
217
+	 * @param string $error_code
218
+	 * @return string
219
+	 */
220
+	public function getErrorCode(&$error_code)
221
+	{
222
+		$error_codes = array(
223
+			'missing-input-secret'   => 'The secret parameter is missing.',
224
+			'invalid-input-secret'   => 'The secret parameter is invalid or malformed.',
225
+			'missing-input-response' => 'The response parameter is missing.',
226
+			'invalid-input-response' => 'The response parameter is invalid or malformed.',
227
+			'bad-request'            => 'The request is invalid or malformed.',
228
+			'timeout-or-duplicate'   => 'The request took too long to be sent or was a duplicate of a previous request.',
229
+		);
230
+		return isset($error_codes[ $error_code ]) ? $error_codes[ $error_code ] : '';
231
+	}
232 232
 
233 233
 
234
-    /**
235
-     * @return array
236
-     * @throws InvalidInterfaceException
237
-     * @throws InvalidDataTypeException
238
-     * @throws InvalidArgumentException
239
-     */
240
-    public function getLocalizedVars()
241
-    {
242
-        return (array) apply_filters(
243
-            'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
244
-            array(
245
-                'siteKey'          => $this->config->recaptcha_publickey,
246
-                'recaptcha_passed' => $this->recaptchaPassed(),
247
-                'wp_debug'         => WP_DEBUG,
248
-                'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
249
-                'failed_message'   => esc_html__(
250
-                    'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.',
251
-                    'event_espresso'
252
-                )
253
-            )
254
-        );
255
-    }
234
+	/**
235
+	 * @return array
236
+	 * @throws InvalidInterfaceException
237
+	 * @throws InvalidDataTypeException
238
+	 * @throws InvalidArgumentException
239
+	 */
240
+	public function getLocalizedVars()
241
+	{
242
+		return (array) apply_filters(
243
+			'FHEE__EventEspresso_caffeinated_modules_recaptcha_invisible_InvisibleRecaptcha__getLocalizedVars__localized_vars',
244
+			array(
245
+				'siteKey'          => $this->config->recaptcha_publickey,
246
+				'recaptcha_passed' => $this->recaptchaPassed(),
247
+				'wp_debug'         => WP_DEBUG,
248
+				'disable_submit'   => defined('EE_EVENT_QUEUE_BASE_URL'),
249
+				'failed_message'   => esc_html__(
250
+					'We\'re sorry but an attempt to verify the form\'s reCAPTCHA has failed. Please try again.',
251
+					'event_espresso'
252
+				)
253
+			)
254
+		);
255
+	}
256 256
 
257 257
 
258
-    /**
259
-     * @return boolean
260
-     * @throws InvalidInterfaceException
261
-     * @throws InvalidDataTypeException
262
-     * @throws InvalidArgumentException
263
-     */
264
-    public function recaptchaPassed()
265
-    {
266
-        if ($this->recaptcha_passed !== null) {
267
-            return $this->recaptcha_passed;
268
-        }
269
-        // logged in means you have already passed a turing test of sorts
270
-        if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
271
-            $this->recaptcha_passed = true;
272
-            return $this->recaptcha_passed;
273
-        }
274
-        // was test already passed?
275
-        $this->recaptcha_passed = filter_var(
276
-            $this->session->get_session_data(
277
-                InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
278
-            ),
279
-            FILTER_VALIDATE_BOOLEAN
280
-        );
281
-        return $this->recaptcha_passed;
282
-    }
258
+	/**
259
+	 * @return boolean
260
+	 * @throws InvalidInterfaceException
261
+	 * @throws InvalidDataTypeException
262
+	 * @throws InvalidArgumentException
263
+	 */
264
+	public function recaptchaPassed()
265
+	{
266
+		if ($this->recaptcha_passed !== null) {
267
+			return $this->recaptcha_passed;
268
+		}
269
+		// logged in means you have already passed a turing test of sorts
270
+		if ($this->useInvisibleRecaptcha() === false || is_user_logged_in()) {
271
+			$this->recaptcha_passed = true;
272
+			return $this->recaptcha_passed;
273
+		}
274
+		// was test already passed?
275
+		$this->recaptcha_passed = filter_var(
276
+			$this->session->get_session_data(
277
+				InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED
278
+			),
279
+			FILTER_VALIDATE_BOOLEAN
280
+		);
281
+		return $this->recaptcha_passed;
282
+	}
283 283
 
284 284
 
285
-    /**
286
-     * @throws InvalidArgumentException
287
-     * @throws InvalidDataTypeException
288
-     * @throws InvalidInterfaceException
289
-     */
290
-    public function setSessionData()
291
-    {
292
-        if ($this->session instanceof EE_Session) {
293
-            $this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]);
294
-        }
295
-    }
285
+	/**
286
+	 * @throws InvalidArgumentException
287
+	 * @throws InvalidDataTypeException
288
+	 * @throws InvalidInterfaceException
289
+	 */
290
+	public function setSessionData()
291
+	{
292
+		if ($this->session instanceof EE_Session) {
293
+			$this->session->set_session_data([InvisibleRecaptcha::SESSION_DATA_KEY_RECAPTCHA_PASSED => true]);
294
+		}
295
+	}
296 296
 }
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_attendees.dmsstage.php 2 patches
Indentation   +636 added lines, -636 removed lines patch added patch discarded remove patch
@@ -183,647 +183,647 @@
 block discarded – undo
183 183
  */
184 184
 class EE_DMS_4_1_0_attendees extends EE_Data_Migration_Script_Stage_Table
185 185
 {
186
-    private $_new_attendee_cpt_table;
187
-    private $_new_attendee_meta_table;
188
-    private $_new_reg_table;
189
-    private $_new_transaction_table;
190
-    private $_new_payment_table;
191
-    private $_new_line_table;
192
-    private $_old_mer_table;
193
-    private $_new_ticket_table;
194
-    private $_new_ticket_datetime_table;
195
-    private $_new_datetime_table;
196
-    private $_new_datetime_ticket_table;
197
-    private $_new_price_table;
198
-    private $_new_ticket_price_table;
199
-    /**
200
-     * Rememebrs whether or not the mer table exists
201
-     * @var boolean
202
-     */
203
-    private $_mer_tables_exist = null;
204
-
205
-    public function __construct()
206
-    {
207
-        global $wpdb;
208
-        $this->_pretty_name = __("Attendees", "event_espresso");
209
-        $this->_old_table = $wpdb->prefix . "events_attendee";
210
-        // Only select the event status column from the event table.
211
-        $this->select_expression = 'att.*, e.event_status';
212
-        // Only select attendees for events that aren't deleted.
213
-        $this->_extra_where_sql = 'AS att
186
+	private $_new_attendee_cpt_table;
187
+	private $_new_attendee_meta_table;
188
+	private $_new_reg_table;
189
+	private $_new_transaction_table;
190
+	private $_new_payment_table;
191
+	private $_new_line_table;
192
+	private $_old_mer_table;
193
+	private $_new_ticket_table;
194
+	private $_new_ticket_datetime_table;
195
+	private $_new_datetime_table;
196
+	private $_new_datetime_ticket_table;
197
+	private $_new_price_table;
198
+	private $_new_ticket_price_table;
199
+	/**
200
+	 * Rememebrs whether or not the mer table exists
201
+	 * @var boolean
202
+	 */
203
+	private $_mer_tables_exist = null;
204
+
205
+	public function __construct()
206
+	{
207
+		global $wpdb;
208
+		$this->_pretty_name = __("Attendees", "event_espresso");
209
+		$this->_old_table = $wpdb->prefix . "events_attendee";
210
+		// Only select the event status column from the event table.
211
+		$this->select_expression = 'att.*, e.event_status';
212
+		// Only select attendees for events that aren't deleted.
213
+		$this->_extra_where_sql = 'AS att
214 214
             INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id
215 215
             WHERE e.event_status!="D"';
216
-        $this->_old_mer_table = $wpdb->prefix . "events_multi_event_registration_id_group";
217
-        $this->_new_attendee_cpt_table = $wpdb->posts;
218
-        $this->_new_attendee_meta_table = $wpdb->prefix . "esp_attendee_meta";
219
-        $this->_new_reg_table = $wpdb->prefix . "esp_registration";
220
-        $this->_new_transaction_table = $wpdb->prefix . "esp_transaction";
221
-        $this->_new_payment_table = $wpdb->prefix . "esp_payment";
222
-        $this->_new_line_table = $wpdb->prefix . "esp_line_item";
223
-        $this->_new_ticket_table = $wpdb->prefix . "esp_ticket";
224
-        $this->_new_ticket_datetime_table = $wpdb->prefix . "esp_datetime_ticket";
225
-        $this->_new_datetime_table = $wpdb->prefix . "esp_datetime";
226
-        $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket";
227
-        $this->_new_price_table = $wpdb->prefix . "esp_price";
228
-        $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price";
229
-        parent::__construct();
230
-    }
231
-
232
-    protected function _migrate_old_row($old_row)
233
-    {
234
-        // first check if there's already a new attendee with similar characteristics
235
-        $new_att_id = $this->_find_attendee_cpt_matching($old_row);
236
-        if (!$new_att_id) {
237
-            $new_att_id = $this->_insert_new_attendee_cpt($old_row);
238
-            if (!$new_att_id) {
239
-                // if we couldnt even make an attendee, abandon all hope
240
-                return false;
241
-            }
242
-            $new_att_meta_id = $this->_insert_attendee_meta_row($old_row, $new_att_id);
243
-            if ($new_att_meta_id) {
244
-                $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_attendee_meta_table, $new_att_meta_id);
245
-            }
246
-        }
247
-        $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_attendee_cpt_table, $new_att_id);
248
-
249
-        $txn_id = $this->_insert_new_transaction($old_row);
250
-        if (!$txn_id) {
251
-            // if we couldnt make the transaction, also abandon all hope
252
-            return false;
253
-        }
254
-        $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_transaction_table, $txn_id);
255
-        $pay_id = $this->_insert_new_payment($old_row, $txn_id);
256
-        if ($pay_id) {
257
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_payment_table, $pay_id);
258
-        }
259
-
260
-
261
-        // even if there was no payment, we can go ahead with adding the reg
262
-        $new_regs = $this->_insert_new_registrations($old_row, $new_att_id, $txn_id);
263
-        if ($new_regs) {
264
-            $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_reg_table, $new_regs);
265
-        }
266
-    }
267
-
268
-    /**
269
-     * Checks if there's already an attendee CPT in the db that has the same
270
-     * first and last name, and email. If so, returns its ID as an int.
271
-     * @global type $wpdb
272
-     * @param array $old_attendee
273
-     * @return int
274
-     */
275
-    private function _find_attendee_cpt_matching($old_attendee)
276
-    {
277
-        global $wpdb;
278
-        $existing_attendee_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_new_attendee_cpt_table . " AS cpt INNER JOIN " . $this->_new_attendee_meta_table . " AS meta ON cpt.ID = meta.ATT_ID WHERE meta.ATT_fname = %s AND meta.ATT_lname = %s AND meta.ATT_email = %s LIMIT 1", $old_attendee['fname'], $old_attendee['lname'], $old_attendee['email']));
279
-        return intval($existing_attendee_id);
280
-    }
281
-
282
-    private function _insert_new_attendee_cpt($old_attendee)
283
-    {
284
-        global $wpdb;
285
-        $cols_n_values = array(
286
-            'post_title' => stripslashes($old_attendee['fname'] . " " . $old_attendee['lname']),// ATT_full_name
287
-            'post_content' => '',// ATT_bio
288
-            'post_name' => sanitize_title($old_attendee['fname'] . "-" . $old_attendee['lname']),// ATT_slug
289
-            'post_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_created
290
-            'post_excerpt' => '',// ATT_short_bio
291
-            'post_modified' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_modified
292
-            'post_author' => 0,// ATT_author
293
-            'post_parent' => 0,// ATT_parent
294
-            'post_type' => 'espresso_attendees',// post_type
295
-            'post_status' => 'publish'// status
296
-        );
297
-        $datatypes = array(
298
-            '%s',// ATT_full_name
299
-            '%s',// ATT_bio
300
-            '%s',// ATT_slug
301
-            '%s',// ATT_created
302
-            '%s',// ATT_short_bio
303
-            '%s',// ATT_modified
304
-            '%d',// ATT_author
305
-            '%d',// ATT_parent
306
-            '%s',// post_type
307
-            '%s',// status
308
-        );
309
-        $success = $wpdb->insert($this->_new_attendee_cpt_table, $cols_n_values, $datatypes);
310
-        if (!$success) {
311
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
312
-            return 0;
313
-        }
314
-        $new_id = $wpdb->insert_id;
315
-        return $new_id;
316
-    }
317
-
318
-    private function _insert_attendee_meta_row($old_attendee, $new_attendee_cpt_id)
319
-    {
320
-        global $wpdb;
321
-        // get the state and country ids from the old row
322
-        try {
323
-            $new_country = $this->get_migration_script()->get_or_create_country(stripslashes($old_attendee['country_id']));
324
-            $new_country_iso = $new_country['CNT_ISO'];
325
-        } catch (EE_Error $exception) {
326
-            $new_country_iso = $this->get_migration_script()->get_default_country_iso();
327
-        }
328
-        try {
329
-            $new_state = $this->get_migration_script()->get_or_create_state(stripslashes($old_attendee['state']), $new_country_iso);
330
-            $new_state_id = $new_state['STA_ID'];
331
-        } catch (EE_Error $exception) {
332
-            $new_state_id = 0;
333
-        }
334
-        $cols_n_values = array(
335
-            'ATT_ID' => $new_attendee_cpt_id,
336
-            'ATT_fname' => stripslashes($old_attendee['fname']),
337
-            'ATT_lname' => stripslashes($old_attendee['lname']),
338
-            'ATT_address' => stripslashes($old_attendee['address']),
339
-            'ATT_address2' => stripslashes($old_attendee['address2']),
340
-            'ATT_city' => stripslashes($old_attendee['city']),
341
-            'STA_ID' => $new_state_id,
342
-            'CNT_ISO' => $new_country_iso,
343
-            'ATT_zip' => stripslashes($old_attendee['zip']),
344
-            'ATT_email' => stripslashes($old_attendee['email']),
345
-            'ATT_phone' => stripslashes($old_attendee['phone']),
346
-        );
347
-        $datatypes = array(
348
-            '%d',// ATT_ID
349
-            '%s',// ATT_fname
350
-            '%s',// ATT_lname
351
-            '%s',// ATT_address
352
-            '%s',// ATT_address2
353
-            '%s',// ATT_city
354
-            '%d',// STA_ID
355
-            '%s',// CNT_ISO
356
-            '%s',// ATT_zip
357
-            '%s',// ATT_email
358
-            '%s',// ATT_phone
359
-        );
360
-        $success = $wpdb->insert($this->_new_attendee_meta_table, $cols_n_values, $datatypes);
361
-        if (!$success) {
362
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_meta_table, $cols_n_values, $datatypes));
363
-            return 0;
364
-        }
365
-        $new_id = $wpdb->insert_id;
366
-        return $new_id;
367
-    }
368
-
369
-    /**
370
-     * Note: we don't necessarily create a new transaction for each attendee row.
371
-     * Only if the old attendee 'is_primary' is true; otherwise we find the old attendee row that
372
-     * 'is_primary' and has the same 'txn_id', then we return ITS new transaction id
373
-     * @global type $wpdb
374
-     * @param type $old_attendee
375
-     * @return int new transaction id
376
-     */
377
-    private function _insert_new_transaction($old_attendee)
378
-    {
379
-        global $wpdb;
380
-
381
-        // first: let's check for an existing transaction for this old attendee
382
-        if (intval($old_attendee['is_primary'])) {// primary attendee, so create txn
383
-            $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($old_attendee['id']), $this->_new_transaction_table);
384
-        } else { // non-primary attendee, so find its primary attendee's transaction
385
-            $primary_attendee_old_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_old_table . " WHERE is_primary=1 and registration_id=%s", $old_attendee['registration_id']));
386
-            if (!$primary_attendee_old_id) {
387
-                $primary_attendee = $this->_find_mer_primary_attendee_using_mer_tables($old_attendee['registration_id']);
388
-                $primary_attendee_old_id = is_array($primary_attendee) ? $primary_attendee['id'] : null;
389
-            }
390
-            $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($primary_attendee_old_id), $this->_new_transaction_table);
391
-            if (!$txn_id) {
392
-                $this->add_error(sprintf(__("Could not find primary attendee's new transaction. Current attendee is: %s, we think the 3.1 primary attendee for it has id %d, but there's no 4.1 transaction for that primary attendee id.", "event_espresso"), $this->_json_encode($old_attendee), $primary_attendee_old_id));
393
-                $txn_id = 0;
394
-            }
395
-        }
396
-        // if there isn't yet a transaction row for this, create one
397
-        // (so even if it was a non-primary attendee with no EE3 primary attendee,
398
-        // it ought to have SOME transaction, so we'll make one)
399
-        if (!$txn_id) {
400
-            // maps 3.1 payment stati onto 4.1 transaction stati
401
-            $txn_status_mapping = array(
402
-                'Completed' => 'TCM',
403
-                'Pending' => 'TIN',
404
-                'Payment Declined' => 'TIN',
405
-                'Incomplete' => 'TIN',
406
-                'Not Completed' => 'TIN',
407
-                'Cancelled' => 'TIN',
408
-                'Declined' => 'TIN'
409
-            );
410
-            $STS_ID = isset($txn_status_mapping[ $old_attendee['payment_status'] ]) ? $txn_status_mapping[ $old_attendee['payment_status'] ] : 'TIN';
411
-            $cols_n_values = array(
412
-                'TXN_timestamp' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
413
-                'TXN_total' => floatval($old_attendee['total_cost']),
414
-                'TXN_paid' => floatval($old_attendee['amount_pd']),
415
-                'STS_ID' => $STS_ID,
416
-                'TXN_hash_salt' => $old_attendee['hashSalt']
417
-            );
418
-            $datatypes = array(
419
-                '%s',// TXN_timestamp
420
-                '%f',// TXN_total
421
-                '%f',// TXN_paid
422
-                '%s',// STS_ID
423
-                '%s',// TXN_hash_salt
424
-            );
425
-            $success = $wpdb->insert($this->_new_transaction_table, $cols_n_values, $datatypes);
426
-            if (!$success) {
427
-                $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_transaction_table, $cols_n_values, $datatypes));
428
-                return 0;
429
-            }
430
-            $txn_id = $wpdb->insert_id;
431
-        }
432
-
433
-        return $txn_id;
434
-    }
435
-
436
-    /**
437
-     * Detects if the MER tables exist
438
-     * @global type $wpdb
439
-     * @return boolean
440
-     */
441
-    private function _mer_tables_exist()
442
-    {
443
-        if ($this->_mer_tables_exist === null) {
444
-            global $wpdb;
445
-
446
-            if ($wpdb->get_var("SHOW TABLES LIKE '{$this->_old_mer_table}'") != $this->_old_mer_table) {
447
-                $this->_mer_tables_exist = false;
448
-            } else {
449
-                $this->_mer_tables_exist = true;
450
-            }
451
-        }
452
-        return $this->_mer_tables_exist;
453
-    }
454
-
455
-    /**
456
-     * Gets the 4.1 registration's status given the 3.1 attendee row. We consider
457
-     * whether the event required pre-approval or not,a dn the 4.1 payment status.
458
-     * @global type $wpdb
459
-     * @param type $old_attendee_row
460
-     * @return string
461
-     */
462
-    private function _get_reg_status_for_old_payment_status($old_attendee_row)
463
-    {
464
-        // need event default reg status and if pre_approval was required
465
-        global $wpdb;
466
-        $event_required_pre_approval = $wpdb->get_var($wpdb->prepare("SELECT require_pre_approval FROM " . $wpdb->prefix . "events_detail WHERE id = %d", $old_attendee_row['event_id']));
467
-        return $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(
468
-            $old_attendee_row['payment_status'],
469
-            intval($event_required_pre_approval) && intval($old_attendee_row['pre_approve'])
470
-        );
471
-    }
472
-
473
-    /**
474
-     * Adds however many rgistrations are indicated by the old attendee's QUANTITY field,
475
-     * and returns an array of their IDs
476
-     * @global type $wpdb
477
-     * @param array $old_attendee
478
-     * @param int $new_attendee_id
479
-     * @param int $new_txn_id
480
-     * @return array of new registratio ids
481
-     */
482
-    private function _insert_new_registrations($old_attendee, $new_attendee_id, $new_txn_id)
483
-    {
484
-        global $wpdb;
485
-
486
-        $STS_ID = $this->_get_reg_status_for_old_payment_status($old_attendee);
487
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . 'events_detail', $old_attendee['event_id'], $wpdb->posts);
488
-        if (!$new_event_id) {
489
-            $this->add_error(sprintf(__("Could not find NEW event CPT ID for old event '%d' on old attendee %s", "event_espresso"), $old_attendee['event_id'], $this->_json_encode($old_attendee)));
490
-        }
491
-
492
-        $ticket_id = $this->_try_to_find_new_ticket_id($old_attendee, $new_event_id);
493
-        if (!$ticket_id) {
494
-            $ticket_id = $this->_insert_new_ticket_because_none_found($old_attendee, $new_event_id);
495
-            $this->add_error(sprintf(__('Could not find a ticket for old attendee with id %d for new event %d, so created a new ticket with id %d', 'event_espresso'), $old_attendee['id'], $new_event_id, $ticket_id));
496
-        }
497
-        $regs_on_this_row = intval($old_attendee['quantity']);
498
-        $new_regs = array();
499
-        // 4 cases we need to account for:
500
-        // 1 old attendee_details row with a quantity of X (no mer)
501
-        // Y old attendee_details rows with a quantity of 1 (no mer) joined by their common registration_id
502
-        // Y old attendee_details rows with a quantity of x (because of mer)
503
-        // Y old attendee_details rows with a quantity of 1 (because of mer) joined by wp_events_multi_event_registration_id_group
504
-        for ($count = 1; $count <= $regs_on_this_row; $count++) {
505
-            // sum regs on older rows
506
-            $regs_on_this_event_and_txn = $this->_sum_old_attendees_on_old_txn($old_attendee, true);
507
-            $cols_n_values = array(
508
-                'EVT_ID' => $new_event_id,
509
-                'ATT_ID' => $new_attendee_id,
510
-                'TXN_ID' => $new_txn_id,
511
-                'TKT_ID' => $ticket_id,
512
-                'STS_ID' => $STS_ID,
513
-                'REG_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
514
-                'REG_final_price' => $old_attendee['final_price'],
515
-                'REG_session' => substr($old_attendee['attendee_session'], 0, 44),
516
-                'REG_code' => sanitize_key($old_attendee['registration_id']),
517
-                'REG_url_link' => sanitize_key($old_attendee['registration_id'] . '-' . $count),
518
-                'REG_count' => $regs_on_this_event_and_txn + $count,
519
-                'REG_group_size' => $this->_sum_old_attendees_on_old_txn($old_attendee, false),
520
-                'REG_att_is_going' => true,
521
-                'REG_deleted' => false
522
-            );
523
-            $datatypes = array(
524
-                '%d',// EVT_ID
525
-                '%d',// ATT_ID
526
-                '%d',// TXN_ID
527
-                '%d',// TKT_ID
528
-                '%s',// STS_ID
529
-                '%s',// REG_date
530
-                '%f',// REG_final_price
531
-                '%s',// REG_session
532
-                '%s',// REG_code
533
-                '%s',// REG_url_link
534
-                '%d',// REG_count
535
-                '%d',// REG_group_size
536
-                '%d',// REG_att_is_going
537
-                '%d',// REG_deleted
538
-            );
539
-            $success = $wpdb->insert($this->_new_reg_table, $cols_n_values, $datatypes);
540
-            if (!$success) {
541
-                $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes));
542
-                return 0;
543
-            }
544
-            $cols_n_values['REG_ID'] = $wpdb->insert_id;
545
-            $new_regs[] = $wpdb->insert_id;
546
-        }
547
-        $this->_add_regs_to_ticket_and_datetimes($ticket_id, count($new_regs), $STS_ID);
548
-        return $new_regs;
549
-    }
550
-
551
-    /**
552
-     * Increments the sold values on the ticket and its related datetimes by the amount sold,
553
-     * which should be done directly after adding the rows. Yes this means we're constantly incrementing
554
-     * the sold amounts as we go, and is less efficient than a single big query,
555
-     * but its safer because we KNOW these regs have been added, rather than inferring
556
-     * that they WILL be added (because the attendees stage runs nearly last during
557
-     * the migration script)
558
-     * @param type $new_ticket_id
559
-     * @param type $sold
560
-     * @param type $STS_ID
561
-     * @return boolean whether they were successfully updated or not
562
-     */
563
-    protected function _add_regs_to_ticket_and_datetimes($new_ticket_id, $quantity_sold, $STS_ID)
564
-    {
565
-        if ($STS_ID != 'RAP') {
566
-            return true;
567
-        }
568
-        global $wpdb;
569
-        $success = $wpdb->query($wpdb->prepare("UPDATE {$this->_new_ticket_table} SET TKT_sold=TKT_sold+%d WHERE TKT_ID=%d", $quantity_sold, $new_ticket_id));
570
-        if ($success) {
571
-            // get the ticket's datetimes, and increment them too
572
-            $success_update_dateimtes = $wpdb->query($wpdb->prepare("UPDATE {$this->_new_ticket_table} TKT
216
+		$this->_old_mer_table = $wpdb->prefix . "events_multi_event_registration_id_group";
217
+		$this->_new_attendee_cpt_table = $wpdb->posts;
218
+		$this->_new_attendee_meta_table = $wpdb->prefix . "esp_attendee_meta";
219
+		$this->_new_reg_table = $wpdb->prefix . "esp_registration";
220
+		$this->_new_transaction_table = $wpdb->prefix . "esp_transaction";
221
+		$this->_new_payment_table = $wpdb->prefix . "esp_payment";
222
+		$this->_new_line_table = $wpdb->prefix . "esp_line_item";
223
+		$this->_new_ticket_table = $wpdb->prefix . "esp_ticket";
224
+		$this->_new_ticket_datetime_table = $wpdb->prefix . "esp_datetime_ticket";
225
+		$this->_new_datetime_table = $wpdb->prefix . "esp_datetime";
226
+		$this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket";
227
+		$this->_new_price_table = $wpdb->prefix . "esp_price";
228
+		$this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price";
229
+		parent::__construct();
230
+	}
231
+
232
+	protected function _migrate_old_row($old_row)
233
+	{
234
+		// first check if there's already a new attendee with similar characteristics
235
+		$new_att_id = $this->_find_attendee_cpt_matching($old_row);
236
+		if (!$new_att_id) {
237
+			$new_att_id = $this->_insert_new_attendee_cpt($old_row);
238
+			if (!$new_att_id) {
239
+				// if we couldnt even make an attendee, abandon all hope
240
+				return false;
241
+			}
242
+			$new_att_meta_id = $this->_insert_attendee_meta_row($old_row, $new_att_id);
243
+			if ($new_att_meta_id) {
244
+				$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_attendee_meta_table, $new_att_meta_id);
245
+			}
246
+		}
247
+		$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_attendee_cpt_table, $new_att_id);
248
+
249
+		$txn_id = $this->_insert_new_transaction($old_row);
250
+		if (!$txn_id) {
251
+			// if we couldnt make the transaction, also abandon all hope
252
+			return false;
253
+		}
254
+		$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_transaction_table, $txn_id);
255
+		$pay_id = $this->_insert_new_payment($old_row, $txn_id);
256
+		if ($pay_id) {
257
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_payment_table, $pay_id);
258
+		}
259
+
260
+
261
+		// even if there was no payment, we can go ahead with adding the reg
262
+		$new_regs = $this->_insert_new_registrations($old_row, $new_att_id, $txn_id);
263
+		if ($new_regs) {
264
+			$this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_reg_table, $new_regs);
265
+		}
266
+	}
267
+
268
+	/**
269
+	 * Checks if there's already an attendee CPT in the db that has the same
270
+	 * first and last name, and email. If so, returns its ID as an int.
271
+	 * @global type $wpdb
272
+	 * @param array $old_attendee
273
+	 * @return int
274
+	 */
275
+	private function _find_attendee_cpt_matching($old_attendee)
276
+	{
277
+		global $wpdb;
278
+		$existing_attendee_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_new_attendee_cpt_table . " AS cpt INNER JOIN " . $this->_new_attendee_meta_table . " AS meta ON cpt.ID = meta.ATT_ID WHERE meta.ATT_fname = %s AND meta.ATT_lname = %s AND meta.ATT_email = %s LIMIT 1", $old_attendee['fname'], $old_attendee['lname'], $old_attendee['email']));
279
+		return intval($existing_attendee_id);
280
+	}
281
+
282
+	private function _insert_new_attendee_cpt($old_attendee)
283
+	{
284
+		global $wpdb;
285
+		$cols_n_values = array(
286
+			'post_title' => stripslashes($old_attendee['fname'] . " " . $old_attendee['lname']),// ATT_full_name
287
+			'post_content' => '',// ATT_bio
288
+			'post_name' => sanitize_title($old_attendee['fname'] . "-" . $old_attendee['lname']),// ATT_slug
289
+			'post_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_created
290
+			'post_excerpt' => '',// ATT_short_bio
291
+			'post_modified' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_modified
292
+			'post_author' => 0,// ATT_author
293
+			'post_parent' => 0,// ATT_parent
294
+			'post_type' => 'espresso_attendees',// post_type
295
+			'post_status' => 'publish'// status
296
+		);
297
+		$datatypes = array(
298
+			'%s',// ATT_full_name
299
+			'%s',// ATT_bio
300
+			'%s',// ATT_slug
301
+			'%s',// ATT_created
302
+			'%s',// ATT_short_bio
303
+			'%s',// ATT_modified
304
+			'%d',// ATT_author
305
+			'%d',// ATT_parent
306
+			'%s',// post_type
307
+			'%s',// status
308
+		);
309
+		$success = $wpdb->insert($this->_new_attendee_cpt_table, $cols_n_values, $datatypes);
310
+		if (!$success) {
311
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
312
+			return 0;
313
+		}
314
+		$new_id = $wpdb->insert_id;
315
+		return $new_id;
316
+	}
317
+
318
+	private function _insert_attendee_meta_row($old_attendee, $new_attendee_cpt_id)
319
+	{
320
+		global $wpdb;
321
+		// get the state and country ids from the old row
322
+		try {
323
+			$new_country = $this->get_migration_script()->get_or_create_country(stripslashes($old_attendee['country_id']));
324
+			$new_country_iso = $new_country['CNT_ISO'];
325
+		} catch (EE_Error $exception) {
326
+			$new_country_iso = $this->get_migration_script()->get_default_country_iso();
327
+		}
328
+		try {
329
+			$new_state = $this->get_migration_script()->get_or_create_state(stripslashes($old_attendee['state']), $new_country_iso);
330
+			$new_state_id = $new_state['STA_ID'];
331
+		} catch (EE_Error $exception) {
332
+			$new_state_id = 0;
333
+		}
334
+		$cols_n_values = array(
335
+			'ATT_ID' => $new_attendee_cpt_id,
336
+			'ATT_fname' => stripslashes($old_attendee['fname']),
337
+			'ATT_lname' => stripslashes($old_attendee['lname']),
338
+			'ATT_address' => stripslashes($old_attendee['address']),
339
+			'ATT_address2' => stripslashes($old_attendee['address2']),
340
+			'ATT_city' => stripslashes($old_attendee['city']),
341
+			'STA_ID' => $new_state_id,
342
+			'CNT_ISO' => $new_country_iso,
343
+			'ATT_zip' => stripslashes($old_attendee['zip']),
344
+			'ATT_email' => stripslashes($old_attendee['email']),
345
+			'ATT_phone' => stripslashes($old_attendee['phone']),
346
+		);
347
+		$datatypes = array(
348
+			'%d',// ATT_ID
349
+			'%s',// ATT_fname
350
+			'%s',// ATT_lname
351
+			'%s',// ATT_address
352
+			'%s',// ATT_address2
353
+			'%s',// ATT_city
354
+			'%d',// STA_ID
355
+			'%s',// CNT_ISO
356
+			'%s',// ATT_zip
357
+			'%s',// ATT_email
358
+			'%s',// ATT_phone
359
+		);
360
+		$success = $wpdb->insert($this->_new_attendee_meta_table, $cols_n_values, $datatypes);
361
+		if (!$success) {
362
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_meta_table, $cols_n_values, $datatypes));
363
+			return 0;
364
+		}
365
+		$new_id = $wpdb->insert_id;
366
+		return $new_id;
367
+	}
368
+
369
+	/**
370
+	 * Note: we don't necessarily create a new transaction for each attendee row.
371
+	 * Only if the old attendee 'is_primary' is true; otherwise we find the old attendee row that
372
+	 * 'is_primary' and has the same 'txn_id', then we return ITS new transaction id
373
+	 * @global type $wpdb
374
+	 * @param type $old_attendee
375
+	 * @return int new transaction id
376
+	 */
377
+	private function _insert_new_transaction($old_attendee)
378
+	{
379
+		global $wpdb;
380
+
381
+		// first: let's check for an existing transaction for this old attendee
382
+		if (intval($old_attendee['is_primary'])) {// primary attendee, so create txn
383
+			$txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($old_attendee['id']), $this->_new_transaction_table);
384
+		} else { // non-primary attendee, so find its primary attendee's transaction
385
+			$primary_attendee_old_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_old_table . " WHERE is_primary=1 and registration_id=%s", $old_attendee['registration_id']));
386
+			if (!$primary_attendee_old_id) {
387
+				$primary_attendee = $this->_find_mer_primary_attendee_using_mer_tables($old_attendee['registration_id']);
388
+				$primary_attendee_old_id = is_array($primary_attendee) ? $primary_attendee['id'] : null;
389
+			}
390
+			$txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($primary_attendee_old_id), $this->_new_transaction_table);
391
+			if (!$txn_id) {
392
+				$this->add_error(sprintf(__("Could not find primary attendee's new transaction. Current attendee is: %s, we think the 3.1 primary attendee for it has id %d, but there's no 4.1 transaction for that primary attendee id.", "event_espresso"), $this->_json_encode($old_attendee), $primary_attendee_old_id));
393
+				$txn_id = 0;
394
+			}
395
+		}
396
+		// if there isn't yet a transaction row for this, create one
397
+		// (so even if it was a non-primary attendee with no EE3 primary attendee,
398
+		// it ought to have SOME transaction, so we'll make one)
399
+		if (!$txn_id) {
400
+			// maps 3.1 payment stati onto 4.1 transaction stati
401
+			$txn_status_mapping = array(
402
+				'Completed' => 'TCM',
403
+				'Pending' => 'TIN',
404
+				'Payment Declined' => 'TIN',
405
+				'Incomplete' => 'TIN',
406
+				'Not Completed' => 'TIN',
407
+				'Cancelled' => 'TIN',
408
+				'Declined' => 'TIN'
409
+			);
410
+			$STS_ID = isset($txn_status_mapping[ $old_attendee['payment_status'] ]) ? $txn_status_mapping[ $old_attendee['payment_status'] ] : 'TIN';
411
+			$cols_n_values = array(
412
+				'TXN_timestamp' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
413
+				'TXN_total' => floatval($old_attendee['total_cost']),
414
+				'TXN_paid' => floatval($old_attendee['amount_pd']),
415
+				'STS_ID' => $STS_ID,
416
+				'TXN_hash_salt' => $old_attendee['hashSalt']
417
+			);
418
+			$datatypes = array(
419
+				'%s',// TXN_timestamp
420
+				'%f',// TXN_total
421
+				'%f',// TXN_paid
422
+				'%s',// STS_ID
423
+				'%s',// TXN_hash_salt
424
+			);
425
+			$success = $wpdb->insert($this->_new_transaction_table, $cols_n_values, $datatypes);
426
+			if (!$success) {
427
+				$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_transaction_table, $cols_n_values, $datatypes));
428
+				return 0;
429
+			}
430
+			$txn_id = $wpdb->insert_id;
431
+		}
432
+
433
+		return $txn_id;
434
+	}
435
+
436
+	/**
437
+	 * Detects if the MER tables exist
438
+	 * @global type $wpdb
439
+	 * @return boolean
440
+	 */
441
+	private function _mer_tables_exist()
442
+	{
443
+		if ($this->_mer_tables_exist === null) {
444
+			global $wpdb;
445
+
446
+			if ($wpdb->get_var("SHOW TABLES LIKE '{$this->_old_mer_table}'") != $this->_old_mer_table) {
447
+				$this->_mer_tables_exist = false;
448
+			} else {
449
+				$this->_mer_tables_exist = true;
450
+			}
451
+		}
452
+		return $this->_mer_tables_exist;
453
+	}
454
+
455
+	/**
456
+	 * Gets the 4.1 registration's status given the 3.1 attendee row. We consider
457
+	 * whether the event required pre-approval or not,a dn the 4.1 payment status.
458
+	 * @global type $wpdb
459
+	 * @param type $old_attendee_row
460
+	 * @return string
461
+	 */
462
+	private function _get_reg_status_for_old_payment_status($old_attendee_row)
463
+	{
464
+		// need event default reg status and if pre_approval was required
465
+		global $wpdb;
466
+		$event_required_pre_approval = $wpdb->get_var($wpdb->prepare("SELECT require_pre_approval FROM " . $wpdb->prefix . "events_detail WHERE id = %d", $old_attendee_row['event_id']));
467
+		return $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(
468
+			$old_attendee_row['payment_status'],
469
+			intval($event_required_pre_approval) && intval($old_attendee_row['pre_approve'])
470
+		);
471
+	}
472
+
473
+	/**
474
+	 * Adds however many rgistrations are indicated by the old attendee's QUANTITY field,
475
+	 * and returns an array of their IDs
476
+	 * @global type $wpdb
477
+	 * @param array $old_attendee
478
+	 * @param int $new_attendee_id
479
+	 * @param int $new_txn_id
480
+	 * @return array of new registratio ids
481
+	 */
482
+	private function _insert_new_registrations($old_attendee, $new_attendee_id, $new_txn_id)
483
+	{
484
+		global $wpdb;
485
+
486
+		$STS_ID = $this->_get_reg_status_for_old_payment_status($old_attendee);
487
+		$new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . 'events_detail', $old_attendee['event_id'], $wpdb->posts);
488
+		if (!$new_event_id) {
489
+			$this->add_error(sprintf(__("Could not find NEW event CPT ID for old event '%d' on old attendee %s", "event_espresso"), $old_attendee['event_id'], $this->_json_encode($old_attendee)));
490
+		}
491
+
492
+		$ticket_id = $this->_try_to_find_new_ticket_id($old_attendee, $new_event_id);
493
+		if (!$ticket_id) {
494
+			$ticket_id = $this->_insert_new_ticket_because_none_found($old_attendee, $new_event_id);
495
+			$this->add_error(sprintf(__('Could not find a ticket for old attendee with id %d for new event %d, so created a new ticket with id %d', 'event_espresso'), $old_attendee['id'], $new_event_id, $ticket_id));
496
+		}
497
+		$regs_on_this_row = intval($old_attendee['quantity']);
498
+		$new_regs = array();
499
+		// 4 cases we need to account for:
500
+		// 1 old attendee_details row with a quantity of X (no mer)
501
+		// Y old attendee_details rows with a quantity of 1 (no mer) joined by their common registration_id
502
+		// Y old attendee_details rows with a quantity of x (because of mer)
503
+		// Y old attendee_details rows with a quantity of 1 (because of mer) joined by wp_events_multi_event_registration_id_group
504
+		for ($count = 1; $count <= $regs_on_this_row; $count++) {
505
+			// sum regs on older rows
506
+			$regs_on_this_event_and_txn = $this->_sum_old_attendees_on_old_txn($old_attendee, true);
507
+			$cols_n_values = array(
508
+				'EVT_ID' => $new_event_id,
509
+				'ATT_ID' => $new_attendee_id,
510
+				'TXN_ID' => $new_txn_id,
511
+				'TKT_ID' => $ticket_id,
512
+				'STS_ID' => $STS_ID,
513
+				'REG_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
514
+				'REG_final_price' => $old_attendee['final_price'],
515
+				'REG_session' => substr($old_attendee['attendee_session'], 0, 44),
516
+				'REG_code' => sanitize_key($old_attendee['registration_id']),
517
+				'REG_url_link' => sanitize_key($old_attendee['registration_id'] . '-' . $count),
518
+				'REG_count' => $regs_on_this_event_and_txn + $count,
519
+				'REG_group_size' => $this->_sum_old_attendees_on_old_txn($old_attendee, false),
520
+				'REG_att_is_going' => true,
521
+				'REG_deleted' => false
522
+			);
523
+			$datatypes = array(
524
+				'%d',// EVT_ID
525
+				'%d',// ATT_ID
526
+				'%d',// TXN_ID
527
+				'%d',// TKT_ID
528
+				'%s',// STS_ID
529
+				'%s',// REG_date
530
+				'%f',// REG_final_price
531
+				'%s',// REG_session
532
+				'%s',// REG_code
533
+				'%s',// REG_url_link
534
+				'%d',// REG_count
535
+				'%d',// REG_group_size
536
+				'%d',// REG_att_is_going
537
+				'%d',// REG_deleted
538
+			);
539
+			$success = $wpdb->insert($this->_new_reg_table, $cols_n_values, $datatypes);
540
+			if (!$success) {
541
+				$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes));
542
+				return 0;
543
+			}
544
+			$cols_n_values['REG_ID'] = $wpdb->insert_id;
545
+			$new_regs[] = $wpdb->insert_id;
546
+		}
547
+		$this->_add_regs_to_ticket_and_datetimes($ticket_id, count($new_regs), $STS_ID);
548
+		return $new_regs;
549
+	}
550
+
551
+	/**
552
+	 * Increments the sold values on the ticket and its related datetimes by the amount sold,
553
+	 * which should be done directly after adding the rows. Yes this means we're constantly incrementing
554
+	 * the sold amounts as we go, and is less efficient than a single big query,
555
+	 * but its safer because we KNOW these regs have been added, rather than inferring
556
+	 * that they WILL be added (because the attendees stage runs nearly last during
557
+	 * the migration script)
558
+	 * @param type $new_ticket_id
559
+	 * @param type $sold
560
+	 * @param type $STS_ID
561
+	 * @return boolean whether they were successfully updated or not
562
+	 */
563
+	protected function _add_regs_to_ticket_and_datetimes($new_ticket_id, $quantity_sold, $STS_ID)
564
+	{
565
+		if ($STS_ID != 'RAP') {
566
+			return true;
567
+		}
568
+		global $wpdb;
569
+		$success = $wpdb->query($wpdb->prepare("UPDATE {$this->_new_ticket_table} SET TKT_sold=TKT_sold+%d WHERE TKT_ID=%d", $quantity_sold, $new_ticket_id));
570
+		if ($success) {
571
+			// get the ticket's datetimes, and increment them too
572
+			$success_update_dateimtes = $wpdb->query($wpdb->prepare("UPDATE {$this->_new_ticket_table} TKT
573 573
 				INNER JOIN {$this->_new_ticket_datetime_table} as DTK ON TKT.TKT_ID = DTK.TKT_ID
574 574
 				INNER JOIN {$this->_new_datetime_table} as DTT ON DTK.DTT_ID = DTT.DTT_ID
575 575
 				SET DTT.DTT_sold = DTT.DTT_sold + %d WHERE TKT.TKT_ID = %d", $quantity_sold, $new_ticket_id));
576
-            if (!$success_update_dateimtes) {
577
-                $this->add_error(sprintf(__("Could not update datetimes related to ticket with ID %d's TKT_sold by %d because %s", "event_espresso"), $new_ticket_id, $quantity_sold, $wpdb->last_error));
578
-            }
579
-        } else {
580
-            $this->add_error(sprintf(__("Could not update ticket with ID %d's TKT_sold by %d because %s", "event_espresso"), $new_ticket_id, $quantity_sold, $wpdb->last_error));
581
-        }
582
-        return true;
583
-    }
584
-
585
-    /**
586
-     * Makes a best guess at which ticket is the one the attendee purchased.
587
-     * Obviously, the old attendee's event_id narrows it down quite a bit;
588
-     * then the old attendee's orig_price and event_time, and price_option can uniquely identify the ticket
589
-     * however, if we don't find an exact match, see if any of those conditions match;
590
-     * and lastly if none of that works, just use the first ticket for the event we find
591
-     * @param array $old_attendee
592
-     */
593
-    private function _try_to_find_new_ticket_id($old_attendee, $new_event_id)
594
-    {
595
-        global $wpdb;
596
-        $tickets_table = $this->_new_ticket_table;
597
-        $datetime_tickets_table = $this->_new_ticket_datetime_table;
598
-        $datetime_table = $this->_new_datetime_table;
599
-
600
-        $old_att_price_option = $old_attendee['price_option'];
601
-        $old_att_price = floatval($old_attendee['orig_price']);
602
-
603
-        $old_att_start_date = $old_attendee['start_date'];
604
-        $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
605
-        $old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
606
-        // add all conditions to an array from which we can SHIFT conditions off in order to widen our search
607
-        // the most important condition should be last, as it will be array_shift'ed off last
608
-        $conditions = array(
609
-            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
610
-            $wpdb->prepare("$tickets_table.TKT_price = %f", $old_att_price),// prices match?
611
-            $wpdb->prepare("$tickets_table.TKT_name = %s", $old_att_price_option),// names match?
612
-            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
613
-        );
614
-        $select_and_join_part = "SELECT $tickets_table.TKT_ID FROM $tickets_table INNER JOIN
576
+			if (!$success_update_dateimtes) {
577
+				$this->add_error(sprintf(__("Could not update datetimes related to ticket with ID %d's TKT_sold by %d because %s", "event_espresso"), $new_ticket_id, $quantity_sold, $wpdb->last_error));
578
+			}
579
+		} else {
580
+			$this->add_error(sprintf(__("Could not update ticket with ID %d's TKT_sold by %d because %s", "event_espresso"), $new_ticket_id, $quantity_sold, $wpdb->last_error));
581
+		}
582
+		return true;
583
+	}
584
+
585
+	/**
586
+	 * Makes a best guess at which ticket is the one the attendee purchased.
587
+	 * Obviously, the old attendee's event_id narrows it down quite a bit;
588
+	 * then the old attendee's orig_price and event_time, and price_option can uniquely identify the ticket
589
+	 * however, if we don't find an exact match, see if any of those conditions match;
590
+	 * and lastly if none of that works, just use the first ticket for the event we find
591
+	 * @param array $old_attendee
592
+	 */
593
+	private function _try_to_find_new_ticket_id($old_attendee, $new_event_id)
594
+	{
595
+		global $wpdb;
596
+		$tickets_table = $this->_new_ticket_table;
597
+		$datetime_tickets_table = $this->_new_ticket_datetime_table;
598
+		$datetime_table = $this->_new_datetime_table;
599
+
600
+		$old_att_price_option = $old_attendee['price_option'];
601
+		$old_att_price = floatval($old_attendee['orig_price']);
602
+
603
+		$old_att_start_date = $old_attendee['start_date'];
604
+		$old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
605
+		$old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
606
+		// add all conditions to an array from which we can SHIFT conditions off in order to widen our search
607
+		// the most important condition should be last, as it will be array_shift'ed off last
608
+		$conditions = array(
609
+			$wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
610
+			$wpdb->prepare("$tickets_table.TKT_price = %f", $old_att_price),// prices match?
611
+			$wpdb->prepare("$tickets_table.TKT_name = %s", $old_att_price_option),// names match?
612
+			$wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
613
+		);
614
+		$select_and_join_part = "SELECT $tickets_table.TKT_ID FROM $tickets_table INNER JOIN
615 615
 			$datetime_tickets_table ON $tickets_table.TKT_ID = $datetime_tickets_table.TKT_ID INNER JOIN
616 616
 			$datetime_table ON $datetime_tickets_table.DTT_ID = $datetime_table.DTT_ID";
617
-        // start running queries, widening search each time by removing a condition
618
-        do {
619
-            $full_query = $select_and_join_part . " WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
620
-            $ticket_id_found = $wpdb->get_var($full_query);
621
-            array_shift($conditions);
622
-        } while (!$ticket_id_found && $conditions);
623
-        return $ticket_id_found;
624
-    }
625
-
626
-    /**
627
-     * If we couldn't find a 4.1 ticket for a 3.1 attendee row, this function creates one;
628
-     * and it also tries to find a datetime that works, and a inserts a price, and associates
629
-     * the new ticket to that datetime and price.
630
-     * @return int ticket id
631
-     */
632
-    private function _insert_new_ticket_because_none_found($old_attendee, $new_event_id)
633
-    {
634
-        global $wpdb;
635
-        $old_att_price_option = $old_attendee['price_option'];
636
-        $old_att_price = floatval($old_attendee['orig_price']);
637
-
638
-        $old_att_start_date = $old_attendee['start_date'];
639
-        $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
640
-        $old_att_start_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
641
-
642
-
643
-        // insert new datetime unless we find one
644
-        $datetime_id = $wpdb->get_var($wpdb->prepare("SELECT DTT_ID FROM " . $this->_new_datetime_table . " WHERE DTT_EVT_start=%s AND EVT_ID=%d LIMIT 1", $old_att_start_datetime, $new_event_id), ARRAY_A);
645
-        if (!$datetime_id) {
646
-            $old_att_end_date = $old_attendee['start_date'];
647
-            $old_att_end_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
648
-            $old_att_end_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_end_date $old_att_end_time:00");
649
-            $wpdb->insert(
650
-                $this->_new_datetime_table,
651
-                array(
652
-                    'EVT_ID' => $new_event_id,
653
-                    'DTT_EVT_start' => $old_att_start_datetime,
654
-                    'DTT_EVT_end' => $old_att_end_datetime,
655
-                    'DTT_deleted' => true
656
-                ),
657
-                array(
658
-                    '%d',// EVT_ID
659
-                    '%s',// DTT_EVT_start
660
-                    '%s',// DTT_EVT_end
661
-                    '%d',// DTT_deleted
662
-                )
663
-            );
664
-            $datetime_id = $wpdb->insert_id;
665
-        }
666
-
667
-        // insert new ticket
668
-        $success = $wpdb->insert(
669
-            $wpdb->prefix . 'esp_ticket',
670
-            array(
671
-                'TKT_name' => $old_att_price_option,
672
-                'TKT_qty' => -1,
673
-                'TKT_price' => $old_att_price,
674
-                'TKT_start_date' => $old_att_start_datetime,// we really have no clue what the time should be, but at least it was available when they attended
675
-                'TKT_end_date' => $old_att_end_datetime,
676
-
677
-            ),
678
-            array(
679
-                '%s',// name
680
-                '%d',// qty
681
-                '%d',// price
682
-                '%s',// start_date
683
-                '%s',// end_date
684
-            )
685
-        );
686
-        $ticket_id = $wpdb->insert_id;
687
-        // associate the ticket with the datetime we found earlier
688
-        $wpdb->insert(
689
-            $this->_new_datetime_ticket_table,
690
-            array(
691
-                'DTT_ID' => $datetime_id,
692
-                'TKT_ID' => $ticket_id
693
-            ),
694
-            array(
695
-                '%d',// DTT_ID
696
-                '%d',// TKT_ID
697
-            )
698
-        );
699
-        // insert new price
700
-        $wpdb->insert(
701
-            $this->_new_price_table,
702
-            array(
703
-                'PRC_amount' => $old_att_price,
704
-                'PRT_ID' => EE_DMS_4_1_0_prices::price_type_base,
705
-                'PRC_name' => $old_att_price_option,
706
-                'PRC_deleted' => true
707
-            ),
708
-            array(
709
-                '%d',// PRC_amount
710
-                '%d',// PRT_ID
711
-                '%s',// PRC_name
712
-                '%d',// PRC_deleted
713
-            )
714
-        );
715
-        $price_id = $wpdb->insert_id;
716
-        // associate the price to the ticket
717
-        $wpdb->insert(
718
-            $this->_new_ticket_price_table,
719
-            array(
720
-                'TKT_ID' => $ticket_id,
721
-                'PRC_ID' => $price_id
722
-            ),
723
-            array(
724
-                '%d',// TKT_ID
725
-                '%d',// PRC_ID
726
-            )
727
-        );
728
-        return $ticket_id;
729
-    }
730
-
731
-    /**
732
-     * Counts all the registrations on this transaction. If $count_only_older is TRUE then returns the number added SO FAR (ie,
733
-     * only considers attendee rows with an ID less than this one's), but if $count_only_older is FALSe returns ALL
734
-     * @global type $wpdb
735
-     * @param array $old_attendee_row
736
-     * @param boolean $count_only_older true if you want the running count (ie, the total up to this row), and false if you want ALL
737
-     * @return int
738
-     */
739
-    private function _sum_old_attendees_on_old_txn($old_attendee_row, $count_only_older = false)
740
-    {
741
-        global $wpdb;
742
-        $count_only_older_sql = $count_only_older ? $wpdb->prepare(" AND id<%d", $old_attendee_row['id']) : '';
743
-        $count = intval($wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM " . $this->_old_table . " WHERE registration_id=%s $count_only_older_sql", $old_attendee_row['registration_id'])));
744
-
745
-        if ($this->_mer_tables_exist()) {
746
-            // if MER exists, then its a little tricky.
747
-            // when users registered by adding items to the cart, and it was a
748
-            // group registration requiring additional attendee INFO, then the attendee rows
749
-            // DO NOT have the same registration_id (although they probably should have)
750
-            // they are related just like MER attendee rows are related, through the MER group table
751
-            // BUT we want to count all the MER attendee rows for the same registration
752
-            $primary_attendee = $this->_find_mer_primary_attendee_using_mer_tables($old_attendee_row['registration_id']);
753
-
754
-            $count_using_mer_table = $wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM {$this->_old_table} att INNER JOIN {$this->_old_mer_table} mer ON att.registration_id = mer.registration_id WHERE att.event_id=%d AND mer.primary_registration_id = %s $count_only_older_sql", $old_attendee_row['event_id'], $primary_attendee['registration_id']));
755
-            $count = max($count_using_mer_table, $count);
756
-        }
757
-        return $count;
758
-    }
759
-
760
-    private function _insert_new_payment($old_attendee, $new_txn_id)
761
-    {
762
-        global $wpdb;
763
-        // Only add a payment for primary attendees. Important note: partial payments were marked as "Pending".
764
-        // Also, an offline payment had blank status (ie, "").
765
-        $old_pay_stati_indicating_no_payment = array('', 'Incomplete', 'Not Completed');
766
-        // if this is for a primary 3.1 attendee which WASN'T free and has a completed, cancelled, or declined payment...
767
-        if (intval($old_attendee['is_primary']) && floatval($old_attendee['total_cost']) && !in_array($old_attendee['payment_status'], $old_pay_stati_indicating_no_payment)) {
768
-            $pay_status_mapping = array(
769
-                'Completed' => 'PAP',
770
-                'Payment Declined' => 'PDC',
771
-                'Cancelled' => 'PCN',
772
-                'Declined' => 'PDC'
773
-            );
774
-            $by_admin = $old_attendee['payment'] == 'Admin';
775
-            $STS_ID = isset($pay_status_mapping[ $old_attendee['payment_status'] ]) ? $pay_status_mapping[ $old_attendee['payment_status'] ] : 'PFL';// IE, if we don't recognize the status, assume payment failed
776
-            $cols_n_values = array(
777
-                'TXN_ID' => $new_txn_id,
778
-                'STS_ID' => $STS_ID,
779
-                'PAY_timestamp' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
780
-                'PAY_method' => 'CART',
781
-                'PAY_amount' => $old_attendee['amount_pd'],
782
-                // 'txn_type' was used both for the gateway's name, and for other payment notes.
783
-                'PAY_gateway' => $old_attendee['txn_type'],
784
-                'PAY_extra_accntng' => $old_attendee['txn_type'],
785
-                'PAY_gateway_response' => '',
786
-                'PAY_txn_id_chq_nmbr' => substr($old_attendee['txn_id'], 0, 32),
787
-                'PAY_via_admin' => $by_admin,
788
-                'PAY_details' => $old_attendee['transaction_details']
789
-            );
790
-            $datatypes = array(
791
-                '%d',// TXN_Id
792
-                '%s',// STS_ID
793
-                '%s',// PAY_timestamp
794
-                '%s',// PAY_method
795
-                '%f',// PAY_amount
796
-                '%s',// PAY_gateway
797
-                '%s',// PAY_gateway_response
798
-                '%s',// PAY_txn_id_chq_nmbr
799
-                '%d',// PAY_via_admin
800
-                '%s',// PAY_details
801
-            );
802
-            $success = $wpdb->insert($this->_new_payment_table, $cols_n_values, $datatypes);
803
-            if (!$success) {
804
-                $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
805
-                return 0;
806
-            }
807
-            $new_id = $wpdb->insert_id;
808
-            return $new_id;
809
-        } else {
810
-            return 0;
811
-        }
812
-    }
813
-
814
-    /**
815
-     * If MER is active, if you want ot fin dthe other registrations on that attendee row
816
-     * @global type $wpdb
817
-     * @param type $old_registration_id
818
-     * @return array
819
-     */
820
-    private function _find_mer_primary_attendee_using_mer_tables($old_registration_id)
821
-    {
822
-        if (!$this->_mer_tables_exist()) {
823
-            return false;
824
-        }
825
-        global $wpdb;
826
-        $old_att_for_primary_reg = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$this->_old_mer_table} AS mer INNER JOIN {$this->_old_table} AS att ON mer.primary_registration_id = att.registration_id WHERE mer.registration_id=%s LIMIT 1", $old_registration_id), ARRAY_A);
827
-        return $old_att_for_primary_reg;
828
-    }
617
+		// start running queries, widening search each time by removing a condition
618
+		do {
619
+			$full_query = $select_and_join_part . " WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
620
+			$ticket_id_found = $wpdb->get_var($full_query);
621
+			array_shift($conditions);
622
+		} while (!$ticket_id_found && $conditions);
623
+		return $ticket_id_found;
624
+	}
625
+
626
+	/**
627
+	 * If we couldn't find a 4.1 ticket for a 3.1 attendee row, this function creates one;
628
+	 * and it also tries to find a datetime that works, and a inserts a price, and associates
629
+	 * the new ticket to that datetime and price.
630
+	 * @return int ticket id
631
+	 */
632
+	private function _insert_new_ticket_because_none_found($old_attendee, $new_event_id)
633
+	{
634
+		global $wpdb;
635
+		$old_att_price_option = $old_attendee['price_option'];
636
+		$old_att_price = floatval($old_attendee['orig_price']);
637
+
638
+		$old_att_start_date = $old_attendee['start_date'];
639
+		$old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
640
+		$old_att_start_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
641
+
642
+
643
+		// insert new datetime unless we find one
644
+		$datetime_id = $wpdb->get_var($wpdb->prepare("SELECT DTT_ID FROM " . $this->_new_datetime_table . " WHERE DTT_EVT_start=%s AND EVT_ID=%d LIMIT 1", $old_att_start_datetime, $new_event_id), ARRAY_A);
645
+		if (!$datetime_id) {
646
+			$old_att_end_date = $old_attendee['start_date'];
647
+			$old_att_end_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
648
+			$old_att_end_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_end_date $old_att_end_time:00");
649
+			$wpdb->insert(
650
+				$this->_new_datetime_table,
651
+				array(
652
+					'EVT_ID' => $new_event_id,
653
+					'DTT_EVT_start' => $old_att_start_datetime,
654
+					'DTT_EVT_end' => $old_att_end_datetime,
655
+					'DTT_deleted' => true
656
+				),
657
+				array(
658
+					'%d',// EVT_ID
659
+					'%s',// DTT_EVT_start
660
+					'%s',// DTT_EVT_end
661
+					'%d',// DTT_deleted
662
+				)
663
+			);
664
+			$datetime_id = $wpdb->insert_id;
665
+		}
666
+
667
+		// insert new ticket
668
+		$success = $wpdb->insert(
669
+			$wpdb->prefix . 'esp_ticket',
670
+			array(
671
+				'TKT_name' => $old_att_price_option,
672
+				'TKT_qty' => -1,
673
+				'TKT_price' => $old_att_price,
674
+				'TKT_start_date' => $old_att_start_datetime,// we really have no clue what the time should be, but at least it was available when they attended
675
+				'TKT_end_date' => $old_att_end_datetime,
676
+
677
+			),
678
+			array(
679
+				'%s',// name
680
+				'%d',// qty
681
+				'%d',// price
682
+				'%s',// start_date
683
+				'%s',// end_date
684
+			)
685
+		);
686
+		$ticket_id = $wpdb->insert_id;
687
+		// associate the ticket with the datetime we found earlier
688
+		$wpdb->insert(
689
+			$this->_new_datetime_ticket_table,
690
+			array(
691
+				'DTT_ID' => $datetime_id,
692
+				'TKT_ID' => $ticket_id
693
+			),
694
+			array(
695
+				'%d',// DTT_ID
696
+				'%d',// TKT_ID
697
+			)
698
+		);
699
+		// insert new price
700
+		$wpdb->insert(
701
+			$this->_new_price_table,
702
+			array(
703
+				'PRC_amount' => $old_att_price,
704
+				'PRT_ID' => EE_DMS_4_1_0_prices::price_type_base,
705
+				'PRC_name' => $old_att_price_option,
706
+				'PRC_deleted' => true
707
+			),
708
+			array(
709
+				'%d',// PRC_amount
710
+				'%d',// PRT_ID
711
+				'%s',// PRC_name
712
+				'%d',// PRC_deleted
713
+			)
714
+		);
715
+		$price_id = $wpdb->insert_id;
716
+		// associate the price to the ticket
717
+		$wpdb->insert(
718
+			$this->_new_ticket_price_table,
719
+			array(
720
+				'TKT_ID' => $ticket_id,
721
+				'PRC_ID' => $price_id
722
+			),
723
+			array(
724
+				'%d',// TKT_ID
725
+				'%d',// PRC_ID
726
+			)
727
+		);
728
+		return $ticket_id;
729
+	}
730
+
731
+	/**
732
+	 * Counts all the registrations on this transaction. If $count_only_older is TRUE then returns the number added SO FAR (ie,
733
+	 * only considers attendee rows with an ID less than this one's), but if $count_only_older is FALSe returns ALL
734
+	 * @global type $wpdb
735
+	 * @param array $old_attendee_row
736
+	 * @param boolean $count_only_older true if you want the running count (ie, the total up to this row), and false if you want ALL
737
+	 * @return int
738
+	 */
739
+	private function _sum_old_attendees_on_old_txn($old_attendee_row, $count_only_older = false)
740
+	{
741
+		global $wpdb;
742
+		$count_only_older_sql = $count_only_older ? $wpdb->prepare(" AND id<%d", $old_attendee_row['id']) : '';
743
+		$count = intval($wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM " . $this->_old_table . " WHERE registration_id=%s $count_only_older_sql", $old_attendee_row['registration_id'])));
744
+
745
+		if ($this->_mer_tables_exist()) {
746
+			// if MER exists, then its a little tricky.
747
+			// when users registered by adding items to the cart, and it was a
748
+			// group registration requiring additional attendee INFO, then the attendee rows
749
+			// DO NOT have the same registration_id (although they probably should have)
750
+			// they are related just like MER attendee rows are related, through the MER group table
751
+			// BUT we want to count all the MER attendee rows for the same registration
752
+			$primary_attendee = $this->_find_mer_primary_attendee_using_mer_tables($old_attendee_row['registration_id']);
753
+
754
+			$count_using_mer_table = $wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM {$this->_old_table} att INNER JOIN {$this->_old_mer_table} mer ON att.registration_id = mer.registration_id WHERE att.event_id=%d AND mer.primary_registration_id = %s $count_only_older_sql", $old_attendee_row['event_id'], $primary_attendee['registration_id']));
755
+			$count = max($count_using_mer_table, $count);
756
+		}
757
+		return $count;
758
+	}
759
+
760
+	private function _insert_new_payment($old_attendee, $new_txn_id)
761
+	{
762
+		global $wpdb;
763
+		// Only add a payment for primary attendees. Important note: partial payments were marked as "Pending".
764
+		// Also, an offline payment had blank status (ie, "").
765
+		$old_pay_stati_indicating_no_payment = array('', 'Incomplete', 'Not Completed');
766
+		// if this is for a primary 3.1 attendee which WASN'T free and has a completed, cancelled, or declined payment...
767
+		if (intval($old_attendee['is_primary']) && floatval($old_attendee['total_cost']) && !in_array($old_attendee['payment_status'], $old_pay_stati_indicating_no_payment)) {
768
+			$pay_status_mapping = array(
769
+				'Completed' => 'PAP',
770
+				'Payment Declined' => 'PDC',
771
+				'Cancelled' => 'PCN',
772
+				'Declined' => 'PDC'
773
+			);
774
+			$by_admin = $old_attendee['payment'] == 'Admin';
775
+			$STS_ID = isset($pay_status_mapping[ $old_attendee['payment_status'] ]) ? $pay_status_mapping[ $old_attendee['payment_status'] ] : 'PFL';// IE, if we don't recognize the status, assume payment failed
776
+			$cols_n_values = array(
777
+				'TXN_ID' => $new_txn_id,
778
+				'STS_ID' => $STS_ID,
779
+				'PAY_timestamp' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
780
+				'PAY_method' => 'CART',
781
+				'PAY_amount' => $old_attendee['amount_pd'],
782
+				// 'txn_type' was used both for the gateway's name, and for other payment notes.
783
+				'PAY_gateway' => $old_attendee['txn_type'],
784
+				'PAY_extra_accntng' => $old_attendee['txn_type'],
785
+				'PAY_gateway_response' => '',
786
+				'PAY_txn_id_chq_nmbr' => substr($old_attendee['txn_id'], 0, 32),
787
+				'PAY_via_admin' => $by_admin,
788
+				'PAY_details' => $old_attendee['transaction_details']
789
+			);
790
+			$datatypes = array(
791
+				'%d',// TXN_Id
792
+				'%s',// STS_ID
793
+				'%s',// PAY_timestamp
794
+				'%s',// PAY_method
795
+				'%f',// PAY_amount
796
+				'%s',// PAY_gateway
797
+				'%s',// PAY_gateway_response
798
+				'%s',// PAY_txn_id_chq_nmbr
799
+				'%d',// PAY_via_admin
800
+				'%s',// PAY_details
801
+			);
802
+			$success = $wpdb->insert($this->_new_payment_table, $cols_n_values, $datatypes);
803
+			if (!$success) {
804
+				$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
805
+				return 0;
806
+			}
807
+			$new_id = $wpdb->insert_id;
808
+			return $new_id;
809
+		} else {
810
+			return 0;
811
+		}
812
+	}
813
+
814
+	/**
815
+	 * If MER is active, if you want ot fin dthe other registrations on that attendee row
816
+	 * @global type $wpdb
817
+	 * @param type $old_registration_id
818
+	 * @return array
819
+	 */
820
+	private function _find_mer_primary_attendee_using_mer_tables($old_registration_id)
821
+	{
822
+		if (!$this->_mer_tables_exist()) {
823
+			return false;
824
+		}
825
+		global $wpdb;
826
+		$old_att_for_primary_reg = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$this->_old_mer_table} AS mer INNER JOIN {$this->_old_table} AS att ON mer.primary_registration_id = att.registration_id WHERE mer.registration_id=%s LIMIT 1", $old_registration_id), ARRAY_A);
827
+		return $old_att_for_primary_reg;
828
+	}
829 829
 }
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -206,26 +206,26 @@  discard block
 block discarded – undo
206 206
     {
207 207
         global $wpdb;
208 208
         $this->_pretty_name = __("Attendees", "event_espresso");
209
-        $this->_old_table = $wpdb->prefix . "events_attendee";
209
+        $this->_old_table = $wpdb->prefix."events_attendee";
210 210
         // Only select the event status column from the event table.
211 211
         $this->select_expression = 'att.*, e.event_status';
212 212
         // Only select attendees for events that aren't deleted.
213 213
         $this->_extra_where_sql = 'AS att
214
-            INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id
214
+            INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON att.event_id=e.id
215 215
             WHERE e.event_status!="D"';
216
-        $this->_old_mer_table = $wpdb->prefix . "events_multi_event_registration_id_group";
216
+        $this->_old_mer_table = $wpdb->prefix."events_multi_event_registration_id_group";
217 217
         $this->_new_attendee_cpt_table = $wpdb->posts;
218
-        $this->_new_attendee_meta_table = $wpdb->prefix . "esp_attendee_meta";
219
-        $this->_new_reg_table = $wpdb->prefix . "esp_registration";
220
-        $this->_new_transaction_table = $wpdb->prefix . "esp_transaction";
221
-        $this->_new_payment_table = $wpdb->prefix . "esp_payment";
222
-        $this->_new_line_table = $wpdb->prefix . "esp_line_item";
223
-        $this->_new_ticket_table = $wpdb->prefix . "esp_ticket";
224
-        $this->_new_ticket_datetime_table = $wpdb->prefix . "esp_datetime_ticket";
225
-        $this->_new_datetime_table = $wpdb->prefix . "esp_datetime";
226
-        $this->_new_datetime_ticket_table = $wpdb->prefix . "esp_datetime_ticket";
227
-        $this->_new_price_table = $wpdb->prefix . "esp_price";
228
-        $this->_new_ticket_price_table = $wpdb->prefix . "esp_ticket_price";
218
+        $this->_new_attendee_meta_table = $wpdb->prefix."esp_attendee_meta";
219
+        $this->_new_reg_table = $wpdb->prefix."esp_registration";
220
+        $this->_new_transaction_table = $wpdb->prefix."esp_transaction";
221
+        $this->_new_payment_table = $wpdb->prefix."esp_payment";
222
+        $this->_new_line_table = $wpdb->prefix."esp_line_item";
223
+        $this->_new_ticket_table = $wpdb->prefix."esp_ticket";
224
+        $this->_new_ticket_datetime_table = $wpdb->prefix."esp_datetime_ticket";
225
+        $this->_new_datetime_table = $wpdb->prefix."esp_datetime";
226
+        $this->_new_datetime_ticket_table = $wpdb->prefix."esp_datetime_ticket";
227
+        $this->_new_price_table = $wpdb->prefix."esp_price";
228
+        $this->_new_ticket_price_table = $wpdb->prefix."esp_ticket_price";
229 229
         parent::__construct();
230 230
     }
231 231
 
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
     {
234 234
         // first check if there's already a new attendee with similar characteristics
235 235
         $new_att_id = $this->_find_attendee_cpt_matching($old_row);
236
-        if (!$new_att_id) {
236
+        if ( ! $new_att_id) {
237 237
             $new_att_id = $this->_insert_new_attendee_cpt($old_row);
238
-            if (!$new_att_id) {
238
+            if ( ! $new_att_id) {
239 239
                 // if we couldnt even make an attendee, abandon all hope
240 240
                 return false;
241 241
             }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
         $this->get_migration_script()->set_mapping($this->_old_table, $old_row['id'], $this->_new_attendee_cpt_table, $new_att_id);
248 248
 
249 249
         $txn_id = $this->_insert_new_transaction($old_row);
250
-        if (!$txn_id) {
250
+        if ( ! $txn_id) {
251 251
             // if we couldnt make the transaction, also abandon all hope
252 252
             return false;
253 253
         }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     private function _find_attendee_cpt_matching($old_attendee)
276 276
     {
277 277
         global $wpdb;
278
-        $existing_attendee_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_new_attendee_cpt_table . " AS cpt INNER JOIN " . $this->_new_attendee_meta_table . " AS meta ON cpt.ID = meta.ATT_ID WHERE meta.ATT_fname = %s AND meta.ATT_lname = %s AND meta.ATT_email = %s LIMIT 1", $old_attendee['fname'], $old_attendee['lname'], $old_attendee['email']));
278
+        $existing_attendee_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".$this->_new_attendee_cpt_table." AS cpt INNER JOIN ".$this->_new_attendee_meta_table." AS meta ON cpt.ID = meta.ATT_ID WHERE meta.ATT_fname = %s AND meta.ATT_lname = %s AND meta.ATT_email = %s LIMIT 1", $old_attendee['fname'], $old_attendee['lname'], $old_attendee['email']));
279 279
         return intval($existing_attendee_id);
280 280
     }
281 281
 
@@ -283,31 +283,31 @@  discard block
 block discarded – undo
283 283
     {
284 284
         global $wpdb;
285 285
         $cols_n_values = array(
286
-            'post_title' => stripslashes($old_attendee['fname'] . " " . $old_attendee['lname']),// ATT_full_name
287
-            'post_content' => '',// ATT_bio
288
-            'post_name' => sanitize_title($old_attendee['fname'] . "-" . $old_attendee['lname']),// ATT_slug
289
-            'post_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_created
290
-            'post_excerpt' => '',// ATT_short_bio
291
-            'post_modified' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),// ATT_modified
292
-            'post_author' => 0,// ATT_author
293
-            'post_parent' => 0,// ATT_parent
294
-            'post_type' => 'espresso_attendees',// post_type
286
+            'post_title' => stripslashes($old_attendee['fname']." ".$old_attendee['lname']), // ATT_full_name
287
+            'post_content' => '', // ATT_bio
288
+            'post_name' => sanitize_title($old_attendee['fname']."-".$old_attendee['lname']), // ATT_slug
289
+            'post_date' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']), // ATT_created
290
+            'post_excerpt' => '', // ATT_short_bio
291
+            'post_modified' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']), // ATT_modified
292
+            'post_author' => 0, // ATT_author
293
+            'post_parent' => 0, // ATT_parent
294
+            'post_type' => 'espresso_attendees', // post_type
295 295
             'post_status' => 'publish'// status
296 296
         );
297 297
         $datatypes = array(
298
-            '%s',// ATT_full_name
299
-            '%s',// ATT_bio
300
-            '%s',// ATT_slug
301
-            '%s',// ATT_created
302
-            '%s',// ATT_short_bio
303
-            '%s',// ATT_modified
304
-            '%d',// ATT_author
305
-            '%d',// ATT_parent
306
-            '%s',// post_type
307
-            '%s',// status
298
+            '%s', // ATT_full_name
299
+            '%s', // ATT_bio
300
+            '%s', // ATT_slug
301
+            '%s', // ATT_created
302
+            '%s', // ATT_short_bio
303
+            '%s', // ATT_modified
304
+            '%d', // ATT_author
305
+            '%d', // ATT_parent
306
+            '%s', // post_type
307
+            '%s', // status
308 308
         );
309 309
         $success = $wpdb->insert($this->_new_attendee_cpt_table, $cols_n_values, $datatypes);
310
-        if (!$success) {
310
+        if ( ! $success) {
311 311
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
312 312
             return 0;
313 313
         }
@@ -345,20 +345,20 @@  discard block
 block discarded – undo
345 345
             'ATT_phone' => stripslashes($old_attendee['phone']),
346 346
         );
347 347
         $datatypes = array(
348
-            '%d',// ATT_ID
349
-            '%s',// ATT_fname
350
-            '%s',// ATT_lname
351
-            '%s',// ATT_address
352
-            '%s',// ATT_address2
353
-            '%s',// ATT_city
354
-            '%d',// STA_ID
355
-            '%s',// CNT_ISO
356
-            '%s',// ATT_zip
357
-            '%s',// ATT_email
358
-            '%s',// ATT_phone
348
+            '%d', // ATT_ID
349
+            '%s', // ATT_fname
350
+            '%s', // ATT_lname
351
+            '%s', // ATT_address
352
+            '%s', // ATT_address2
353
+            '%s', // ATT_city
354
+            '%d', // STA_ID
355
+            '%s', // CNT_ISO
356
+            '%s', // ATT_zip
357
+            '%s', // ATT_email
358
+            '%s', // ATT_phone
359 359
         );
360 360
         $success = $wpdb->insert($this->_new_attendee_meta_table, $cols_n_values, $datatypes);
361
-        if (!$success) {
361
+        if ( ! $success) {
362 362
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_meta_table, $cols_n_values, $datatypes));
363 363
             return 0;
364 364
         }
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
         if (intval($old_attendee['is_primary'])) {// primary attendee, so create txn
383 383
             $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($old_attendee['id']), $this->_new_transaction_table);
384 384
         } else { // non-primary attendee, so find its primary attendee's transaction
385
-            $primary_attendee_old_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM " . $this->_old_table . " WHERE is_primary=1 and registration_id=%s", $old_attendee['registration_id']));
386
-            if (!$primary_attendee_old_id) {
385
+            $primary_attendee_old_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM ".$this->_old_table." WHERE is_primary=1 and registration_id=%s", $old_attendee['registration_id']));
386
+            if ( ! $primary_attendee_old_id) {
387 387
                 $primary_attendee = $this->_find_mer_primary_attendee_using_mer_tables($old_attendee['registration_id']);
388 388
                 $primary_attendee_old_id = is_array($primary_attendee) ? $primary_attendee['id'] : null;
389 389
             }
390 390
             $txn_id = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, intval($primary_attendee_old_id), $this->_new_transaction_table);
391
-            if (!$txn_id) {
391
+            if ( ! $txn_id) {
392 392
                 $this->add_error(sprintf(__("Could not find primary attendee's new transaction. Current attendee is: %s, we think the 3.1 primary attendee for it has id %d, but there's no 4.1 transaction for that primary attendee id.", "event_espresso"), $this->_json_encode($old_attendee), $primary_attendee_old_id));
393 393
                 $txn_id = 0;
394 394
             }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
         // if there isn't yet a transaction row for this, create one
397 397
         // (so even if it was a non-primary attendee with no EE3 primary attendee,
398 398
         // it ought to have SOME transaction, so we'll make one)
399
-        if (!$txn_id) {
399
+        if ( ! $txn_id) {
400 400
             // maps 3.1 payment stati onto 4.1 transaction stati
401 401
             $txn_status_mapping = array(
402 402
                 'Completed' => 'TCM',
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                 'Cancelled' => 'TIN',
408 408
                 'Declined' => 'TIN'
409 409
             );
410
-            $STS_ID = isset($txn_status_mapping[ $old_attendee['payment_status'] ]) ? $txn_status_mapping[ $old_attendee['payment_status'] ] : 'TIN';
410
+            $STS_ID = isset($txn_status_mapping[$old_attendee['payment_status']]) ? $txn_status_mapping[$old_attendee['payment_status']] : 'TIN';
411 411
             $cols_n_values = array(
412 412
                 'TXN_timestamp' => $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, $old_attendee['date']),
413 413
                 'TXN_total' => floatval($old_attendee['total_cost']),
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
                 'TXN_hash_salt' => $old_attendee['hashSalt']
417 417
             );
418 418
             $datatypes = array(
419
-                '%s',// TXN_timestamp
420
-                '%f',// TXN_total
421
-                '%f',// TXN_paid
422
-                '%s',// STS_ID
423
-                '%s',// TXN_hash_salt
419
+                '%s', // TXN_timestamp
420
+                '%f', // TXN_total
421
+                '%f', // TXN_paid
422
+                '%s', // STS_ID
423
+                '%s', // TXN_hash_salt
424 424
             );
425 425
             $success = $wpdb->insert($this->_new_transaction_table, $cols_n_values, $datatypes);
426
-            if (!$success) {
426
+            if ( ! $success) {
427 427
                 $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_transaction_table, $cols_n_values, $datatypes));
428 428
                 return 0;
429 429
             }
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     {
464 464
         // need event default reg status and if pre_approval was required
465 465
         global $wpdb;
466
-        $event_required_pre_approval = $wpdb->get_var($wpdb->prepare("SELECT require_pre_approval FROM " . $wpdb->prefix . "events_detail WHERE id = %d", $old_attendee_row['event_id']));
466
+        $event_required_pre_approval = $wpdb->get_var($wpdb->prepare("SELECT require_pre_approval FROM ".$wpdb->prefix."events_detail WHERE id = %d", $old_attendee_row['event_id']));
467 467
         return $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID(
468 468
             $old_attendee_row['payment_status'],
469 469
             intval($event_required_pre_approval) && intval($old_attendee_row['pre_approve'])
@@ -484,13 +484,13 @@  discard block
 block discarded – undo
484 484
         global $wpdb;
485 485
 
486 486
         $STS_ID = $this->_get_reg_status_for_old_payment_status($old_attendee);
487
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . 'events_detail', $old_attendee['event_id'], $wpdb->posts);
488
-        if (!$new_event_id) {
487
+        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix.'events_detail', $old_attendee['event_id'], $wpdb->posts);
488
+        if ( ! $new_event_id) {
489 489
             $this->add_error(sprintf(__("Could not find NEW event CPT ID for old event '%d' on old attendee %s", "event_espresso"), $old_attendee['event_id'], $this->_json_encode($old_attendee)));
490 490
         }
491 491
 
492 492
         $ticket_id = $this->_try_to_find_new_ticket_id($old_attendee, $new_event_id);
493
-        if (!$ticket_id) {
493
+        if ( ! $ticket_id) {
494 494
             $ticket_id = $this->_insert_new_ticket_because_none_found($old_attendee, $new_event_id);
495 495
             $this->add_error(sprintf(__('Could not find a ticket for old attendee with id %d for new event %d, so created a new ticket with id %d', 'event_espresso'), $old_attendee['id'], $new_event_id, $ticket_id));
496 496
         }
@@ -514,30 +514,30 @@  discard block
 block discarded – undo
514 514
                 'REG_final_price' => $old_attendee['final_price'],
515 515
                 'REG_session' => substr($old_attendee['attendee_session'], 0, 44),
516 516
                 'REG_code' => sanitize_key($old_attendee['registration_id']),
517
-                'REG_url_link' => sanitize_key($old_attendee['registration_id'] . '-' . $count),
517
+                'REG_url_link' => sanitize_key($old_attendee['registration_id'].'-'.$count),
518 518
                 'REG_count' => $regs_on_this_event_and_txn + $count,
519 519
                 'REG_group_size' => $this->_sum_old_attendees_on_old_txn($old_attendee, false),
520 520
                 'REG_att_is_going' => true,
521 521
                 'REG_deleted' => false
522 522
             );
523 523
             $datatypes = array(
524
-                '%d',// EVT_ID
525
-                '%d',// ATT_ID
526
-                '%d',// TXN_ID
527
-                '%d',// TKT_ID
528
-                '%s',// STS_ID
529
-                '%s',// REG_date
530
-                '%f',// REG_final_price
531
-                '%s',// REG_session
532
-                '%s',// REG_code
533
-                '%s',// REG_url_link
534
-                '%d',// REG_count
535
-                '%d',// REG_group_size
536
-                '%d',// REG_att_is_going
537
-                '%d',// REG_deleted
524
+                '%d', // EVT_ID
525
+                '%d', // ATT_ID
526
+                '%d', // TXN_ID
527
+                '%d', // TKT_ID
528
+                '%s', // STS_ID
529
+                '%s', // REG_date
530
+                '%f', // REG_final_price
531
+                '%s', // REG_session
532
+                '%s', // REG_code
533
+                '%s', // REG_url_link
534
+                '%d', // REG_count
535
+                '%d', // REG_group_size
536
+                '%d', // REG_att_is_going
537
+                '%d', // REG_deleted
538 538
             );
539 539
             $success = $wpdb->insert($this->_new_reg_table, $cols_n_values, $datatypes);
540
-            if (!$success) {
540
+            if ( ! $success) {
541 541
                 $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_reg_table, $cols_n_values, $datatypes));
542 542
                 return 0;
543 543
             }
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 				INNER JOIN {$this->_new_ticket_datetime_table} as DTK ON TKT.TKT_ID = DTK.TKT_ID
574 574
 				INNER JOIN {$this->_new_datetime_table} as DTT ON DTK.DTT_ID = DTT.DTT_ID
575 575
 				SET DTT.DTT_sold = DTT.DTT_sold + %d WHERE TKT.TKT_ID = %d", $quantity_sold, $new_ticket_id));
576
-            if (!$success_update_dateimtes) {
576
+            if ( ! $success_update_dateimtes) {
577 577
                 $this->add_error(sprintf(__("Could not update datetimes related to ticket with ID %d's TKT_sold by %d because %s", "event_espresso"), $new_ticket_id, $quantity_sold, $wpdb->last_error));
578 578
             }
579 579
         } else {
@@ -606,20 +606,20 @@  discard block
 block discarded – undo
606 606
         // add all conditions to an array from which we can SHIFT conditions off in order to widen our search
607 607
         // the most important condition should be last, as it will be array_shift'ed off last
608 608
         $conditions = array(
609
-            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
610
-            $wpdb->prepare("$tickets_table.TKT_price = %f", $old_att_price),// prices match?
611
-            $wpdb->prepare("$tickets_table.TKT_name = %s", $old_att_price_option),// names match?
612
-            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
609
+            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime), // times match?
610
+            $wpdb->prepare("$tickets_table.TKT_price = %f", $old_att_price), // prices match?
611
+            $wpdb->prepare("$tickets_table.TKT_name = %s", $old_att_price_option), // names match?
612
+            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id), // events match?
613 613
         );
614 614
         $select_and_join_part = "SELECT $tickets_table.TKT_ID FROM $tickets_table INNER JOIN
615 615
 			$datetime_tickets_table ON $tickets_table.TKT_ID = $datetime_tickets_table.TKT_ID INNER JOIN
616 616
 			$datetime_table ON $datetime_tickets_table.DTT_ID = $datetime_table.DTT_ID";
617 617
         // start running queries, widening search each time by removing a condition
618 618
         do {
619
-            $full_query = $select_and_join_part . " WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
619
+            $full_query = $select_and_join_part." WHERE ".implode(" AND ", $conditions)." LIMIT 1";
620 620
             $ticket_id_found = $wpdb->get_var($full_query);
621 621
             array_shift($conditions);
622
-        } while (!$ticket_id_found && $conditions);
622
+        }while ( ! $ticket_id_found && $conditions);
623 623
         return $ticket_id_found;
624 624
     }
625 625
 
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 
642 642
 
643 643
         // insert new datetime unless we find one
644
-        $datetime_id = $wpdb->get_var($wpdb->prepare("SELECT DTT_ID FROM " . $this->_new_datetime_table . " WHERE DTT_EVT_start=%s AND EVT_ID=%d LIMIT 1", $old_att_start_datetime, $new_event_id), ARRAY_A);
645
-        if (!$datetime_id) {
644
+        $datetime_id = $wpdb->get_var($wpdb->prepare("SELECT DTT_ID FROM ".$this->_new_datetime_table." WHERE DTT_EVT_start=%s AND EVT_ID=%d LIMIT 1", $old_att_start_datetime, $new_event_id), ARRAY_A);
645
+        if ( ! $datetime_id) {
646 646
             $old_att_end_date = $old_attendee['start_date'];
647 647
             $old_att_end_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
648 648
             $old_att_end_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_end_date $old_att_end_time:00");
@@ -655,10 +655,10 @@  discard block
 block discarded – undo
655 655
                     'DTT_deleted' => true
656 656
                 ),
657 657
                 array(
658
-                    '%d',// EVT_ID
659
-                    '%s',// DTT_EVT_start
660
-                    '%s',// DTT_EVT_end
661
-                    '%d',// DTT_deleted
658
+                    '%d', // EVT_ID
659
+                    '%s', // DTT_EVT_start
660
+                    '%s', // DTT_EVT_end
661
+                    '%d', // DTT_deleted
662 662
                 )
663 663
             );
664 664
             $datetime_id = $wpdb->insert_id;
@@ -666,21 +666,21 @@  discard block
 block discarded – undo
666 666
 
667 667
         // insert new ticket
668 668
         $success = $wpdb->insert(
669
-            $wpdb->prefix . 'esp_ticket',
669
+            $wpdb->prefix.'esp_ticket',
670 670
             array(
671 671
                 'TKT_name' => $old_att_price_option,
672 672
                 'TKT_qty' => -1,
673 673
                 'TKT_price' => $old_att_price,
674
-                'TKT_start_date' => $old_att_start_datetime,// we really have no clue what the time should be, but at least it was available when they attended
674
+                'TKT_start_date' => $old_att_start_datetime, // we really have no clue what the time should be, but at least it was available when they attended
675 675
                 'TKT_end_date' => $old_att_end_datetime,
676 676
 
677 677
             ),
678 678
             array(
679
-                '%s',// name
680
-                '%d',// qty
681
-                '%d',// price
682
-                '%s',// start_date
683
-                '%s',// end_date
679
+                '%s', // name
680
+                '%d', // qty
681
+                '%d', // price
682
+                '%s', // start_date
683
+                '%s', // end_date
684 684
             )
685 685
         );
686 686
         $ticket_id = $wpdb->insert_id;
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
                 'TKT_ID' => $ticket_id
693 693
             ),
694 694
             array(
695
-                '%d',// DTT_ID
696
-                '%d',// TKT_ID
695
+                '%d', // DTT_ID
696
+                '%d', // TKT_ID
697 697
             )
698 698
         );
699 699
         // insert new price
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
                 'PRC_deleted' => true
707 707
             ),
708 708
             array(
709
-                '%d',// PRC_amount
710
-                '%d',// PRT_ID
711
-                '%s',// PRC_name
712
-                '%d',// PRC_deleted
709
+                '%d', // PRC_amount
710
+                '%d', // PRT_ID
711
+                '%s', // PRC_name
712
+                '%d', // PRC_deleted
713 713
             )
714 714
         );
715 715
         $price_id = $wpdb->insert_id;
@@ -721,8 +721,8 @@  discard block
 block discarded – undo
721 721
                 'PRC_ID' => $price_id
722 722
             ),
723 723
             array(
724
-                '%d',// TKT_ID
725
-                '%d',// PRC_ID
724
+                '%d', // TKT_ID
725
+                '%d', // PRC_ID
726 726
             )
727 727
         );
728 728
         return $ticket_id;
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
     {
741 741
         global $wpdb;
742 742
         $count_only_older_sql = $count_only_older ? $wpdb->prepare(" AND id<%d", $old_attendee_row['id']) : '';
743
-        $count = intval($wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM " . $this->_old_table . " WHERE registration_id=%s $count_only_older_sql", $old_attendee_row['registration_id'])));
743
+        $count = intval($wpdb->get_var($wpdb->prepare("SELECT SUM(quantity) FROM ".$this->_old_table." WHERE registration_id=%s $count_only_older_sql", $old_attendee_row['registration_id'])));
744 744
 
745 745
         if ($this->_mer_tables_exist()) {
746 746
             // if MER exists, then its a little tricky.
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
         // Also, an offline payment had blank status (ie, "").
765 765
         $old_pay_stati_indicating_no_payment = array('', 'Incomplete', 'Not Completed');
766 766
         // if this is for a primary 3.1 attendee which WASN'T free and has a completed, cancelled, or declined payment...
767
-        if (intval($old_attendee['is_primary']) && floatval($old_attendee['total_cost']) && !in_array($old_attendee['payment_status'], $old_pay_stati_indicating_no_payment)) {
767
+        if (intval($old_attendee['is_primary']) && floatval($old_attendee['total_cost']) && ! in_array($old_attendee['payment_status'], $old_pay_stati_indicating_no_payment)) {
768 768
             $pay_status_mapping = array(
769 769
                 'Completed' => 'PAP',
770 770
                 'Payment Declined' => 'PDC',
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
                 'Declined' => 'PDC'
773 773
             );
774 774
             $by_admin = $old_attendee['payment'] == 'Admin';
775
-            $STS_ID = isset($pay_status_mapping[ $old_attendee['payment_status'] ]) ? $pay_status_mapping[ $old_attendee['payment_status'] ] : 'PFL';// IE, if we don't recognize the status, assume payment failed
775
+            $STS_ID = isset($pay_status_mapping[$old_attendee['payment_status']]) ? $pay_status_mapping[$old_attendee['payment_status']] : 'PFL'; // IE, if we don't recognize the status, assume payment failed
776 776
             $cols_n_values = array(
777 777
                 'TXN_ID' => $new_txn_id,
778 778
                 'STS_ID' => $STS_ID,
@@ -788,19 +788,19 @@  discard block
 block discarded – undo
788 788
                 'PAY_details' => $old_attendee['transaction_details']
789 789
             );
790 790
             $datatypes = array(
791
-                '%d',// TXN_Id
792
-                '%s',// STS_ID
793
-                '%s',// PAY_timestamp
794
-                '%s',// PAY_method
795
-                '%f',// PAY_amount
796
-                '%s',// PAY_gateway
797
-                '%s',// PAY_gateway_response
798
-                '%s',// PAY_txn_id_chq_nmbr
799
-                '%d',// PAY_via_admin
800
-                '%s',// PAY_details
791
+                '%d', // TXN_Id
792
+                '%s', // STS_ID
793
+                '%s', // PAY_timestamp
794
+                '%s', // PAY_method
795
+                '%f', // PAY_amount
796
+                '%s', // PAY_gateway
797
+                '%s', // PAY_gateway_response
798
+                '%s', // PAY_txn_id_chq_nmbr
799
+                '%d', // PAY_via_admin
800
+                '%s', // PAY_details
801 801
             );
802 802
             $success = $wpdb->insert($this->_new_payment_table, $cols_n_values, $datatypes);
803
-            if (!$success) {
803
+            if ( ! $success) {
804 804
                 $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_attendee, $this->_new_attendee_cpt_table, $cols_n_values, $datatypes));
805 805
                 return 0;
806 806
             }
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
      */
820 820
     private function _find_mer_primary_attendee_using_mer_tables($old_registration_id)
821 821
     {
822
-        if (!$this->_mer_tables_exist()) {
822
+        if ( ! $this->_mer_tables_exist()) {
823 823
             return false;
824 824
         }
825 825
         global $wpdb;
Please login to merge, or discard this patch.
core/services/commands/CommandHandlerInterface.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,24 +8,24 @@
 block discarded – undo
8 8
  */
9 9
 interface CommandHandlerInterface
10 10
 {
11
-    /**
12
-     * verifies that the supplied command is the correct class for the handler.
13
-     *
14
-     * !!! IMPORTANT !!!
15
-     * Must return $this (ie: the handler itself)
16
-     * as the CommandBus utilizes method chaining
17
-     *
18
-     * @param CommandInterface $command
19
-     * @return CommandHandlerInterface
20
-     * @since 4.9.80.p
21
-     */
22
-    public function verify(CommandInterface $command);
11
+	/**
12
+	 * verifies that the supplied command is the correct class for the handler.
13
+	 *
14
+	 * !!! IMPORTANT !!!
15
+	 * Must return $this (ie: the handler itself)
16
+	 * as the CommandBus utilizes method chaining
17
+	 *
18
+	 * @param CommandInterface $command
19
+	 * @return CommandHandlerInterface
20
+	 * @since 4.9.80.p
21
+	 */
22
+	public function verify(CommandInterface $command);
23 23
 
24
-    /**
25
-     * Performs the command handler's logic.
26
-     *
27
-     * @param CommandInterface $command
28
-     * @return mixed
29
-     */
30
-    public function handle(CommandInterface $command);
24
+	/**
25
+	 * Performs the command handler's logic.
26
+	 *
27
+	 * @param CommandInterface $command
28
+	 * @return mixed
29
+	 */
30
+	public function handle(CommandInterface $command);
31 31
 }
Please login to merge, or discard this patch.
core/services/json/JsonSerializableAndUnserializable.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@
 block discarded – undo
15 15
  */
16 16
 interface JsonSerializableAndUnserializable
17 17
 {
18
-    /**
19
-     * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
-     * wp_json_serialize().
21
-     * @since 4.9.80.p
22
-     * @return mixed
23
-     */
24
-    public function toJsonSerializableData();
18
+	/**
19
+	 * Creates a simple PHP array or stdClass from this object's properties, which can be easily serialized using
20
+	 * wp_json_serialize().
21
+	 * @since 4.9.80.p
22
+	 * @return mixed
23
+	 */
24
+	public function toJsonSerializableData();
25 25
 
26
-    /**
27
-     * Initializes this object from data
28
-     * @since 4.9.80.p
29
-     * @param mixed $data
30
-     * @return boolean success
31
-     */
32
-    public function fromJsonSerializedData($data);
26
+	/**
27
+	 * Initializes this object from data
28
+	 * @since 4.9.80.p
29
+	 * @param mixed $data
30
+	 * @return boolean success
31
+	 */
32
+	public function fromJsonSerializedData($data);
33 33
 }
34 34
 // End of file JsonSerializableAndUnserializable.php
35 35
 // Location: EventEspresso\core\services\json/JsonSerializableAndUnserializable.php
Please login to merge, or discard this patch.
core/services/request/files/FileSubmissionInterface.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,37 +15,37 @@
 block discarded – undo
15 15
 interface FileSubmissionInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function getName();
22
-
23
-    /**
24
-     * @return string
25
-     */
26
-    public function getType();
27
-
28
-    /**
29
-     * @return int
30
-     */
31
-    public function getSize();
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    public function getTmpFile();
37
-
38
-    /**
39
-     * Should just return the filename.
40
-     * @since 4.9.80.p
41
-     * @return string
42
-     */
43
-    public function __toString();
44
-
45
-    /**
46
-     * @return string
47
-     */
48
-    public function getErrorCode();
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function getName();
22
+
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function getType();
27
+
28
+	/**
29
+	 * @return int
30
+	 */
31
+	public function getSize();
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function getTmpFile();
37
+
38
+	/**
39
+	 * Should just return the filename.
40
+	 * @since 4.9.80.p
41
+	 * @return string
42
+	 */
43
+	public function __toString();
44
+
45
+	/**
46
+	 * @return string
47
+	 */
48
+	public function getErrorCode();
49 49
 }
50 50
 // End of file FileSubmissionInterface.php
51 51
 // Location: EventEspresso\core\services\request\files/FileSubmissionInterface.php
Please login to merge, or discard this patch.
core/services/options/JsonWpOptionSerializableInterface.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
  */
18 18
 interface JsonWpOptionSerializableInterface extends JsonSerializableAndUnserializable
19 19
 {
20
-    /**
21
-     * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
-     * determine what option name to use.
23
-     * @since 4.9.80.p
24
-     * @return string
25
-     */
26
-    public function getWpOptionName();
20
+	/**
21
+	 * Gets the value to use for wp_options.option_name. Note this is not static, so it can use object properties to
22
+	 * determine what option name to use.
23
+	 * @since 4.9.80.p
24
+	 * @return string
25
+	 */
26
+	public function getWpOptionName();
27 27
 }
28 28
 // End of file JsonWpOptionSerializableInterface.php
29 29
 // Location: EventEspresso\core\services\options/JsonWpOptionSerializableInterface.php
Please login to merge, or discard this patch.
core/domain/Domain.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@
 block discarded – undo
63 63
      */
64 64
     private function setCaffeinated()
65 65
     {
66
-        $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
67
-            && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
66
+        $this->caffeinated = ( ! defined('EE_DECAF') || EE_DECAF !== true)
67
+            && is_readable($this->pluginPath().'caffeinated/brewing_regular.php');
68 68
     }
69 69
 
70 70
 
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -15,70 +15,70 @@
 block discarded – undo
15 15
  */
16 16
 class Domain extends DomainBase implements CaffeinatedInterface
17 17
 {
18
-    /**
19
-     * URL path component used to denote an API request
20
-     */
21
-    const API_NAMESPACE = 'ee/v';
22
-
23
-    const ASSET_NAMESPACE = 'eventespresso';
24
-
25
-    const TEXT_DOMAIN = 'event_espresso';
26
-
27
-    /**
28
-     * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin
29
-     * Page ui.
30
-     */
31
-    const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN
32
-        = 'manual_registration_status_change_from_registration_admin';
33
-
34
-    const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
35
-        = 'manual_registration_status_change_from_registration_admin_and_notify';
36
-
37
-
38
-    /**
39
-     * Whether or not EE core is the full premium version.
40
-     * @since 4.9.59.p
41
-     * @var bool
42
-     */
43
-    private $caffeinated;
44
-
45
-
46
-    public function __construct(FilePath $plugin_file, Version $version)
47
-    {
48
-        parent::__construct($plugin_file, $version);
49
-        $this->setCaffeinated();
50
-    }
51
-
52
-    /**
53
-     * Whether or not EE core is the full premium version.
54
-     * @since 4.9.59.p
55
-     * @return bool
56
-     */
57
-    public function isCaffeinated()
58
-    {
59
-        return $this->caffeinated;
60
-    }
61
-
62
-
63
-    /**
64
-     * Setter for $is_caffeinated property.
65
-     * @since 4.9.59.p
66
-     */
67
-    private function setCaffeinated()
68
-    {
69
-        $this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
70
-            && is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
71
-    }
72
-
73
-
74
-    /**
75
-     * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces
76
-     * to allow for filtering the brand.
77
-     *
78
-     * @return string
79
-     */
80
-    public static function brandName()
81
-    {
82
-        return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso');
83
-    }
18
+	/**
19
+	 * URL path component used to denote an API request
20
+	 */
21
+	const API_NAMESPACE = 'ee/v';
22
+
23
+	const ASSET_NAMESPACE = 'eventespresso';
24
+
25
+	const TEXT_DOMAIN = 'event_espresso';
26
+
27
+	/**
28
+	 * Slug used for the context where a registration status is changed from a manual trigger in the Registration Admin
29
+	 * Page ui.
30
+	 */
31
+	const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN
32
+		= 'manual_registration_status_change_from_registration_admin';
33
+
34
+	const CONTEXT_REGISTRATION_STATUS_CHANGE_REGISTRATION_ADMIN_NOTIFY
35
+		= 'manual_registration_status_change_from_registration_admin_and_notify';
36
+
37
+
38
+	/**
39
+	 * Whether or not EE core is the full premium version.
40
+	 * @since 4.9.59.p
41
+	 * @var bool
42
+	 */
43
+	private $caffeinated;
44
+
45
+
46
+	public function __construct(FilePath $plugin_file, Version $version)
47
+	{
48
+		parent::__construct($plugin_file, $version);
49
+		$this->setCaffeinated();
50
+	}
51
+
52
+	/**
53
+	 * Whether or not EE core is the full premium version.
54
+	 * @since 4.9.59.p
55
+	 * @return bool
56
+	 */
57
+	public function isCaffeinated()
58
+	{
59
+		return $this->caffeinated;
60
+	}
61
+
62
+
63
+	/**
64
+	 * Setter for $is_caffeinated property.
65
+	 * @since 4.9.59.p
66
+	 */
67
+	private function setCaffeinated()
68
+	{
69
+		$this->caffeinated = (! defined('EE_DECAF') || EE_DECAF !== true)
70
+			&& is_readable($this->pluginPath() . 'caffeinated/brewing_regular.php');
71
+	}
72
+
73
+
74
+	/**
75
+	 * This should be used everywhere the Event Espresso brand name is referenced in public facing interfaces
76
+	 * to allow for filtering the brand.
77
+	 *
78
+	 * @return string
79
+	 */
80
+	public static function brandName()
81
+	{
82
+		return (string) apply_filters('FHEE__EventEspresso_core_domain_Domain__brandName', 'Event Espresso');
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_display.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         <td>
17 17
             <span class="description">
18 18
                 <?php _e(
19
-                    "The following settings affect the content and/or appearance of the downloadable PDF invoice.",
20
-                    'event_espresso'
21
-                ); ?></span>
19
+					"The following settings affect the content and/or appearance of the downloadable PDF invoice.",
20
+					'event_espresso'
21
+				); ?></span>
22 22
         </td>
23 23
     </tr>
24 24
 </table>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Invoice/templates/invoice_settings_header_gateway.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
         <td>
17 17
             <span class="description">
18 18
                 <?php _e(
19
-                    "The following settings affect the functioning of the Invoice gateway.",
20
-                    'event_espresso'
21
-                ); ?></span>
19
+					"The following settings affect the functioning of the Invoice gateway.",
20
+					'event_espresso'
21
+				); ?></span>
22 22
         </td>
23 23
     </tr>
24 24
 </table>
25 25
\ No newline at end of file
Please login to merge, or discard this patch.