Completed
Branch BUG-10205-fix-usage-of-gmdate (fdeabe)
by
unknown
18:03
created
data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_transactions.dmsstage.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,6 @@
 block discarded – undo
49 49
 	/**
50 50
 	 *
51 51
 	 * @global type $wpdb
52
-	 * @param int $id
53 52
 	 * @return string
54 53
 	 */
55 54
 	protected function _get_payment_method_id_by_gateway_name( $gateway_name ){
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -12,38 +12,38 @@  discard block
 block discarded – undo
12 12
  * @author				Mike Nelson
13 13
  *
14 14
  */
15
-class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table{
15
+class EE_DMS_4_6_0_transactions extends EE_Data_Migration_Script_Stage_Table {
16 16
 	protected $_transaction_table;
17 17
 	protected $_payment_method_table;
18
-	function __construct(){
18
+	function __construct() {
19 19
 		global $wpdb;
20
-		$this->_old_table = $wpdb->prefix . 'esp_extra_meta';
21
-		$this->_transaction_table = $wpdb->prefix . 'esp_transaction';
22
-		$this->_payment_method_table = $wpdb->prefix . 'esp_payment_method';
20
+		$this->_old_table = $wpdb->prefix.'esp_extra_meta';
21
+		$this->_transaction_table = $wpdb->prefix.'esp_transaction';
22
+		$this->_payment_method_table = $wpdb->prefix.'esp_payment_method';
23 23
 		$this->_pretty_name = __('Transaction Payment Method Relations', 'event_espresso');
24 24
 		$this->_extra_where_sql = "WHERE EXM_key = 'gateway' AND EXM_type = 'Transaction'";
25 25
 		parent::__construct();
26 26
 	}
27
-	protected function _migrate_old_row( $extra_meta_row ) {
27
+	protected function _migrate_old_row($extra_meta_row) {
28 28
 		global $wpdb;
29 29
 		//get the payment method's ID
30
-		$PMD_ID = $this->_get_payment_method_id_by_gateway_name( $extra_meta_row[ 'EXM_value' ] );
31
-		if( ! $PMD_ID ){
32
-			$this->add_error( sprintf( __( 'Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso' ), $extra_meta_row[ 'EXM_value' ], $this->_json_encode( $extra_meta_row ) ) );
30
+		$PMD_ID = $this->_get_payment_method_id_by_gateway_name($extra_meta_row['EXM_value']);
31
+		if ( ! $PMD_ID) {
32
+			$this->add_error(sprintf(__('Could not find payment method with PMD_type = \'%1$s\' when migrating extra meta row %2$s', 'event_espresso'), $extra_meta_row['EXM_value'], $this->_json_encode($extra_meta_row)));
33 33
 			return;
34 34
 		}
35
-		$new_values = array( 'PMD_ID' => $PMD_ID );
36
-		$wheres = array( 'TXN_ID' => $extra_meta_row[ 'OBJ_ID' ] );
37
-		$new_value_datatypes = array( '%d' );
38
-		$where_datatypes = array( '%d' );
39
-		$success = $wpdb->update( $this->_transaction_table,
35
+		$new_values = array('PMD_ID' => $PMD_ID);
36
+		$wheres = array('TXN_ID' => $extra_meta_row['OBJ_ID']);
37
+		$new_value_datatypes = array('%d');
38
+		$where_datatypes = array('%d');
39
+		$success = $wpdb->update($this->_transaction_table,
40 40
 				$new_values,
41 41
 				$wheres,
42 42
 				$new_value_datatypes,
43 43
 				$where_datatypes
44 44
 				);
45
-		if( ! $success ){
46
-			$this->add_error( sprintf( __( 'Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso' ), $this->_json_encode( $new_values ), $this->_transaction_table, $this->_json_encode( $wheres ) ) );
45
+		if ( ! $success) {
46
+			$this->add_error(sprintf(__('Couldnt set %1$s row in table %2$s where %3$s', 'event_espresso'), $this->_json_encode($new_values), $this->_transaction_table, $this->_json_encode($wheres)));
47 47
 		}
48 48
 	}
49 49
 	/**
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @param int $id
53 53
 	 * @return string
54 54
 	 */
55
-	protected function _get_payment_method_id_by_gateway_name( $gateway_name ){
55
+	protected function _get_payment_method_id_by_gateway_name($gateway_name) {
56 56
 		global $wpdb;
57
-		return $wpdb->get_var( $wpdb->prepare( "SELECT PMD_ID FROM " . $wpdb->prefix . "esp_payment_method WHERE PMD_type = %s", $gateway_name ) );
57
+		return $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM ".$wpdb->prefix."esp_payment_method WHERE PMD_type = %s", $gateway_name));
58 58
 	}
59 59
 
60 60
 
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_Data_Migration_Class_Base.core.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@
 block discarded – undo
234 234
 	 * @param array $old_row_as_array
235 235
 	 * @param string $new_table
236 236
 	 * @param array $new_row_as_array columns=>values like used in wpdb->insert
237
-	 * @param array $data_types numerically indexed
237
+	 * @param string[] $data_types numerically indexed
238 238
 	 * @return string
239 239
 	 */
240 240
 	protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types){
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -264,9 +264,9 @@
 block discarded – undo
264 264
 	/**
265 265
 	 * Same as json_encode, just avoids putting
266 266
 	 * serialized arrays into the http build query, as that would
267
-	* @param array $array_of_data
268
-	* @return string
269
-	*/
267
+	 * @param array $array_of_data
268
+	 * @return string
269
+	 */
270 270
 	protected function _json_encode($array_of_data){
271 271
 		//we'd rather NOT serialize the transaction details
272 272
 		$fields_to_include = array();
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		$errors = $this->get_errors();
120 120
 		if($errors){
121 121
 			return end($errors);
122
-		}else{
122
+		} else{
123 123
 			return null;
124 124
 		}
125 125
 	}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	public function add_error($error, $force = FALSE ){
132 132
 		if( ! defined( 'EE_DMS_ERROR_LIMIT' ) ){
133 133
 			$limit = 50;
134
-		}else{
134
+		} else{
135 135
 			$limit = EE_DMS_ERROR_LIMIT;
136 136
 		}
137 137
 		//make sure errors is an array, see ticket #8261
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 				$this->_errors = array_slice( $this->_errors, $limit / 2, $limit / 2 );
145 145
 				$this->_errors[] = "Limit reached; removed first half of errors to save space";
146 146
 				$this->_errors[] = $error;
147
-			}else{
147
+			} else{
148 148
 				$this->_errors[ $limit ] = 'More, but limit reached...';
149 149
 			}
150
-		}else{
150
+		} else{
151 151
 			$this->_errors[] = $error;
152 152
 		}
153 153
 	}
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 
22 22
 
23
-abstract class EE_Data_Migration_Class_Base{
23
+abstract class EE_Data_Migration_Class_Base {
24 24
 
25 25
 	/**
26 26
 	 * @var $records_to_migrate int count of all that have been migrated
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param TableManager  $table_manager
73 73
 	 * @param TableAnalysis $table_analysis
74 74
 	 */
75
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ){
75
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
76 76
 		$this->_table_manager = $table_manager;
77 77
 		$this->_table_analysis = $table_analysis;
78 78
 		$this->set_status(EE_Data_Migration_Manager::status_continue);
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * @throws EE_Error
86 86
 	 * @return string
87 87
 	 */
88
-	public function pretty_name(){
89
-		if($this->_pretty_name === null){
90
-			throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"),get_class($this)));
88
+	public function pretty_name() {
89
+		if ($this->_pretty_name === null) {
90
+			throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"), get_class($this)));
91 91
 		}
92 92
 		return $this->_pretty_name;
93 93
 	}
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return int
97 97
 	 */
98
-	public function count_records_to_migrate(){
99
-		if( $this->_records_to_migrate == null){
98
+	public function count_records_to_migrate() {
99
+		if ($this->_records_to_migrate == null) {
100 100
 			$this->_records_to_migrate = $this->_count_records_to_migrate();
101 101
 		}
102 102
 		return $this->_records_to_migrate;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @return string one of EE_Data_Migration_Manager::status_* constants
117 117
 	 * @throws EE_Error
118 118
 	 */
119
-	public function get_status(){
120
-		if($this->_status === null){
121
-			throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"),get_class($this)));
119
+	public function get_status() {
120
+		if ($this->_status === null) {
121
+			throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"), get_class($this)));
122 122
 		}
123 123
 		return $this->_status;
124 124
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param string $status
128 128
 	 * @return void
129 129
 	 */
130
-	protected function set_status($status){
130
+	protected function set_status($status) {
131 131
 		$this->_status = $status;
132 132
 	}
133 133
 	/**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * Returns the last error that occurred. If none occurred, returns null
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_last_error(){
142
+	public function get_last_error() {
143 143
 		$errors = $this->get_errors();
144
-		if($errors){
144
+		if ($errors) {
145 145
 			return end($errors);
146
-		}else{
146
+		} else {
147 147
 			return null;
148 148
 		}
149 149
 	}
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
 	 * @param string $error a string describing the error that will be useful for debugging. Consider including all the data that led to the error, and a stack trace etc.
153 153
 	 * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are already at their limit, we will purposefully forget the first half
154 154
 	 */
155
-	public function add_error($error, $force = FALSE ){
156
-		if( ! defined( 'EE_DMS_ERROR_LIMIT' ) ){
155
+	public function add_error($error, $force = FALSE) {
156
+		if ( ! defined('EE_DMS_ERROR_LIMIT')) {
157 157
 			$limit = 50;
158
-		}else{
158
+		} else {
159 159
 			$limit = EE_DMS_ERROR_LIMIT;
160 160
 		}
161 161
 		//make sure errors is an array, see ticket #8261
162
-		if( is_string( $this->_errors ) ){
163
-			$this->_errors = array( $this->_errors );
162
+		if (is_string($this->_errors)) {
163
+			$this->_errors = array($this->_errors);
164 164
 		}
165
-		if(count($this->_errors) >= $limit ){
166
-			if( $force ){
165
+		if (count($this->_errors) >= $limit) {
166
+			if ($force) {
167 167
 				//get rid of the first half of the errors and any above the limit
168
-				$this->_errors = array_slice( $this->_errors, $limit / 2, $limit / 2 );
168
+				$this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2);
169 169
 				$this->_errors[] = "Limit reached; removed first half of errors to save space";
170 170
 				$this->_errors[] = $error;
171
-			}else{
172
-				$this->_errors[ $limit ] = 'More, but limit reached...';
171
+			} else {
172
+				$this->_errors[$limit] = 'More, but limit reached...';
173 173
 			}
174
-		}else{
174
+		} else {
175 175
 			$this->_errors[] = $error;
176 176
 		}
177 177
 	}
@@ -180,57 +180,57 @@  discard block
 block discarded – undo
180 180
 	 * Indicates there was a fatal error and the migration cannot possibly continue
181 181
 	 * @return boolean
182 182
 	 */
183
-	public function is_broken(){
183
+	public function is_broken() {
184 184
 		return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error;
185 185
 	}
186 186
 	/**
187 187
 	 * @deprecated since 4.6.12
188 188
 	 */
189
-	public function is_borked(){
190
-		EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12');
189
+	public function is_borked() {
190
+		EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12');
191 191
 		return $this->is_broken();
192 192
 	}
193 193
 	/**
194 194
 	 * Sets the status to as having a fatal error
195 195
 	 */
196
-	public function set_broken(){
196
+	public function set_broken() {
197 197
 		$this->_status = EE_Data_Migration_Manager::status_fatal_error;
198 198
 	}
199 199
 	/**
200 200
 	 *
201 201
 	 * @deprecated since 4.6.12
202 202
 	 */
203
-	public function set_borked(){
204
-		EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12');
203
+	public function set_borked() {
204
+		EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12');
205 205
 		return $this->set_broken();
206 206
 	}
207 207
 	/**
208 208
 	 * Checks if this thing believes it is completed
209 209
 	 * @return boolean
210 210
 	 */
211
-	public function is_completed(){
211
+	public function is_completed() {
212 212
 		return $this->get_status() == EE_Data_Migration_Manager::status_completed;
213 213
 	}
214 214
 	/**
215 215
 	 * Checks if the current script has more to do or not (ie, if it's status is CONTINUE)
216 216
 	 * @return boolean
217 217
 	 */
218
-	public function has_more_to_do(){
218
+	public function has_more_to_do() {
219 219
 		return $this->get_status() == EE_Data_Migration_Manager::status_continue;
220 220
 	}
221 221
 	/**
222 222
 	 * Marks that we believe this migration thing is completed
223 223
 	 */
224
-	public function set_completed(){
224
+	public function set_completed() {
225 225
 		$this->_status = EE_Data_Migration_Manager::status_completed;
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * Marks that we think this migration class can continue to migrate
230 230
 	 */
231
-	public function reattempt(){
231
+	public function reattempt() {
232 232
 		$this->_status = EE_Data_Migration_Manager::status_continue;
233
-		$this->add_error( __( 'Reattempt migration', 'event_espresso' ), TRUE );
233
+		$this->add_error(__('Reattempt migration', 'event_espresso'), TRUE);
234 234
 	}
235 235
 
236 236
 	/**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * possible that this class is defined when it goes to sleep, but NOT available when it
240 240
 	 * awakes (eg, this class is part of an addon that is deactivated at some point).
241 241
 	 */
242
-	public function properties_as_array(){
243
-		$properties =  get_object_vars($this);
242
+	public function properties_as_array() {
243
+		$properties = get_object_vars($this);
244 244
 		$properties['class'] = get_class($this);
245 245
 		unset($properties['_migration_script']);
246 246
 		return $properties;
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 	 * @param array $data_types numerically indexed
262 262
 	 * @return string
263 263
 	 */
264
-	protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types){
264
+	protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types) {
265 265
 		global $wpdb;
266 266
 		$old_columns_and_values_for_string = array();
267
-		foreach($old_row_as_array as $column => $value){
267
+		foreach ($old_row_as_array as $column => $value) {
268 268
 			$old_columns_and_values_for_string[] = "$column => $value";
269 269
 		}
270 270
 		$new_columns_and_values_for_string = array();
271 271
 		$count = 0;
272
-		foreach($new_row_as_array as $column => $value){
272
+		foreach ($new_row_as_array as $column => $value) {
273 273
 			$new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")";
274 274
 		}
275 275
 		return sprintf(
276 276
 			__('Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4%s.', "event_espresso"),
277
-			implode(", ",$new_columns_and_values_for_string),
277
+			implode(", ", $new_columns_and_values_for_string),
278 278
 			$new_table,
279
-			implode(", ",$old_columns_and_values_for_string),
279
+			implode(", ", $old_columns_and_values_for_string),
280 280
 			$old_table,
281 281
 			'<br/>',
282 282
 			$wpdb->last_error
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	* @param array $array_of_data
292 292
 	* @return string
293 293
 	*/
294
-	protected function _json_encode($array_of_data){
294
+	protected function _json_encode($array_of_data) {
295 295
 		//we'd rather NOT serialize the transaction details
296 296
 		$fields_to_include = array();
297
-		foreach($array_of_data as $name => $value){
297
+		foreach ($array_of_data as $name => $value) {
298 298
 			$unserialized_data = @unserialize($value);
299
-			if($unserialized_data === FALSE){
299
+			if ($unserialized_data === FALSE) {
300 300
 				$fields_to_include[$name] = $value;
301 301
 			}
302 302
 		}
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * @throws EE_Error
310 310
 	 */
311 311
 	protected function _get_table_manager() {
312
-		if( $this->_table_manager instanceof TableManager ) {
312
+		if ($this->_table_manager instanceof TableManager) {
313 313
 			return $this->_table_manager;
314 314
 		} else {
315 315
 			throw new EE_Error( 
316 316
 				sprintf( 
317
-					__( 'Table manager on migration class %1$s is not set properly.', 'event_espresso'), 
318
-					get_class( $this ) 
317
+					__('Table manager on migration class %1$s is not set properly.', 'event_espresso'), 
318
+					get_class($this) 
319 319
 				) 	
320 320
 			);
321 321
 		}
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 	 * @throws EE_Error
328 328
 	 */
329 329
 	protected function _get_table_analysis() {
330
-		if( $this->_table_analysis instanceof TableAnalysis ) {
330
+		if ($this->_table_analysis instanceof TableAnalysis) {
331 331
 			return $this->_table_analysis;
332 332
 		} else {
333 333
 			throw new EE_Error( 
334 334
 				sprintf( 
335
-					__( 'Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), 
336
-					get_class( $this ) 
335
+					__('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), 
336
+					get_class($this) 
337 337
 				) 
338 338
 			);
339 339
 		}
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_1_0.dms.php 4 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1434,7 +1434,6 @@  discard block
 block discarded – undo
1434 1434
 	/**
1435 1435
 	 * Makes sure the 3.1's image url is converted to an image attachment post to the 4.1 CPT event
1436 1436
 	 * and sets it as the featured image on the CPT event
1437
-	 * @param type $old_event
1438 1437
 	 * @param type $new_cpt_id
1439 1438
 	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1440 1439
 	 * @return boolean whether or not we had to do the big job of creating an image attachment
@@ -1482,7 +1481,7 @@  discard block
 block discarded – undo
1482 1481
 	/**
1483 1482
 	 * Creates an image attachment post for the GUID. If the GUID points to a remote image,
1484 1483
 	 * we download it to our uploads directory so that it can be properly processed (eg, creates different sizes of thumbnails)
1485
-	 * @param type $guid
1484
+	 * @param string $guid
1486 1485
 	 * @param EE_Data_Migration_Script_Stage $migration_stage
1487 1486
 	 * @return int
1488 1487
 	 */
@@ -1558,7 +1557,7 @@  discard block
 block discarded – undo
1558 1557
 	/**
1559 1558
 	 * Returns a mysql-formatted DATETIME in UTC time, given a $DATETIME_string
1560 1559
 	 * (and optionally a timezone; if none is given, the wp DEFAULT is used)
1561
-	 * @param EE_Data_Migration_Script_base $stage
1560
+	 * @param EE_Data_Migration_Script_Stage $stage
1562 1561
 	 * @param array $row_of_data, the row from the DB (as an array) we're trying to find the UTC time for
1563 1562
 	 * @param string $DATETIME_string
1564 1563
 	 * @param string $timezone
Please login to merge, or discard this patch.
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1607,19 +1607,19 @@
 block discarded – undo
1607 1607
 	private function timezone_convert_to_string_from_offset($offset){
1608 1608
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1609 1609
 		$offset *= 3600; // convert hour offset to seconds
1610
-        $abbrarray = timezone_abbreviations_list();
1611
-        foreach ($abbrarray as $abbr){
1612
-                foreach ($abbr as $city)
1613
-                {
1614
-                        if ($city['offset'] == $offset)
1615
-                        {
1616
-
1617
-                                return $city['timezone_id'];
1618
-                        }
1619
-                }
1620
-        }
1621
-
1622
-        return FALSE;
1610
+		$abbrarray = timezone_abbreviations_list();
1611
+		foreach ($abbrarray as $abbr){
1612
+				foreach ($abbr as $city)
1613
+				{
1614
+						if ($city['offset'] == $offset)
1615
+						{
1616
+
1617
+								return $city['timezone_id'];
1618
+						}
1619
+				}
1620
+		}
1621
+
1622
+		return FALSE;
1623 1623
 	}
1624 1624
 
1625 1625
 	public function migration_page_hooks(){
Please login to merge, or discard this patch.
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
73 73
 		if($results){
74 74
 			return true;
75
-		}else{
75
+		} else{
76 76
 			return false;
77 77
 		}
78 78
 	}
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 		if($version_string < '4.0.0' && $version_string > '3.1.26' ){
82 82
 //			echo "$version_string can be migrated fro";
83 83
 			return true;
84
-		}elseif( ! $version_string ){
84
+		} elseif( ! $version_string ){
85 85
 //			echo "no version string provided: $version_string";
86 86
 			//no version string provided... this must be pre 4.1
87 87
 			//because since 4.1 we're
88 88
 			return false;//changed mind. dont want people thinking they should migrate yet because they cant
89
-		}else{
89
+		} else{
90 90
 //			echo "$version_string doesnt apply";
91 91
 			return false;
92 92
 		}
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 		try{
1089 1089
 			$country = $this->get_or_create_country($country_name);
1090 1090
 			$country_iso = $country['CNT_ISO'];
1091
-		}catch(EE_Error $e){
1091
+		} catch(EE_Error $e){
1092 1092
 			$country_iso = $this->get_default_country_iso();
1093 1093
 		}
1094 1094
 		global $wpdb;
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		if( ! $matches || count($matches)<3){
1133 1133
 			$hour = '00';
1134 1134
 			$minutes = '00';
1135
-		}else{
1135
+		} else{
1136 1136
 			$hour = intval($matches[1]);
1137 1137
 			$minutes = $matches[2];
1138 1138
 		}
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1409 1409
 		if($this_thing_required_pre_approval){
1410 1410
 				return 'RNA';
1411
-		}else{
1411
+		} else{
1412 1412
 				$mapping = $default_reg_stati_conversions=array(
1413 1413
 			'Completed'=>'RAP',
1414 1414
 			''=>'RPP',
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 			//double-check we actually have an attachment post
1454 1454
 			if( $attachment_post_id){
1455 1455
 				update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id);
1456
-			}else{
1456
+			} else{
1457 1457
 				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id));
1458 1458
 			}
1459 1459
 		}
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
 		$head_response = wp_remote_head($original_guid);
1475 1475
 		if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){
1476 1476
 			return $original_guid;
1477
-		}else{
1477
+		} else{
1478 1478
 			return $guid_in_old_event;
1479 1479
 		}
1480 1480
 	}
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 			fwrite($savefile, $contents);
1511 1511
 			fclose($savefile);
1512 1512
 			$guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath);
1513
-		}else{
1513
+		} else{
1514 1514
 			$local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid);
1515 1515
 		}
1516 1516
 
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 		try{
1577 1577
 			$date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) );
1578 1578
 			$date_obj->setTimezone(new DateTimeZone('UTC'));
1579
-		}catch(Exception $e){
1579
+		} catch(Exception $e){
1580 1580
 			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone));
1581 1581
 			$date_obj = new DateTime();
1582 1582
 		}
Please login to merge, or discard this patch.
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 //(all other times it gets resurrected from a wordpress option)
12 12
 $stages = glob(EE_CORE.'data_migration_scripts/4_1_0_stages/*');
13 13
 $class_to_filepath = array();
14
-if ( ! empty( $stages ) ) {
15
-	foreach($stages as $filepath){
14
+if ( ! empty($stages)) {
15
+	foreach ($stages as $filepath) {
16 16
 		$matches = array();
17
-		preg_match('~4_1_0_stages/(.*).dmsstage.php~',$filepath,$matches);
17
+		preg_match('~4_1_0_stages/(.*).dmsstage.php~', $filepath, $matches);
18 18
 		$class_to_filepath[$matches[1]] = $filepath;
19 19
 	}
20 20
 }
21 21
 //give addons a chance to autoload their stages too
22
-$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages',$class_to_filepath);
22
+$class_to_filepath = apply_filters('FHEE__EE_DMS_4_1_0__autoloaded_stages', $class_to_filepath);
23 23
 EEH_Autoloader::register_autoloader($class_to_filepath);
24 24
 
25 25
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
  * --a function named update_espresso_config() which saves the EE_Config object to the database
38 38
  * --...and all its subclasses... really, you're best off copying the whole thing when 4.1 is released into this file and wrapping its declaration in if( ! class_exists()){...}
39 39
  */
40
-class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base{
40
+class EE_DMS_Core_4_1_0 extends EE_Data_Migration_Script_Base {
41 41
 
42 42
 
43 43
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param TableManager  $table_manager
48 48
 	 * @param TableAnalysis $table_analysis
49 49
 	 */
50
-	public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) {
50
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) {
51 51
 		$this->_pretty_name = __("Data Migration to Event Espresso 4.1.0P", "event_espresso");
52 52
 		$this->_priority = 10;
53 53
 		$this->_migration_stages = array(
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			new EE_DMS_4_1_0_answers(),
70 70
 			new EE_DMS_4_1_0_checkins(),
71 71
 		);
72
-		parent::__construct( $table_manager, $table_analysis );
72
+		parent::__construct($table_manager, $table_analysis);
73 73
 	}
74 74
 	/**
75 75
 	 * Checks if this 3.1 Check-in table exists. If it doesn't we can't migrate Check-ins
@@ -77,27 +77,27 @@  discard block
 block discarded – undo
77 77
 	 * @global wpdb $wpdb
78 78
 	 * @return boolean
79 79
 	 */
80
-	private function _checkin_table_exists(){
80
+	private function _checkin_table_exists() {
81 81
 		global $wpdb;
82 82
 		$results = $wpdb->get_results("SHOW TABLES LIKE '".$wpdb->prefix."events_attendee_checkin"."'");
83
-		if($results){
83
+		if ($results) {
84 84
 			return true;
85
-		}else{
85
+		} else {
86 86
 			return false;
87 87
 		}
88 88
 	}
89 89
 
90 90
 	public function can_migrate_from_version($version_array) {
91 91
 		$version_string = $version_array['Core'];
92
-		if ( version_compare( $version_string, '4.0.0', '<=' ) && version_compare( $version_string, '3.1.26', '>=' ) ) {
92
+		if (version_compare($version_string, '4.0.0', '<=') && version_compare($version_string, '3.1.26', '>=')) {
93 93
 //			echo "$version_string can be migrated fro";
94 94
 			return true;
95
-		}elseif( ! $version_string ){
95
+		}elseif ( ! $version_string) {
96 96
 //			echo "no version string provided: $version_string";
97 97
 			//no version string provided... this must be pre 4.1
98 98
 			//because since 4.1 we're
99
-			return false;//changed mind. dont want people thinking they should migrate yet because they cant
100
-		}else{
99
+			return false; //changed mind. dont want people thinking they should migrate yet because they cant
100
+		} else {
101 101
 //			echo "$version_string doesnt apply";
102 102
 			return false;
103 103
 		}
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	public function schema_changes_before_migration() {
109 109
 		//relies on 4.1's EEH_Activation::create_table
110
-		require_once( EE_HELPERS . 'EEH_Activation.helper.php' );
110
+		require_once(EE_HELPERS.'EEH_Activation.helper.php');
111 111
 
112
-		$table_name='esp_answer';
113
-		$sql=" ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
112
+		$table_name = 'esp_answer';
113
+		$sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
114 114
 					REG_ID INT UNSIGNED NOT NULL,
115 115
 					QST_ID INT UNSIGNED NOT NULL,
116 116
 					ANS_value TEXT NOT NULL,
117 117
 					PRIMARY KEY  (ANS_ID)";
118
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
118
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
119 119
 
120 120
 		$table_name = 'esp_attendee_meta';
121 121
 		$sql = "ATTM_ID INT(10) UNSIGNED NOT	NULL AUTO_INCREMENT,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 					  CNT_is_EU TINYINT(1) DEFAULT '0',
156 156
 					  CNT_active TINYINT(1) DEFAULT '0',
157 157
 					  PRIMARY KEY  (CNT_ISO)";
158
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
158
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
159 159
 
160 160
 
161 161
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 
178 178
 
179
-		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB' );
179
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
180 180
 		$table_name = 'esp_event_meta';
181 181
 		$sql = "
182 182
 			EVTM_ID INT NOT NULL AUTO_INCREMENT,
@@ -193,41 +193,41 @@  discard block
 block discarded – undo
193 193
 			EVT_external_URL VARCHAR(200) NULL,
194 194
 			EVT_donations TINYINT(1) NULL,
195 195
 			PRIMARY KEY  (EVTM_ID)";
196
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
196
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
197 197
 
198 198
 
199 199
 
200
-		$table_name='esp_event_question_group';
201
-		$sql="EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
200
+		$table_name = 'esp_event_question_group';
201
+		$sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
202 202
 					EVT_ID BIGINT(20) UNSIGNED NOT NULL,
203 203
 					QSG_ID INT UNSIGNED NOT NULL,
204 204
 					EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
205 205
 					PRIMARY KEY  (EQG_ID)";
206
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
206
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
207 207
 
208 208
 
209 209
 
210
-		$table_name='esp_event_venue';
211
-		$sql="EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
210
+		$table_name = 'esp_event_venue';
211
+		$sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT,
212 212
 				EVT_ID BIGINT(20) UNSIGNED NOT NULL,
213 213
 				VNU_ID BIGINT(20) UNSIGNED NOT NULL,
214 214
 				EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
215 215
 				PRIMARY KEY  (EVV_ID)";
216
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
216
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
217 217
 
218 218
 
219 219
 
220
-		$table_name='esp_extra_meta';
221
-		$sql="EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
220
+		$table_name = 'esp_extra_meta';
221
+		$sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT,
222 222
 				OBJ_ID INT(11) DEFAULT NULL,
223 223
 				EXM_type VARCHAR(45) DEFAULT NULL,
224 224
 				EXM_key VARCHAR(45) DEFAULT NULL,
225 225
 				EXM_value TEXT,
226 226
 				PRIMARY KEY  (EXM_ID)";
227
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
227
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
228 228
 
229
-		$table_name='esp_line_item';
230
-		$sql="LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
229
+		$table_name = 'esp_line_item';
230
+		$sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT,
231 231
 				LIN_code VARCHAR(245) NOT NULL DEFAULT '',
232 232
 				TXN_ID INT(11) DEFAULT NULL,
233 233
 				LIN_name VARCHAR(245) NOT NULL DEFAULT '',
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 				OBJ_ID INT(11) DEFAULT NULL,
244 244
 				OBJ_type VARCHAR(45)DEFAULT NULL,
245 245
 				PRIMARY KEY  (LIN_ID)";
246
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB' );
246
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
247 247
 
248 248
 		$table_name = 'esp_message_template';
249 249
 		$sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					PRIMARY KEY  (GRP_ID),
271 271
 					KEY EVT_ID (EVT_ID),
272 272
 					KEY MTP_user_id (MTP_user_id)";
273
-		$this->_table_is_new_in_this_version( $table_name, $sql, 'ENGINE=InnoDB');
273
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
274 274
 
275 275
 
276 276
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 
379 379
 
380 380
 
381
-		$table_name='esp_question';
382
-		$sql='QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
381
+		$table_name = 'esp_question';
382
+		$sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
383 383
 					QST_display_text TEXT NOT NULL,
384 384
 					QST_admin_label VARCHAR(255) NOT NULL,
385 385
 					QST_system VARCHAR(25) DEFAULT NULL,
@@ -391,12 +391,12 @@  discard block
 block discarded – undo
391 391
 					QST_wp_user BIGINT UNSIGNED NULL,
392 392
 					QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0,
393 393
 					PRIMARY KEY  (QST_ID)';
394
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
394
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
395 395
 
396
-		$this->_get_table_manager()->dropIndex( 'esp_question_group', 'QSG_identifier_UNIQUE' );
396
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
397 397
 
398 398
 		$table_name = 'esp_question_group';
399
-		$sql='QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
399
+		$sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
400 400
 					QSG_name VARCHAR(255) NOT NULL,
401 401
 					QSG_identifier VARCHAR(100) NOT NULL,
402 402
 					QSG_desc TEXT NULL,
@@ -407,27 +407,27 @@  discard block
 block discarded – undo
407 407
 					QSG_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
408 408
 					PRIMARY KEY  (QSG_ID),
409 409
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
410
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
410
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
411 411
 
412 412
 
413 413
 
414
-		$table_name='esp_question_group_question';
415
-		$sql="QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
414
+		$table_name = 'esp_question_group_question';
415
+		$sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
416 416
 					QSG_ID INT UNSIGNED NOT NULL,
417 417
 					QST_ID INT UNSIGNED NOT NULL,
418 418
 					PRIMARY KEY  (QGQ_ID) ";
419
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
419
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
420 420
 
421 421
 
422 422
 
423
-		$table_name='esp_question_option';
424
-		$sql="QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
423
+		$table_name = 'esp_question_option';
424
+		$sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT,
425 425
 					QSO_value VARCHAR(255) NOT NULL,
426 426
 					QSO_desc TEXT NOT NULL,
427 427
 					QST_ID INT UNSIGNED NOT NULL,
428 428
 					QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
429 429
 					PRIMARY KEY  (QSO_ID)";
430
-		$this->_table_is_new_in_this_version($table_name,$sql, 'ENGINE=InnoDB');
430
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
431 431
 
432 432
 
433 433
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 
461 461
 
462 462
 
463
-		$table_name='esp_checkin';
464
-		$sql="CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
463
+		$table_name = 'esp_checkin';
464
+		$sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
465 465
 					REG_ID INT(10) UNSIGNED NOT NULL,
466 466
 					DTT_ID INT(10) UNSIGNED NOT NULL,
467 467
 					CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 
569 569
 		global $wpdb;
570 570
 		$state_table = $wpdb->prefix."esp_state";
571
-		if ( $this->_get_table_analysis()->tableExists( $state_table ) ) {
571
+		if ($this->_get_table_analysis()->tableExists($state_table)) {
572 572
 
573
-			$SQL = "SELECT COUNT('STA_ID') FROM " . $state_table;
573
+			$SQL = "SELECT COUNT('STA_ID') FROM ".$state_table;
574 574
 			$states = $wpdb->get_var($SQL);
575
-			if ( ! $states ) {
576
-				$SQL = "INSERT INTO " . $state_table . "
575
+			if ( ! $states) {
576
+				$SQL = "INSERT INTO ".$state_table."
577 577
 				(STA_ID, CNT_ISO, STA_abbrev, STA_name, STA_active) VALUES
578 578
 				(1, 'US', 'AK', 'Alaska', 1),
579 579
 				(2, 'US', 'AL', 'Alabama', 1),
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
 
661 661
 		global $wpdb;
662 662
 		$country_table = $wpdb->prefix."esp_country";
663
-		if ( $this->_get_table_analysis()->tableExists( $country_table ) ) {
663
+		if ($this->_get_table_analysis()->tableExists($country_table)) {
664 664
 
665
-			$SQL = "SELECT COUNT('CNT_ISO') FROM " . $country_table;
665
+			$SQL = "SELECT COUNT('CNT_ISO') FROM ".$country_table;
666 666
 			$countries = $wpdb->get_var($SQL);
667
-			if ( ! $countries ) {
668
-				$SQL = "INSERT INTO " . $country_table . "
667
+			if ( ! $countries) {
668
+				$SQL = "INSERT INTO ".$country_table."
669 669
 				(CNT_ISO, CNT_ISO3, RGN_ID, CNT_name, CNT_cur_code, CNT_cur_single, CNT_cur_plural, CNT_cur_sign, CNT_cur_sign_b4, CNT_cur_dec_plc, CNT_tel_code, CNT_is_EU, CNT_active) VALUES
670 670
 				('AD', 'AND', 0, 'Andorra', 'EUR', 'Euro', 'Euros', '€', 1, 2, '+376', 0, 0),
671 671
 				('AE', 'ARE', 0, 'United Arab Emirates', 'AED', 'Dirham', 'Dirhams', 'د.إ', 1, 2, '+971', 0, 0),
@@ -912,20 +912,20 @@  discard block
 block discarded – undo
912 912
 		global $wpdb;
913 913
 		$price_type_table = $wpdb->prefix."esp_price_type";
914 914
 
915
-		if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) {
915
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
916 916
 
917
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
918
-			$price_types_exist = $wpdb->get_var( $SQL );
917
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
918
+			$price_types_exist = $wpdb->get_var($SQL);
919 919
 
920
-			if ( ! $price_types_exist ) {
920
+			if ( ! $price_types_exist) {
921 921
 				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_deleted ) VALUES
922
-							(1, '" . __('Base Price', 'event_espresso') . "', 1,  0, 0, 0),
923
-							(2, '" . __('Percent Discount', 'event_espresso') . "', 2,  1, 20, 0),
924
-							(3, '" . __('Fixed Discount', 'event_espresso') . "', 2,  0, 30, 0),
925
-							(4, '" . __('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, 0),
926
-							(5, '" . __('Fixed Surcharge', 'event_espresso') . "', 3,  0, 50, 0);";
927
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL );
928
-				$wpdb->query( $SQL );
922
+							(1, '".__('Base Price', 'event_espresso')."', 1,  0, 0, 0),
923
+							(2, '" . __('Percent Discount', 'event_espresso')."', 2,  1, 20, 0),
924
+							(3, '" . __('Fixed Discount', 'event_espresso')."', 2,  0, 30, 0),
925
+							(4, '" . __('Percent Surcharge', 'event_espresso')."', 3,  1, 40, 0),
926
+							(5, '" . __('Fixed Surcharge', 'event_espresso')."', 3,  0, 50, 0);";
927
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_price_types__SQL', $SQL);
928
+				$wpdb->query($SQL);
929 929
 			}
930 930
 		}
931 931
 	}
@@ -945,16 +945,16 @@  discard block
 block discarded – undo
945 945
 		global $wpdb;
946 946
 		$price_table = $wpdb->prefix."esp_price";
947 947
 
948
-		if ( $this->_get_table_analysis()->tableExists(  $price_table ) ) {
948
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
949 949
 
950
-			$SQL = 'SELECT COUNT(PRC_ID) FROM ' .$price_table;
951
-			$prices_exist = $wpdb->get_var( $SQL );
950
+			$SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
951
+			$prices_exist = $wpdb->get_var($SQL);
952 952
 
953
-			if ( ! $prices_exist ) {
953
+			if ( ! $prices_exist) {
954 954
 				$SQL = "INSERT INTO $price_table
955 955
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_order, PRC_deleted, PRC_parent ) VALUES
956 956
 							(1, 1, '0.00', 'Free Admission', '', 1, NULL, 0, 0, 0);";
957
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL );
957
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_prices__SQL', $SQL);
958 958
 				$wpdb->query($SQL);
959 959
 			}
960 960
 		}
@@ -971,34 +971,34 @@  discard block
 block discarded – undo
971 971
 
972 972
 		global $wpdb;
973 973
 		$ticket_table = $wpdb->prefix."esp_ticket";
974
-		if ( $this->_get_table_analysis()->tableExists( $ticket_table ) ) {
974
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
975 975
 
976
-			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
976
+			$SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
977 977
 			$tickets_exist = $wpdb->get_var($SQL);
978 978
 
979
-			if ( ! $tickets_exist ) {
979
+			if ( ! $tickets_exist) {
980 980
 				$SQL = "INSERT INTO $ticket_table
981 981
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_deleted ) VALUES
982
-					( 1, 0, '" . __("Free Ticket", "event_espresso") . "', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL );
982
+					( 1, 0, '".__("Free Ticket", "event_espresso")."', '', 100, 0, -1, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, 0);";
983
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL', $SQL);
984 984
 				$wpdb->query($SQL);
985 985
 			}
986 986
 		}
987 987
 		$ticket_price_table = $wpdb->prefix."esp_ticket_price";
988 988
 
989
-		if ( $this->_get_table_analysis()->tableExists( $ticket_price_table ) ) {
989
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
990 990
 
991
-			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
991
+			$SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
992 992
 			$ticket_prc_exist = $wpdb->get_var($SQL);
993 993
 
994
-			if ( ! $ticket_prc_exist ) {
994
+			if ( ! $ticket_prc_exist) {
995 995
 
996 996
 				$SQL = "INSERT INTO $ticket_price_table
997 997
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
998 998
 				( 1, 1, 1 )
999 999
 				";
1000 1000
 
1001
-				$SQL = apply_filters( 'FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL );
1001
+				$SQL = apply_filters('FHEE__EE_DMS_4_1_0__insert_default_tickets__SQL__ticket_price', $SQL);
1002 1002
 				$wpdb->query($SQL);
1003 1003
 			}
1004 1004
 		}
@@ -1011,20 +1011,20 @@  discard block
 block discarded – undo
1011 1011
 	 * @param string $country_name
1012 1012
 	 * @return array where keys are columns, values are column values
1013 1013
 	 */
1014
-	public function get_or_create_country($country_name){
1015
-		if( ! $country_name ){
1014
+	public function get_or_create_country($country_name) {
1015
+		if ( ! $country_name) {
1016 1016
 			throw new EE_Error(__("Could not get a country because country name is blank", "event_espresso"));
1017 1017
 		}
1018 1018
 		global $wpdb;
1019 1019
 		$country_table = $wpdb->prefix."esp_country";
1020
-		if(is_int($country_name)){
1020
+		if (is_int($country_name)) {
1021 1021
 			$country_name = $this->get_iso_from_3_1_country_id($country_name);
1022 1022
 		}
1023 1023
 		$country = $wpdb->get_row($wpdb->prepare("SELECT * FROM $country_table WHERE
1024 1024
 			CNT_ISO LIKE %s OR
1025 1025
 			CNT_ISO3 LIKE %s OR
1026
-			CNT_name LIKE %s LIMIT 1",$country_name,$country_name,$country_name),ARRAY_A);
1027
-		if( ! $country ){
1026
+			CNT_name LIKE %s LIMIT 1", $country_name, $country_name, $country_name), ARRAY_A);
1027
+		if ( ! $country) {
1028 1028
 			//insert a new one then
1029 1029
 			$cols_n_values = array(
1030 1030
 				'CNT_ISO'=> $this->_find_available_country_iso(2),
@@ -1044,26 +1044,26 @@  discard block
 block discarded – undo
1044 1044
 				'CNT_active'=>true
1045 1045
 			);
1046 1046
 			$data_types = array(
1047
-				'%s',//CNT_ISO
1048
-				'%s',//CNT_ISO3
1049
-				'%d',//RGN_ID
1050
-				'%s',//CNT_name
1051
-				'%s',//CNT_cur_code
1052
-				'%s',//CNT_cur_single
1053
-				'%s',//CNT_cur_plural
1054
-				'%s',//CNT_cur_sign
1055
-				'%d',//CNT_cur_sign_b4
1056
-				'%d',//CNT_cur_dec_plc
1057
-				'%s',//CNT_cur_dec_mrk
1058
-				'%s',//CNT_cur_thsnds
1059
-				'%s',//CNT_tel_code
1060
-				'%d',//CNT_is_EU
1061
-				'%d',//CNT_active
1047
+				'%s', //CNT_ISO
1048
+				'%s', //CNT_ISO3
1049
+				'%d', //RGN_ID
1050
+				'%s', //CNT_name
1051
+				'%s', //CNT_cur_code
1052
+				'%s', //CNT_cur_single
1053
+				'%s', //CNT_cur_plural
1054
+				'%s', //CNT_cur_sign
1055
+				'%d', //CNT_cur_sign_b4
1056
+				'%d', //CNT_cur_dec_plc
1057
+				'%s', //CNT_cur_dec_mrk
1058
+				'%s', //CNT_cur_thsnds
1059
+				'%s', //CNT_tel_code
1060
+				'%d', //CNT_is_EU
1061
+				'%d', //CNT_active
1062 1062
 			);
1063 1063
 			$success = $wpdb->insert($country_table,
1064 1064
 					$cols_n_values,
1065 1065
 					$data_types);
1066
-			if( ! $success){
1066
+			if ( ! $success) {
1067 1067
 				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('country_id'=>$country_name), $country_table, $cols_n_values, $data_types));
1068 1068
 			}
1069 1069
 			$country = $cols_n_values;
@@ -1075,13 +1075,13 @@  discard block
 block discarded – undo
1075 1075
 	 * @global type $wpdb
1076 1076
 	 * @return string
1077 1077
 	 */
1078
-	private function _find_available_country_iso($num_letters = 2){
1078
+	private function _find_available_country_iso($num_letters = 2) {
1079 1079
 		global $wpdb;
1080 1080
 		$country_table = $wpdb->prefix."esp_country";
1081
-		do{
1081
+		do {
1082 1082
 			$current_iso = strtoupper(wp_generate_password($num_letters, false));
1083
-			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s",$current_iso));
1084
-		}while(intval($country_with_that_iso));
1083
+			$country_with_that_iso = $wpdb->get_var($wpdb->prepare("SELECT count(CNT_ISO) FROM ".$country_table." WHERE CNT_ISO=%s", $current_iso));
1084
+		}while (intval($country_with_that_iso));
1085 1085
 		return $current_iso;
1086 1086
 	}
1087 1087
 
@@ -1092,14 +1092,14 @@  discard block
 block discarded – undo
1092 1092
 	 * @param string $state_name
1093 1093
 	 * @return array where keys are columns, values are column values
1094 1094
 	 */
1095
-	public function get_or_create_state($state_name,$country_name = ''){
1096
-		if( ! $state_name ){
1095
+	public function get_or_create_state($state_name, $country_name = '') {
1096
+		if ( ! $state_name) {
1097 1097
 			throw new EE_Error(__("Could not get-or-create state because no state name was provided", "event_espresso"));
1098 1098
 		}
1099
-		try{
1099
+		try {
1100 1100
 			$country = $this->get_or_create_country($country_name);
1101 1101
 			$country_iso = $country['CNT_ISO'];
1102
-		}catch(EE_Error $e){
1102
+		} catch (EE_Error $e) {
1103 1103
 			$country_iso = $this->get_default_country_iso();
1104 1104
 		}
1105 1105
 		global $wpdb;
@@ -1107,24 +1107,24 @@  discard block
 block discarded – undo
1107 1107
 		$state = $wpdb->get_row($wpdb->prepare("SELECT * FROM $state_table WHERE
1108 1108
 			(STA_abbrev LIKE %s OR
1109 1109
 			STA_name LIKE %s) AND
1110
-			CNT_ISO LIKE %s LIMIT 1",$state_name,$state_name,$country_iso),ARRAY_A);
1111
-		if ( ! $state){
1110
+			CNT_ISO LIKE %s LIMIT 1", $state_name, $state_name, $country_iso), ARRAY_A);
1111
+		if ( ! $state) {
1112 1112
 			//insert a new one then
1113 1113
 			$cols_n_values = array(
1114 1114
 				'CNT_ISO'=>$country_iso,
1115
-				'STA_abbrev'=>substr($state_name,0,6),
1115
+				'STA_abbrev'=>substr($state_name, 0, 6),
1116 1116
 				'STA_name'=>$state_name,
1117 1117
 				'STA_active'=>true
1118 1118
 			);
1119 1119
 			$data_types = array(
1120
-				'%s',//CNT_ISO
1121
-				'%s',//STA_abbrev
1122
-				'%s',//STA_name
1123
-				'%d',//STA_active
1120
+				'%s', //CNT_ISO
1121
+				'%s', //STA_abbrev
1122
+				'%s', //STA_name
1123
+				'%d', //STA_active
1124 1124
 			);
1125
-			$success = $wpdb->insert($state_table,$cols_n_values,$data_types);
1126
-			if ( ! $success ){
1127
-				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name,'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1125
+			$success = $wpdb->insert($state_table, $cols_n_values, $data_types);
1126
+			if ( ! $success) {
1127
+				throw new EE_Error($this->_create_error_message_for_db_insertion('N/A', array('state'=>$state_name, 'country_id'=>$country_name), $state_table, $cols_n_values, $data_types));
1128 1128
 			}
1129 1129
 			$state = $cols_n_values;
1130 1130
 			$state['STA_ID'] = $wpdb->insert_id;
@@ -1137,21 +1137,21 @@  discard block
 block discarded – undo
1137 1137
 	 * @param type $timeString
1138 1138
 	 * @return string in the php DATETIME format: "G:i" (24-hour format hour with leading zeros, a colon, and minutes with leading zeros)
1139 1139
 	 */
1140
-	public function convertTimeFromAMPM($timeString){
1140
+	public function convertTimeFromAMPM($timeString) {
1141 1141
 		$matches = array();
1142
-		preg_match("~(\\d*):(\\d*)~",$timeString,$matches);
1143
-		if( ! $matches || count($matches)<3){
1142
+		preg_match("~(\\d*):(\\d*)~", $timeString, $matches);
1143
+		if ( ! $matches || count($matches) < 3) {
1144 1144
 			$hour = '00';
1145 1145
 			$minutes = '00';
1146
-		}else{
1146
+		} else {
1147 1147
 			$hour = intval($matches[1]);
1148 1148
 			$minutes = $matches[2];
1149 1149
 		}
1150
-		if(strpos($timeString, 'PM') || strpos($timeString, 'pm')){
1150
+		if (strpos($timeString, 'PM') || strpos($timeString, 'pm')) {
1151 1151
 			$hour = intval($hour) + 12;
1152 1152
 		}
1153
-		$hour = str_pad( "$hour", 2, '0',STR_PAD_LEFT);
1154
-		$minutes = str_pad( "$minutes", 2, '0',STR_PAD_LEFT);
1153
+		$hour = str_pad("$hour", 2, '0', STR_PAD_LEFT);
1154
+		$minutes = str_pad("$minutes", 2, '0', STR_PAD_LEFT);
1155 1155
 		return "$hour:$minutes";
1156 1156
 	}
1157 1157
 
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	 * @param int $country_id
1161 1161
 	 * @return string the country's ISO3 code
1162 1162
 	 */
1163
-	public function get_iso_from_3_1_country_id($country_id){
1163
+	public function get_iso_from_3_1_country_id($country_id) {
1164 1164
 		$old_countries = array(
1165 1165
 			array(64, 'United States', 'US', 'USA', 1),
1166 1166
 			array(15, 'Australia', 'AU', 'AUS', 1),
@@ -1386,9 +1386,9 @@  discard block
 block discarded – undo
1386 1386
 			array(226, 'Zimbabwe', 'ZW', 'ZWE', 1));
1387 1387
 
1388 1388
 		$country_iso = 'US';
1389
-		foreach($old_countries as $country_array){
1389
+		foreach ($old_countries as $country_array) {
1390 1390
 			//note: index 0 is the 3.1 country ID
1391
-			if($country_array[0] == $country_id){
1391
+			if ($country_array[0] == $country_id) {
1392 1392
 				//note: index 2 is the ISO
1393 1393
 				$country_iso = $country_array[2];
1394 1394
 				break;
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
 	 * Gets the ISO3 for the
1402 1402
 	 * @return string
1403 1403
 	 */
1404
-	public function get_default_country_iso(){
1405
-		$old_org_options= get_option('events_organization_settings');
1404
+	public function get_default_country_iso() {
1405
+		$old_org_options = get_option('events_organization_settings');
1406 1406
 		$iso = $this->get_iso_from_3_1_country_id($old_org_options['organization_country']);
1407 1407
 		return $iso;
1408 1408
 	}
@@ -1414,13 +1414,13 @@  discard block
 block discarded – undo
1414 1414
 	 * the event's DEFAULT payment status, or the attendee's payment status) required pre-approval.
1415 1415
 	 * @return string STS_ID for use in 4.1
1416 1416
 	 */
1417
-	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false){
1417
+	public function convert_3_1_payment_status_to_4_1_STS_ID($payment_status, $this_thing_required_pre_approval = false) {
1418 1418
 
1419 1419
 		//EE team can read the related discussion: https://app.asana.com/0/2400967562914/9418495544455
1420
-		if($this_thing_required_pre_approval){
1420
+		if ($this_thing_required_pre_approval) {
1421 1421
 				return 'RNA';
1422
-		}else{
1423
-				$mapping = $default_reg_stati_conversions=array(
1422
+		} else {
1423
+				$mapping = $default_reg_stati_conversions = array(
1424 1424
 			'Completed'=>'RAP',
1425 1425
 			''=>'RPP',
1426 1426
 			'Incomplete'=>'RPP',
@@ -1450,22 +1450,22 @@  discard block
 block discarded – undo
1450 1450
 	 * @param  EE_Data_Migration_Script_Stage $migration_stage the stage which called this, where errors should be added
1451 1451
 	 * @return boolean whether or not we had to do the big job of creating an image attachment
1452 1452
 	 */
1453
-	public function convert_image_url_to_attachment_and_attach_to_post($guid,$new_cpt_id,  EE_Data_Migration_Script_Stage $migration_stage){
1453
+	public function convert_image_url_to_attachment_and_attach_to_post($guid, $new_cpt_id, EE_Data_Migration_Script_Stage $migration_stage) {
1454 1454
 		$created_attachment_post = false;
1455 1455
 		$guid = $this->_get_original_guid($guid);
1456
-		if($guid){
1456
+		if ($guid) {
1457 1457
 			//check for an existing attachment post with this guid
1458 1458
 			$attachment_post_id = $this->_get_image_attachment_id_by_GUID($guid);
1459
-			if( ! $attachment_post_id){
1459
+			if ( ! $attachment_post_id) {
1460 1460
 				//post thumbnail with that GUID doesn't exist, we should create one
1461 1461
 				$attachment_post_id = $this->_create_image_attachment_from_GUID($guid, $migration_stage);
1462 1462
 				$created_attachment_post = true;
1463 1463
 			}
1464 1464
 			//double-check we actually have an attachment post
1465
-			if( $attachment_post_id){
1466
-				update_post_meta($new_cpt_id,'_thumbnail_id',$attachment_post_id);
1467
-			}else{
1468
-				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"),$guid,$new_cpt_id,$attachment_post_id));
1465
+			if ($attachment_post_id) {
1466
+				update_post_meta($new_cpt_id, '_thumbnail_id', $attachment_post_id);
1467
+			} else {
1468
+				$migration_stage->add_error(sprintf(__("Could not update event image %s for CPT with ID %d, but attachments post ID is %d", "event_espresso"), $guid, $new_cpt_id, $attachment_post_id));
1469 1469
 			}
1470 1470
 		}
1471 1471
 		return $created_attachment_post;
@@ -1479,13 +1479,13 @@  discard block
 block discarded – undo
1479 1479
 	 * @param string $guid_in_old_event
1480 1480
 	 * @return string either the original guid, or $guid_in_old_event if we couldn't figure out what the original was
1481 1481
 	 */
1482
-	private function _get_original_guid($guid_in_old_event){
1483
-		$original_guid = preg_replace('~-\d*x\d*\.~','.',$guid_in_old_event,1);
1482
+	private function _get_original_guid($guid_in_old_event) {
1483
+		$original_guid = preg_replace('~-\d*x\d*\.~', '.', $guid_in_old_event, 1);
1484 1484
 		//do a head request to verify the file exists
1485 1485
 		$head_response = wp_remote_head($original_guid);
1486
-		if( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK'){
1486
+		if ( ! $head_response instanceof WP_Error && $head_response['response']['message'] == 'OK') {
1487 1487
 			return $original_guid;
1488
-		}else{
1488
+		} else {
1489 1489
 			return $guid_in_old_event;
1490 1490
 		}
1491 1491
 	}
@@ -1497,32 +1497,32 @@  discard block
 block discarded – undo
1497 1497
 	 * @param EE_Data_Migration_Script_Stage $migration_stage
1498 1498
 	 * @return int
1499 1499
 	 */
1500
-	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage){
1501
-		if ( ! $guid){
1500
+	private function _create_image_attachment_from_GUID($guid, EE_Data_Migration_Script_Stage $migration_stage) {
1501
+		if ( ! $guid) {
1502 1502
 			$migration_stage->add_error(sprintf(__("Cannot create image attachment for a blank GUID!", "event_espresso")));
1503 1503
 			return 0;
1504 1504
 		}
1505
-		$wp_filetype = wp_check_filetype(basename($guid), null );
1505
+		$wp_filetype = wp_check_filetype(basename($guid), null);
1506 1506
 		$wp_upload_dir = wp_upload_dir();
1507 1507
 		//if the file is located remotely, download it to our uploads DIR, because wp_genereate_attachmnet_metadata needs the file to be local
1508
-		if(strpos($guid,$wp_upload_dir['url']) === FALSE){
1508
+		if (strpos($guid, $wp_upload_dir['url']) === FALSE) {
1509 1509
 			//image is located remotely. download it and place it in the uploads directory
1510
-			if( ! is_readable($guid)){
1511
-				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"),$guid));
1510
+			if ( ! is_readable($guid)) {
1511
+				$migration_stage->add_error(sprintf(__("Could not create image attachment from non-existent file: %s", "event_espresso"), $guid));
1512 1512
 				return 0;
1513 1513
 			}
1514
-			$contents= file_get_contents($guid);
1515
-			if($contents === FALSE){
1516
-				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"),$guid));
1514
+			$contents = file_get_contents($guid);
1515
+			if ($contents === FALSE) {
1516
+				$migration_stage->add_error(sprintf(__("Could not read image at %s, and therefore couldnt create an attachment post for it.", "event_espresso"), $guid));
1517 1517
 				return false;
1518 1518
 			}
1519
-			$local_filepath  = $wp_upload_dir['path'].DS.basename($guid);
1519
+			$local_filepath = $wp_upload_dir['path'].DS.basename($guid);
1520 1520
 			$savefile = fopen($local_filepath, 'w');
1521 1521
 			fwrite($savefile, $contents);
1522 1522
 			fclose($savefile);
1523
-			$guid = str_replace($wp_upload_dir['path'],$wp_upload_dir['url'],$local_filepath);
1524
-		}else{
1525
-			$local_filepath = str_replace($wp_upload_dir['url'],$wp_upload_dir['path'],$guid);
1523
+			$guid = str_replace($wp_upload_dir['path'], $wp_upload_dir['url'], $local_filepath);
1524
+		} else {
1525
+			$local_filepath = str_replace($wp_upload_dir['url'], $wp_upload_dir['path'], $guid);
1526 1526
 		}
1527 1527
 
1528 1528
 		$attachment = array(
@@ -1532,24 +1532,24 @@  discard block
 block discarded – undo
1532 1532
 		   'post_content' => '',
1533 1533
 		   'post_status' => 'inherit'
1534 1534
 		);
1535
-		$attach_id = wp_insert_attachment( $attachment, $guid );
1536
-		if( ! $attach_id ){
1537
-			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"),$guid,$this->_json_encode($attachment)));
1535
+		$attach_id = wp_insert_attachment($attachment, $guid);
1536
+		if ( ! $attach_id) {
1537
+			$migration_stage->add_error(sprintf(__("Could not create image attachment post from image '%s'. Attachment data was %s.", "event_espresso"), $guid, $this->_json_encode($attachment)));
1538 1538
 			return $attach_id;
1539 1539
 		}
1540 1540
 
1541 1541
 		// you must first include the image.php file
1542 1542
 		// for the function wp_generate_attachment_metadata() to work
1543
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
1543
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1544 1544
 
1545
-		$attach_data = wp_generate_attachment_metadata( $attach_id, $local_filepath );
1546
-		if( ! $attach_data){
1547
-			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"),$attach_id,$local_filepath,$guid));
1545
+		$attach_data = wp_generate_attachment_metadata($attach_id, $local_filepath);
1546
+		if ( ! $attach_data) {
1547
+			$migration_stage->add_error(sprintf(__("Coudl not genereate attachment metadata for attachment post %d with filepath %s and GUID %s. Please check the file was downloaded properly.", "event_espresso"), $attach_id, $local_filepath, $guid));
1548 1548
 			return $attach_id;
1549 1549
 		}
1550
-		$metadata_save_result = wp_update_attachment_metadata( $attach_id, $attach_data );
1551
-		if( ! $metadata_save_result ){
1552
-			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"),$attach_id,$this->_json_encode($attach_data)));
1550
+		$metadata_save_result = wp_update_attachment_metadata($attach_id, $attach_data);
1551
+		if ( ! $metadata_save_result) {
1552
+			$migration_stage->add_error(sprintf(__("Could not update attachment metadata for attachment %d with data %s", "event_espresso"), $attach_id, $this->_json_encode($attach_data)));
1553 1553
 		}
1554 1554
 		return $attach_id;
1555 1555
 	}
@@ -1561,9 +1561,9 @@  discard block
 block discarded – undo
1561 1561
 	 * @param string $guid
1562 1562
 	 * @return int
1563 1563
 	 */
1564
-	private function _get_image_attachment_id_by_GUID($guid){
1564
+	private function _get_image_attachment_id_by_GUID($guid) {
1565 1565
 		global $wpdb;
1566
-		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1",$guid));
1566
+		$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid=%s LIMIT 1", $guid));
1567 1567
 		return $attachment_id;
1568 1568
 	}
1569 1569
 	/**
@@ -1575,20 +1575,20 @@  discard block
 block discarded – undo
1575 1575
 	 * @param string $timezone
1576 1576
 	 * @return string
1577 1577
 	 */
1578
-	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string,$timezone = null){
1578
+	public function convert_date_string_to_utc(EE_Data_Migration_Script_Stage $stage, $row_of_data, $DATETIME_string, $timezone = null) {
1579 1579
 		$original_tz = $timezone;
1580
-		if( ! $timezone){
1580
+		if ( ! $timezone) {
1581 1581
 			$timezone = $this->_get_wp_timezone();
1582 1582
 		}
1583
-		if( ! $timezone){
1584
-			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"),$original_tz,$row_of_data));
1583
+		if ( ! $timezone) {
1584
+			$stage->add_error(sprintf(__("Could not find timezone given %s for %s", "event_espresso"), $original_tz, $row_of_data));
1585 1585
 			$timezone = 'UTC';
1586 1586
 		}
1587
-		try{
1588
-			$date_obj = new DateTime( $DATETIME_string, new DateTimeZone( $timezone ) );
1587
+		try {
1588
+			$date_obj = new DateTime($DATETIME_string, new DateTimeZone($timezone));
1589 1589
 			$date_obj->setTimezone(new DateTimeZone('UTC'));
1590
-		}catch(Exception $e){
1591
-			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"),$DATETIME_string,$timezone));
1590
+		} catch (Exception $e) {
1591
+			$stage->add_error(sprintf(__("Could not convert time string '%s' using timezone '%s' into a proper DATETIME. Using current time instead.", "event_espresso"), $DATETIME_string, $timezone));
1592 1592
 			$date_obj = new DateTime();
1593 1593
 		}
1594 1594
 
@@ -1599,14 +1599,14 @@  discard block
 block discarded – undo
1599 1599
 	 * Gets the DEFAULT timezone string from wordpress (even if they set a gmt offset)
1600 1600
 	 * @return string
1601 1601
 	 */
1602
-	private function _get_wp_timezone(){
1603
-		$timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone;
1602
+	private function _get_wp_timezone() {
1603
+		$timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
1604 1604
 
1605 1605
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
1606
-		if ( empty( $timezone ) ) {
1606
+		if (empty($timezone)) {
1607 1607
 			//let's get a the WordPress UTC offset
1608 1608
 			$offset = get_option('gmt_offset');
1609
-			$timezone = $this->timezone_convert_to_string_from_offset( $offset );
1609
+			$timezone = $this->timezone_convert_to_string_from_offset($offset);
1610 1610
 		}
1611 1611
 		return $timezone;
1612 1612
 	}
@@ -1615,11 +1615,11 @@  discard block
 block discarded – undo
1615 1615
 	 * @param int $offset
1616 1616
 	 * @return boolean
1617 1617
 	 */
1618
-	private function timezone_convert_to_string_from_offset($offset){
1618
+	private function timezone_convert_to_string_from_offset($offset) {
1619 1619
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
1620 1620
 		$offset *= 3600; // convert hour offset to seconds
1621 1621
         $abbrarray = timezone_abbreviations_list();
1622
-        foreach ($abbrarray as $abbr){
1622
+        foreach ($abbrarray as $abbr) {
1623 1623
                 foreach ($abbr as $city)
1624 1624
                 {
1625 1625
                         if ($city['offset'] == $offset)
@@ -1633,32 +1633,32 @@  discard block
 block discarded – undo
1633 1633
         return FALSE;
1634 1634
 	}
1635 1635
 
1636
-	public function migration_page_hooks(){
1637
-		add_filter('FHEE__ee_migration_page__header',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1638
-		add_filter('FHEE__ee_migration_page__p_after_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1639
-		add_filter('FHEE__ee_migration_page__option_1_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1640
-		add_filter('FHEE__ee_migration_page__option_1_button_text',array($this,'_migrate_page_hook_simplify_version_strings'),10,3);
1641
-		add_action('AHEE__ee_migration_page__option_1_extra_details',array($this,'_migration_page_hook_option_1_extra_details'),10,3);
1642
-		add_filter('FHEE__ee_migration_page__option_2_main',array($this,'_migrate_page_hook_simplify_version_strings'),10,4);
1643
-		add_filter('FHEE__ee_migration_page__option_2_button_text',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1644
-		add_filter('FHEE__ee_migration_page__option_2_details',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1645
-		add_action('AHEE__ee_migration_page__after_migration_options_table',array($this,'_migration_page_hook_after_migration_options_table'));
1646
-		add_filter('FHEE__ee_migration_page__done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1647
-		add_filter('FHEE__ee_migration_page__p_after_done_migration_header',array($this,'_migration_page_hook_simplify_next_db_state'),10,2);
1636
+	public function migration_page_hooks() {
1637
+		add_filter('FHEE__ee_migration_page__header', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1638
+		add_filter('FHEE__ee_migration_page__p_after_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1639
+		add_filter('FHEE__ee_migration_page__option_1_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1640
+		add_filter('FHEE__ee_migration_page__option_1_button_text', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 3);
1641
+		add_action('AHEE__ee_migration_page__option_1_extra_details', array($this, '_migration_page_hook_option_1_extra_details'), 10, 3);
1642
+		add_filter('FHEE__ee_migration_page__option_2_main', array($this, '_migrate_page_hook_simplify_version_strings'), 10, 4);
1643
+		add_filter('FHEE__ee_migration_page__option_2_button_text', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1644
+		add_filter('FHEE__ee_migration_page__option_2_details', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1645
+		add_action('AHEE__ee_migration_page__after_migration_options_table', array($this, '_migration_page_hook_after_migration_options_table'));
1646
+		add_filter('FHEE__ee_migration_page__done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1647
+		add_filter('FHEE__ee_migration_page__p_after_done_migration_header', array($this, '_migration_page_hook_simplify_next_db_state'), 10, 2);
1648 1648
 	}
1649 1649
 
1650
-	public function _migrate_page_hook_simplify_version_strings($old_content,$current_db_state,$next_db_state,$ultimate_db_state = NULL){
1651
-		return str_replace(array($current_db_state,$next_db_state,$ultimate_db_state),array(__('EE3','event_espresso'),__('EE4','event_espresso'),  __("EE4", 'event_espresso')),$old_content);
1650
+	public function _migrate_page_hook_simplify_version_strings($old_content, $current_db_state, $next_db_state, $ultimate_db_state = NULL) {
1651
+		return str_replace(array($current_db_state, $next_db_state, $ultimate_db_state), array(__('EE3', 'event_espresso'), __('EE4', 'event_espresso'), __("EE4", 'event_espresso')), $old_content);
1652 1652
 	}
1653
-	public function _migration_page_hook_simplify_next_db_state($old_content,$next_db_state){
1654
-		return str_replace($next_db_state,  __("EE4", 'event_espresso'),$old_content);
1653
+	public function _migration_page_hook_simplify_next_db_state($old_content, $next_db_state) {
1654
+		return str_replace($next_db_state, __("EE4", 'event_espresso'), $old_content);
1655 1655
 	}
1656
-	public function _migration_page_hook_option_1_extra_details(){
1657
-		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso"));?></p><?php
1656
+	public function _migration_page_hook_option_1_extra_details() {
1657
+		?><p><?php	printf(__("Note: many of your EE3 shortcodes will be changed to EE4 shortcodes during this migration (among many other things). Should you revert to EE3, then you should restore to your backup or manually change the EE4 shortcodes back to their EE3 equivalents", "event_espresso")); ?></p><?php
1658 1658
 	}
1659
-	public function _migration_page_hook_after_migration_options_table(){
1659
+	public function _migration_page_hook_after_migration_options_table() {
1660 1660
 		?><p class="ee-attention">
1661
-				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso");?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso");	?>
1661
+				<strong><span class="reminder-spn"><?php _e("Important note to those using Event Espresso 3 addons: ", "event_espresso"); ?></span></strong><br/><?php _e("Unless an addon's description on our website explicitly states that it is compatible with EE4, you should consider it incompatible and know that it WILL NOT WORK correctly with this new version of Event Espresso 4 (EE4). As well, any data for incompatible addons will NOT BE MIGRATED until an updated EE4 compatible version of the addon is available. If you want, or need to keep using your EE3 addons, you should simply continue using EE3 until EE4 compatible versions of your addons become available. To continue using EE3 for now, just deactivate EE4 and reactivate EE3.", "event_espresso"); ?>
1662 1662
 			</p><?php
1663 1663
 	}
1664 1664
 }
Please login to merge, or discard this patch.
core/db_classes/EE_CSV.class.php 4 patches
Doc Comments   +6 added lines, -8 removed lines patch added patch discarded remove patch
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * Sends HTTP headers to indicate that the browser should download a file,
288 288
 	 * and starts writing the file to PHP's output. Returns the file handle so other functions can
289 289
 	 * also write to it
290
-	 * @param string $new_filename the name of the file that the user will download
290
+	 * @param string|false $filename the name of the file that the user will download
291 291
 	 * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc.
292 292
 	 */
293 293
 	public function begin_sending_csv($filename){
@@ -343,9 +343,7 @@  discard block
 block discarded – undo
343 343
 	/**
344 344
 	 * Writes $data to the csv file open in $filehandle. uses the array indices of $data for column headers
345 345
 	 * @param array $data 2D array, first numerically-indexed, and next-level-down preferably indexed by string
346
-	 * @param boolean $add_csv_column_names whether or not we should add the keys in the bottom-most array as a row for headers in the CSV.
347
-	 * Eg, if $data looked like array(0=>array('EVT_ID'=>1,'EVT_name'=>'monkey'...), 1=>array(...),...))
348
-	 * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..."
346
+	 * @param resource $filehandle
349 347
 	 * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing)
350 348
 	 */
351 349
 	public function write_data_array_to_csv($filehandle, $data){
@@ -427,7 +425,7 @@  discard block
 block discarded – undo
427 425
 	 * @param array $model_data_array is assumed to be a 3d array: 1st layer has keys of model names (eg 'Event'),
428 426
 	 * next layer is numerically indexed to represent each model object (eg, each individual event), and the last layer
429 427
 	 * has all the attributes o fthat model object (eg, the event's id, name, etc)
430
-	 * @return boolean success
428
+	 * @return boolean|null success
431 429
 	 */
432 430
 	public function write_model_data_to_csv($filehandle,$model_data_array){
433 431
 		$this->write_metadata_to_csv($filehandle);
@@ -456,8 +454,8 @@  discard block
 block discarded – undo
456 454
 	 * Writes the CSV file to the output buffer, with rows corresponding to $model_data_array,
457 455
 	 * and dies (in order to avoid other plugins from messing up the csv output)
458 456
 	 * @param string $filename the filename you want to give the file
459
-	 * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv()
460
-	 * @return bool | void writes CSV file to output and dies
457
+	 * @param boolean $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv()
458
+	 * @return boolean|null | void writes CSV file to output and dies
461 459
 	 */
462 460
 	public function export_multiple_model_data_to_csv($filename,$model_data_array){
463 461
 		$filehandle = $this->begin_sending_csv($filename);
@@ -469,7 +467,7 @@  discard block
 block discarded – undo
469 467
 	 *		  @access public
470 468
 	 *			@param array $data - the array of data to be converted to csv and exported
471 469
 	 *			@param string $filename - name for newly created csv file
472
-	 *			@return TRUE on success, FALSE on fail
470
+	 *			@return false|null on success, FALSE on fail
473 471
 	 */
474 472
 	public function export_array_to_csv( $data = FALSE, $filename = FALSE  ) {
475 473
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * CSV Import Export class
4 6
  *
@@ -105,8 +107,9 @@  discard block
 block discarded – undo
105 107
 			  $fc = $fc . $c;
106 108
 			}
107 109
 		}
108
-		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254))
109
-		$fc = substr($fc,2);
110
+		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254)) {
111
+				$fc = substr($fc,2);
112
+		}
110 113
 		return ($fc);
111 114
 }
112 115
 
@@ -144,7 +147,7 @@  discard block
 block discarded – undo
144 147
 				while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){
145 148
 					$csvarray[]= $data;
146 149
 				}
147
-			}else{
150
+			} else{
148 151
 				// loop through each row of the file
149 152
 				while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) {
150 153
 					$csvarray[]=$data;
@@ -153,7 +156,7 @@  discard block
 block discarded – undo
153 156
 			# Close the File.
154 157
 			fclose($file_handle);
155 158
 			return $csvarray;
156
-		}else{
159
+		} else{
157 160
 			EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ );
158 161
 			return false;
159 162
 		}
@@ -234,7 +237,7 @@  discard block
 block discarded – undo
234 237
 						$matches = array();
235 238
 						if($model_name == EE_CSV::metadata_header){
236 239
 							$headers[$i] = $column_name;
237
-						}else{
240
+						} else{
238 241
 							//now get the db table name from it (the part between square brackets)
239 242
 							$success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches);
240 243
 							if (!$success){
@@ -244,7 +247,7 @@  discard block
 block discarded – undo
244 247
 							$headers[$i] = $matches[2];
245 248
 						}
246 249
 
247
-					}else{
250
+					} else{
248 251
 						// no column names means our final array will just use counters for keys
249 252
 						$model_entry[$headers[$i]] = $data[$i];
250 253
 						$headers[$i] = $i;
@@ -371,7 +374,7 @@  discard block
 block discarded – undo
371 374
 				echo $this->fputcsv2($filehandle, $data_row);
372 375
 			}
373 376
 			return true;
374
-		}else{
377
+		} else{
375 378
 			//no data TO write... so we can assume that's a success
376 379
 			return true;
377 380
 		}
@@ -438,7 +441,7 @@  discard block
 block discarded – undo
438 441
 
439 442
 			if( ! empty($model_instance_arrays) ){
440 443
 				$this->write_data_array_to_csv($filehandle, $model_instance_arrays);
441
-			}else{
444
+			} else{
442 445
 //				echo "no data to write... so just write the headers";
443 446
 				//so there's actually NO model objects for that model.
444 447
 				//probably still want to show the columns
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@
 block discarded – undo
315 315
 //		header("Content-Type: application/download");
316 316
 		header('Content-disposition: attachment; filename='.$filename);
317 317
 		header("Content-Type: text/csv; charset=utf-8");
318
-                do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' );
318
+				do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' );
319 319
 		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
320 320
 		$fh = fopen('php://output', 'w');
321 321
 		return $fh;
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3 3
  * CSV Import Export class
4 4
  *
@@ -45,31 +45,31 @@  discard block
 block discarded – undo
45 45
 		global $wpdb;
46 46
 
47 47
 		$this->_primary_keys = array(
48
-				$wpdb->prefix . 'esp_answer' => array( 'ANS_ID' ),
49
-				$wpdb->prefix . 'esp_attendee' => array( 'ATT_ID' ),
50
-				$wpdb->prefix . 'esp_datetime'	=> array( 'DTT_ID' ),
51
-				$wpdb->prefix . 'esp_event_question_group'	=> array( 'EQG_ID' ),
52
-				$wpdb->prefix . 'esp_message_template'	=> array( 'MTP_ID' ),
53
-				$wpdb->prefix . 'esp_payment'	=> array( 'PAY_ID' ),
54
-				$wpdb->prefix . 'esp_price'	=> array( 'PRC_ID' ),
55
-				$wpdb->prefix . 'esp_price_type'	=> array( 'PRT_ID' ),
56
-				$wpdb->prefix . 'esp_question'	=> array( 'QST_ID' ),
57
-				$wpdb->prefix . 'esp_question_group'	=> array( 'QSG_ID' ),
58
-				$wpdb->prefix . 'esp_question_group_question'	=> array( 'QGQ_ID' ),
59
-				$wpdb->prefix . 'esp_question_option'	=> array( 'QSO_ID' ),
60
-				$wpdb->prefix . 'esp_registration'	=> array( 'REG_ID' ),
61
-				$wpdb->prefix . 'esp_status'	=> array( 'STS_ID' ),
62
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
63
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
64
-				$wpdb->prefix . 'events_detail'	=> array( 'id' ),
65
-				$wpdb->prefix . 'events_category_detail'	=> array( 'id' ),
66
-				$wpdb->prefix . 'events_category_rel'	=> array( 'id' ),
67
-				$wpdb->prefix . 'events_venue'	=> array( 'id' ),
68
-				$wpdb->prefix . 'events_venue_rel' =>  array( 'emeta_id' ),
69
-				$wpdb->prefix . 'events_locale'	=> array( 'id' ),
70
-				$wpdb->prefix . 'events_locale_rel'	=> array( 'id' ),
71
-				$wpdb->prefix . 'events_personnel' =>  array( 'id' ),
72
-				$wpdb->prefix . 'events_personnel_rel' =>  array( 'id' ),
48
+				$wpdb->prefix.'esp_answer' => array('ANS_ID'),
49
+				$wpdb->prefix.'esp_attendee' => array('ATT_ID'),
50
+				$wpdb->prefix.'esp_datetime'	=> array('DTT_ID'),
51
+				$wpdb->prefix.'esp_event_question_group'	=> array('EQG_ID'),
52
+				$wpdb->prefix.'esp_message_template'	=> array('MTP_ID'),
53
+				$wpdb->prefix.'esp_payment'	=> array('PAY_ID'),
54
+				$wpdb->prefix.'esp_price'	=> array('PRC_ID'),
55
+				$wpdb->prefix.'esp_price_type'	=> array('PRT_ID'),
56
+				$wpdb->prefix.'esp_question'	=> array('QST_ID'),
57
+				$wpdb->prefix.'esp_question_group'	=> array('QSG_ID'),
58
+				$wpdb->prefix.'esp_question_group_question'	=> array('QGQ_ID'),
59
+				$wpdb->prefix.'esp_question_option'	=> array('QSO_ID'),
60
+				$wpdb->prefix.'esp_registration'	=> array('REG_ID'),
61
+				$wpdb->prefix.'esp_status'	=> array('STS_ID'),
62
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
63
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
64
+				$wpdb->prefix.'events_detail'	=> array('id'),
65
+				$wpdb->prefix.'events_category_detail'	=> array('id'),
66
+				$wpdb->prefix.'events_category_rel'	=> array('id'),
67
+				$wpdb->prefix.'events_venue'	=> array('id'),
68
+				$wpdb->prefix.'events_venue_rel' =>  array('emeta_id'),
69
+				$wpdb->prefix.'events_locale'	=> array('id'),
70
+				$wpdb->prefix.'events_locale_rel'	=> array('id'),
71
+				$wpdb->prefix.'events_personnel' =>  array('id'),
72
+				$wpdb->prefix.'events_personnel_rel' =>  array('id'),
73 73
 			);
74 74
 
75 75
 	}
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	 *		@ access public
82 82
 	 *		@return EE_CSV
83 83
 	 */
84
-	public static function instance ( ) {
84
+	public static function instance( ) {
85 85
 		// check if class object is instantiated
86
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_CSV )) {
86
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) {
87 87
 			self::$_instance = new self();
88 88
 		}
89 89
 		return self::$_instance;
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 	 * @return string
96 96
 	 * @throws EE_Error
97 97
 	 */
98
-	private function read_unicode_file($file_path){
98
+	private function read_unicode_file($file_path) {
99 99
 		$fc = "";
100
-		$fh = fopen($file_path,"rb");
101
-		if( ! $fh ){
102
-			throw new EE_Error( sprintf( __("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path ) );
100
+		$fh = fopen($file_path, "rb");
101
+		if ( ! $fh) {
102
+			throw new EE_Error(sprintf(__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path));
103 103
 		}
104 104
 		$flen = filesize($file_path);
105 105
 		$bc = fread($fh, $flen);
106
-		for ($i=0; $i<$flen; $i++){
107
-			$c = substr($bc,$i,1);
108
-			if ((ord($c) != 0) && (ord($c) != 13)){
109
-			  $fc = $fc . $c;
106
+		for ($i = 0; $i < $flen; $i++) {
107
+			$c = substr($bc, $i, 1);
108
+			if ((ord($c) != 0) && (ord($c) != 13)) {
109
+			  $fc = $fc.$c;
110 110
 			}
111 111
 		}
112
-		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254))
113
-		$fc = substr($fc,2);
112
+		if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254))
113
+		$fc = substr($fc, 2);
114 114
 		return ($fc);
115 115
 }
116 116
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 * @param string $path_to_file
123 123
 	 * @return array of arrays. Top-level array has rows, second-level array has each item
124 124
 	 */
125
-	public function import_csv_to_multi_dimensional_array($path_to_file){
125
+	public function import_csv_to_multi_dimensional_array($path_to_file) {
126 126
 		// needed to deal with Mac line endings
127
-		ini_set('auto_detect_line_endings',TRUE);
127
+		ini_set('auto_detect_line_endings', TRUE);
128 128
 
129 129
 		// because fgetcsv does not correctly deal with backslashed quotes such as \"
130 130
 		// we'll read the file into a string
131
-		$file_contents = $this->read_unicode_file( $path_to_file );
131
+		$file_contents = $this->read_unicode_file($path_to_file);
132 132
 		// replace backslashed quotes with CSV enclosures
133
-		$file_contents = str_replace ( '\\"', '"""', $file_contents );
133
+		$file_contents = str_replace('\\"', '"""', $file_contents);
134 134
 		// HEY YOU! PUT THAT FILE BACK!!!
135 135
 		file_put_contents($path_to_file, $file_contents);
136 136
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 			$csvarray = array();
141 141
 
142 142
 			// in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what?
143
-			if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
143
+			if (version_compare(PHP_VERSION, '5.3.0') < 0) {
144 144
 
145 145
 				//  PHP 5.2- version
146 146
 
147 147
 				// loop through each row of the file
148
-				while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){
149
-					$csvarray[]= $data;
148
+				while (($data = fgetcsv($file_handle, 0, ',', '"')) !== FALSE) {
149
+					$csvarray[] = $data;
150 150
 				}
151
-			}else{
151
+			} else {
152 152
 				// loop through each row of the file
153
-				while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) {
154
-					$csvarray[]=$data;
153
+				while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== FALSE) {
154
+					$csvarray[] = $data;
155 155
 				}
156 156
 			}
157 157
 			# Close the File.
158 158
 			fclose($file_handle);
159 159
 			return $csvarray;
160
-		}else{
161
-			EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ );
160
+		} else {
161
+			EE_Error::add_error(sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), __FILE__, __FUNCTION__, __LINE__);
162 162
 			return false;
163 163
 		}
164 164
 	}
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 *						...
189 189
 	 *						)
190 190
 	 */
191
-	public function import_csv_to_model_data_array( $path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE ) {
191
+	public function import_csv_to_model_data_array($path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE) {
192 192
 		$multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file);
193
-		if( ! $multi_dimensional_array ){
193
+		if ( ! $multi_dimensional_array) {
194 194
 			return false;
195 195
 		}
196 196
 		// gotta start somewhere
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		$ee_formatted_data = array();
200 200
 		// array to store headers (column names)
201 201
 		$headers = array();
202
-		foreach($multi_dimensional_array as $data){
202
+		foreach ($multi_dimensional_array as $data) {
203 203
 			// if first cell is MODEL, then second cell is the MODEL name
204
-			if ( $data[0]	== 'MODEL' ) {
204
+			if ($data[0] == 'MODEL') {
205 205
 				$model_name = $data[1];
206 206
 				//don't bother looking for model data in this row. The rest of this
207 207
 				//row should be blank
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 				$headers = array();
212 212
 				continue;
213 213
 			}
214
-			if( strpos( $data[0], EE_CSV::metadata_header ) !==FALSE ){
214
+			if (strpos($data[0], EE_CSV::metadata_header) !== FALSE) {
215 215
 				$model_name = EE_CSV::metadata_header;
216 216
 				//store like model data, we just won't try importing it etc.
217 217
 				$row = 1;
@@ -224,31 +224,31 @@  discard block
 block discarded – undo
224 224
 
225 225
 			$model_entry = array();
226 226
 			// loop through each column
227
-			for ( $i=0; $i < $columns; $i++ ) {
227
+			for ($i = 0; $i < $columns; $i++) {
228 228
 
229 229
 				//replace csv_enclosures with backslashed quotes
230
-				$data[$i] = str_replace ( '"""', '\\"', $data[$i] );
230
+				$data[$i] = str_replace('"""', '\\"', $data[$i]);
231 231
 				// do we need to grab the column names?
232
-				if ( $row === 1){
233
-					if( $first_row_is_headers ) {
232
+				if ($row === 1) {
233
+					if ($first_row_is_headers) {
234 234
 						// store the column names to use for keys
235 235
 						$column_name = $data[$i];
236 236
 						//check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end...
237
-						if(!$column_name){continue;}
237
+						if ( ! $column_name) {continue; }
238 238
 						$matches = array();
239
-						if($model_name == EE_CSV::metadata_header){
239
+						if ($model_name == EE_CSV::metadata_header) {
240 240
 							$headers[$i] = $column_name;
241
-						}else{
241
+						} else {
242 242
 							//now get the db table name from it (the part between square brackets)
243
-							$success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches);
244
-							if (!$success){
245
-								EE_Error::add_error( sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"),$column_name,implode(",",$data)), __FILE__, __FUNCTION__, __LINE__ );
243
+							$success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches);
244
+							if ( ! $success) {
245
+								EE_Error::add_error(sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"), $column_name, implode(",", $data)), __FILE__, __FUNCTION__, __LINE__);
246 246
 								return false;
247 247
 							}
248 248
 							$headers[$i] = $matches[2];
249 249
 						}
250 250
 
251
-					}else{
251
+					} else {
252 252
 						// no column names means our final array will just use counters for keys
253 253
 						$model_entry[$headers[$i]] = $data[$i];
254 254
 						$headers[$i] = $i;
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 					// and we need to store csv data
257 257
 				} else {
258 258
 					// this column isn' ta header, store it if there is a header for it
259
-					if(isset($headers[$i])){
259
+					if (isset($headers[$i])) {
260 260
 						$model_entry[$headers[$i]] = $data[$i];
261 261
 					}
262 262
 				}
263 263
 
264 264
 			}
265 265
 			//save the row's data IF it's a non-header-row
266
-			if( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)){
266
+			if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) {
267 267
 				$ee_formatted_data[$model_name][] = $model_entry;
268 268
 			}
269 269
 			// advance to next row
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 
285
-	public function save_csv_to_db( $csv_data_array, $model_name = FALSE ) {
286
-		EE_Error::doing_it_wrong('save_csv_to_db', __( 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso' ), '4.6.7' );
287
-		return EE_Import::instance()->save_csv_data_array_to_db( $csv_data_array, $model_name );
285
+	public function save_csv_to_db($csv_data_array, $model_name = FALSE) {
286
+		EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7');
287
+		return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name);
288 288
 	}
289 289
 
290 290
 	/**
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 * @param string $new_filename the name of the file that the user will download
295 295
 	 * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc.
296 296
 	 */
297
-	public function begin_sending_csv($filename){
297
+	public function begin_sending_csv($filename) {
298 298
 		// grab file extension
299 299
 		$ext = substr(strrchr($filename, '.'), 1);
300
-		if ( $ext == '.csv' or  $ext == '.xls' ) {
301
-			str_replace( $ext, '', $filename );
300
+		if ($ext == '.csv' or $ext == '.xls') {
301
+			str_replace($ext, '', $filename);
302 302
 		}
303 303
 		$filename .= '.csv';
304 304
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 //		header("Content-Type: application/download");
320 320
 		header('Content-disposition: attachment; filename='.$filename);
321 321
 		header("Content-Type: text/csv; charset=utf-8");
322
-                do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' );
323
-		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
322
+                do_action('AHEE__EE_CSV__begin_sending_csv__headers');
323
+		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF"); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
324 324
 		$fh = fopen('php://output', 'w');
325 325
 		return $fh;
326 326
 	}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 	 * mentioning the version and timezone
331 331
 	 * @param resource $filehandle
332 332
 	 */
333
-	public function write_metadata_to_csv($filehandle){
334
-		$data_row = array(EE_CSV::metadata_header);//do NOT translate because this exact string is used when importing
333
+	public function write_metadata_to_csv($filehandle) {
334
+		$data_row = array(EE_CSV::metadata_header); //do NOT translate because this exact string is used when importing
335 335
 		$this->fputcsv2($filehandle, $data_row);
336
-		$meta_data = array( 0=> array(
336
+		$meta_data = array(0=> array(
337 337
 			'version'=>espresso_version(),
338 338
 			'timezone'=>  EEH_DTT_Helper::get_timezone(),
339 339
 			'time_of_export'=>current_time('mysql'),
@@ -351,29 +351,29 @@  discard block
 block discarded – undo
351 351
 	 * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..."
352 352
 	 * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing)
353 353
 	 */
354
-	public function write_data_array_to_csv($filehandle, $data){
354
+	public function write_data_array_to_csv($filehandle, $data) {
355 355
 
356 356
 
357 357
 		//determine if $data is actually a 2d array
358
-		if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){
358
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
359 359
 			//make sure top level is numerically indexed,
360 360
 
361
-			if( EEH_Array::is_associative_array($data)){
362
-				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data))));
361
+			if (EEH_Array::is_associative_array($data)) {
362
+				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data))));
363 363
 			}
364 364
 			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
365 365
 			//now, is the last item in the top-level array of $data an associative or numeric array?
366
-			if(EEH_Array::is_associative_array($item_in_top_level_array)){
366
+			if (EEH_Array::is_associative_array($item_in_top_level_array)) {
367 367
 				//its associative, so we want to output its keys as column headers
368 368
 				$keys = array_keys($item_in_top_level_array);
369 369
 				echo $this->fputcsv2($filehandle, $keys);
370 370
 			}
371 371
 			//start writing data
372
-			foreach($data as $data_row){
372
+			foreach ($data as $data_row) {
373 373
 				echo $this->fputcsv2($filehandle, $data_row);
374 374
 			}
375 375
 			return true;
376
-		}else{
376
+		} else {
377 377
 			//no data TO write... so we can assume that's a success
378 378
 			return true;
379 379
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 * Calls exit to prevent polluting the CSV file with other junk
419 419
 	 * @param resource $fh filehandle where we're writing the CSV to
420 420
 	 */
421
-	public function end_sending_csv($fh){
421
+	public function end_sending_csv($fh) {
422 422
 		fclose($fh);
423 423
 		exit(0);
424 424
 	}
@@ -431,23 +431,23 @@  discard block
 block discarded – undo
431 431
 	 * has all the attributes o fthat model object (eg, the event's id, name, etc)
432 432
 	 * @return boolean success
433 433
 	 */
434
-	public function write_model_data_to_csv($filehandle,$model_data_array){
434
+	public function write_model_data_to_csv($filehandle, $model_data_array) {
435 435
 		$this->write_metadata_to_csv($filehandle);
436
-		foreach($model_data_array as $model_name => $model_instance_arrays){
436
+		foreach ($model_data_array as $model_name => $model_instance_arrays) {
437 437
 			//first: output a special row stating the model
438
-			echo $this->fputcsv2($filehandle,array('MODEL',$model_name));
438
+			echo $this->fputcsv2($filehandle, array('MODEL', $model_name));
439 439
 			//if we have items to put in the CSV, do it normally
440 440
 
441
-			if( ! empty($model_instance_arrays) ){
441
+			if ( ! empty($model_instance_arrays)) {
442 442
 				$this->write_data_array_to_csv($filehandle, $model_instance_arrays);
443
-			}else{
443
+			} else {
444 444
 //				echo "no data to write... so just write the headers";
445 445
 				//so there's actually NO model objects for that model.
446 446
 				//probably still want to show the columns
447 447
 				$model = EE_Registry::instance()->load_model($model_name);
448 448
 				$column_names = array();
449
-				foreach($model->field_settings() as $field){
450
-					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null ;
449
+				foreach ($model->field_settings() as $field) {
450
+					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null;
451 451
 				}
452 452
 				$this->write_data_array_to_csv($filehandle, array($column_names));
453 453
 			}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv()
462 462
 	 * @return bool | void writes CSV file to output and dies
463 463
 	 */
464
-	public function export_multiple_model_data_to_csv($filename,$model_data_array){
464
+	public function export_multiple_model_data_to_csv($filename, $model_data_array) {
465 465
 		$filehandle = $this->begin_sending_csv($filename);
466 466
 		$this->write_model_data_to_csv($filehandle, $model_data_array);
467 467
 		$this->end_sending_csv($filehandle);
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 	 *			@param string $filename - name for newly created csv file
474 474
 	 *			@return TRUE on success, FALSE on fail
475 475
 	 */
476
-	public function export_array_to_csv( $data = FALSE, $filename = FALSE  ) {
476
+	public function export_array_to_csv($data = FALSE, $filename = FALSE) {
477 477
 
478 478
 		// no data file?? get outta here
479
-		if ( ! $data or ! is_array( $data ) or empty( $data ) ) {
479
+		if ( ! $data or ! is_array($data) or empty($data)) {
480 480
 			return FALSE;
481 481
 		}
482 482
 
483 483
 		// no filename?? get outta here
484
-		if ( ! $filename ) {
484
+		if ( ! $filename) {
485 485
 			return FALSE;
486 486
 		}
487 487
 
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	 *			@param int $percent_of_max - desired percentage of the max upload_mb
508 508
 	 *			@return int KB
509 509
 	 */
510
-	public function get_max_upload_size ( $percent_of_max = FALSE ) {
510
+	public function get_max_upload_size($percent_of_max = FALSE) {
511 511
 
512
-		$max_upload = (int)(ini_get('upload_max_filesize'));
513
-		$max_post = (int)(ini_get('post_max_size'));
514
-		$memory_limit = (int)(ini_get('memory_limit'));
512
+		$max_upload = (int) (ini_get('upload_max_filesize'));
513
+		$max_post = (int) (ini_get('post_max_size'));
514
+		$memory_limit = (int) (ini_get('memory_limit'));
515 515
 
516 516
 		// determine the smallest of the three values from above
517 517
 		$upload_mb = min($max_upload, $max_post, $memory_limit);
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
 		$upload_mb = $upload_mb * 1024;
521 521
 
522 522
 		// don't want the full monty? then reduce the max uplaod size
523
-		if ( $percent_of_max ) {
523
+		if ($percent_of_max) {
524 524
 			// is percent_of_max like this -> 50 or like this -> 0.50 ?
525
-			if ( $percent_of_max > 1 ) {
525
+			if ($percent_of_max > 1) {
526 526
 				// chnages 50 to 0.50
527 527
 				$percent_of_max = $percent_of_max / 100;
528 528
 			}
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 	 *			@param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
545 545
 	 *			@return void
546 546
 	 */
547
-	private function fputcsv2 ($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
547
+	private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
548 548
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
549
-		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
550
-		$enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure );
549
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
550
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
551 551
 
552 552
 		$delimiter_esc = preg_quote($delimiter, '/');
553 553
 		$enclosure_esc = preg_quote($enclosure, '/');
554 554
 
555 555
 		$output = array();
556 556
 		foreach ($row as $field_value) {
557
-			if(is_object($field_value) || is_array($field_value)){
557
+			if (is_object($field_value) || is_array($field_value)) {
558 558
 				$field_value = serialize($field_value);
559 559
 			}
560 560
 			if ($field_value === null && $mysql_null) {
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
 			}
564 564
 
565 565
 			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
566
-				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
566
+				($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
567 567
 		}
568 568
 
569
-		fwrite($fh, join($delimiter, $output) . PHP_EOL);
569
+		fwrite($fh, join($delimiter, $output).PHP_EOL);
570 570
 	}
571 571
 
572 572
 
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 	 * @param string $current_format
605 605
 	 * @return string
606 606
 	 */
607
-	public function get_date_format_for_csv( $current_format = null ) {
608
-		return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format );
607
+	public function get_date_format_for_csv($current_format = null) {
608
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
609 609
 	}
610 610
 
611 611
 	/**
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * @param string $current_format
614 614
 	 * @return string
615 615
 	 */
616
-	public function get_time_format_for_csv( $current_format = null ) {
617
-		return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format );
616
+	public function get_time_format_for_csv($current_format = null) {
617
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
618 618
 	}
619 619
 
620 620
 
Please login to merge, or discard this patch.
core/db_classes/EE_Currency_Payment_Method.class.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	 * @param array $props_n_values  incoming values from the database
60 60
 	 * @param string $timezone  incoming timezone as set by the model.  If not set the timezone for
61 61
 	 *                          		the website will be used.
62
-	 * @return EE_Attendee
62
+	 * @return EE_Currency_Payment_Method
63 63
 	 */
64 64
 	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
65 65
 		return new self( $props_n_values, TRUE, $timezone );
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 /**
6 7
  * Event Espresso
7 8
  *
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * ------------------------------------------------------------------------
28 28
  */
29
-class EE_Currency_Payment_Method extends EE_Base_Class{
29
+class EE_Currency_Payment_Method extends EE_Base_Class {
30 30
 
31 31
 	/** Currency to Payment Method Link ID @var CPM_ID*/
32 32
 	protected $_CPM_ID = NULL;
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 *                             		    date_format and the second value is the time format
49 49
 	 * @return EE_Attendee
50 50
 	 */
51
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
52
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
53
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
51
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
52
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
53
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
54 54
 	}
55 55
 
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 *                          		the website will be used.
62 62
 	 * @return EE_Attendee
63 63
 	 */
64
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
65
-		return new self( $props_n_values, TRUE, $timezone );
64
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
65
+		return new self($props_n_values, TRUE, $timezone);
66 66
 	}
67 67
 
68 68
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime_Ticket.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 	 * @param array $props_n_values  incoming values from the database
47 47
 	 * @param string $timezone  incoming timezone as set by the model.  If not set the timezone for
48 48
 	 *                          		the website will be used.
49
-	 * @return EE_Attendee
49
+	 * @return EE_Datetime_Ticket
50 50
 	 */
51 51
 	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
52 52
 		return new self( $props_n_values, TRUE, $timezone );
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *                             		    date_format and the second value is the time format
36 36
 	 * @return EE_Attendee
37 37
 	 */
38
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
39
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
40
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
38
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
40
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
41 41
 	}
42 42
 
43 43
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *                          		the website will be used.
49 49
 	 * @return EE_Attendee
50 50
 	 */
51
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
52
-		return new self( $props_n_values, TRUE, $timezone );
51
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
52
+		return new self($props_n_values, TRUE, $timezone);
53 53
 	}
54 54
 } //end EE_Datetime_Ticket class
Please login to merge, or discard this patch.
core/db_classes/EE_Export.class.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 *			@Export Event Espresso data - routes export requests
71 71
 	 *		  @access public
72
-	 *			@return void | bool
72
+	 *			@return false|null | bool
73 73
 	 */
74 74
 	public function export() {
75 75
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	 *	@recursive function for exporting table data and merging the results with the next results
606 606
 	 *	@access private
607 607
 	 *	@param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all
608
-	 *	@return array on success, FALSE on fail
608
+	 *	@return boolean on success, FALSE on fail
609 609
 	 */
610 610
 	private function _get_export_data_for_models( $models_to_export = array() ) {
611 611
 		$table_data = FALSE;
Please login to merge, or discard this patch.
Braces   +18 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
3 5
 /**
4 6
  * EE_Export class
@@ -256,10 +258,10 @@  discard block
 block discarded – undo
256 258
 				if( $field_name == 'STA_ID' ){
257 259
 					$state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' );
258 260
 					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
259
-				}elseif( $field_name == 'CNT_ISO' ){
261
+				} elseif( $field_name == 'CNT_ISO' ){
260 262
 					$country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' );
261 263
 					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
262
-				}else{
264
+				} else{
263 265
 					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
264 266
 				}
265 267
 			}
@@ -313,9 +315,9 @@  discard block
 block discarded – undo
313 315
 		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
314 316
 		if( $pretty_schema === true){
315 317
 			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
316
-		}elseif( is_string( $pretty_schema ) ) {
318
+		} elseif( is_string( $pretty_schema ) ) {
317 319
 			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
318
-		}else{
320
+		} else{
319 321
 			return $field_obj->prepare_for_get( $value_on_model_obj );
320 322
 		}
321 323
 	}
@@ -370,7 +372,7 @@  discard block
 block discarded – undo
370 372
 		);
371 373
 		if( $event_id ){
372 374
 			$query_params[0]['EVT_ID'] =  $event_id;
373
-		}else{
375
+		} else{
374 376
 			$query_params[ 'force_join' ][] = 'Event';
375 377
 		}
376 378
 		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
@@ -394,11 +396,11 @@  discard block
 block discarded – undo
394 396
 					$field = $reg_model->field_settings_for($field_name);
395 397
 					if($field_name == 'REG_final_price'){
396 398
 						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
397
-					}elseif( $field_name == 'REG_count' ){
399
+					} elseif( $field_name == 'REG_count' ){
398 400
 						$value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
399
-					}elseif( $field_name == 'REG_date' ) {
401
+					} elseif( $field_name == 'REG_date' ) {
400 402
 						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
401
-					}else{
403
+					} else{
402 404
 						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
403 405
 					}
404 406
 					$reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
@@ -470,12 +472,12 @@  discard block
 block discarded – undo
470 472
 					if( $reg_row[ 'Attendee_CPT.ID' ]){
471 473
 						if($att_field_name == 'STA_ID'){
472 474
 							$value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
473
-						}elseif($att_field_name == 'CNT_ISO'){
475
+						} elseif($att_field_name == 'CNT_ISO'){
474 476
 							$value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
475
-						}else{
477
+						} else{
476 478
 							$value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
477 479
 						}
478
-					}else{
480
+					} else{
479 481
 						$value = '';
480 482
 					}
481 483
 
@@ -493,7 +495,7 @@  discard block
 block discarded – undo
493 495
 					/* @var $answer EE_Answer */
494 496
 					if( $answer_row[ 'Question.QST_ID' ] ){
495 497
 						$question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] );
496
-					}else{
498
+					} else{
497 499
 						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
498 500
 					}
499 501
 					$reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
@@ -523,7 +525,7 @@  discard block
 block discarded – undo
523 525
 			if( ! $event_slug ) {
524 526
 				$event_slug = __( 'unknown', 'event_espresso' );
525 527
 			}
526
-		}else{
528
+		} else{
527 529
 			$event_slug = __( 'all', 'event_espresso' );
528 530
 		}
529 531
 		$filename = sprintf( "registrations-for-%s", $event_slug );
@@ -593,7 +595,7 @@  discard block
 block discarded – undo
593 595
 			$filename = get_bloginfo('name') . '-' . $export_name;
594 596
 			$filename = sanitize_key( $filename ) . '-' . $this->today;
595 597
 			return $filename;
596
-		}	 else {
598
+		} else {
597 599
 			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
598 600
 		}
599 601
 		return false;
@@ -629,8 +631,7 @@  discard block
 block discarded – undo
629 631
 //							$field->set_date_format('Y-m-d');
630 632
 //							$field->set_time_format('H:i:s');
631 633
 							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s');
632
-						}
633
-						else{
634
+						} else{
634 635
 							$model_data_array[$column_name] = $model_object->get($field->get_name());
635 636
 						}
636 637
 					}
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -500,11 +500,11 @@
 block discarded – undo
500 500
 					}else{
501 501
 						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
502 502
 					}
503
-                                        if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) {
504
-                                            $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] );
505
-                                        } else {
506
-                                            $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
507
-                                        }
503
+										if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) {
504
+											$reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] );
505
+										} else {
506
+											$reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
507
+										}
508 508
 				}
509 509
 				$registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row );
510 510
 			}
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * EE_Export class
5 5
  * 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	  * @access private
40 40
 	  * @param array $request_data
41 41
 	  */
42
- 	private function __construct( $request_data = array() ) {
42
+ 	private function __construct($request_data = array()) {
43 43
 		$this->_req_data = $request_data;
44
-		$this->today = date("Y-m-d",time());
45
-		require_once( EE_CLASSES . 'EE_CSV.class.php' );
46
-		$this->EE_CSV= EE_CSV::instance();
44
+		$this->today = date("Y-m-d", time());
45
+		require_once(EE_CLASSES.'EE_CSV.class.php');
46
+		$this->EE_CSV = EE_CSV::instance();
47 47
 	}
48 48
 
49 49
 
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	  * @param array $request_data
56 56
 	  * @return \EE_Export
57 57
 	  */
58
-	public static function instance( $request_data = array() ) {
58
+	public static function instance($request_data = array()) {
59 59
 		// check if class object is instantiated
60
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) {
61
-			self::$_instance = new self( $request_data );
60
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) {
61
+			self::$_instance = new self($request_data);
62 62
 		}
63 63
 		return self::$_instance;
64 64
 	}
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	public function export() {
73 73
 
74 74
 		// in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword
75
-		if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) {
75
+		if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) {
76 76
 			// check if action2 has export action
77
-			if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) {
77
+			if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) {
78 78
 				// whoop! there it is!
79 79
 				$this->_req_data['action'] = $this->_req_data['action2'];
80 80
 			}
81 81
 		}
82 82
 
83
-		$this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : '';
83
+		$this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : '';
84 84
 
85 85
 		switch ($this->_req_data['export']) {
86 86
 			case 'report':
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 					break;
95 95
 
96 96
 					case 'registrations_report_for_event':
97
-						$this->report_registrations_for_event( $this->_req_data['EVT_ID'] );
97
+						$this->report_registrations_for_event($this->_req_data['EVT_ID']);
98 98
 					break;
99 99
 
100 100
 					case 'attendees':
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 					break;
107 107
 
108 108
 					default:
109
-						EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ;
109
+						EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
110 110
 						return FALSE;
111 111
 					break;
112 112
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * Downloads a CSV file with all the columns, but no data. This should be used for importing
125 125
 	 * @return null kills execution
126 126
 	 */
127
-	function export_sample(){
127
+	function export_sample() {
128 128
 		$event = EEM_Event::instance()->get_one();
129 129
 		$this->_req_data['EVT_ID'] = $event->ID();
130 130
 		$this->export_all_event_data();
@@ -150,23 +150,23 @@  discard block
 block discarded – undo
150 150
 		$state_country_query_params = array();
151 151
 		$question_group_query_params = array();
152 152
 		$question_query_params = array();
153
-		if ( isset( $this->_req_data['EVT_ID'] )) {
153
+		if (isset($this->_req_data['EVT_ID'])) {
154 154
 			// do we have an array of IDs ?
155 155
 
156
-			if ( is_array( $this->_req_data['EVT_ID'] )) {
157
-				$EVT_IDs =  array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] );
158
-				$value_to_equal = array('IN',$EVT_IDs);
156
+			if (is_array($this->_req_data['EVT_ID'])) {
157
+				$EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']);
158
+				$value_to_equal = array('IN', $EVT_IDs);
159 159
 				$filename = 'events';
160 160
 			} else {
161 161
 				// generate regular where = clause
162
-				$EVT_ID = absint( $this->_req_data['EVT_ID'] );
162
+				$EVT_ID = absint($this->_req_data['EVT_ID']);
163 163
 				$value_to_equal = $EVT_ID;
164 164
 				$event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID);
165 165
 
166
-				$filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) );
166
+				$filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso'));
167 167
 
168 168
 			}
169
-			$event_query_params[0]['EVT_ID'] =$value_to_equal;
169
+			$event_query_params[0]['EVT_ID'] = $value_to_equal;
170 170
 			$related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal;
171 171
 			$related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal;
172 172
 			$datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal;
@@ -210,42 +210,42 @@  discard block
 block discarded – undo
210 210
 
211 211
 			);
212 212
 
213
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
213
+		$model_data = $this->_get_export_data_for_models($models_to_export);
214 214
 
215
-		$filename = $this->generate_filename ( $filename );
215
+		$filename = $this->generate_filename($filename);
216 216
 
217
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
218
-			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
217
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
218
+			EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
219 219
 		}
220 220
 	}
221 221
 
222
-	function report_attendees(){
222
+	function report_attendees() {
223 223
 		$attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( 
224 224
 			array( 
225
-				'force_join' => array( 'State', 'Country' ), 
225
+				'force_join' => array('State', 'Country'), 
226 226
 				'caps' => EEM_Base::caps_read_admin 
227 227
 			) 
228 228
 		);
229 229
 		$csv_data = array();
230
-		foreach( $attendee_rows as $attendee_row ){
230
+		foreach ($attendee_rows as $attendee_row) {
231 231
 			$csv_row = array();
232
-			foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){
233
-				if( $field_name == 'STA_ID' ){
234
-					$state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' );
235
-					$csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ];
236
-				}elseif( $field_name == 'CNT_ISO' ){
237
-					$country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' );
238
-					$csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ];
239
-				}else{
240
-					$csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ];
232
+			foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) {
233
+				if ($field_name == 'STA_ID') {
234
+					$state_name_field = EEM_State::instance()->field_settings_for('STA_name');
235
+					$csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()];
236
+				}elseif ($field_name == 'CNT_ISO') {
237
+					$country_name_field = EEM_Country::instance()->field_settings_for('CNT_name');
238
+					$csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()];
239
+				} else {
240
+					$csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()];
241 241
 				}
242 242
 			}
243 243
 			$csv_data[] = $csv_row;
244 244
 		}
245 245
 
246
-		$filename = $this->generate_filename ( 'contact-list-report' );
246
+		$filename = $this->generate_filename('contact-list-report');
247 247
 
248
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
248
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
249 249
 		$this->EE_CSV->write_data_array_to_csv($handle, $csv_data);
250 250
 		$this->EE_CSV->end_sending_csv($handle);
251 251
 	}
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 		$countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL'))));
263 263
 //		$states_to_export_query_params
264 264
 		$models_to_export = array(
265
-			'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))),
266
-			'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))),
265
+			'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))),
266
+			'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))),
267 267
 			'Attendee'=>array(),
268 268
 		);
269 269
 
270 270
 
271 271
 
272
-		$model_data = $this->_get_export_data_for_models( $models_to_export );
273
-		$filename = $this->generate_filename ( 'all-attendees' );
272
+		$model_data = $this->_get_export_data_for_models($models_to_export);
273
+		$filename = $this->generate_filename('all-attendees');
274 274
 
275
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) {
276
-			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
275
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) {
276
+			EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
277 277
 		}
278 278
 	}
279 279
 
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
 	 * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty
286 286
 	 * @return string
287 287
 	 */
288
-	protected function _prepare_value_from_db_for_display( $model, $field_name,  $raw_db_value, $pretty_schema = true ) {
289
-		$field_obj = $model->field_settings_for( $field_name );
290
-		$value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value );
291
-		if( $field_obj instanceof EE_Datetime_Field ) {
292
-			$field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema );
293
-			$field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema );
288
+	protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) {
289
+		$field_obj = $model->field_settings_for($field_name);
290
+		$value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value);
291
+		if ($field_obj instanceof EE_Datetime_Field) {
292
+			$field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema);
293
+			$field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema);
294 294
 		}
295
-		if( $pretty_schema === true){
296
-			return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj );
297
-		}elseif( is_string( $pretty_schema ) ) {
298
-			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema );
299
-		}else{
300
-			return $field_obj->prepare_for_get( $value_on_model_obj );
295
+		if ($pretty_schema === true) {
296
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj);
297
+		}elseif (is_string($pretty_schema)) {
298
+			return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema);
299
+		} else {
300
+			return $field_obj->prepare_for_get($value_on_model_obj);
301 301
 		}
302 302
 	}
303 303
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * and the questions associated with the registrations
307 307
 	 * @param int $event_id
308 308
 	 */
309
-	function report_registrations_for_event( $event_id = NULL ){
309
+	function report_registrations_for_event($event_id = NULL) {
310 310
 		$reg_fields_to_include = array(
311 311
 				'TXN_ID',
312 312
 				'ATT_ID',
@@ -338,126 +338,126 @@  discard block
 block discarded – undo
338 338
 				array(
339 339
 					'OR' => array(
340 340
 						//don't include registrations from failed or abandoned transactions...
341
-						'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ),
341
+						'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)),
342 342
 						//unless the registration is approved, in which case include it regardless of transaction status
343 343
 						'STS_ID' => EEM_Registration::status_id_approved
344 344
 						),
345
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
345
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
346 346
 					),
347
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
348
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
347
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
348
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
349 349
 				'caps' => EEM_Base::caps_read_admin
350 350
 			),
351 351
 			$event_id
352 352
 		);
353
-		if( $event_id ){
354
-			$query_params[0]['EVT_ID'] =  $event_id;
355
-		}else{
356
-			$query_params[ 'force_join' ][] = 'Event';
353
+		if ($event_id) {
354
+			$query_params[0]['EVT_ID'] = $event_id;
355
+		} else {
356
+			$query_params['force_join'][] = 'Event';
357 357
 		}
358
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
358
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
359 359
 		//get all questions which relate to someone in this group
360 360
 		$registration_ids = array();
361
-		foreach( $registration_rows as $reg_row ) {
362
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
361
+		foreach ($registration_rows as $reg_row) {
362
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
363 363
 		}
364 364
 //		EEM_Question::instance()->show_next_x_db_queries();
365
-		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids))));
366
-		foreach($registration_rows as $reg_row){
367
-			if ( is_array( $reg_row ) ) {
365
+		$questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids))));
366
+		foreach ($registration_rows as $reg_row) {
367
+			if (is_array($reg_row)) {
368 368
 				$reg_csv_array = array();
369
-				if( ! $event_id ){
369
+				if ( ! $event_id) {
370 370
 					//get the event's name and Id
371
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
371
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
372 372
 				}
373
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
373
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
374 374
 				/*@var $reg_row EE_Registration */
375
-				foreach($reg_fields_to_include as $field_name){
375
+				foreach ($reg_fields_to_include as $field_name) {
376 376
 					$field = $reg_model->field_settings_for($field_name);
377
-					if($field_name == 'REG_final_price'){
378
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
379
-					}elseif( $field_name == 'REG_count' ){
380
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
381
-					}elseif( $field_name == 'REG_date' ) {
382
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
383
-					}else{
384
-						$value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
377
+					if ($field_name == 'REG_final_price') {
378
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
379
+					}elseif ($field_name == 'REG_count') {
380
+						$value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
381
+					}elseif ($field_name == 'REG_date') {
382
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
383
+					} else {
384
+						$value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
385 385
 					}
386 386
 					$reg_csv_array[$this->_get_column_name_for_field($field)] = $value;
387
-					if($field_name == 'REG_final_price'){
387
+					if ($field_name == 'REG_final_price') {
388 388
 						//add a column named Currency after the final price
389 389
 						$reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code;
390 390
 					}
391 391
 				}
392 392
 				//get pretty status
393
-				$stati = EEM_Status::instance()->localized_status( array(
394
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
395
-					$reg_row[ 'TransactionTable.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
393
+				$stati = EEM_Status::instance()->localized_status(array(
394
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
395
+					$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso') ),
396 396
 						FALSE,
397
-						'sentence' );
398
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
397
+						'sentence');
398
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
399 399
 				//get pretty trnasaction status
400
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'TransactionTable.STS_ID' ] ];
401
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'TransactionTable.TXN_total' ], 'localized_float' ) : '0.00';
402
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'TransactionTable.TXN_paid' ], 'localized_float' ) : '0.00';
400
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']];
401
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00';
402
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00';
403 403
 				$payment_methods = array();
404 404
 				$gateway_txn_ids_etc = array();
405 405
 				$payment_times = array();
406
-				if( $is_primary_reg && $reg_row[ 'TransactionTable.TXN_ID' ] ){
406
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
407 407
 					$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
408 408
 							array(
409 409
 								array(
410
-									'TXN_ID' => $reg_row[ 'TransactionTable.TXN_ID' ],
410
+									'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
411 411
 									'STS_ID' => EEM_Payment::status_id_approved
412 412
 								),
413
-								'force_join' => array( 'Payment_Method' ),
413
+								'force_join' => array('Payment_Method'),
414 414
 
415 415
 							),
416 416
 							ARRAY_A,
417 417
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
418 418
 
419
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
420
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
421
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
422
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
419
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
420
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
421
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
422
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
423 423
 					}
424 424
 
425 425
 				}
426
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
427
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
428
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
426
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
427
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
428
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
429 429
 
430 430
 				//get whether or not the user has checked in
431
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
431
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
432 432
 				//get ticket of registration and its price
433 433
 				$ticket_model = EE_Registry::instance()->load_model('Ticket');
434
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
435
-					$ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
434
+				if ($reg_row['Ticket.TKT_ID']) {
435
+					$ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
436 436
 					$datetimes_strings = array();
437
-					foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
438
-						$datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
437
+					foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
438
+						$datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
439 439
 					}
440 440
 
441 441
 				} else {
442
-					$ticket_name = __( 'Unknown', 'event_espresso' );
443
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
442
+					$ticket_name = __('Unknown', 'event_espresso');
443
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
444 444
 				}
445 445
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
446 446
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
447 447
 				//get datetime(s) of registration
448 448
 
449 449
 				//add attendee columns
450
-				foreach($att_fields_to_include as $att_field_name){
450
+				foreach ($att_fields_to_include as $att_field_name) {
451 451
 					$field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
452
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
453
-						if($att_field_name == 'STA_ID'){
454
-							$value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
455
-						}elseif($att_field_name == 'CNT_ISO'){
456
-							$value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
457
-						}else{
458
-							$value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
452
+					if ($reg_row['Attendee_CPT.ID']) {
453
+						if ($att_field_name == 'STA_ID') {
454
+							$value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
455
+						}elseif ($att_field_name == 'CNT_ISO') {
456
+							$value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
457
+						} else {
458
+							$value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
459 459
 						}
460
-					}else{
460
+					} else {
461 461
 						$value = '';
462 462
 					}
463 463
 
@@ -465,56 +465,56 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 
467 467
 				//make sure each registration has the same questions in the same order
468
-				foreach($questions_for_these_regs_rows as $question_row){
469
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
470
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
468
+				foreach ($questions_for_these_regs_rows as $question_row) {
469
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
470
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
471 471
 					}
472 472
 				}
473 473
 				//now fill out the questions THEY answered
474
-				foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){
474
+				foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) {
475 475
 					/* @var $answer EE_Answer */
476
-					if( $answer_row[ 'Question.QST_ID' ] ){
477
-						$question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] );
478
-					}else{
479
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
476
+					if ($answer_row['Question.QST_ID']) {
477
+						$question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']);
478
+					} else {
479
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
480 480
 					}
481
-                                        if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) {
482
-                                            $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] );
481
+                                        if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) {
482
+                                            $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']);
483 483
                                         } else {
484
-                                            $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] );
484
+                                            $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']);
485 485
                                         }
486 486
 				}
487
-				$registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row );
487
+				$registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row);
488 488
 			}
489 489
 		}
490 490
 
491 491
 		//if we couldn't export anything, we want to at least show the column headers
492
-		if(empty($registrations_csv_ready_array)){
492
+		if (empty($registrations_csv_ready_array)) {
493 493
 			$reg_csv_array = array();
494 494
 			$model_and_fields_to_include = array(
495 495
 				'Registration' => $reg_fields_to_include,
496 496
 				'Attendee' => $att_fields_to_include
497 497
 			);
498
-			foreach($model_and_fields_to_include as $model_name => $field_list){
498
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
499 499
 				$model = EE_Registry::instance()->load_model($model_name);
500
-				foreach($field_list as $field_name){
500
+				foreach ($field_list as $field_name) {
501 501
 					$field = $model->field_settings_for($field_name);
502
-					$reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name());
502
+					$reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name());
503 503
 				}
504 504
 			}
505 505
 			$registrations_csv_ready_array [] = $reg_csv_array;
506 506
 		}
507
-		if( $event_id ){
508
-			$event_slug =  EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
509
-			if( ! $event_slug ) {
510
-				$event_slug = __( 'unknown', 'event_espresso' );
507
+		if ($event_id) {
508
+			$event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
509
+			if ( ! $event_slug) {
510
+				$event_slug = __('unknown', 'event_espresso');
511 511
 			}
512
-		}else{
513
-			$event_slug = __( 'all', 'event_espresso' );
512
+		} else {
513
+			$event_slug = __('all', 'event_espresso');
514 514
 		}
515
-		$filename = sprintf( "registrations-for-%s", $event_slug );
515
+		$filename = sprintf("registrations-for-%s", $event_slug);
516 516
 
517
-		$handle = $this->EE_CSV->begin_sending_csv( $filename);
517
+		$handle = $this->EE_CSV->begin_sending_csv($filename);
518 518
 		$this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array);
519 519
 		$this->EE_CSV->end_sending_csv($handle);
520 520
 	}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @param EE_Model_Field_Base $field
525 525
 	 * @return string
526 526
 	 */
527
-	protected function _get_column_name_for_field(EE_Model_Field_Base $field){
527
+	protected function _get_column_name_for_field(EE_Model_Field_Base $field) {
528 528
 		return $field->get_nicename()."[".$field->get_name()."]";
529 529
 	}
530 530
 
@@ -537,17 +537,17 @@  discard block
 block discarded – undo
537 537
 	function export_categories() {
538 538
 		// are any Event IDs set?
539 539
 		$query_params = array();
540
-		if ( isset( $this->_req_data['EVT_CAT_ID'] )) {
540
+		if (isset($this->_req_data['EVT_CAT_ID'])) {
541 541
 			// do we have an array of IDs ?
542
-			if ( is_array( $this->_req_data['EVT_CAT_ID'] )) {
542
+			if (is_array($this->_req_data['EVT_CAT_ID'])) {
543 543
 				// generate an "IN (CSV)" where clause
544
-				$EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] );
544
+				$EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']);
545 545
 				$filename = 'event-categories';
546
-				$query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs);
546
+				$query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs);
547 547
 			} else {
548 548
 				// generate regular where = clause
549
-				$EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] );
550
-				$filename = 'event-category#' . $EVT_CAT_ID;
549
+				$EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']);
550
+				$filename = 'event-category#'.$EVT_CAT_ID;
551 551
 				$query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID;
552 552
 			}
553 553
 		} else {
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 				'Term_Taxonomy' => $query_params
560 560
 			);
561 561
 
562
-		$table_data = $this->_get_export_data_for_models( $tables_to_export );
563
-		$filename = $this->generate_filename ( $filename );
562
+		$table_data = $this->_get_export_data_for_models($tables_to_export);
563
+		$filename = $this->generate_filename($filename);
564 564
 
565
-		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) {
566
-			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
565
+		if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) {
566
+			EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
567 567
 		}
568 568
 	}
569 569
 
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
 	 *		  @param string - export_name
575 575
 	 *			@return string on success, FALSE on fail
576 576
 	 */
577
-	private function generate_filename ( $export_name = '' ) {
578
-		if ( $export_name != '' ) {
579
-			$filename = get_bloginfo('name') . '-' . $export_name;
580
-			$filename = sanitize_key( $filename ) . '-' . $this->today;
577
+	private function generate_filename($export_name = '') {
578
+		if ($export_name != '') {
579
+			$filename = get_bloginfo('name').'-'.$export_name;
580
+			$filename = sanitize_key($filename).'-'.$this->today;
581 581
 			return $filename;
582
-		}	 else {
583
-			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ );
582
+		} else {
583
+			EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
584 584
 		}
585 585
 		return false;
586 586
 	}
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 	 *	@param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all
594 594
 	 *	@return array on success, FALSE on fail
595 595
 	 */
596
-	private function _get_export_data_for_models( $models_to_export = array() ) {
596
+	private function _get_export_data_for_models($models_to_export = array()) {
597 597
 		$table_data = FALSE;
598
-		if ( is_array( $models_to_export ) ) {
599
-			foreach ( $models_to_export as $model_name => $query_params ) {
598
+		if (is_array($models_to_export)) {
599
+			foreach ($models_to_export as $model_name => $query_params) {
600 600
 				//check for a numerically-indexed array. in that case, $model_name is the value!!
601
-				if(is_int($model_name)){
601
+				if (is_int($model_name)) {
602 602
 					$model_name = $query_params;
603 603
 					$query_params = array();
604 604
 				}
@@ -606,17 +606,17 @@  discard block
 block discarded – undo
606 606
 				$model_objects = $model->get_all($query_params);
607 607
 
608 608
 				$table_data[$model_name] = array();
609
-				foreach($model_objects as $model_object){
609
+				foreach ($model_objects as $model_object) {
610 610
 					$model_data_array = array();
611 611
 					$fields = $model->field_settings();
612
-					foreach($fields as $field){
612
+					foreach ($fields as $field) {
613 613
 						$column_name = $field->get_nicename()."[".$field->get_name()."]";
614
-						if($field instanceof EE_Datetime_Field){
614
+						if ($field instanceof EE_Datetime_Field) {
615 615
 //							$field->set_date_format('Y-m-d');
616 616
 //							$field->set_time_format('H:i:s');
617
-							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s');
617
+							$model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s');
618 618
 						}
619
-						else{
619
+						else {
620 620
 							$model_data_array[$column_name] = $model_object->get($field->get_name());
621 621
 						}
622 622
 					}
Please login to merge, or discard this patch.
core/db_classes/EE_Import.class.php 4 patches
Doc Comments   +4 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,10 +79,6 @@  discard block
 block discarded – undo
79 79
 	 *	@ access 	public
80 80
 	 * 	@param 	string 		$title - heading for the form
81 81
 	 * 	@param 	string 		$intro - additional text explaing what to do
82
-	 * 	@param 	string 		$page - EE Admin page to direct form to - in the form "espresso_{pageslug}"
83
-	 * 	@param 	string 		$action - EE Admin page route array "action" that form will direct to
84
-	 * 	@param 	string 		$type - type of file to import
85
-	 *	@ return 	string
86 82
 	 */
87 83
 	public function upload_form ( $title, $intro, $form_url, $action, $type  ) {
88 84
 
@@ -121,7 +117,7 @@  discard block
 block discarded – undo
121 117
 	/**
122 118
 	 *	@Import Event Espresso data - some code "borrowed" from event espresso csv_import.php
123 119
 	 *	@access public
124
-	 *	@return boolean success
120
+	 *	@return boolean|null success
125 121
 	 */
126 122
 	public function import() {
127 123
 
@@ -269,8 +265,7 @@  discard block
 block discarded – undo
269 265
 	 * update that event, instead of adding a new event).
270 266
 	 *		  @access public
271 267
 	 *			@param array $csv_data_array - the array containing the csv data produced from EE_CSV::import_csv_to_model_data_array()
272
-	 *			@param array $fields_to_save - an array containing the csv column names as keys with the corresponding db table fields they will be saved to
273
-	 *			@return TRUE on success, FALSE on fail
268
+	 * @return boolean
274 269
 	 */
275 270
 	public function save_csv_data_array_to_db( $csv_data_array, $model_name = FALSE ) {
276 271
 
@@ -367,7 +362,7 @@  discard block
 block discarded – undo
367 362
 	 * we need to insert a new row for that ID, and then map from the non-existent ID
368 363
 	 * to the newly-inserted real ID.
369 364
 	 * @param type $csv_data_array
370
-	 * @param type $export_from_site_a_to_b
365
+	 * @param boolean $export_from_site_a_to_b
371 366
 	 * @param type $old_db_to_new_db_mapping
372 367
 	 * @return array updated $old_db_to_new_db_mapping
373 368
 	 */
@@ -484,7 +479,6 @@  discard block
 block discarded – undo
484 479
 	 * @param type $id_in_csv
485 480
 	 * @param type $model_object_data
486 481
 	 * @param EEM_Base $model
487
-	 * @param type $old_db_to_new_db_mapping
488 482
 	 * @return
489 483
 	 */
490 484
 	protected function _decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model ) {
@@ -594,7 +588,7 @@  discard block
 block discarded – undo
594 588
 	 * @param type $object_id
595 589
 	 * @param string $model_name
596 590
 	 * @param array $old_db_to_new_db_mapping
597
-	 * @param type $export_from_site_a_to_b
591
+	 * @param boolean $export_from_site_a_to_b
598 592
 	 * @return int
599 593
 	 */
600 594
 	protected function _find_mapping_in( $object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -131,43 +131,43 @@  discard block
 block discarded – undo
131 131
 		if ( isset( $_REQUEST['import'] )) {
132 132
 			if( isset( $_POST['csv_submitted'] )) {
133 133
 
134
-			    switch ( $_FILES['file']['error'][0] ) {
135
-			        case UPLOAD_ERR_OK:
136
-			            $error_msg = FALSE;
137
-			            break;
138
-			        case UPLOAD_ERR_INI_SIZE:
139
-			            $error_msg = __("'The uploaded file exceeds the upload_max_filesize directive in php.ini.'", "event_espresso");
140
-			            break;
141
-			        case UPLOAD_ERR_FORM_SIZE:
142
-			            $error_msg = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', "event_espresso");
143
-			            break;
144
-			        case UPLOAD_ERR_PARTIAL:
145
-			            $error_msg = __('The uploaded file was only partially uploaded.', "event_espresso");
146
-			            break;
147
-			        case UPLOAD_ERR_NO_FILE:
148
-			            $error_msg = __('No file was uploaded.', "event_espresso");
149
-			            break;
150
-			        case UPLOAD_ERR_NO_TMP_DIR:
151
-			            $error_msg = __('Missing a temporary folder.', "event_espresso");
152
-			            break;
153
-			        case UPLOAD_ERR_CANT_WRITE:
154
-			            $error_msg = __('Failed to write file to disk.', "event_espresso");
155
-			            break;
156
-			        case UPLOAD_ERR_EXTENSION:
157
-			            $error_msg = __('File upload stopped by extension.', "event_espresso");
158
-			            break;
159
-			        default:
160
-			            $error_msg = __('An unknown error occurred and the file could not be uploaded', "event_espresso");
161
-			            break;
162
-			    }
134
+				switch ( $_FILES['file']['error'][0] ) {
135
+					case UPLOAD_ERR_OK:
136
+						$error_msg = FALSE;
137
+						break;
138
+					case UPLOAD_ERR_INI_SIZE:
139
+						$error_msg = __("'The uploaded file exceeds the upload_max_filesize directive in php.ini.'", "event_espresso");
140
+						break;
141
+					case UPLOAD_ERR_FORM_SIZE:
142
+						$error_msg = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', "event_espresso");
143
+						break;
144
+					case UPLOAD_ERR_PARTIAL:
145
+						$error_msg = __('The uploaded file was only partially uploaded.', "event_espresso");
146
+						break;
147
+					case UPLOAD_ERR_NO_FILE:
148
+						$error_msg = __('No file was uploaded.', "event_espresso");
149
+						break;
150
+					case UPLOAD_ERR_NO_TMP_DIR:
151
+						$error_msg = __('Missing a temporary folder.', "event_espresso");
152
+						break;
153
+					case UPLOAD_ERR_CANT_WRITE:
154
+						$error_msg = __('Failed to write file to disk.', "event_espresso");
155
+						break;
156
+					case UPLOAD_ERR_EXTENSION:
157
+						$error_msg = __('File upload stopped by extension.', "event_espresso");
158
+						break;
159
+					default:
160
+						$error_msg = __('An unknown error occurred and the file could not be uploaded', "event_espresso");
161
+						break;
162
+				}
163 163
 
164 164
 				if ( ! $error_msg ) {
165 165
 
166
-				    $filename	= $_FILES['file']['name'][0];
166
+					$filename	= $_FILES['file']['name'][0];
167 167
 					$file_ext 		= substr( strrchr( $filename, '.' ), 1 );
168
-				    $file_type 	= $_FILES['file']['type'][0];
169
-				    $temp_file	= $_FILES['file']['tmp_name'][0];
170
-				    $filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
168
+					$file_type 	= $_FILES['file']['type'][0];
169
+					$temp_file	= $_FILES['file']['tmp_name'][0];
170
+					$filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
171 171
 
172 172
 					if ( $file_ext=='csv' ) {
173 173
 
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 			unset($csv_data_array[EE_CSV::metadata_header]);
303 303
 		}
304 304
 		/**
305
-		* @var $old_db_to_new_db_mapping 2d array: toplevel keys being model names, bottom-level keys being the original key, and
306
-		* the value will be the newly-inserted ID.
307
-		* If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
308
-		*/
305
+		 * @var $old_db_to_new_db_mapping 2d array: toplevel keys being model names, bottom-level keys being the original key, and
306
+		 * the value will be the newly-inserted ID.
307
+		 * If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
308
+		 */
309 309
 	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url),array());
310 310
 	   if( $old_db_to_new_db_mapping){
311 311
 		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"),$old_site_url,site_url()));
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3 3
 /**
4 4
  * EE_Import class
5 5
  *
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public static function instance() {
58 58
 		// check if class object is instantiated
59
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Import )) {
59
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Import)) {
60 60
 			self::$_instance = new self();
61 61
 		}
62 62
 		return self::$_instance;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * Resets the importer
67 67
 	 * @return EE_Import
68 68
 	 */
69
-	public static function reset(){
69
+	public static function reset() {
70 70
 		self::$_instance = null;
71 71
 		return self::instance();
72 72
 	}
@@ -84,27 +84,27 @@  discard block
 block discarded – undo
84 84
 	 * 	@param 	string 		$type - type of file to import
85 85
 	 *	@ return 	string
86 86
 	 */
87
-	public function upload_form ( $title, $intro, $form_url, $action, $type  ) {
87
+	public function upload_form($title, $intro, $form_url, $action, $type) {
88 88
 
89
-		$form_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => $action ), $form_url );
89
+		$form_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => $action), $form_url);
90 90
 
91 91
 		ob_start();
92 92
 ?>
93 93
 	<div class="ee-upload-form-dv">
94
-		<h3><?php echo $title;?></h3>
95
-		<p><?php echo $intro;?></p>
94
+		<h3><?php echo $title; ?></h3>
95
+		<p><?php echo $intro; ?></p>
96 96
 
97 97
 		<form action="<?php echo $form_url?>" method="post" enctype="multipart/form-data">
98
-			<input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time();?>">
99
-			<input name="import" type="hidden" value="<?php echo $type;?>" />
98
+			<input type="hidden" name="csv_submitted" value="TRUE" id="<?php echo time(); ?>">
99
+			<input name="import" type="hidden" value="<?php echo $type; ?>" />
100 100
 			<input type="file" name="file[]" size="90" >
101
-			<input class="button-primary" type="submit" value="<?php _e( 'Upload File', 'event_espresso' );?>">
101
+			<input class="button-primary" type="submit" value="<?php _e('Upload File', 'event_espresso'); ?>">
102 102
 		</form>
103 103
 
104 104
 		<p class="ee-attention">
105
-			<b><?php _e( 'Attention', 'event_espresso' );?></b><br/>
106
-			<?php echo sprintf( __( 'Accepts .%s file types only.', 'event_espresso' ), $type ) ;?>
107
-			<?php echo __( 'Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso' );?>
105
+			<b><?php _e('Attention', 'event_espresso'); ?></b><br/>
106
+			<?php echo sprintf(__('Accepts .%s file types only.', 'event_espresso'), $type); ?>
107
+			<?php echo __('Please only import CSV files exported from Event Espresso, or compatible 3rd-party software.', 'event_espresso'); ?>
108 108
 		</p>
109 109
 
110 110
 	</div>
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function import() {
127 127
 
128
-		require_once( EE_CLASSES . 'EE_CSV.class.php' );
128
+		require_once(EE_CLASSES.'EE_CSV.class.php');
129 129
 		$this->EE_CSV = EE_CSV::instance();
130 130
 
131
-		if ( isset( $_REQUEST['import'] )) {
132
-			if( isset( $_POST['csv_submitted'] )) {
131
+		if (isset($_REQUEST['import'])) {
132
+			if (isset($_POST['csv_submitted'])) {
133 133
 
134
-			    switch ( $_FILES['file']['error'][0] ) {
134
+			    switch ($_FILES['file']['error'][0]) {
135 135
 			        case UPLOAD_ERR_OK:
136 136
 			            $error_msg = FALSE;
137 137
 			            break;
@@ -161,32 +161,32 @@  discard block
 block discarded – undo
161 161
 			            break;
162 162
 			    }
163 163
 
164
-				if ( ! $error_msg ) {
164
+				if ( ! $error_msg) {
165 165
 
166
-				    $filename	= $_FILES['file']['name'][0];
167
-					$file_ext 		= substr( strrchr( $filename, '.' ), 1 );
168
-				    $file_type 	= $_FILES['file']['type'][0];
169
-				    $temp_file	= $_FILES['file']['tmp_name'][0];
170
-				    $filesize    	= $_FILES['file']['size'][0] / 1024;//convert from bytes to KB
166
+				    $filename = $_FILES['file']['name'][0];
167
+					$file_ext = substr(strrchr($filename, '.'), 1);
168
+				    $file_type = $_FILES['file']['type'][0];
169
+				    $temp_file = $_FILES['file']['tmp_name'][0];
170
+				    $filesize = $_FILES['file']['size'][0] / 1024; //convert from bytes to KB
171 171
 
172
-					if ( $file_ext=='csv' ) {
172
+					if ($file_ext == 'csv') {
173 173
 
174
-						$max_upload = $this->EE_CSV->get_max_upload_size();//max upload size in KB
175
-						if ( $filesize < $max_upload || true) {
174
+						$max_upload = $this->EE_CSV->get_max_upload_size(); //max upload size in KB
175
+						if ($filesize < $max_upload || true) {
176 176
 
177
-							$wp_upload_dir = str_replace( array( '\\', '/' ), DS, wp_upload_dir());
178
-							$path_to_file = $wp_upload_dir['basedir'] . DS . 'espresso' . DS . $filename;
177
+							$wp_upload_dir = str_replace(array('\\', '/'), DS, wp_upload_dir());
178
+							$path_to_file = $wp_upload_dir['basedir'].DS.'espresso'.DS.$filename;
179 179
 
180
-							if( move_uploaded_file( $temp_file, $path_to_file )) {
180
+							if (move_uploaded_file($temp_file, $path_to_file)) {
181 181
 
182 182
 								// convert csv to array
183
-								$this->csv_array = $this->EE_CSV->import_csv_to_model_data_array( $path_to_file );
183
+								$this->csv_array = $this->EE_CSV->import_csv_to_model_data_array($path_to_file);
184 184
 
185 185
 								// was data successfully stored in an array?
186
-								if ( is_array( $this->csv_array ) ) {
186
+								if (is_array($this->csv_array)) {
187 187
 
188
-									$import_what = str_replace( 'csv_import_', '', $_REQUEST['action'] );
189
-									$import_what = str_replace( '_', ' ', ucwords( $import_what ));
188
+									$import_what = str_replace('csv_import_', '', $_REQUEST['action']);
189
+									$import_what = str_replace('_', ' ', ucwords($import_what));
190 190
 									$processed_data = $this->csv_array;
191 191
 									$this->columns_to_save = FALSE;
192 192
 
@@ -205,33 +205,33 @@  discard block
 block discarded – undo
205 205
 
206 206
 									}
207 207
 									// save processed codes to db
208
-									if ( $this->save_csv_data_array_to_db( $processed_data, $this->columns_to_save ) ) {
208
+									if ($this->save_csv_data_array_to_db($processed_data, $this->columns_to_save)) {
209 209
 										return TRUE;
210 210
 
211 211
 									}
212 212
 								} else {
213 213
 									// no array? must be an error
214
-									EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
214
+									EE_Error::add_error(sprintf(__("No file seems to have been uploaded", "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
215 215
 									return FALSE;
216 216
 								}
217 217
 
218 218
 							} else {
219
-								EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ );
219
+								EE_Error::add_error(sprintf(__("%s was not successfully uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__);
220 220
 								return FALSE;
221 221
 							}
222 222
 
223 223
 						} else {
224
-							EE_Error::add_error( sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"),$filename,$max_upload), __FILE__, __FUNCTION__, __LINE__ );
224
+							EE_Error::add_error(sprintf(__("%s was too large of a file and could not be uploaded. The max filesize is %s' KB.", "event_espresso"), $filename, $max_upload), __FILE__, __FUNCTION__, __LINE__);
225 225
 							return FALSE;
226 226
 						}
227 227
 
228 228
 					} else {
229
-						EE_Error::add_error( sprintf(__("%s  had an invalid file extension, not uploaded", "event_espresso"),$filename), __FILE__, __FUNCTION__, __LINE__ );
229
+						EE_Error::add_error(sprintf(__("%s  had an invalid file extension, not uploaded", "event_espresso"), $filename), __FILE__, __FUNCTION__, __LINE__);
230 230
 						return FALSE;
231 231
 					}
232 232
 
233 233
 				} else {
234
-					EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
234
+					EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
235 235
 					return FALSE;
236 236
 				}
237 237
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 *			@param array $fields_to_save - an array containing the csv column names as keys with the corresponding db table fields they will be saved to
273 273
 	 *			@return TRUE on success, FALSE on fail
274 274
 	 */
275
-	public function save_csv_data_array_to_db( $csv_data_array, $model_name = FALSE ) {
275
+	public function save_csv_data_array_to_db($csv_data_array, $model_name = FALSE) {
276 276
 
277 277
 
278 278
 		$success = FALSE;
@@ -282,22 +282,22 @@  discard block
 block discarded – undo
282 282
 		$export_from_site_a_to_b = true;
283 283
 		// first level of array is not table information but a table name was passed to the function
284 284
 		// array is only two levels deep, so let's fix that by adding a level, else the next steps will fail
285
-		if($model_name){
285
+		if ($model_name) {
286 286
 			$csv_data_array = array($csv_data_array);
287 287
 		}
288 288
 		// begin looking through the $csv_data_array, expecting the toplevel key to be the model's name...
289 289
 		$old_site_url = 'none-specified';
290 290
 
291 291
 		//hanlde metadata
292
-		if(isset($csv_data_array[EE_CSV::metadata_header]) ){
292
+		if (isset($csv_data_array[EE_CSV::metadata_header])) {
293 293
 			$csv_metadata = array_shift($csv_data_array[EE_CSV::metadata_header]);
294 294
 			//ok so its metadata, dont try to save it to ehte db obviously...
295
-			if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){
295
+			if (isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()) {
296 296
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso")));
297 297
 				$export_from_site_a_to_b = false;
298
-			}else{
299
-				$old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
300
-				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url()));
298
+			} else {
299
+				$old_site_url = isset($csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
300
+				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"), $old_site_url, site_url()));
301 301
 			};
302 302
 			unset($csv_data_array[EE_CSV::metadata_header]);
303 303
 		}
@@ -306,40 +306,40 @@  discard block
 block discarded – undo
306 306
 		* the value will be the newly-inserted ID.
307 307
 		* If we have already imported data from the same website via CSV, it shoudl be kept in this wp option
308 308
 		*/
309
-	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url),array());
310
-	   if( $old_db_to_new_db_mapping){
311
-		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"),$old_site_url,site_url()));
309
+	   $old_db_to_new_db_mapping = get_option('ee_id_mapping_from'.sanitize_title($old_site_url), array());
310
+	   if ($old_db_to_new_db_mapping) {
311
+		   EE_Error::add_attention(sprintf(__("We noticed you have imported data via CSV from %s before. Because of this, IDs in your CSV have been mapped to their new IDs in %s", "event_espresso"), $old_site_url, site_url()));
312 312
 	   }
313 313
 	   $old_db_to_new_db_mapping = $this->save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping);
314 314
 
315 315
 		//save the mapping from old db to new db in case they try re-importing the same data from the same website again
316
-		update_option('ee_id_mapping_from'.sanitize_title($old_site_url),$old_db_to_new_db_mapping);
316
+		update_option('ee_id_mapping_from'.sanitize_title($old_site_url), $old_db_to_new_db_mapping);
317 317
 
318
-		if ( $this->_total_updates > 0 ) {
319
-			EE_Error::add_success( sprintf(__("%s existing records in the database were updated.", "event_espresso"),$this->_total_updates));
318
+		if ($this->_total_updates > 0) {
319
+			EE_Error::add_success(sprintf(__("%s existing records in the database were updated.", "event_espresso"), $this->_total_updates));
320 320
 			$success = true;
321 321
 		}
322
-		if ( $this->_total_inserts > 0 ) {
323
-			EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"),$this->_total_inserts));
322
+		if ($this->_total_inserts > 0) {
323
+			EE_Error::add_success(sprintf(__("%s new records were added to the database.", "event_espresso"), $this->_total_inserts));
324 324
 			$success = true;
325 325
 		}
326 326
 
327
-		if ( $this->_total_update_errors > 0 ) {
328
-			EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"),$this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__ );
327
+		if ($this->_total_update_errors > 0) {
328
+			EE_Error::add_error(sprintf(__("'One or more errors occurred, and a total of %s existing records in the database were <strong>not</strong> updated.'", "event_espresso"), $this->_total_update_errors), __FILE__, __FUNCTION__, __LINE__);
329 329
 			$error = true;
330 330
 		}
331
-		if ( $this->_total_insert_errors > 0 ) {
332
-			EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"),$this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__ );
331
+		if ($this->_total_insert_errors > 0) {
332
+			EE_Error::add_error(sprintf(__("One or more errors occurred, and a total of %s new records were <strong>not</strong> added to the database.'", "event_espresso"), $this->_total_insert_errors), __FILE__, __FUNCTION__, __LINE__);
333 333
 			$error = true;
334 334
 		}
335 335
 
336 336
 		//lastly, we need to update the datetime and ticket sold amounts
337 337
 		//as those may ahve been affected by this
338
-		EEM_Datetime::instance()->update_sold( EEM_Datetime::instance()->get_all() );
338
+		EEM_Datetime::instance()->update_sold(EEM_Datetime::instance()->get_all());
339 339
 		EEM_Ticket::instance()->update_tickets_sold(EEM_Ticket::instance()->get_all());
340 340
 
341 341
 		// if there was at least one success and absolutely no errors
342
-		if ( $success && ! $error ) {
342
+		if ($success && ! $error) {
343 343
 			return TRUE;
344 344
 		} else {
345 345
 			return FALSE;
@@ -371,81 +371,81 @@  discard block
 block discarded – undo
371 371
 	 * @param type $old_db_to_new_db_mapping
372 372
 	 * @return array updated $old_db_to_new_db_mapping
373 373
 	 */
374
-	public function save_data_rows_to_db( $csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping ) {
375
-		foreach ( $csv_data_array as $model_name_in_csv_data => $model_data_from_import ) {
374
+	public function save_data_rows_to_db($csv_data_array, $export_from_site_a_to_b, $old_db_to_new_db_mapping) {
375
+		foreach ($csv_data_array as $model_name_in_csv_data => $model_data_from_import) {
376 376
 			//now check that assumption was correct. If
377
-			if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
377
+			if (EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
378 378
 				$model_name = $model_name_in_csv_data;
379
-			}else {
379
+			} else {
380 380
 				// no table info in the array and no table name passed to the function?? FAIL
381
-				EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
381
+				EE_Error::add_error(__('No table information was specified and/or found, therefore the import could not be completed', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
382 382
 				return FALSE;
383 383
 			}
384 384
 			/* @var $model EEM_Base */
385 385
 			$model = EE_Registry::instance()->load_model($model_name);
386 386
 
387 387
 			//so without further ado, scanning all the data provided for primary keys and their inital values
388
-			foreach ( $model_data_from_import as $model_object_data ) {
388
+			foreach ($model_data_from_import as $model_object_data) {
389 389
 				//before we do ANYTHING, make sure the csv row wasn't just completely blank
390 390
 				$row_is_completely_empty = true;
391
-				foreach($model_object_data as $field){
392
-					if($field){
391
+				foreach ($model_object_data as $field) {
392
+					if ($field) {
393 393
 						$row_is_completely_empty = false;
394 394
 					}
395 395
 				}
396
-				if($row_is_completely_empty){
396
+				if ($row_is_completely_empty) {
397 397
 					continue;
398 398
 				}
399 399
 				//find the PK in the row of data (or a combined key if
400 400
 				//there is no primary key)
401
-				if($model->has_primary_key_field()){
402
-					$id_in_csv =  $model_object_data[$model->primary_key_name()];
403
-				}else{
401
+				if ($model->has_primary_key_field()) {
402
+					$id_in_csv = $model_object_data[$model->primary_key_name()];
403
+				} else {
404 404
 					$id_in_csv = $model->get_index_primary_key_string($model_object_data);
405 405
 				}
406 406
 
407 407
 
408
-				$model_object_data = $this->_replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b );
408
+				$model_object_data = $this->_replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b);
409 409
 				//now we need to decide if we're going to add a new model object given the $model_object_data,
410 410
 				//or just update.
411
-				if($export_from_site_a_to_b){
412
-					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
413
-				}else{//this is just a re-import
414
-					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
411
+				if ($export_from_site_a_to_b) {
412
+					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
413
+				} else {//this is just a re-import
414
+					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
415 415
 				}
416
-				if( $what_to_do == self::do_nothing ) {
416
+				if ($what_to_do == self::do_nothing) {
417 417
 					continue;
418 418
 				}
419 419
 
420 420
 				//double-check we actually want to insert, if that's what we're planning
421 421
 				//based on whether this item would be unique in the DB or not
422
-				if( $what_to_do == self::do_insert ) {
422
+				if ($what_to_do == self::do_insert) {
423 423
 					//we're supposed to be inserting. But wait, will this thing
424 424
 					//be acceptable if inserted?
425
-					$conflicting = $model->get_one_conflicting( $model_object_data, false );
426
-					if($conflicting){
425
+					$conflicting = $model->get_one_conflicting($model_object_data, false);
426
+					if ($conflicting) {
427 427
 						//ok, this item would conflict if inserted. Just update the item that it conflicts with.
428 428
 						$what_to_do = self::do_update;
429 429
 						//and if this model has a primary key, remember its mapping
430
-						if($model->has_primary_key_field()){
430
+						if ($model->has_primary_key_field()) {
431 431
 							$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID();
432 432
 							$model_object_data[$model->primary_key_name()] = $conflicting->ID();
433
-						}else{
433
+						} else {
434 434
 							//we want to update this conflicting item, instead of inserting a conflicting item
435 435
 							//so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields
436 436
 							//for the WHERE conditions in the update). At the time of this comment, there were no models like this
437
-							foreach($model->get_combined_primary_key_fields() as $key_field){
437
+							foreach ($model->get_combined_primary_key_fields() as $key_field) {
438 438
 								$model_object_data[$key_field->get_name()] = $conflicting->get($key_field->get_name());
439 439
 							}
440 440
 						}
441 441
 					}
442 442
 				}
443
-				if( $what_to_do == self::do_insert ) {
444
-					$old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
445
-				}elseif( $what_to_do == self::do_update ) {
446
-					$old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
447
-				}else{
448
-					throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) );
443
+				if ($what_to_do == self::do_insert) {
444
+					$old_db_to_new_db_mapping = $this->_insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
445
+				}elseif ($what_to_do == self::do_update) {
446
+					$old_db_to_new_db_mapping = $this->_update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping);
447
+				} else {
448
+					throw new EE_Error(sprintf(__('Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso'), $what_to_do));
449 449
 				}
450 450
 			}
451 451
 		}
@@ -466,13 +466,13 @@  discard block
 block discarded – undo
466 466
 	 * @param array $old_db_to_new_db_mapping by reference so it can be modified
467 467
 	 * @return string one of the consts on this class that starts with do_*
468 468
 	 */
469
-	protected function _decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) {
469
+	protected function _decide_whether_to_insert_or_update_given_data_from_other_db($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
470 470
 		$model_name = $model->get_this_model_name();
471 471
 		//if it's a site-to-site export-and-import, see if this modelobject's id
472 472
 		//in the old data that we know of
473
-		if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){
473
+		if (isset($old_db_to_new_db_mapping[$model_name][$id_in_csv])) {
474 474
 			return self::do_update;
475
-		}else{
475
+		} else {
476 476
 			return self::do_insert;
477 477
 		}
478 478
 	}
@@ -487,11 +487,11 @@  discard block
 block discarded – undo
487 487
 	 * @param type $old_db_to_new_db_mapping
488 488
 	 * @return
489 489
 	 */
490
-	protected function _decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model ) {
490
+	protected function _decide_whether_to_insert_or_update_given_data_from_same_db($id_in_csv, $model_object_data, $model) {
491 491
 		//in this case, check if this thing ACTUALLY exists in the database
492
-		if( $model->get_one_conflicting( $model_object_data ) ){
492
+		if ($model->get_one_conflicting($model_object_data)) {
493 493
 			return self::do_update;
494
-		}else{
494
+		} else {
495 495
 			return self::do_insert;
496 496
 		}
497 497
 	}
@@ -510,55 +510,55 @@  discard block
 block discarded – undo
510 510
 	 * @param boolean $export_from_site_a_to_b
511 511
 	 * @return array updated model object data with temp IDs removed
512 512
 	 */
513
-	protected function _replace_temp_ids_with_mappings( $model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b ) {
513
+	protected function _replace_temp_ids_with_mappings($model_object_data, $model, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
514 514
 		//if this model object's primary key is in the mapping, replace it
515
-		if( $model->has_primary_key_field() &&
515
+		if ($model->has_primary_key_field() &&
516 516
 				$model->get_primary_key_field()->is_auto_increment() &&
517
-				isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ] ) &&
518
-				isset( $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ] ) ) {
519
-			$model_object_data[ $model->primary_key_name() ] = $old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $model_object_data[ $model->primary_key_name() ] ];
517
+				isset($old_db_to_new_db_mapping[$model->get_this_model_name()]) &&
518
+				isset($old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]])) {
519
+			$model_object_data[$model->primary_key_name()] = $old_db_to_new_db_mapping[$model->get_this_model_name()][$model_object_data[$model->primary_key_name()]];
520 520
 		}
521 521
 
522
-		try{
522
+		try {
523 523
 			$model_name_field = $model->get_field_containing_related_model_name();
524 524
 			$models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
525
-		}catch( EE_Error $e ){
525
+		} catch (EE_Error $e) {
526 526
 			$model_name_field = NULL;
527 527
 			$models_pointed_to_by_model_name_field = array();
528 528
 		}
529
-		foreach( $model->field_settings( true )  as $field_obj ){
530
-			if( $field_obj instanceof EE_Foreign_Key_Int_Field ) {
529
+		foreach ($model->field_settings(true)  as $field_obj) {
530
+			if ($field_obj instanceof EE_Foreign_Key_Int_Field) {
531 531
 				$models_pointed_to = $field_obj->get_model_names_pointed_to();
532 532
 				$found_a_mapping = false;
533
-				foreach( $models_pointed_to as $model_pointed_to_by_fk ) {
533
+				foreach ($models_pointed_to as $model_pointed_to_by_fk) {
534 534
 
535
-					if( $model_name_field ){
536
-						$value_of_model_name_field = $model_object_data[ $model_name_field->get_name() ];
537
-						if( $value_of_model_name_field == $model_pointed_to_by_fk ) {
538
-							$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
539
-									$model_object_data[ $field_obj->get_name() ],
535
+					if ($model_name_field) {
536
+						$value_of_model_name_field = $model_object_data[$model_name_field->get_name()];
537
+						if ($value_of_model_name_field == $model_pointed_to_by_fk) {
538
+							$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in(
539
+									$model_object_data[$field_obj->get_name()],
540 540
 									$model_pointed_to_by_fk,
541 541
 									$old_db_to_new_db_mapping,
542 542
 									$export_from_site_a_to_b );
543 543
 								$found_a_mapping = true;
544 544
 								break;
545 545
 						}
546
-					}else{
547
-						$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
548
-								$model_object_data[ $field_obj->get_name() ],
546
+					} else {
547
+						$model_object_data[$field_obj->get_name()] = $this->_find_mapping_in(
548
+								$model_object_data[$field_obj->get_name()],
549 549
 								$model_pointed_to_by_fk,
550 550
 								$old_db_to_new_db_mapping,
551 551
 								$export_from_site_a_to_b );
552 552
 						$found_a_mapping = true;
553 553
 					}
554 554
 					//once we've found a mapping for this field no need to continue
555
-					if( $found_a_mapping ) {
555
+					if ($found_a_mapping) {
556 556
 						break;
557 557
 					}
558 558
 
559 559
 
560 560
 				}
561
-			}else{
561
+			} else {
562 562
 				//it's a string foreign key (which we leave alone, because those are things
563 563
 				//like country names, which we'd really rather not make 2 USAs etc (we'd actually
564 564
 				//prefer to just update one)
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
 			}
567 567
 		}
568 568
 		//
569
-		if( $model instanceof EEM_Term_Taxonomy ){
570
-			$model_object_data = $this->_handle_split_term_ids( $model_object_data );
569
+		if ($model instanceof EEM_Term_Taxonomy) {
570
+			$model_object_data = $this->_handle_split_term_ids($model_object_data);
571 571
 		}
572 572
 		return $model_object_data;
573 573
 	}
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
 	 * @param type $model_object_data
580 580
 	 * @return array new model object data
581 581
 	 */
582
-	protected function _handle_split_term_ids( $model_object_data ){
583
-		if( isset( $model_object_data['term_id'] ) && isset( $model_object_data[ 'taxonomy' ]) && apply_filters( 'FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists( 'wp_get_split_term' ), $model_object_data ) ) {
584
-			$new_term_id = wp_get_split_term( $model_object_data[ 'term_id' ], $model_object_data[ 'taxonomy' ] );
585
-			if( $new_term_id ){
586
-				$model_object_data[ 'term_id' ] = $new_term_id;
582
+	protected function _handle_split_term_ids($model_object_data) {
583
+		if (isset($model_object_data['term_id']) && isset($model_object_data['taxonomy']) && apply_filters('FHEE__EE_Import__handle_split_term_ids__function_exists', function_exists('wp_get_split_term'), $model_object_data)) {
584
+			$new_term_id = wp_get_split_term($model_object_data['term_id'], $model_object_data['taxonomy']);
585
+			if ($new_term_id) {
586
+				$model_object_data['term_id'] = $new_term_id;
587 587
 			}
588 588
 		}
589 589
 		return $model_object_data;
@@ -597,18 +597,18 @@  discard block
 block discarded – undo
597 597
 	 * @param type $export_from_site_a_to_b
598 598
 	 * @return int
599 599
 	 */
600
-	protected function _find_mapping_in( $object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
601
-		if(	isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){
600
+	protected function _find_mapping_in($object_id, $model_name, $old_db_to_new_db_mapping, $export_from_site_a_to_b) {
601
+		if (isset($old_db_to_new_db_mapping[$model_name][$object_id])) {
602 602
 
603
-				return $old_db_to_new_db_mapping[ $model_name ][ $object_id ];
604
-			}elseif( $object_id == '0' || $object_id == '' ) {
603
+				return $old_db_to_new_db_mapping[$model_name][$object_id];
604
+			}elseif ($object_id == '0' || $object_id == '') {
605 605
 				//leave as-is
606 606
 				return $object_id;
607
-			}elseif( $export_from_site_a_to_b ){
607
+			}elseif ($export_from_site_a_to_b) {
608 608
 				//we couldn't find a mapping for this, and it's from a different site,
609 609
 				//so blank it out
610 610
 				return NULL;
611
-			}elseif( ! $export_from_site_a_to_b ) {
611
+			}elseif ( ! $export_from_site_a_to_b) {
612 612
 				//we coudln't find a mapping for this, but it's from thsi DB anyway
613 613
 				//so let's just leave it as-is
614 614
 				return $object_id;
@@ -623,36 +623,36 @@  discard block
 block discarded – undo
623 623
 	 * @param type $old_db_to_new_db_mapping
624 624
 	 * @return array updated $old_db_to_new_db_mapping
625 625
 	 */
626
-	protected function _insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping ) {
626
+	protected function _insert_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
627 627
 		//remove the primary key, if there is one (we don't want it for inserts OR updates)
628 628
 		//we'll put it back in if we need it
629
-		if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){
629
+		if ($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()) {
630 630
 			$effective_id = $model_object_data[$model->primary_key_name()];
631 631
 			unset($model_object_data[$model->primary_key_name()]);
632
-		}else{
633
-			$effective_id = $model->get_index_primary_key_string( $model_object_data );
632
+		} else {
633
+			$effective_id = $model->get_index_primary_key_string($model_object_data);
634 634
 		}
635 635
 		//the model takes care of validating the CSV's input
636
-		try{
636
+		try {
637 637
 			$new_id = $model->insert($model_object_data);
638
-			if( $new_id ){
638
+			if ($new_id) {
639 639
 				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id;
640 640
 				$this->_total_inserts++;
641
-				EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data)));
642
-			}else{
641
+				EE_Error::add_success(sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"), $model->get_this_model_name(), $new_id, implode(",", $model_object_data)));
642
+			} else {
643 643
 				$this->_total_insert_errors++;
644 644
 				//put the ID used back in there for the error message
645
-				if($model->has_primary_key_field()){
645
+				if ($model->has_primary_key_field()) {
646 646
 					$model_object_data[$model->primary_key_name()] = $effective_id;
647 647
 				}
648
-				EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ );
648
+				EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__);
649 649
 			}
650
-		}catch(EE_Error $e){
650
+		} catch (EE_Error $e) {
651 651
 			$this->_total_insert_errors++;
652
-			if($model->has_primary_key_field()){
652
+			if ($model->has_primary_key_field()) {
653 653
 				$model_object_data[$model->primary_key_name()] = $effective_id;
654 654
 			}
655
-			EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage()), __FILE__, __FUNCTION__, __LINE__ );
655
+			EE_Error::add_error(sprintf(__("Could not insert new %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
656 656
 		}
657 657
 		return $old_db_to_new_db_mapping;
658 658
 	}
@@ -665,55 +665,55 @@  discard block
 block discarded – undo
665 665
 	 * @param array $old_db_to_new_db_mapping
666 666
 	 * @return array updated $old_db_to_new_db_mapping
667 667
 	 */
668
-	protected function _update_from_data_array( $id_in_csv,  $model_object_data, $model, $old_db_to_new_db_mapping ) {
669
-		try{
668
+	protected function _update_from_data_array($id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping) {
669
+		try {
670 670
 			//let's keep two copies of the model object data:
671 671
 			//one for performing an update, one for everthing else
672 672
 			$model_object_data_for_update = $model_object_data;
673
-			if($model->has_primary_key_field()){
673
+			if ($model->has_primary_key_field()) {
674 674
 				$conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]);
675 675
 				//remove the primary key because we shouldn't use it for updating
676 676
 				unset($model_object_data_for_update[$model->primary_key_name()]);
677
-			}elseif($model->get_combined_primary_key_fields() > 1 ){
677
+			}elseif ($model->get_combined_primary_key_fields() > 1) {
678 678
 				$conditions = array();
679
-				foreach($model->get_combined_primary_key_fields() as $key_field){
679
+				foreach ($model->get_combined_primary_key_fields() as $key_field) {
680 680
 					$conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()];
681 681
 				}
682
-			}else{
683
-				$model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
682
+			} else {
683
+				$model->primary_key_name(); //this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
684 684
 			}
685 685
 
686
-			$success = $model->update($model_object_data_for_update,array($conditions));
687
-			if($success){
686
+			$success = $model->update($model_object_data_for_update, array($conditions));
687
+			if ($success) {
688 688
 				$this->_total_updates++;
689
-				EE_Error::add_success( sprintf(__("Successfully updated %s with csv data %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data_for_update)));
689
+				EE_Error::add_success(sprintf(__("Successfully updated %s with csv data %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data_for_update)));
690 690
 				//we should still record the mapping even though it was an update
691 691
 				//because if we were going to insert somethign but it was going to conflict
692 692
 				//we would have last-minute decided to update. So we'd like to know what we updated
693 693
 				//and so we record what record ended up being updated using the mapping
694
-				if( $model->has_primary_key_field() ){
695
-					$new_key_for_mapping = $model_object_data[ $model->primary_key_name() ];
696
-				}else{
694
+				if ($model->has_primary_key_field()) {
695
+					$new_key_for_mapping = $model_object_data[$model->primary_key_name()];
696
+				} else {
697 697
 					//no primary key just a combined key
698
-					$new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data );
698
+					$new_key_for_mapping = $model->get_index_primary_key_string($model_object_data);
699 699
 				}
700
-				$old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping;
701
-			}else{
700
+				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_key_for_mapping;
701
+			} else {
702 702
 				$matched_items = $model->get_all(array($conditions));
703
-				if( ! $matched_items){
703
+				if ( ! $matched_items) {
704 704
 					//no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck?
705 705
 					$this->_total_update_errors++;
706
-					EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ );
707
-				}else{
706
+					EE_Error::add_error(sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"), $model->get_this_model_name(), http_build_query($model_object_data), http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__);
707
+				} else {
708 708
 					$this->_total_updates++;
709
-					EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data)));
709
+					EE_Error::add_success(sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data)));
710 710
 				}
711 711
 			}
712
-		}catch(EE_Error $e){
712
+		} catch (EE_Error $e) {
713 713
 			$this->_total_update_errors++;
714
-			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage());
715
-			$debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString();
716
-			EE_Error::add_error( "$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__ );
714
+			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"), $model->get_this_model_name(), implode(",", $model_object_data), $e->getMessage());
715
+			$debug_message = $basic_message.' Stack trace: '.$e->getTraceAsString();
716
+			EE_Error::add_error("$basic_message | $debug_message", __FILE__, __FUNCTION__, __LINE__);
717 717
 		}
718 718
 		return $old_db_to_new_db_mapping;
719 719
 	}
@@ -722,28 +722,28 @@  discard block
 block discarded – undo
722 722
 	 * Gets the number of inserts performed since importer was instantiated or reset
723 723
 	 * @return int
724 724
 	 */
725
-	public function get_total_inserts(){
725
+	public function get_total_inserts() {
726 726
 		return $this->_total_inserts;
727 727
 	}
728 728
 	/**
729 729
 	 *  Gets the number of insert errors since importer was instantiated or reset
730 730
 	 * @return int
731 731
 	 */
732
-	public function get_total_insert_errors(){
732
+	public function get_total_insert_errors() {
733 733
 		return $this->_total_insert_errors;
734 734
 	}
735 735
 	/**
736 736
 	 *  Gets the number of updates performed since importer was instantiated or reset
737 737
 	 * @return int
738 738
 	 */
739
-	public function get_total_updates(){
739
+	public function get_total_updates() {
740 740
 		return $this->_total_updates;
741 741
 	}
742 742
 	/**
743 743
 	 *  Gets the number of update errors since importer was instantiated or reset
744 744
 	 * @return int
745 745
 	 */
746
-	public function get_total_update_errors(){
746
+	public function get_total_update_errors() {
747 747
 		return $this->_total_update_errors;
748 748
 	}
749 749
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
3 5
 /**
4 6
  * EE_Import class
@@ -295,7 +297,7 @@  discard block
 block discarded – undo
295 297
 			if(isset($csv_metadata['site_url']) && $csv_metadata['site_url'] == site_url()){
296 298
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from the same database, so attempting to update data", "event_espresso")));
297 299
 				$export_from_site_a_to_b = false;
298
-			}else{
300
+			} else{
299 301
 				$old_site_url = isset( $csv_metadata['site_url']) ? $csv_metadata['site_url'] : $old_site_url;
300 302
 				EE_Error::add_attention(sprintf(__("CSV Data appears to be from a different database (%s instead of %s), so we assume IDs in the CSV data DO NOT correspond to IDs in this database", "event_espresso"),$old_site_url,site_url()));
301 303
 			};
@@ -376,7 +378,7 @@  discard block
 block discarded – undo
376 378
 			//now check that assumption was correct. If
377 379
 			if ( EE_Registry::instance()->is_model_name($model_name_in_csv_data)) {
378 380
 				$model_name = $model_name_in_csv_data;
379
-			}else {
381
+			} else {
380 382
 				// no table info in the array and no table name passed to the function?? FAIL
381 383
 				EE_Error::add_error( __('No table information was specified and/or found, therefore the import could not be completed','event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
382 384
 				return FALSE;
@@ -400,7 +402,7 @@  discard block
 block discarded – undo
400 402
 				//there is no primary key)
401 403
 				if($model->has_primary_key_field()){
402 404
 					$id_in_csv =  $model_object_data[$model->primary_key_name()];
403
-				}else{
405
+				} else{
404 406
 					$id_in_csv = $model->get_index_primary_key_string($model_object_data);
405 407
 				}
406 408
 
@@ -410,7 +412,7 @@  discard block
 block discarded – undo
410 412
 				//or just update.
411 413
 				if($export_from_site_a_to_b){
412 414
 					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_other_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
413
-				}else{//this is just a re-import
415
+				} else{//this is just a re-import
414 416
 					$what_to_do = $this->_decide_whether_to_insert_or_update_given_data_from_same_db( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
415 417
 				}
416 418
 				if( $what_to_do == self::do_nothing ) {
@@ -430,7 +432,7 @@  discard block
 block discarded – undo
430 432
 						if($model->has_primary_key_field()){
431 433
 							$old_db_to_new_db_mapping[$model_name][$id_in_csv] = $conflicting->ID();
432 434
 							$model_object_data[$model->primary_key_name()] = $conflicting->ID();
433
-						}else{
435
+						} else{
434 436
 							//we want to update this conflicting item, instead of inserting a conflicting item
435 437
 							//so we need to make sure they match entirely (its possible that they only conflicted on one field, but we need them to match on other fields
436 438
 							//for the WHERE conditions in the update). At the time of this comment, there were no models like this
@@ -442,9 +444,9 @@  discard block
 block discarded – undo
442 444
 				}
443 445
 				if( $what_to_do == self::do_insert ) {
444 446
 					$old_db_to_new_db_mapping = $this->_insert_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
445
-				}elseif( $what_to_do == self::do_update ) {
447
+				} elseif( $what_to_do == self::do_update ) {
446 448
 					$old_db_to_new_db_mapping = $this->_update_from_data_array( $id_in_csv, $model_object_data, $model, $old_db_to_new_db_mapping );
447
-				}else{
449
+				} else{
448 450
 					throw new EE_Error( sprintf( __( 'Programming error. We shoudl be inserting or updating, but instead we are being told to "%s", whifh is invalid', 'event_espresso' ), $what_to_do ) );
449 451
 				}
450 452
 			}
@@ -472,7 +474,7 @@  discard block
 block discarded – undo
472 474
 		//in the old data that we know of
473 475
 		if( isset($old_db_to_new_db_mapping[$model_name][$id_in_csv]) ){
474 476
 			return self::do_update;
475
-		}else{
477
+		} else{
476 478
 			return self::do_insert;
477 479
 		}
478 480
 	}
@@ -491,7 +493,7 @@  discard block
 block discarded – undo
491 493
 		//in this case, check if this thing ACTUALLY exists in the database
492 494
 		if( $model->get_one_conflicting( $model_object_data ) ){
493 495
 			return self::do_update;
494
-		}else{
496
+		} else{
495 497
 			return self::do_insert;
496 498
 		}
497 499
 	}
@@ -522,7 +524,7 @@  discard block
 block discarded – undo
522 524
 		try{
523 525
 			$model_name_field = $model->get_field_containing_related_model_name();
524 526
 			$models_pointed_to_by_model_name_field = $model_name_field->get_model_names_pointed_to();
525
-		}catch( EE_Error $e ){
527
+		} catch( EE_Error $e ){
526 528
 			$model_name_field = NULL;
527 529
 			$models_pointed_to_by_model_name_field = array();
528 530
 		}
@@ -543,7 +545,7 @@  discard block
 block discarded – undo
543 545
 								$found_a_mapping = true;
544 546
 								break;
545 547
 						}
546
-					}else{
548
+					} else{
547 549
 						$model_object_data[ $field_obj->get_name() ] = $this->_find_mapping_in(
548 550
 								$model_object_data[ $field_obj->get_name() ],
549 551
 								$model_pointed_to_by_fk,
@@ -558,7 +560,7 @@  discard block
 block discarded – undo
558 560
 
559 561
 
560 562
 				}
561
-			}else{
563
+			} else{
562 564
 				//it's a string foreign key (which we leave alone, because those are things
563 565
 				//like country names, which we'd really rather not make 2 USAs etc (we'd actually
564 566
 				//prefer to just update one)
@@ -601,14 +603,14 @@  discard block
 block discarded – undo
601 603
 		if(	isset( $old_db_to_new_db_mapping[ $model_name ][ $object_id ] ) ){
602 604
 
603 605
 				return $old_db_to_new_db_mapping[ $model_name ][ $object_id ];
604
-			}elseif( $object_id == '0' || $object_id == '' ) {
606
+			} elseif( $object_id == '0' || $object_id == '' ) {
605 607
 				//leave as-is
606 608
 				return $object_id;
607
-			}elseif( $export_from_site_a_to_b ){
609
+			} elseif( $export_from_site_a_to_b ){
608 610
 				//we couldn't find a mapping for this, and it's from a different site,
609 611
 				//so blank it out
610 612
 				return NULL;
611
-			}elseif( ! $export_from_site_a_to_b ) {
613
+			} elseif( ! $export_from_site_a_to_b ) {
612 614
 				//we coudln't find a mapping for this, but it's from thsi DB anyway
613 615
 				//so let's just leave it as-is
614 616
 				return $object_id;
@@ -629,7 +631,7 @@  discard block
 block discarded – undo
629 631
 		if($model->has_primary_key_field() && $model->get_primary_key_field()->is_auto_increment()){
630 632
 			$effective_id = $model_object_data[$model->primary_key_name()];
631 633
 			unset($model_object_data[$model->primary_key_name()]);
632
-		}else{
634
+		} else{
633 635
 			$effective_id = $model->get_index_primary_key_string( $model_object_data );
634 636
 		}
635 637
 		//the model takes care of validating the CSV's input
@@ -639,7 +641,7 @@  discard block
 block discarded – undo
639 641
 				$old_db_to_new_db_mapping[$model->get_this_model_name()][$id_in_csv] = $new_id;
640 642
 				$this->_total_inserts++;
641 643
 				EE_Error::add_success( sprintf(__("Successfully added new %s (with id %s) with csv data %s", "event_espresso"),$model->get_this_model_name(),$new_id, implode(",",$model_object_data)));
642
-			}else{
644
+			} else{
643 645
 				$this->_total_insert_errors++;
644 646
 				//put the ID used back in there for the error message
645 647
 				if($model->has_primary_key_field()){
@@ -647,7 +649,7 @@  discard block
 block discarded – undo
647 649
 				}
648 650
 				EE_Error::add_error( sprintf(__("Could not insert new %s with the csv data: %s", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data)), __FILE__, __FUNCTION__, __LINE__ );
649 651
 			}
650
-		}catch(EE_Error $e){
652
+		} catch(EE_Error $e){
651 653
 			$this->_total_insert_errors++;
652 654
 			if($model->has_primary_key_field()){
653 655
 				$model_object_data[$model->primary_key_name()] = $effective_id;
@@ -674,12 +676,12 @@  discard block
 block discarded – undo
674 676
 				$conditions = array($model->primary_key_name() => $model_object_data[$model->primary_key_name()]);
675 677
 				//remove the primary key because we shouldn't use it for updating
676 678
 				unset($model_object_data_for_update[$model->primary_key_name()]);
677
-			}elseif($model->get_combined_primary_key_fields() > 1 ){
679
+			} elseif($model->get_combined_primary_key_fields() > 1 ){
678 680
 				$conditions = array();
679 681
 				foreach($model->get_combined_primary_key_fields() as $key_field){
680 682
 					$conditions[$key_field->get_name()] = $model_object_data[$key_field->get_name()];
681 683
 				}
682
-			}else{
684
+			} else{
683 685
 				$model->primary_key_name();//this shoudl just throw an exception, explaining that we dont have a primary key (or a combine dkey)
684 686
 			}
685 687
 
@@ -693,23 +695,23 @@  discard block
 block discarded – undo
693 695
 				//and so we record what record ended up being updated using the mapping
694 696
 				if( $model->has_primary_key_field() ){
695 697
 					$new_key_for_mapping = $model_object_data[ $model->primary_key_name() ];
696
-				}else{
698
+				} else{
697 699
 					//no primary key just a combined key
698 700
 					$new_key_for_mapping = $model->get_index_primary_key_string( $model_object_data );
699 701
 				}
700 702
 				$old_db_to_new_db_mapping[ $model->get_this_model_name() ][ $id_in_csv ] = $new_key_for_mapping;
701
-			}else{
703
+			} else{
702 704
 				$matched_items = $model->get_all(array($conditions));
703 705
 				if( ! $matched_items){
704 706
 					//no items were matched (so we shouldn't have updated)... but then we should have inserted? what the heck?
705 707
 					$this->_total_update_errors++;
706 708
 					EE_Error::add_error( sprintf(__("Could not update %s with the csv data: '%s' for an unknown reason (using WHERE conditions %s)", "event_espresso"),$model->get_this_model_name(),http_build_query($model_object_data),http_build_query($conditions)), __FILE__, __FUNCTION__, __LINE__ );
707
-				}else{
709
+				} else{
708 710
 					$this->_total_updates++;
709 711
 					EE_Error::add_success( sprintf(__("%s with csv data '%s' was found in the database and didn't need updating because all the data is identical.", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data)));
710 712
 				}
711 713
 			}
712
-		}catch(EE_Error $e){
714
+		} catch(EE_Error $e){
713 715
 			$this->_total_update_errors++;
714 716
 			$basic_message = sprintf(__("Could not update %s with the csv data: %s because %s", "event_espresso"),$model->get_this_model_name(),implode(",",$model_object_data),$e->getMessage());
715 717
 			$debug_message = $basic_message . ' Stack trace: ' . $e->getTraceAsString();
Please login to merge, or discard this patch.
core/db_classes/EE_Question_Form_Input.class.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 *        generate_question_form_inputs_for_object
227 227
 	 *
228 228
 	 * @access    protected
229
-	 * @param bool|object $object $object
229
+	 * @param EE_Base_Class|null $object $object
230 230
 	 * @param    array    $input_types
231 231
 	 * @return        array
232 232
 	 */
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 *    add_temp_option
325 325
 	 * @access public
326 326
 	 * @param \EE_Question_Option $QSO EE_Question_Option
327
-	 * @return boolean
327
+	 * @return boolean|null
328 328
 	 */
329 329
 	public function add_temp_option( EE_Question_Option $QSO ) {
330 330
 		$this->_QST->add_temp_option( $QSO );
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * set property values for question form input
337 337
 	 * @access public
338 338
 	 * @param    string $property
339
-	 * @param    mixed  $value
340
-	 * @return mixed
339
+	 * @param    boolean  $value
340
+	 * @return boolean|null
341 341
 	 */
342 342
 	public function set( $property = NULL, $value = NULL ) {
343 343
 		if ( ! empty( $property ) ) {
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 *    get_meta
378 378
 	 * @access public
379
-	 * @param mixed $key
379
+	 * @param string $key
380 380
 	 * @return mixed
381 381
 	 */
382 382
 	public function get_meta( $key = FALSE ) {
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 * @access public
83 83
 	 * @return \EE_Question_Form_Input
84 84
 	 */
85
-	public function __construct( EE_Question $QST = NULL, EE_Answer $ANS = NULL, $q_meta = array() ) {
86
-		if ( empty( $QST ) || empty( $ANS ) ) {
87
-			EE_Error::add_error( __( 'An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
85
+	public function __construct(EE_Question $QST = NULL, EE_Answer $ANS = NULL, $q_meta = array()) {
86
+		if (empty($QST) || empty($ANS)) {
87
+			EE_Error::add_error(__('An error occurred. A valid EE_Question or EE_Answer object was not received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
88 88
 			return NULL;
89 89
 		}
90 90
 		$this->_QST = $QST;
91 91
 		$this->_ANS = $ANS;
92
-		$this->set_question_form_input_meta( $q_meta );
92
+		$this->set_question_form_input_meta($q_meta);
93 93
 		$this->set_question_form_input_init();
94 94
 	}
95 95
 
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param array $q_meta
102 102
 	 * @return void
103 103
 	 */
104
-	public function set_question_form_input_meta( $q_meta = array() ) {
105
-		$default_q_meta = array( 'att_nmbr' => 1, 'ticket_id' => '', 'date' => '', 'time' => '', 'input_name' => '', 'input_id' => '', 'input_class' => '', 'input_prefix' => 'qstn', 'append_qstn_id' => TRUE, 'htmlentities' => TRUE, 'allow_null' => FALSE );
106
-		$this->_QST_meta = array_merge( $default_q_meta, $q_meta );
104
+	public function set_question_form_input_meta($q_meta = array()) {
105
+		$default_q_meta = array('att_nmbr' => 1, 'ticket_id' => '', 'date' => '', 'time' => '', 'input_name' => '', 'input_id' => '', 'input_class' => '', 'input_prefix' => 'qstn', 'append_qstn_id' => TRUE, 'htmlentities' => TRUE, 'allow_null' => FALSE);
106
+		$this->_QST_meta = array_merge($default_q_meta, $q_meta);
107 107
 	}
108 108
 
109 109
 
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
 	 */
116 116
 	public function set_question_form_input_init() {
117 117
 		$qstn_id = $this->_QST->system_ID() ? $this->_QST->system_ID() : $this->_QST->ID();
118
-		$this->_set_input_name( $qstn_id );
119
-		$this->_set_input_id( $qstn_id );
120
-		$this->_set_input_class( $qstn_id );
121
-		$this->set_question_form_input_answer( $qstn_id );
118
+		$this->_set_input_name($qstn_id);
119
+		$this->_set_input_id($qstn_id);
120
+		$this->_set_input_class($qstn_id);
121
+		$this->set_question_form_input_answer($qstn_id);
122 122
 	}
123 123
 
124 124
 
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	 * @param $qstn_id
130 130
 	 * @return void
131 131
 	 */
132
-	private function _set_input_name( $qstn_id ) {
133
-		if ( ! empty( $qstn_id ) ) {
134
-			$ANS_ID = $this->get( 'ANS_ID' );
135
-			$qstn_id = ! empty( $ANS_ID ) ? '[' . $qstn_id . '][' . $ANS_ID . ']' : '[' . $qstn_id . ']';
132
+	private function _set_input_name($qstn_id) {
133
+		if ( ! empty($qstn_id)) {
134
+			$ANS_ID = $this->get('ANS_ID');
135
+			$qstn_id = ! empty($ANS_ID) ? '['.$qstn_id.']['.$ANS_ID.']' : '['.$qstn_id.']';
136 136
 		}
137
-		$this->QST_input_name = $this->_QST_meta[ 'append_qstn_id' ] && ! empty( $qstn_id ) ? $this->_QST_meta[ 'input_prefix' ] . $this->_QST_meta[ 'input_name' ] . $qstn_id : $this->_QST_meta[ 'input_prefix' ] . $this->_QST_meta[ 'input_name' ];
137
+		$this->QST_input_name = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) ? $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'].$qstn_id : $this->_QST_meta['input_prefix'].$this->_QST_meta['input_name'];
138 138
 	}
139 139
 
140 140
 
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 	 * @param    string $property
146 146
 	 * @return mixed
147 147
 	 */
148
-	public function get( $property = NULL ) {
149
-		if ( ! empty( $property ) ) {
150
-			if ( EEM_Question::instance()->has_field( $property ) ) {
151
-				return $this->_QST->get( $property );
152
-			} else if ( EEM_Answer::instance()->has_field( $property ) ) {
153
-				return $this->_ANS->get( $property );
154
-			} else if ( $this->_question_form_input_property_exists( __CLASS__, $property ) ) {
148
+	public function get($property = NULL) {
149
+		if ( ! empty($property)) {
150
+			if (EEM_Question::instance()->has_field($property)) {
151
+				return $this->_QST->get($property);
152
+			} else if (EEM_Answer::instance()->has_field($property)) {
153
+				return $this->_ANS->get($property);
154
+			} else if ($this->_question_form_input_property_exists(__CLASS__, $property)) {
155 155
 				return $this->{$property};
156 156
 			}
157 157
 		}
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 	 * @param    string $property
168 168
 	 * @return boolean
169 169
 	 */
170
-	private function _question_form_input_property_exists( $classname, $property ) {
170
+	private function _question_form_input_property_exists($classname, $property) {
171 171
 		// first try regular property exists method which works as expected in PHP 5.3+
172
-		$prop = EEH_Class_Tools::has_property( $classname, $property );
173
-		if ( ! $prop ) {
172
+		$prop = EEH_Class_Tools::has_property($classname, $property);
173
+		if ( ! $prop) {
174 174
 			// use reflection for < PHP 5.3 as a double check when property is not found, possible due to access restriction
175
-			$reflector = new ReflectionClass( $classname );
176
-			$prop = $reflector->hasProperty( $property );
175
+			$reflector = new ReflectionClass($classname);
176
+			$prop = $reflector->hasProperty($property);
177 177
 		}
178 178
 		return $prop;
179 179
 	}
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
 	 * @param $qstn_id
187 187
 	 * @return void
188 188
 	 */
189
-	private function _set_input_id( $qstn_id ) {
190
-		$input_id = isset( $this->_QST_meta[ 'input_id' ] ) && ! empty( $this->_QST_meta[ 'input_id' ] ) ? $this->_QST_meta[ 'input_id' ] : sanitize_key( strip_tags( $this->_QST->get( 'QST_display_text' ) ) );
191
-		$this->QST_input_id = $this->_QST_meta[ 'append_qstn_id' ] && ! empty( $qstn_id ) ? $input_id . '-' . $qstn_id : $input_id;
189
+	private function _set_input_id($qstn_id) {
190
+		$input_id = isset($this->_QST_meta['input_id']) && ! empty($this->_QST_meta['input_id']) ? $this->_QST_meta['input_id'] : sanitize_key(strip_tags($this->_QST->get('QST_display_text')));
191
+		$this->QST_input_id = $this->_QST_meta['append_qstn_id'] && ! empty($qstn_id) ? $input_id.'-'.$qstn_id : $input_id;
192 192
 	}
193 193
 
194 194
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @return void
200 200
 	 */
201 201
 	private function _set_input_class() {
202
-		$this->QST_input_class = isset( $this->_QST_meta[ 'input_class' ] ) ? $this->_QST_meta[ 'input_class' ] : '';
202
+		$this->QST_input_class = isset($this->_QST_meta['input_class']) ? $this->_QST_meta['input_class'] : '';
203 203
 	}
204 204
 
205 205
 
@@ -210,12 +210,12 @@  discard block
 block discarded – undo
210 210
 	 * @param mixed    int | string    $qstn_id
211 211
 	 * @return void
212 212
 	 */
213
-	public function set_question_form_input_answer( $qstn_id ) {
213
+	public function set_question_form_input_answer($qstn_id) {
214 214
 		// check for answer in $_REQUEST in case we are reprocessing a form after an error
215
-		if ( isset( $this->_QST_meta[ 'EVT_ID' ] ) && isset( $this->_QST_meta[ 'att_nmbr' ] ) && isset( $this->_QST_meta[ 'date' ] ) && isset( $this->_QST_meta[ 'time' ] ) && isset( $this->_QST_meta[ 'price_id' ] ) ) {
216
-			if ( isset( $_REQUEST[ 'qstn' ][ $this->_QST_meta[ 'EVT_ID' ] ][ $this->_QST_meta[ 'att_nmbr' ] ][ $this->_QST_meta[ 'date' ] ][ $this->_QST_meta[ 'time' ] ][ $this->_QST_meta[ 'price_id' ] ][ $qstn_id ] ) ) {
217
-				$answer = $_REQUEST[ 'qstn' ][ $this->_QST_meta[ 'EVT_ID' ] ][ $this->_QST_meta[ 'att_nmbr' ] ][ $this->_QST_meta[ 'date' ] ][ $this->_QST_meta[ 'time' ] ][ $this->_QST_meta[ 'price_id' ] ][ $qstn_id ];
218
-				$this->_ANS->set( 'ANS_value', $answer );
215
+		if (isset($this->_QST_meta['EVT_ID']) && isset($this->_QST_meta['att_nmbr']) && isset($this->_QST_meta['date']) && isset($this->_QST_meta['time']) && isset($this->_QST_meta['price_id'])) {
216
+			if (isset($_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id])) {
217
+				$answer = $_REQUEST['qstn'][$this->_QST_meta['EVT_ID']][$this->_QST_meta['att_nmbr']][$this->_QST_meta['date']][$this->_QST_meta['time']][$this->_QST_meta['price_id']][$qstn_id];
218
+				$this->_ANS->set('ANS_value', $answer);
219 219
 			}
220 220
 		}
221 221
 	}
@@ -230,40 +230,40 @@  discard block
 block discarded – undo
230 230
 	 * @param    array    $input_types
231 231
 	 * @return        array
232 232
 	 */
233
-	static function generate_question_form_inputs_for_object( $object = FALSE, $input_types = array() ) {
234
-		if ( ! is_object( $object ) ) {
233
+	static function generate_question_form_inputs_for_object($object = FALSE, $input_types = array()) {
234
+		if ( ! is_object($object)) {
235 235
 			return FALSE;
236 236
 		}
237 237
 		$inputs = array();
238
-		$fields = $object->get_model()->field_settings( FALSE );
238
+		$fields = $object->get_model()->field_settings(FALSE);
239 239
 		//		$pk = $object->ID(); <<< NO!
240 240
 		//		EEH_Debug_Tools::printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
241 241
 		//		EEH_Debug_Tools::printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
242 242
 		//		EEH_Debug_Tools::printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
243
-		foreach ( $fields as $field_ID => $field ) {
244
-			if ( $field instanceof EE_Model_Field_Base ) {
243
+		foreach ($fields as $field_ID => $field) {
244
+			if ($field instanceof EE_Model_Field_Base) {
245 245
 				//			echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
246 246
 				//			EEH_Debug_Tools::printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
247
-				if ( isset( $input_types[ $field_ID ] ) ) {
247
+				if (isset($input_types[$field_ID])) {
248 248
 					// get saved value for field
249
-					$value = $object->get( $field_ID );
249
+					$value = $object->get($field_ID);
250 250
 					//				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
251 251
 					// if no saved value, then use default
252 252
 					$value = $value !== NULL ? $value : $field->get_default_value();
253 253
 					//			if ( $field_ID == 'CNT_active' )
254 254
 					//				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
255 255
 					// determine question type
256
-					$type = isset( $input_types[ $field_ID ] ) ? $input_types[ $field_ID ][ 'type' ] : 'TEXT';
256
+					$type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT';
257 257
 					// input name
258
-					$input_name = isset( $input_types[ $field_ID ] ) && isset( $input_types[ $field_ID ][ 'input_name' ] ) ? $input_types[ $field_ID ][ 'input_name' ] . '[' . $field_ID . ']' : $field_ID;
258
+					$input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) ? $input_types[$field_ID]['input_name'].'['.$field_ID.']' : $field_ID;
259 259
 					// css class for input
260
-					$class = isset( $input_types[ $field_ID ][ 'class' ] ) && ! empty( $input_types[ $field_ID ][ 'class' ] ) ? ' ' . $input_types[ $field_ID ][ 'class' ] : '';
260
+					$class = isset($input_types[$field_ID]['class']) && ! empty($input_types[$field_ID]['class']) ? ' '.$input_types[$field_ID]['class'] : '';
261 261
 					// whether to apply htmlentities to answer
262
-					$htmlentities = isset( $input_types[ $field_ID ][ 'htmlentities' ] ) ? $input_types[ $field_ID ][ 'htmlentities' ] : TRUE;
262
+					$htmlentities = isset($input_types[$field_ID]['htmlentities']) ? $input_types[$field_ID]['htmlentities'] : TRUE;
263 263
 					// whether to apply htmlentities to answer
264
-					$label_b4 = isset( $input_types[ $field_ID ][ 'label_b4' ] ) ? $input_types[ $field_ID ][ 'label_b4' ] : FALSE;
264
+					$label_b4 = isset($input_types[$field_ID]['label_b4']) ? $input_types[$field_ID]['label_b4'] : FALSE;
265 265
 					// whether to apply htmlentities to answer
266
-					$use_desc_4_label = isset( $input_types[ $field_ID ][ 'use_desc_4_label' ] ) ? $input_types[ $field_ID ][ 'use_desc_4_label' ] : FALSE;
266
+					$use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) ? $input_types[$field_ID]['use_desc_4_label'] : FALSE;
267 267
 
268 268
 					// create EE_Question_Form_Input object
269 269
 					$QFI = new EE_Question_Form_Input(
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 							)
284 284
 						),
285 285
 						array(
286
-							'input_id' => $field_ID . '-' . $object->ID(),
286
+							'input_id' => $field_ID.'-'.$object->ID(),
287 287
 							'input_name' => $input_name,
288
-							'input_class' => $field_ID . $class,
288
+							'input_class' => $field_ID.$class,
289 289
 							'input_prefix' => '',
290 290
 							'append_qstn_id' => FALSE,
291 291
 							'htmlentities' => $htmlentities,
@@ -294,21 +294,21 @@  discard block
 block discarded – undo
294 294
 						)
295 295
 					);
296 296
 					// does question type have options ?
297
-					if ( in_array( $type, array( 'DROPDOWN', 'RADIO_BTN', 'CHECKBOX' ) ) && isset ( $input_types[ $field_ID ] ) && isset ( $input_types[ $field_ID ][ 'options' ] ) ) {
298
-						foreach ( $input_types[ $field_ID ][ 'options' ] as $option ) {
299
-							$option = stripslashes_deep( $option );
300
-							$option_id = ! empty( $option[ 'id' ] ) ? $option[ 'id' ] : 0;
301
-							$QSO = EE_Question_Option::new_instance( array( 'QSO_value' => (string)$option_id, 'QSO_desc' => $option[ 'text' ], 'QSO_deleted' => FALSE ) );
297
+					if (in_array($type, array('DROPDOWN', 'RADIO_BTN', 'CHECKBOX')) && isset ($input_types[$field_ID]) && isset ($input_types[$field_ID]['options'])) {
298
+						foreach ($input_types[$field_ID]['options'] as $option) {
299
+							$option = stripslashes_deep($option);
300
+							$option_id = ! empty($option['id']) ? $option['id'] : 0;
301
+							$QSO = EE_Question_Option::new_instance(array('QSO_value' => (string) $option_id, 'QSO_desc' => $option['text'], 'QSO_deleted' => FALSE));
302 302
 							// all QST (and ANS) properties can be accessed indirectly thru QFI
303
-							$QFI->add_temp_option( $QSO );
303
+							$QFI->add_temp_option($QSO);
304 304
 						}
305 305
 					}
306 306
 					// we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
307
-					if ( $field_ID == $object->get_model()->primary_key_name() ) {
308
-						$QFI->set( 'QST_disabled', TRUE );
307
+					if ($field_ID == $object->get_model()->primary_key_name()) {
308
+						$QFI->set('QST_disabled', TRUE);
309 309
 					}
310 310
 					//EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
311
-					$inputs[ $field_ID ] = $QFI;
311
+					$inputs[$field_ID] = $QFI;
312 312
 					//			if ( $field_ID == 'CNT_active' ) {
313 313
 					//				EEH_Debug_Tools::printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
314 314
 					//			}
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 * @param \EE_Question_Option $QSO EE_Question_Option
327 327
 	 * @return boolean
328 328
 	 */
329
-	public function add_temp_option( EE_Question_Option $QSO ) {
330
-		$this->_QST->add_temp_option( $QSO );
329
+	public function add_temp_option(EE_Question_Option $QSO) {
330
+		$this->_QST->add_temp_option($QSO);
331 331
 	}
332 332
 
333 333
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @param    mixed  $value
340 340
 	 * @return mixed
341 341
 	 */
342
-	public function set( $property = NULL, $value = NULL ) {
343
-		if ( ! empty( $property ) ) {
344
-			if ( EEM_Question::instance()->has_field( $property ) ) {
345
-				$this->_QST->set( $property, $value );
346
-			} else if ( EEM_Answer::instance()->has_field( $property ) ) {
347
-				$this->_ANS->set( $property, $value );
348
-			} else if ( $this->_question_form_input_property_exists( __CLASS__, $property ) ) {
342
+	public function set($property = NULL, $value = NULL) {
343
+		if ( ! empty($property)) {
344
+			if (EEM_Question::instance()->has_field($property)) {
345
+				$this->_QST->set($property, $value);
346
+			} else if (EEM_Answer::instance()->has_field($property)) {
347
+				$this->_ANS->set($property, $value);
348
+			} else if ($this->_question_form_input_property_exists(__CLASS__, $property)) {
349 349
 				echo "<hr>$property is a prop of QFI";
350 350
 				$this->{$property} = $value;
351 351
 				return TRUE;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 	 *                                                       whether it was trashed or not.
367 367
 	 * @return EE_Question_Option
368 368
 	 */
369
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
369
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
370 370
 		$temp_options = $this->_QST->temp_options();
371
-		return ! empty( $temp_options ) ? $temp_options : $this->_QST->options( $notDeletedOptionsOnly, $selected_value_to_always_include );
371
+		return ! empty($temp_options) ? $temp_options : $this->_QST->options($notDeletedOptionsOnly, $selected_value_to_always_include);
372 372
 	}
373 373
 
374 374
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param mixed $key
380 380
 	 * @return mixed
381 381
 	 */
382
-	public function get_meta( $key = FALSE ) {
383
-		return $key && isset( $this->_QST_meta[ $key ] ) ? $this->_QST_meta[ $key ] : FALSE;
382
+	public function get_meta($key = FALSE) {
383
+		return $key && isset($this->_QST_meta[$key]) ? $this->_QST_meta[$key] : FALSE;
384 384
 	}
385 385
 
386 386
 
Please login to merge, or discard this patch.