Completed
Branch BUG-9623-config-log (c144cd)
by
unknown
110:09 queued 92:18
created
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				// generate hidden input
172 172
 				if (
173 173
 					isset( $subsections[ $primary_registrant ] )
174
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
174
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
175 175
 				) {
176 176
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
177 177
 				}
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
903 903
 						// do we need to copy basic info from primary attendee ?
904 904
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
905
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
905
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
906 906
 							? true
907 907
 							: false;
908 908
 						// filter form input data for this registration
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 			? $form_input
1080 1080
 			: $form_input . '-' . $registration->reg_url_link();
1081 1081
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1082
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1083 1083
 			? true
1084 1084
 			: false;
1085 1085
 		//rename form_inputs if they are EE_Attendee properties
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		}
1320 1320
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1321 1321
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1322
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1322
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1323 1323
 			) {
1324 1324
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1325 1325
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +233 added lines, -234 removed lines patch added patch discarded remove patch
@@ -42,21 +42,21 @@  discard block
 block discarded – undo
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 * @return    \EE_SPCO_Reg_Step_Attendee_Information
44 44
 	 */
45
-	public function __construct( EE_Checkout $checkout ) {
45
+	public function __construct(EE_Checkout $checkout) {
46 46
 		$this->_slug = 'attendee_information';
47 47
 		$this->_name = __('Attendee Information', 'event_espresso');
48
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
48
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
49 49
 		$this->checkout = $checkout;
50 50
 		$this->_reset_success_message();
51 51
 		$this->set_instructions(
52
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
52
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
53 53
 		);
54 54
 	}
55 55
 
56 56
 
57 57
 
58 58
 	public function translate_js_strings() {
59
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
59
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
60 60
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
61 61
 			' is a required question. Please enter a value for at least one of the options.',
62 62
 			'event_espresso'
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		// calculate taxes
117 117
 		$Line_Item_Display->display_line_item(
118 118
 			$this->checkout->cart->get_grand_total(),
119
-			array( 'set_tax_rate' => true )
119
+			array('set_tax_rate' => true)
120 120
 		);
121 121
 		/** @var $subsections EE_Form_Section_Proper[] */
122 122
 		$subsections = array(
@@ -128,51 +128,51 @@  discard block
 block discarded – undo
128 128
 			'ticket_count' 	=> array()
129 129
 		);
130 130
 		// grab the saved registrations from the transaction
131
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
132
-		if ( $registrations ) {
133
-			foreach ( $registrations as $registration ) {
131
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
132
+		if ($registrations) {
133
+			foreach ($registrations as $registration) {
134 134
 				// can this registration be processed during this visit ?
135 135
 				if (
136 136
 					$registration instanceof EE_Registration
137
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
137
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
138 138
 				) {
139
-					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
140
-					if ( ! $this->checkout->admin_request ) {
141
-						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
142
-						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
143
-							$template_args['ticket_count'][ $registration->ticket()->ID() ]
139
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
140
+					if ( ! $this->checkout->admin_request) {
141
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
142
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
143
+							$template_args['ticket_count'][$registration->ticket()->ID()]
144 144
 						)
145
-							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
145
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
146 146
 							: 1;
147 147
 						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
148 148
 							$this->checkout->cart->get_grand_total(),
149 149
 							'Ticket',
150
-							array( $registration->ticket()->ID() )
150
+							array($registration->ticket()->ID())
151 151
 						);
152
-						$ticket_line_item = is_array( $ticket_line_item )
153
-							? reset( $ticket_line_item )
152
+						$ticket_line_item = is_array($ticket_line_item)
153
+							? reset($ticket_line_item)
154 154
 							: $ticket_line_item;
155
-						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item(
155
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item(
156 156
 							$ticket_line_item
157 157
 						);
158 158
 					}
159
-					if ( $registration->is_primary_registrant() ) {
159
+					if ($registration->is_primary_registrant()) {
160 160
 						$primary_registrant = $registration->reg_url_link();
161 161
 					}
162 162
 				}
163 163
 			}
164 164
 			// print_copy_info ?
165
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
165
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
166 166
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
167 167
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
168 168
 					? $this->_copy_attendee_info_form()
169 169
 					: $this->_auto_copy_attendee_info();
170 170
 				// generate hidden input
171 171
 				if (
172
-					isset( $subsections[ $primary_registrant ] )
173
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
172
+					isset($subsections[$primary_registrant])
173
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
174 174
 				) {
175
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
175
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
176 176
 				}
177 177
 			}
178 178
 
@@ -184,8 +184,7 @@  discard block
 block discarded – undo
184 184
 				'html_id' 					=> $this->reg_form_name(),
185 185
 				'subsections' 			=> $subsections,
186 186
 				'layout_strategy'		=> $this->checkout->admin_request ?
187
-					new EE_Div_Per_Section_Layout() :
188
-					new EE_Template_Layout(
187
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
189 188
 						array(
190 189
 							'layout_template_file' 	=> $this->_template, // layout_template
191 190
 							'template_args' 				=> $template_args
@@ -203,11 +202,11 @@  discard block
 block discarded – undo
203 202
 	 * @return EE_Form_Section_Proper
204 203
 	 * @throws \EE_Error
205 204
 	 */
206
-	private function _registrations_reg_form( EE_Registration $registration ) {
205
+	private function _registrations_reg_form(EE_Registration $registration) {
207 206
 		static $attendee_nmbr = 1;
208 207
 		// array of params to pass to parent constructor
209 208
 		$form_args = array(
210
-			'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
209
+			'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
211 210
 			'html_class'      => 'ee-reg-form-attendee-dv',
212 211
 			'html_style'      => $this->checkout->admin_request
213 212
 				? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -216,24 +215,24 @@  discard block
 block discarded – undo
216 215
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
217 216
 				array(
218 217
 					'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
219
-					'legend_text'  => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
218
+					'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
220 219
 				)
221 220
 			)
222 221
 		);
223 222
 		// verify that registration has valid event
224
-		if ( $registration->event() instanceof EE_Event ) {
223
+		if ($registration->event() instanceof EE_Event) {
225 224
 			$query_params = array(
226 225
 				array(
227 226
 					'Event.EVT_ID' => $registration->event()->ID(),
228 227
 					'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
229 228
 				),
230
-				'order_by'=>array( 'QSG_order'=>'ASC' )
229
+				'order_by'=>array('QSG_order'=>'ASC')
231 230
 			);
232
-			$question_groups = $registration->event()->question_groups( $query_params );
233
-			if ( $question_groups ) {
234
-				foreach ( $question_groups as $question_group ) {
235
-					if ( $question_group instanceof EE_Question_Group ) {
236
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
231
+			$question_groups = $registration->event()->question_groups($query_params);
232
+			if ($question_groups) {
233
+				foreach ($question_groups as $question_group) {
234
+					if ($question_group instanceof EE_Question_Group) {
235
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
237 236
 							$registration,
238 237
 							$question_group
239 238
 						);
@@ -246,10 +245,10 @@  discard block
 block discarded – undo
246 245
 				// if we have question groups for additional attendees, then display the copy options
247 246
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
248 247
 			} else {
249
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link(
250
-				) ] = new EE_Form_Section_HTML(
248
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link(
249
+				)] = new EE_Form_Section_HTML(
251 250
 					EEH_Template::locate_template(
252
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
251
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
253 252
 						apply_filters(
254 253
 							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args',
255 254
 							array()
@@ -265,12 +264,12 @@  discard block
 block discarded – undo
265 264
 				);
266 265
 			}
267 266
 		}
268
-		if ( $registration->is_primary_registrant() ) {
267
+		if ($registration->is_primary_registrant()) {
269 268
 			// generate hidden input
270
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
269
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
271 270
 		}
272 271
 		$attendee_nmbr++;
273
-		return new EE_Form_Section_Proper( $form_args );
272
+		return new EE_Form_Section_Proper($form_args);
274 273
 	}
275 274
 
276 275
 
@@ -291,7 +290,7 @@  discard block
 block discarded – undo
291 290
 		// generate hidden input
292 291
 		return new EE_Hidden_Input(
293 292
 			array(
294
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
293
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
295 294
 				'default' => $additional_attendee_reg_info
296 295
 			)
297 296
 		);
@@ -305,26 +304,26 @@  discard block
 block discarded – undo
305 304
 	 * @return EE_Form_Section_Proper
306 305
 	 * @throws \EE_Error
307 306
 	 */
308
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
307
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
309 308
 		// array of params to pass to parent constructor
310 309
 		$form_args = array(
311
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
310
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
312 311
 			'html_class'      => $this->checkout->admin_request
313 312
 				? 'form-table ee-reg-form-qstn-grp-dv'
314 313
 				: 'ee-reg-form-qstn-grp-dv',
315
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
314
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
316 315
 			'subsections'     => array(
317
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
316
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
318 317
 			),
319 318
 			'layout_strategy' => $this->checkout->admin_request
320 319
 				? new EE_Admin_Two_Column_Layout()
321 320
 				: new EE_Div_Per_Section_Layout()
322 321
 		);
323 322
 		// where params
324
-		$query_params = array( 'QST_deleted' => 0 );
323
+		$query_params = array('QST_deleted' => 0);
325 324
 		// don't load admin only questions on the frontend
326
-		if ( ! $this->checkout->admin_request ) {
327
-			$query_params['QST_admin_only'] = array( '!=', true );
325
+		if ( ! $this->checkout->admin_request) {
326
+			$query_params['QST_admin_only'] = array('!=', true);
328 327
 		}
329 328
 		$questions = $question_group->get_many_related(
330 329
 			'Question',
@@ -346,10 +345,10 @@  discard block
 block discarded – undo
346 345
 			)
347 346
 		);
348 347
 		// loop thru questions
349
-		foreach ( $questions as $question ) {
350
-			if( $question instanceof EE_Question ){
348
+		foreach ($questions as $question) {
349
+			if ($question instanceof EE_Question) {
351 350
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
352
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
351
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
353 352
 			}
354 353
 		}
355 354
 		$form_args['subsections'] = apply_filters(
@@ -370,7 +369,7 @@  discard block
 block discarded – undo
370 369
 			)
371 370
 		);
372 371
 //		d( $form_args );
373
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
372
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
374 373
 		return apply_filters(
375 374
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
376 375
 			$question_group_reg_form,
@@ -387,11 +386,11 @@  discard block
 block discarded – undo
387 386
 	 * @param EE_Question_Group $question_group
388 387
 	 * @return 	EE_Form_Section_HTML
389 388
 	 */
390
-	private function _question_group_header( EE_Question_Group $question_group ){
389
+	private function _question_group_header(EE_Question_Group $question_group) {
391 390
 		$html = '';
392 391
 		// group_name
393
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
394
-			if ( $this->checkout->admin_request ) {
392
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
393
+			if ($this->checkout->admin_request) {
395 394
 				$html .= EEH_HTML::br();
396 395
 				$html .= EEH_HTML::h3(
397 396
 					$question_group->name(),
@@ -405,7 +404,7 @@  discard block
 block discarded – undo
405 404
 			}
406 405
 		}
407 406
 		// group_desc
408
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
407
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
409 408
 			$html .= EEH_HTML::p(
410 409
 				$question_group->desc(),
411 410
 				'',
@@ -415,7 +414,7 @@  discard block
 block discarded – undo
415 414
 			);
416 415
 
417 416
 		}
418
-		return new EE_Form_Section_HTML( $html );
417
+		return new EE_Form_Section_HTML($html);
419 418
 	}
420 419
 
421 420
 
@@ -425,7 +424,7 @@  discard block
 block discarded – undo
425 424
 	 * @return    EE_Form_Section_Proper
426 425
 	 * @throws \EE_Error
427 426
 	 */
428
-	private function _copy_attendee_info_form(){
427
+	private function _copy_attendee_info_form() {
429 428
 		// array of params to pass to parent constructor
430 429
 		return new EE_Form_Section_Proper(
431 430
 			array(
@@ -454,7 +453,7 @@  discard block
 block discarded – undo
454 453
 	private function _auto_copy_attendee_info() {
455 454
 		return new EE_Form_Section_HTML(
456 455
 			EEH_Template::locate_template(
457
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
456
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
458 457
 				apply_filters(
459 458
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
460 459
 					array()
@@ -478,32 +477,32 @@  discard block
 block discarded – undo
478 477
 		$copy_attendee_info_inputs = array();
479 478
 		$prev_ticket = NULL;
480 479
 		// grab the saved registrations from the transaction
481
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
482
-		foreach ( $registrations as $registration ) {
480
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
481
+		foreach ($registrations as $registration) {
483 482
 			// for all  attendees other than the primary attendee
484
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
483
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
485 484
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
486
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
485
+				if ($registration->ticket()->ID() !== $prev_ticket) {
487 486
 					$item_name = $registration->ticket()->name();
488 487
 					$item_name .= $registration->ticket()->description() !== ''
489
-						? ' - ' . $registration->ticket()->description()
488
+						? ' - '.$registration->ticket()->description()
490 489
 						: '';
491
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
492
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
490
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
491
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
493 492
 					);
494 493
 					$prev_ticket = $registration->ticket()->ID();
495 494
 				}
496 495
 
497
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
496
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
498 497
 				EE_Checkbox_Multi_Input(
499 498
 					array(
500 499
 						$registration->ID() => sprintf(
501
-							__( 'Attendee #%s', 'event_espresso' ),
500
+							__('Attendee #%s', 'event_espresso'),
502 501
 							$registration->count()
503 502
 						)
504 503
 					),
505 504
 					array(
506
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
505
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
507 506
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
508 507
 						'display_html_label_text' => false
509 508
 					)
@@ -523,7 +522,7 @@  discard block
 block discarded – undo
523 522
 	 * @return    EE_Form_Input_Base
524 523
 	 * @throws \EE_Error
525 524
 	 */
526
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
525
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
527 526
 		// generate hidden input
528 527
 		return new EE_Hidden_Input(
529 528
 			array(
@@ -542,7 +541,7 @@  discard block
 block discarded – undo
542 541
 	 * @return    EE_Form_Input_Base
543 542
 	 * @throws \EE_Error
544 543
 	 */
545
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
544
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
546 545
 
547 546
 		// if this question was for an attendee detail, then check for that answer
548 547
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -551,32 +550,32 @@  discard block
 block discarded – undo
551 550
 		);
552 551
 		$answer = $answer_value === null
553 552
 			? EEM_Answer::instance()->get_one(
554
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
553
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
555 554
 			)
556 555
 			: null;
557 556
 		// if NOT returning to edit an existing registration
558 557
 		// OR if this question is for an attendee property
559 558
 		// OR we still don't have an EE_Answer object
560
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
559
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
561 560
 			// create an EE_Answer object for storing everything in
562
-			$answer = EE_Answer::new_instance ( array(
561
+			$answer = EE_Answer::new_instance(array(
563 562
 				'QST_ID'=> $question->ID(),
564 563
 				'REG_ID'=> $registration->ID()
565 564
 			));
566 565
 		}
567 566
 		// verify instance
568
-		if( $answer instanceof EE_Answer ){
569
-			if ( ! empty( $answer_value )) {
570
-				$answer->set( 'ANS_value', $answer_value );
567
+		if ($answer instanceof EE_Answer) {
568
+			if ( ! empty($answer_value)) {
569
+				$answer->set('ANS_value', $answer_value);
571 570
 			}
572
-			$answer->cache( 'Question', $question );
571
+			$answer->cache('Question', $question);
573 572
 			//remember system ID had a bug where sometimes it could be null
574
-			$answer_cache_id =$question->is_system_question()
575
-				? $question->system_ID() . '-' . $registration->reg_url_link()
576
-				: $question->ID() . '-' . $registration->reg_url_link();			
577
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
573
+			$answer_cache_id = $question->is_system_question()
574
+				? $question->system_ID().'-'.$registration->reg_url_link()
575
+				: $question->ID().'-'.$registration->reg_url_link();			
576
+			$registration->cache('Answer', $answer, $answer_cache_id);
578 577
 		}
579
-		return $this->_generate_question_input( $registration, $question, $answer );
578
+		return $this->_generate_question_input($registration, $question, $answer);
580 579
 
581 580
 	}
582 581
 
@@ -589,46 +588,46 @@  discard block
 block discarded – undo
589 588
 	 * @return EE_Form_Input_Base
590 589
 	 * @throws \EE_Error
591 590
 	 */
592
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
591
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
593 592
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
594
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
593
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
595 594
 		add_filter(
596 595
 			'FHEE__EE_Question__generate_form_input__country_options',
597
-			array( $this, 'use_cached_countries_for_form_input' ),
596
+			array($this, 'use_cached_countries_for_form_input'),
598 597
 			10,
599 598
 			4
600 599
 		);
601 600
 		add_filter(
602 601
 			'FHEE__EE_Question__generate_form_input__state_options',
603
-			array( $this, 'use_cached_states_for_form_input' ),
602
+			array($this, 'use_cached_states_for_form_input'),
604 603
 			10,
605 604
 			4
606 605
 		);
607 606
 		$input_constructor_args = array(
608
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
609
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
610
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
611
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
607
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
608
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
609
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
610
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
612 611
 			'html_label_class'	=> 'ee-reg-qstn',
613 612
 		);
614
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
615
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
616
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
617
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
618
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
613
+		$input_constructor_args['html_label_id'] .= '-lbl';
614
+		if ($answer instanceof EE_Answer && $answer->ID()) {
615
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
616
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
617
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
619 618
 		}
620
-		$form_input =  $question->generate_form_input(
619
+		$form_input = $question->generate_form_input(
621 620
 			$registration,
622 621
 			$answer,
623 622
 			$input_constructor_args
624 623
 		);
625 624
 		remove_filter(
626 625
 			'FHEE__EE_Question__generate_form_input__country_options',
627
-			array( $this, 'use_cached_countries_for_form_input' )
626
+			array($this, 'use_cached_countries_for_form_input')
628 627
 		);
629 628
 		remove_filter(
630 629
 			'FHEE__EE_Question__generate_form_input__state_options',
631
-			array( $this, 'use_cached_states_for_form_input' )
630
+			array($this, 'use_cached_states_for_form_input')
632 631
 		);
633 632
 		return $form_input;
634 633
 	}
@@ -642,23 +641,23 @@  discard block
 block discarded – undo
642 641
 	 * @return array 2d keys are country IDs, values are their names
643 642
 	 * @throws \EE_Error
644 643
 	 */
645
-	public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) {
646
-		$country_options = array( '' => '' );
644
+	public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) {
645
+		$country_options = array('' => '');
647 646
 		// get possibly cached list of countries
648 647
 		$countries = $this->checkout->action === 'process_reg_step'
649 648
 			? EEM_Country::instance()->get_all_countries()
650 649
 			: EEM_Country::instance()->get_all_active_countries();
651
-		if ( ! empty( $countries )) {
652
-			foreach( $countries as $country ){
653
-				if ( $country instanceof EE_Country ) {
654
-					$country_options[ $country->ID() ] = $country->name();
650
+		if ( ! empty($countries)) {
651
+			foreach ($countries as $country) {
652
+				if ($country instanceof EE_Country) {
653
+					$country_options[$country->ID()] = $country->name();
655 654
 				}
656 655
 			}
657 656
 		}
658
-		if( $question instanceof EE_Question
659
-			&& $registration instanceof EE_Registration ) {
657
+		if ($question instanceof EE_Question
658
+			&& $registration instanceof EE_Registration) {
660 659
 			$answer = EEM_Answer::instance()->get_one(
661
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
660
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
662 661
 			);
663 662
 		} else {
664 663
 			$answer = EE_Answer::new_instance();
@@ -685,15 +684,15 @@  discard block
 block discarded – undo
685 684
 	 * @return array 2d keys are state IDs, values are their names
686 685
 	 * @throws \EE_Error
687 686
 	 */
688
-	public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) {
689
-		$state_options = array( '' => array( '' => ''));
687
+	public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) {
688
+		$state_options = array('' => array('' => ''));
690 689
 		$states = $this->checkout->action === 'process_reg_step'
691 690
 			? EEM_State::instance()->get_all_states()
692 691
 			: EEM_State::instance()->get_all_active_states();
693
-		if ( ! empty( $states )) {
694
-			foreach( $states as $state ){
695
-				if ( $state instanceof EE_State ) {
696
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
692
+		if ( ! empty($states)) {
693
+			foreach ($states as $state) {
694
+				if ($state instanceof EE_State) {
695
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
697 696
 				}
698 697
 			}
699 698
 		}
@@ -721,24 +720,24 @@  discard block
 block discarded – undo
721 720
 	 * @throws \EE_Error
722 721
 	 */
723 722
 	public function process_reg_step() {
724
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
723
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
725 724
 		// grab validated data from form
726 725
 		$valid_data = $this->checkout->current_step->valid_data();
727 726
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
728 727
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
729 728
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
730
-		if ( empty( $valid_data ))  {
729
+		if (empty($valid_data)) {
731 730
 			EE_Error::add_error(
732
-				__( 'No valid question responses were received.', 'event_espresso' ),
731
+				__('No valid question responses were received.', 'event_espresso'),
733 732
 				__FILE__,
734 733
 				__FUNCTION__,
735 734
 				__LINE__
736 735
 			);
737 736
 			return false;
738 737
 		}
739
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
738
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
740 739
 			EE_Error::add_error(
741
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
740
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
742 741
 				__FILE__,
743 742
 				__FUNCTION__,
744 743
 				__LINE__
@@ -746,11 +745,11 @@  discard block
 block discarded – undo
746 745
 			return false;
747 746
 		}
748 747
 		// get cached registrations
749
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
748
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
750 749
 		// verify we got the goods
751
-		if ( empty( $registrations )) {
750
+		if (empty($registrations)) {
752 751
 			EE_Error::add_error(
753
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
752
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
754 753
 				__FILE__,
755 754
 				__FUNCTION__,
756 755
 				__LINE__
@@ -758,15 +757,15 @@  discard block
 block discarded – undo
758 757
 			return false;
759 758
 		}
760 759
 		// extract attendee info from form data and save to model objects
761
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
760
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
762 761
 		// if first pass thru SPCO,
763 762
 		// then let's check processed registrations against the total number of tickets in the cart
764
-		if ( $registrations_processed === false ) {
763
+		if ($registrations_processed === false) {
765 764
 			// but return immediately if the previous step exited early due to errors
766 765
 			return false;
767
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
766
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
768 767
 			// generate a correctly translated string for all possible singular/plural combinations
769
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
768
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
770 769
 				$error_msg = sprintf(
771 770
 					__(
772 771
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 					$this->checkout->total_ticket_count,
776 775
 					$registrations_processed
777 776
 				);
778
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
777
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
779 778
 				$error_msg = sprintf(
780 779
 					__(
781 780
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -794,17 +793,17 @@  discard block
 block discarded – undo
794 793
 					$registrations_processed
795 794
 				);
796 795
 			}
797
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
796
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
798 797
 			return false;
799 798
 		}
800 799
 		// mark this reg step as completed
801 800
 		$this->set_completed();
802 801
 		$this->_set_success_message(
803
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
802
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
804 803
 		);
805 804
 		//do action in case a plugin wants to do something with the data submitted in step 1.
806 805
 		//passes EE_Single_Page_Checkout, and it's posted data
807
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
806
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
808 807
 		return true;
809 808
 	}
810 809
 
@@ -818,9 +817,9 @@  discard block
 block discarded – undo
818 817
 	 * @return boolean | int
819 818
 	 * @throws \EE_Error
820 819
 	 */
821
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
820
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
822 821
 		// load resources and set some defaults
823
-		EE_Registry::instance()->load_model( 'Attendee' );
822
+		EE_Registry::instance()->load_model('Attendee');
824 823
 		// holder for primary registrant attendee object
825 824
 		$this->checkout->primary_attendee_obj = NULL;
826 825
 		// array for tracking reg form data for the primary registrant
@@ -837,9 +836,9 @@  discard block
 block discarded – undo
837 836
 		// attendee counter
838 837
 		$att_nmbr = 0;
839 838
 		// grab the saved registrations from the transaction
840
-		foreach ( $registrations  as $registration ) {
839
+		foreach ($registrations  as $registration) {
841 840
 			// verify EE_Registration object
842
-			if ( ! $registration instanceof EE_Registration ) {
841
+			if ( ! $registration instanceof EE_Registration) {
843 842
 				EE_Error::add_error(
844 843
 					__(
845 844
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -854,12 +853,12 @@  discard block
 block discarded – undo
854 853
 			/** @var string $reg_url_link */
855 854
 			$reg_url_link = $registration->reg_url_link();
856 855
 			// reg_url_link exists ?
857
-			if ( ! empty( $reg_url_link ) ) {
856
+			if ( ! empty($reg_url_link)) {
858 857
 				// should this registration be processed during this visit ?
859
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
858
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
860 859
 					// if NOT revisiting, then let's save the registration now,
861 860
 					// so that we have a REG_ID to use when generating other objects
862
-					if ( ! $this->checkout->revisit ) {
861
+					if ( ! $this->checkout->revisit) {
863 862
 						$registration->save();
864 863
 					}
865 864
 					/**
@@ -869,7 +868,7 @@  discard block
 block discarded – undo
869 868
 					 * @var bool   if true is returned by the plugin then the
870 869
 					 *      		registration processing is halted.
871 870
 					 */
872
-					if ( apply_filters(
871
+					if (apply_filters(
873 872
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
874 873
 						false,
875 874
 						$att_nmbr,
@@ -877,38 +876,38 @@  discard block
 block discarded – undo
877 876
 						$registrations,
878 877
 						$valid_data,
879 878
 						$this
880
-					) ) {
879
+					)) {
881 880
 						return false;
882 881
 					}
883 882
 
884 883
 					// Houston, we have a registration!
885 884
 					$att_nmbr++;
886
-					$this->_attendee_data[ $reg_url_link ] = array();
885
+					$this->_attendee_data[$reg_url_link] = array();
887 886
 					// grab any existing related answer objects
888 887
 					$this->_registration_answers = $registration->answers();
889 888
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
890
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
889
+					if (isset($valid_data[$reg_url_link])) {
891 890
 						// do we need to copy basic info from primary attendee ?
892
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
893
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
891
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
892
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
894 893
 							? true
895 894
 							: false;
896 895
 						// filter form input data for this registration
897
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
896
+						$valid_data[$reg_url_link] = (array) apply_filters(
898 897
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
899
-							$valid_data[ $reg_url_link ]
898
+							$valid_data[$reg_url_link]
900 899
 						);
901 900
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
902
-						if ( isset( $valid_data['primary_attendee'] )) {
903
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
901
+						if (isset($valid_data['primary_attendee'])) {
902
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
904 903
 								? $valid_data['primary_attendee']
905 904
 								: false;
906
-							unset( $valid_data['primary_attendee'] );
905
+							unset($valid_data['primary_attendee']);
907 906
 						}
908 907
 						// now loop through our array of valid post data && process attendee reg forms
909
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
910
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
911
-								foreach ( $form_inputs as $form_input => $input_value ) {
908
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
909
+							if ( ! in_array($form_section, $non_input_form_sections)) {
910
+								foreach ($form_inputs as $form_input => $input_value) {
912 911
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
913 912
 									// check for critical inputs
914 913
 									if (
@@ -922,16 +921,16 @@  discard block
 block discarded – undo
922 921
 									// store a bit of data about the primary attendee
923 922
 									if (
924 923
 										$att_nmbr === 1
925
-										&& ! empty( $input_value )
924
+										&& ! empty($input_value)
926 925
 										&& $reg_url_link === $primary_registrant['line_item_id']
927 926
 									) {
928
-										$primary_registrant[ $form_input ] = $input_value;
927
+										$primary_registrant[$form_input] = $input_value;
929 928
 									} else if (
930 929
 										$copy_primary
931 930
 										&& $input_value === null
932
-										&& isset( $primary_registrant[ $form_input ] )
931
+										&& isset($primary_registrant[$form_input])
933 932
 									) {
934
-										$input_value = $primary_registrant[ $form_input ];
933
+										$input_value = $primary_registrant[$form_input];
935 934
 									}
936 935
 									// now attempt to save the input data
937 936
 									if (
@@ -973,57 +972,57 @@  discard block
 block discarded – undo
973 972
 						// have we met before?
974 973
 						$attendee = $this->_find_existing_attendee(
975 974
 							$registration,
976
-							$this->_attendee_data[ $reg_url_link ]
975
+							$this->_attendee_data[$reg_url_link]
977 976
 						);
978 977
 						// did we find an already existing record for this attendee ?
979
-						if ( $attendee instanceof EE_Attendee ) {
978
+						if ($attendee instanceof EE_Attendee) {
980 979
 							$attendee = $this->_update_existing_attendee_data(
981 980
 								$attendee,
982
-								$this->_attendee_data[ $reg_url_link ]
981
+								$this->_attendee_data[$reg_url_link]
983 982
 							);
984 983
 						} else {
985 984
 							// ensure critical details are set for additional attendees
986
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
985
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
987 986
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
988
-									$this->_attendee_data[ $reg_url_link ]
987
+									$this->_attendee_data[$reg_url_link]
989 988
 								)
990
-								: $this->_attendee_data[ $reg_url_link ];
989
+								: $this->_attendee_data[$reg_url_link];
991 990
 							$attendee = $this->_create_new_attendee(
992 991
 								$registration,
993
-								$this->_attendee_data[ $reg_url_link ]
992
+								$this->_attendee_data[$reg_url_link]
994 993
 							);
995 994
 						}
996 995
 						// who's #1 ?
997
-						if ( $att_nmbr === 1 ) {
996
+						if ($att_nmbr === 1) {
998 997
 							$this->checkout->primary_attendee_obj = $attendee;
999 998
 						}
1000 999
 					}
1001 1000
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1002 1001
 					// add relation to registration, set attendee ID, and cache attendee
1003
-					$this->_associate_attendee_with_registration( $registration, $attendee );
1002
+					$this->_associate_attendee_with_registration($registration, $attendee);
1004 1003
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1005
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1006
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
1004
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
1005
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1007 1006
 						return false;
1008 1007
 					}
1009 1008
 					/** @type EE_Registration_Processor $registration_processor */
1010
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1009
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1011 1010
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1012
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1011
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1013 1012
 					/** @type EE_Transaction_Processor $transaction_processor */
1014
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1013
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1015 1014
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1016
-					$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1015
+					$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1017 1016
 					// if we've gotten this far, then let's save what we have
1018 1017
 					$registration->save();
1019 1018
 					// add relation between TXN and registration
1020
-					$this->_associate_registration_with_transaction( $registration );
1019
+					$this->_associate_registration_with_transaction($registration);
1021 1020
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1022 1021
 
1023
-			}  else {
1024
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1022
+			} else {
1023
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1025 1024
 				// remove malformed data
1026
-				unset( $valid_data[ $reg_url_link ] );
1025
+				unset($valid_data[$reg_url_link]);
1027 1026
 				return false;
1028 1027
 			}
1029 1028
 
@@ -1052,26 +1051,26 @@  discard block
 block discarded – undo
1052 1051
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1053 1052
 		// allow for plugins to hook in and do their own processing of the form input.
1054 1053
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1055
-		if ( apply_filters(
1054
+		if (apply_filters(
1056 1055
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1057 1056
 			false,
1058 1057
 			$registration,
1059 1058
 			$form_input,
1060 1059
 			$input_value,
1061 1060
 			$this
1062
-		) ) {
1061
+		)) {
1063 1062
 			return true;
1064 1063
 		}
1065 1064
 		// $answer_cache_id is the key used to find the EE_Answer we want
1066 1065
 		$answer_cache_id = $this->checkout->reg_url_link
1067 1066
 			? $form_input
1068
-			: $form_input . '-' . $registration->reg_url_link();
1069
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1070
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1067
+			: $form_input.'-'.$registration->reg_url_link();
1068
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1069
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1071 1070
 			? true
1072 1071
 			: false;
1073 1072
 		//rename form_inputs if they are EE_Attendee properties
1074
-		switch( (string)$form_input ) {
1073
+		switch ((string) $form_input) {
1075 1074
 
1076 1075
 			case 'state' :
1077 1076
 			case 'STA_ID' :
@@ -1086,32 +1085,32 @@  discard block
 block discarded – undo
1086 1085
 				break;
1087 1086
 
1088 1087
 			default :
1089
-				$ATT_input = 'ATT_' . $form_input;
1088
+				$ATT_input = 'ATT_'.$form_input;
1090 1089
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1091
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1092
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1090
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1091
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1093 1092
 		}
1094 1093
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1095 1094
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1096 1095
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1097 1096
 		// if this form input has a corresponding attendee property
1098
-		if ( $attendee_property ) {
1099
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1100
-			if ( $answer_is_obj ) {
1097
+		if ($attendee_property) {
1098
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1099
+			if ($answer_is_obj) {
1101 1100
 				// and delete the corresponding answer since we won't be storing this data in that object
1102
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1103
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1101
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1102
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1104 1103
 			}
1105 1104
 			return true;
1106
-		} elseif ( $answer_is_obj ) {
1105
+		} elseif ($answer_is_obj) {
1107 1106
 			// save this data to the answer object
1108
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1109
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1107
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1108
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1110 1109
 			return $result !== false ? true : false;
1111 1110
 		} else {
1112
-			foreach ( $this->_registration_answers as $answer ) {
1113
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1114
-					$answer->set_value( $input_value );
1111
+			foreach ($this->_registration_answers as $answer) {
1112
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1113
+					$answer->set_value($input_value);
1115 1114
 					$result = $answer->save();
1116 1115
 					return $result !== false ? true : false;
1117 1116
 				}
@@ -1133,15 +1132,15 @@  discard block
 block discarded – undo
1133 1132
 		$form_input = '',
1134 1133
 		$input_value = ''
1135 1134
 	) {
1136
-		if ( empty( $input_value ) ) {
1135
+		if (empty($input_value)) {
1137 1136
 			// if the form input isn't marked as being required, then just return
1138
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1137
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1139 1138
 				return true;
1140 1139
 			}
1141
-			switch ( $form_input ) {
1140
+			switch ($form_input) {
1142 1141
 				case 'fname' :
1143 1142
 					EE_Error::add_error(
1144
-						__( 'First Name is a required value.', 'event_espresso' ),
1143
+						__('First Name is a required value.', 'event_espresso'),
1145 1144
 						__FILE__,
1146 1145
 						__FUNCTION__,
1147 1146
 						__LINE__
@@ -1150,7 +1149,7 @@  discard block
 block discarded – undo
1150 1149
 					break;
1151 1150
 				case 'lname' :
1152 1151
 					EE_Error::add_error(
1153
-						__( 'Last Name is a required value.', 'event_espresso' ),
1152
+						__('Last Name is a required value.', 'event_espresso'),
1154 1153
 						__FILE__,
1155 1154
 						__FUNCTION__,
1156 1155
 						__LINE__
@@ -1159,7 +1158,7 @@  discard block
 block discarded – undo
1159 1158
 					break;
1160 1159
 				case 'email' :
1161 1160
 					EE_Error::add_error(
1162
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1161
+						__('Please enter a valid email address.', 'event_espresso'),
1163 1162
 						__FILE__,
1164 1163
 						__FUNCTION__,
1165 1164
 						__LINE__
@@ -1192,21 +1191,21 @@  discard block
 block discarded – undo
1192 1191
 	 * @param array           $attendee_data
1193 1192
 	 * @return boolean
1194 1193
 	 */
1195
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1194
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1196 1195
 		$existing_attendee = null;
1197 1196
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1198
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1197
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1199 1198
 			? $attendee_data['ATT_fname']
1200 1199
 			: '';
1201
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1200
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1202 1201
 			? $attendee_data['ATT_lname']
1203 1202
 			: '';
1204
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1203
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1205 1204
 			? $attendee_data['ATT_email']
1206 1205
 			: '';
1207 1206
 		// but only if those have values
1208
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1209
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1207
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1208
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1210 1209
 				'ATT_fname' => $ATT_fname,
1211 1210
 				'ATT_lname' => $ATT_lname,
1212 1211
 				'ATT_email' => $ATT_email
@@ -1230,13 +1229,13 @@  discard block
 block discarded – undo
1230 1229
 	 * @return \EE_Attendee
1231 1230
 	 * @throws \EE_Error
1232 1231
 	 */
1233
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1232
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1234 1233
 		// first remove fname, lname, and email from attendee data
1235
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1234
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1236 1235
 		// now loop thru what's left and add to attendee CPT
1237
-		foreach ( $attendee_data as $property_name => $property_value ) {
1238
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1239
-				$existing_attendee->set( $property_name, $property_value );
1236
+		foreach ($attendee_data as $property_name => $property_value) {
1237
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1238
+				$existing_attendee->set($property_name, $property_value);
1240 1239
 			}
1241 1240
 		}
1242 1241
 		// better save that now
@@ -1254,11 +1253,11 @@  discard block
 block discarded – undo
1254 1253
 	 * @return void
1255 1254
 	 * @throws \EE_Error
1256 1255
 	 */
1257
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1256
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1258 1257
 		// add relation to attendee
1259
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1260
-		$registration->set_attendee_id( $attendee->ID() );
1261
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1258
+		$registration->_add_relation_to($attendee, 'Attendee');
1259
+		$registration->set_attendee_id($attendee->ID());
1260
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1262 1261
 	}
1263 1262
 
1264 1263
 
@@ -1270,10 +1269,10 @@  discard block
 block discarded – undo
1270 1269
 	 * @return void
1271 1270
 	 * @throws \EE_Error
1272 1271
 	 */
1273
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1272
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1274 1273
 		// add relation to attendee
1275
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1276
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1274
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1275
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1277 1276
 	}
1278 1277
 
1279 1278
 
@@ -1286,14 +1285,14 @@  discard block
 block discarded – undo
1286 1285
 	 * @return array
1287 1286
 	 * @throws \EE_Error
1288 1287
 	 */
1289
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1288
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1290 1289
 		// bare minimum critical details include first name, last name, email address
1291
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1290
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1292 1291
 		// add address info to critical details?
1293
-		if ( apply_filters(
1292
+		if (apply_filters(
1294 1293
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1295 1294
 			false
1296
-		) ) {
1295
+		)) {
1297 1296
 			$address_details = array(
1298 1297
 				'ATT_address',
1299 1298
 				'ATT_address2',
@@ -1303,13 +1302,13 @@  discard block
 block discarded – undo
1303 1302
 				'ATT_zip',
1304 1303
 				'ATT_phone'
1305 1304
 			);
1306
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1305
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1307 1306
 		}
1308
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1309
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1310
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1307
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1308
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1309
+			     || empty($attendee_data[$critical_attendee_detail])
1311 1310
 			) {
1312
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1311
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1313 1312
 					$critical_attendee_detail
1314 1313
 				);
1315 1314
 			}
@@ -1327,11 +1326,11 @@  discard block
 block discarded – undo
1327 1326
 	 * @return \EE_Attendee
1328 1327
 	 * @throws \EE_Error
1329 1328
 	 */
1330
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1329
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1331 1330
 		// create new attendee object
1332
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1331
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1333 1332
 		// set author to event creator
1334
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1333
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1335 1334
 		$new_attendee->save();
1336 1335
 		return $new_attendee;
1337 1336
 	}
@@ -1348,7 +1347,7 @@  discard block
 block discarded – undo
1348 1347
 	 */
1349 1348
 	public function update_reg_step() {
1350 1349
 		// save everything
1351
-		if ( $this->process_reg_step() ) {
1350
+		if ($this->process_reg_step()) {
1352 1351
 			$this->checkout->redirect = true;
1353 1352
 			$this->checkout->redirect_url = add_query_arg(
1354 1353
 				array(
@@ -1357,7 +1356,7 @@  discard block
 block discarded – undo
1357 1356
 				),
1358 1357
 				$this->checkout->thank_you_page_url
1359 1358
 			);
1360
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1359
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1361 1360
 			return true;
1362 1361
 		}
1363 1362
 		return false;
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function
413 413
 	 * for getting attendees and how many registrations they each have for an event)
414 414
 	 *
415
-	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
415
+	 * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT'
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 * Gets all the extra meta info on this payment
694 694
 	 *
695 695
 	 * @param array $query_params like EEM_Base::get_all
696
-	 * @return EE_Extra_Meta
696
+	 * @return EE_Base_Class[]
697 697
 	 * @throws \EE_Error
698 698
 	 */
699 699
 	public function extra_meta( $query_params = array() ) {
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 	 * Sets PMD_ID
871 871
 	 *
872 872
 	 * @param int $PMD_ID
873
-	 * @return boolean
873
+	 * @return boolean|null
874 874
 	 * @throws \EE_Error
875 875
 	 */
876 876
 	public function set_payment_method_ID($PMD_ID) {
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 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
  * EE_Transaction class
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	 * @return EE_Transaction
26 26
 	 * @throws \EE_Error
27 27
 	 */
28
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
29
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
28
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
29
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
30 30
 		return $has_object
31 31
 			? $has_object
32
-			: new self( $props_n_values, false, $timezone, $date_formats );
32
+			: new self($props_n_values, false, $timezone, $date_formats);
33 33
 	}
34 34
 
35 35
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 * @return EE_Transaction
42 42
 	 * @throws \EE_Error
43 43
 	 */
44
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
45
-		return new self( $props_n_values, TRUE, $timezone );
44
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
45
+		return new self($props_n_values, TRUE, $timezone);
46 46
 	}
47 47
 
48 48
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function lock() {
60 60
 		// attempt to set lock, but if that fails...
61
-		if ( ! $this->add_extra_meta( 'lock', time(), true )  ) {
61
+		if ( ! $this->add_extra_meta('lock', time(), true)) {
62 62
 			// then attempt to remove the lock in case it is expired
63
-			if ( $this->_remove_expired_lock() ) {
63
+			if ($this->_remove_expired_lock()) {
64 64
 				// if removal was successful, then try setting lock again
65 65
 				$this->lock();
66 66
 			} else {
67 67
 				// but if the lock can not be removed, then throw an exception
68 68
 				throw new EE_Error(
69 69
 					sprintf(
70
-						__( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ),
70
+						__('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'),
71 71
 						$this->ID()
72 72
 					)
73 73
 				);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @throws \EE_Error
87 87
 	 */
88 88
 	public function unlock() {
89
-		return $this->delete_extra_meta( 'lock' );
89
+		return $this->delete_extra_meta('lock');
90 90
 	}
91 91
 
92 92
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function is_locked() {
109 109
 		// if TXN is not locked, then return false immediately
110
-		if ( ! $this->_get_lock() ) {
110
+		if ( ! $this->_get_lock()) {
111 111
 			return false;
112 112
 		}
113 113
 		// if not, then let's try and remove the lock in case it's expired...
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @throws \EE_Error
129 129
 	 */
130 130
 	protected function _get_lock() {
131
-		return (int)$this->get_extra_meta( 'lock', true, 0 );
131
+		return (int) $this->get_extra_meta('lock', true, 0);
132 132
 	}
133 133
 
134 134
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function _remove_expired_lock() {
145 145
 		$locked = $this->_get_lock();
146
-		if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) {
146
+		if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) {
147 147
 			return $this->unlock();
148 148
 		}
149 149
 		return 0;
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param        float $total total value of transaction
159 159
 	 * @throws \EE_Error
160 160
 	 */
161
-	public function set_total( $total = 0.00 ) {
162
-		$this->set( 'TXN_total', (float)$total );
161
+	public function set_total($total = 0.00) {
162
+		$this->set('TXN_total', (float) $total);
163 163
 	}
164 164
 
165 165
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
172 172
 	 * @throws \EE_Error
173 173
 	 */
174
-	public function set_paid( $total_paid = 0.00 ) {
175
-		$this->set( 'TXN_paid', (float)$total_paid );
174
+	public function set_paid($total_paid = 0.00) {
175
+		$this->set('TXN_paid', (float) $total_paid);
176 176
 	}
177 177
 
178 178
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
185 185
 	 * @throws \EE_Error
186 186
 	 */
187
-	public function set_status( $status = '' ) {
188
-		$this->set( 'STS_ID', $status );
187
+	public function set_status($status = '') {
188
+		$this->set('STS_ID', $status);
189 189
 	}
190 190
 
191 191
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param        string $hash_salt required for some payment gateways
198 198
 	 * @throws \EE_Error
199 199
 	 */
200
-	public function set_hash_salt( $hash_salt = '' ) {
201
-		$this->set( 'TXN_hash_salt', $hash_salt );
200
+	public function set_hash_salt($hash_salt = '') {
201
+		$this->set('TXN_hash_salt', $hash_salt);
202 202
 	}
203 203
 
204 204
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param array $txn_reg_steps
210 210
 	 * @throws \EE_Error
211 211
 	 */
212
-	public function set_reg_steps( array $txn_reg_steps ) {
213
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
212
+	public function set_reg_steps(array $txn_reg_steps) {
213
+		$this->set('TXN_reg_steps', $txn_reg_steps);
214 214
 	}
215 215
 
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @throws \EE_Error
223 223
 	 */
224 224
 	public function reg_steps() {
225
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
226
-		return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array();
225
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
226
+		return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array();
227 227
 	}
228 228
 
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @throws \EE_Error
234 234
 	 */
235 235
 	public function pretty_total() {
236
-		return $this->get_pretty( 'TXN_total' );
236
+		return $this->get_pretty('TXN_total');
237 237
 	}
238 238
 
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @throws \EE_Error
246 246
 	 */
247 247
 	public function pretty_paid() {
248
-		return $this->get_pretty( 'TXN_paid' );
248
+		return $this->get_pretty('TXN_paid');
249 249
 	}
250 250
 
251 251
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @throws \EE_Error
259 259
 	 */
260 260
 	public function remaining() {
261
-		return (float)( $this->total() - $this->paid() );
261
+		return (float) ($this->total() - $this->paid());
262 262
 	}
263 263
 
264 264
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @throws \EE_Error
272 272
 	 */
273 273
 	public function total() {
274
-		return (float)$this->get( 'TXN_total' );
274
+		return (float) $this->get('TXN_total');
275 275
 	}
276 276
 
277 277
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws \EE_Error
285 285
 	 */
286 286
 	public function paid() {
287
-		return (float)$this->get( 'TXN_paid' );
287
+		return (float) $this->get('TXN_paid');
288 288
 	}
289 289
 
290 290
 
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	 * @throws \EE_Error
297 297
 	 */
298 298
 	public function get_cart_session() {
299
-		$session_data = (array)$this->get( 'TXN_session_data' );
300
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart
301
-			? $session_data[ 'cart' ]
299
+		$session_data = (array) $this->get('TXN_session_data');
300
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart
301
+			? $session_data['cart']
302 302
 			: null;
303 303
 	}
304 304
 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	 * @throws \EE_Error
312 312
 	 */
313 313
 	public function session_data() {
314
-		$session_data = $this->get( 'TXN_session_data' );
315
-		if ( empty( $session_data ) ) {
314
+		$session_data = $this->get('TXN_session_data');
315
+		if (empty($session_data)) {
316 316
 			$session_data = array(
317 317
 				'id'            => null,
318 318
 				'user_id'       => null,
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	 * @param        EE_Session|array $session_data
336 336
 	 * @throws \EE_Error
337 337
 	 */
338
-	public function set_txn_session_data( $session_data ) {
339
-		if ( $session_data instanceof EE_Session ) {
340
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
338
+	public function set_txn_session_data($session_data) {
339
+		if ($session_data instanceof EE_Session) {
340
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
341 341
 		} else {
342
-			$this->set( 'TXN_session_data', $session_data );
342
+			$this->set('TXN_session_data', $session_data);
343 343
 		}
344 344
 	}
345 345
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @throws \EE_Error
353 353
 	 */
354 354
 	public function hash_salt_() {
355
-		return $this->get( 'TXN_hash_salt' );
355
+		return $this->get('TXN_hash_salt');
356 356
 	}
357 357
 
358 358
 
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 	 * @return    string | int
373 373
 	 * @throws \EE_Error
374 374
 	 */
375
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
376
-		if ( $format ) {
377
-			return $this->get_pretty( 'TXN_timestamp' );
378
-		} else if ( $gmt ) {
379
-			return $this->get_raw( 'TXN_timestamp' );
375
+	public function datetime($format = FALSE, $gmt = FALSE) {
376
+		if ($format) {
377
+			return $this->get_pretty('TXN_timestamp');
378
+		} else if ($gmt) {
379
+			return $this->get_raw('TXN_timestamp');
380 380
 		} else {
381
-			return $this->get( 'TXN_timestamp' );
381
+			return $this->get('TXN_timestamp');
382 382
 		}
383 383
 	}
384 384
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @return EE_Registration[]
393 393
 	 * @throws \EE_Error
394 394
 	 */
395
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
396
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) )
395
+	public function registrations($query_params = array(), $get_cached = FALSE) {
396
+		$query_params = (empty($query_params) || ! is_array($query_params))
397 397
 			? array(
398 398
 				'order_by' => array(
399 399
 					'Event.EVT_name' => 'ASC',
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 			)
404 404
 			: $query_params;
405 405
 		$query_params = $get_cached ? array() : $query_params;
406
-		return $this->get_many_related( 'Registration', $query_params );
406
+		return $this->get_many_related('Registration', $query_params);
407 407
 	}
408 408
 
409 409
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
419
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
419
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
420 420
 	}
421 421
 
422 422
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @return EE_Payment[]
429 429
 	 * @throws \EE_Error
430 430
 	 */
431
-	public function payments( $query_params = array() ) {
432
-		return $this->get_many_related( 'Payment', $query_params );
431
+	public function payments($query_params = array()) {
432
+		return $this->get_many_related('Payment', $query_params);
433 433
 	}
434 434
 
435 435
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @throws \EE_Error
442 442
 	 */
443 443
 	public function approved_payments() {
444
-		EE_Registry::instance()->load_model( 'Payment' );
445
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
444
+		EE_Registry::instance()->load_model('Payment');
445
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
446 446
 	}
447 447
 
448 448
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @return string
455 455
 	 * @throws \EE_Error
456 456
 	 */
457
-	public function e_pretty_status( $show_icons = FALSE ) {
458
-		echo $this->pretty_status( $show_icons );
457
+	public function e_pretty_status($show_icons = FALSE) {
458
+		echo $this->pretty_status($show_icons);
459 459
 	}
460 460
 
461 461
 
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 * @return string
468 468
 	 * @throws \EE_Error
469 469
 	 */
470
-	public function pretty_status( $show_icons = FALSE ) {
471
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
470
+	public function pretty_status($show_icons = FALSE) {
471
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
472 472
 		$icon = '';
473
-		switch ( $this->status_ID() ) {
473
+		switch ($this->status_ID()) {
474 474
 			case EEM_Transaction::complete_status_code:
475 475
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
476 476
 				break;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
488 488
 				break;
489 489
 		}
490
-		return $icon . $status[ $this->status_ID() ];
490
+		return $icon.$status[$this->status_ID()];
491 491
 	}
492 492
 
493 493
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @throws \EE_Error
500 500
 	 */
501 501
 	public function status_ID() {
502
-		return $this->get( 'STS_ID' );
502
+		return $this->get('STS_ID');
503 503
 	}
504 504
 
505 505
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * @throws \EE_Error
512 512
 	 */
513 513
 	public function is_free() {
514
-		return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' );
514
+		return EEH_Money::compare_floats($this->get('TXN_total'), 0, '==');
515 515
 	}
516 516
 
517 517
 
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
 	 * @return string
592 592
 	 * @throws \EE_Error
593 593
 	 */
594
-	public function invoice_url( $type = 'html' ) {
594
+	public function invoice_url($type = 'html') {
595 595
 		$REG = $this->primary_registration();
596
-		if ( ! $REG instanceof EE_Registration ) {
596
+		if ( ! $REG instanceof EE_Registration) {
597 597
 			return '';
598 598
 		}
599
-		return $REG->invoice_url( $type );
599
+		return $REG->invoice_url($type);
600 600
 	}
601 601
 
602 602
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @throws \EE_Error
609 609
 	 */
610 610
 	public function primary_registration() {
611
-		return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) );
611
+		return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
612 612
 	}
613 613
 
614 614
 
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 * @throws \EE_Error
622 622
 	 */
623
-	public function receipt_url( $type = 'html' ) {
623
+	public function receipt_url($type = 'html') {
624 624
 		$REG = $this->primary_registration();
625
-		if ( ! $REG instanceof EE_Registration ) {
625
+		if ( ! $REG instanceof EE_Registration) {
626 626
 			return '';
627 627
 		}
628
-		return $REG->receipt_url( $type );
628
+		return $REG->receipt_url($type);
629 629
 	}
630 630
 
631 631
 
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 * @return boolean
654 654
 	 * @throws \EE_Error
655 655
 	 */
656
-	public function update_based_on_payments(){
656
+	public function update_based_on_payments() {
657 657
 		EE_Error::doing_it_wrong(
658
-			__CLASS__ . '::' . __FUNCTION__,
659
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
658
+			__CLASS__.'::'.__FUNCTION__,
659
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
660 660
 			'4.6.0'
661 661
 		);
662 662
 		/** @type EE_Transaction_Processor $transaction_processor */
663
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
664
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this );
663
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
664
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
665 665
 	}
666 666
 
667 667
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 * @throws \EE_Error
672 672
 	 */
673 673
 	public function gateway_response_on_transaction() {
674
-		$payment = $this->get_first_related( 'Payment' );
674
+		$payment = $this->get_first_related('Payment');
675 675
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
676 676
 	}
677 677
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * @throws \EE_Error
685 685
 	 */
686 686
 	public function status_obj() {
687
-		return $this->get_first_related( 'Status' );
687
+		return $this->get_first_related('Status');
688 688
 	}
689 689
 
690 690
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 	 * @return EE_Extra_Meta
697 697
 	 * @throws \EE_Error
698 698
 	 */
699
-	public function extra_meta( $query_params = array() ) {
700
-		return $this->get_many_related( 'Extra_Meta', $query_params );
699
+	public function extra_meta($query_params = array()) {
700
+		return $this->get_many_related('Extra_Meta', $query_params);
701 701
 	}
702 702
 
703 703
 
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 	 * @return EE_Base_Class the relation was added to
710 710
 	 * @throws \EE_Error
711 711
 	 */
712
-	public function add_registration( EE_Registration $registration ) {
713
-		return $this->_add_relation_to( $registration, 'Registration' );
712
+	public function add_registration(EE_Registration $registration) {
713
+		return $this->_add_relation_to($registration, 'Registration');
714 714
 	}
715 715
 
716 716
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	 * @return EE_Base_Class that was removed from being related
724 724
 	 * @throws \EE_Error
725 725
 	 */
726
-	public function remove_registration_with_id( $registration_or_id ) {
727
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
726
+	public function remove_registration_with_id($registration_or_id) {
727
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
728 728
 	}
729 729
 
730 730
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 * @throws \EE_Error
737 737
 	 */
738 738
 	public function items_purchased() {
739
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
739
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
740 740
 	}
741 741
 
742 742
 
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @return EE_Base_Class the relation was added to
749 749
 	 * @throws \EE_Error
750 750
 	 */
751
-	public function add_line_item( EE_Line_Item $line_item ) {
752
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
751
+	public function add_line_item(EE_Line_Item $line_item) {
752
+		return $this->_add_relation_to($line_item, 'Line_Item');
753 753
 	}
754 754
 
755 755
 
@@ -761,8 +761,8 @@  discard block
 block discarded – undo
761 761
 	 * @return EE_Line_Item[]
762 762
 	 * @throws \EE_Error
763 763
 	 */
764
-	public function line_items( $query_params = array() ) {
765
-		return $this->get_many_related( 'Line_Item', $query_params );
764
+	public function line_items($query_params = array()) {
765
+		return $this->get_many_related('Line_Item', $query_params);
766 766
 	}
767 767
 
768 768
 
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @throws \EE_Error
775 775
 	 */
776 776
 	public function tax_items() {
777
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
777
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
778 778
 	}
779 779
 
780 780
 
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 	 * @throws \EE_Error
788 788
 	 */
789 789
 	public function total_line_item() {
790
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
791
-		if( ! $item ){
792
-			$item = EEH_Line_Item::create_total_line_item( $this );
790
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
791
+		if ( ! $item) {
792
+			$item = EEH_Line_Item::create_total_line_item($this);
793 793
 		}
794 794
 		return $item;
795 795
 	}
@@ -805,10 +805,10 @@  discard block
 block discarded – undo
805 805
 	 */
806 806
 	public function tax_total() {
807 807
 		$tax_line_item = $this->tax_total_line_item();
808
-		if ( $tax_line_item ) {
809
-			return (float)$tax_line_item->total();
808
+		if ($tax_line_item) {
809
+			return (float) $tax_line_item->total();
810 810
 		} else {
811
-			return (float)0;
811
+			return (float) 0;
812 812
 		}
813 813
 	}
814 814
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @throws \EE_Error
822 822
 	 */
823 823
 	public function tax_total_line_item() {
824
-		return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() );
824
+		return EEH_Line_Item::get_taxes_subtotal($this->total_line_item());
825 825
 	}
826 826
 
827 827
 
@@ -832,20 +832,20 @@  discard block
 block discarded – undo
832 832
 	 * @return EE_Form_Section_Proper
833 833
 	 * @throws \EE_Error
834 834
 	 */
835
-	public function billing_info(){
835
+	public function billing_info() {
836 836
 		$payment_method = $this->payment_method();
837
-		if ( !$payment_method){
837
+		if ( ! $payment_method) {
838 838
 			EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
839 839
 			return false;
840 840
 		}
841 841
 		$primary_reg = $this->primary_registration();
842
-		if ( ! $primary_reg ) {
843
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
842
+		if ( ! $primary_reg) {
843
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
844 844
 			return FALSE;
845 845
 		}
846 846
 		$attendee = $primary_reg->attendee();
847
-		if ( ! $attendee ) {
848
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
847
+		if ( ! $attendee) {
848
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
849 849
 			return FALSE;
850 850
 		}
851 851
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -886,15 +886,15 @@  discard block
 block discarded – undo
886 886
 	 * @return EE_Payment_Method
887 887
 	 * @throws \EE_Error
888 888
 	 */
889
-	public function payment_method(){
889
+	public function payment_method() {
890 890
 		$pm = $this->get_first_related('Payment_Method');
891
-		if( $pm instanceof EE_Payment_Method ){
891
+		if ($pm instanceof EE_Payment_Method) {
892 892
 			return $pm;
893
-		}else{
893
+		} else {
894 894
 			$last_payment = $this->last_payment();
895
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
895
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
896 896
 				return $last_payment->payment_method();
897
-			}else{
897
+			} else {
898 898
 				return NULL;
899 899
 			}
900 900
 		}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @throws \EE_Error
910 910
 	 */
911 911
 	public function last_payment() {
912
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
912
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
913 913
 	}
914 914
 
915 915
 
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @return EE_Line_Item[]
921 921
 	 * @throws \EE_Error
922 922
 	 */
923
-	public function non_ticket_line_items(){
924
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
923
+	public function non_ticket_line_items() {
924
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
925 925
 	}
926 926
 
927 927
 
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 4 patches
Braces   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
542 542
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
543 543
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
544
-		}else{
544
+		} else{
545 545
 			return array();
546 546
 		}
547 547
 }
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
 				$last_model_name = end( $models_to_follow_to_wp_users );
767 767
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
768 768
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
769
-			}else{
769
+			} else{
770 770
 				$model_with_fk_to_wp_users = $this;
771 771
 				$model_chain_to_wp_user = '';
772 772
 			}
773 773
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
774 774
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
775
-		}catch( EE_Error $e ) {
775
+		} catch( EE_Error $e ) {
776 776
 			return false;
777 777
 		}
778 778
 	}
@@ -800,11 +800,11 @@  discard block
 block discarded – undo
800 800
 	public function is_owned() {
801 801
 		if( $this->model_chain_to_wp_user() ){
802 802
 			return true;
803
-		}else{
803
+		} else{
804 804
 			try{
805 805
 				$this->get_foreign_key_to( 'WP_User' );
806 806
 				return true;
807
-			}catch( EE_Error $e ){
807
+			} catch( EE_Error $e ){
808 808
 				return false;
809 809
 			}
810 810
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
901 901
 			}
902 902
 			$columns_to_select_string = implode(", ",$select_sql_array);
903
-		}else{
903
+		} else{
904 904
 			$columns_to_select_string = $columns_to_select;
905 905
 		}
906 906
 		return $columns_to_select_string;
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 		}
957 957
 		if( $this->has_primary_key_field ( ) ) {
958 958
 			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
959
+		} else{
960 960
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961 961
 			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
962 962
 		}
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		$items = $this->get_all($query_params);
983 983
 		if(empty($items)){
984 984
 			return null;
985
-		}else{
985
+		} else{
986 986
 			return array_shift($items);
987 987
 		}
988 988
 	}
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1371 1371
 				if( $this->has_primary_key_field() ){
1372 1372
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1373
-				}else{
1373
+				} else{
1374 1374
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1375 1375
 					$main_table_pk_value = null;
1376 1376
 				}
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1410 1410
 			if( $this->has_primary_key_field() ){
1411 1411
 				$model_objs_affected_ids = $this->get_col( $query_params );
1412
-			}else{
1412
+			} else{
1413 1413
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1414 1414
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1415 1415
 				$model_objs_affected_ids = array();
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
 
1474 1474
 		if( $field_to_select ){
1475 1475
 			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1476
+		} elseif( $this->has_primary_key_field ( ) ){
1477 1477
 			$field = $this->get_primary_key_field();
1478
-		}else{
1478
+		} else{
1479 1479
 			//no primary key, just grab the first column
1480 1480
 			$field = reset( $this->field_settings());
1481 1481
 		}
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
 		$col = $this->get_col( $query_params, $field_to_select );
1503 1503
 		if( ! empty( $col ) ) {
1504 1504
 			return reset( $col );
1505
-		}else{
1505
+		} else{
1506 1506
 			return NULL;
1507 1507
 		}
1508 1508
 	}
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 
1630 1630
 			//		/echo "delete sql:$SQL";
1631 1631
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1632
-		}else{
1632
+		} else{
1633 1633
 			$rows_deleted = 0;
1634 1634
 		}
1635 1635
 
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 		//first, if $ignore_this_model_obj was supplied, get its model
1674 1674
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1675 1675
 			$ignored_model = $ignore_this_model_obj->get_model();
1676
-		}else{
1676
+		} else{
1677 1677
 			$ignored_model = null;
1678 1678
 		}
1679 1679
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
 				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1687 1687
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1688 1688
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1689
-				}else{
1689
+				} else{
1690 1690
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1691 1691
 				}
1692 1692
 
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
 			}
1760 1760
 
1761 1761
 			return !empty($query) ? implode(' AND ', $query ) : '';
1762
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1762
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1763 1763
 			$ways_to_identify_a_row = array();
1764 1764
 			$fields = $this->get_combined_primary_key_fields();
1765 1765
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1772 1772
 			}
1773 1773
 			return implode(" OR ",$ways_to_identify_a_row);
1774
-		}else{
1774
+		} else{
1775 1775
 			//so there's no primary key and no combined key...
1776 1776
 			//sorry, can't help you
1777 1777
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1795,10 +1795,10 @@  discard block
 block discarded – undo
1795 1795
 		if($field_to_count){
1796 1796
 			$field_obj = $this->field_settings_for($field_to_count);
1797 1797
 			$column_to_count = $field_obj->get_qualified_column();
1798
-		}elseif($this->has_primary_key_field ()){
1798
+		} elseif($this->has_primary_key_field ()){
1799 1799
 			$pk_field_obj = $this->get_primary_key_field();
1800 1800
 			$column_to_count = $pk_field_obj->get_qualified_column();
1801
-		}else{//there's no primary key
1801
+		} else{//there's no primary key
1802 1802
 			$column_to_count = '*';
1803 1803
 		}
1804 1804
 
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
 		if($field_to_sum){
1824 1824
 			$field_obj = $this->field_settings_for($field_to_sum);
1825 1825
 
1826
-		}else{
1826
+		} else{
1827 1827
 			$field_obj = $this->get_primary_key_field();
1828 1828
 		}
1829 1829
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1833,7 +1833,7 @@  discard block
 block discarded – undo
1833 1833
 		$data_type = $field_obj->get_wpdb_data_type();
1834 1834
 		if( $data_type === '%d' || $data_type === '%s' ){
1835 1835
 			return (float)$return_value;
1836
-		}else{//must be %f
1836
+		} else{//must be %f
1837 1837
 			return (float)$return_value;
1838 1838
 		}
1839 1839
 	}
@@ -1871,10 +1871,10 @@  discard block
 block discarded – undo
1871 1871
 			$wpdb->show_errors( $old_show_errors_value );
1872 1872
 			if( ! empty( $wpdb->last_error ) ){
1873 1873
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1874
-			}elseif( $result === false ){
1874
+			} elseif( $result === false ){
1875 1875
 				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1876 1876
 			}
1877
-		}elseif( $result === false ) {
1877
+		} elseif( $result === false ) {
1878 1878
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1879 1879
 		}
1880 1880
 		return $result;
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2207 2207
 		if( $results ){
2208 2208
 			return array_shift($results);
2209
-		}else{
2209
+		} else{
2210 2210
 			return null;
2211 2211
 		}
2212 2212
 
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 			 */
2278 2278
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2279 2279
 			return $new_id;
2280
-		}else{
2280
+		} else{
2281 2281
 			return FALSE;
2282 2282
 		}
2283 2283
 	}
@@ -2335,9 +2335,9 @@  discard block
 block discarded – undo
2335 2335
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2336 2336
 		if($obj_or_fields_array instanceof EE_Base_Class){
2337 2337
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2338
-		}elseif( is_array($obj_or_fields_array)){
2338
+		} elseif( is_array($obj_or_fields_array)){
2339 2339
 			$fields_n_values = $obj_or_fields_array;
2340
-		}else{
2340
+		} else{
2341 2341
 			throw new EE_Error(
2342 2342
 				sprintf(
2343 2343
 					__(
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
 		//if there is nothing to base this search on, then we shouldn't find anything
2363 2363
 		if( empty( $query_params ) ){
2364 2364
 			return array();
2365
-		}else{
2365
+		} else{
2366 2366
 			return $this->get_one($query_params);
2367 2367
 		}
2368 2368
 	}
@@ -2443,12 +2443,12 @@  discard block
 block discarded – undo
2443 2443
 		if($this->has_primary_key_field()){
2444 2444
 			if($this->get_primary_key_field()->is_auto_increment()){
2445 2445
 				return $wpdb->insert_id;
2446
-			}else{
2446
+			} else{
2447 2447
 				//it's not an auto-increment primary key, so
2448 2448
 				//it must have been supplied
2449 2449
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2450 2450
 			}
2451
-		}else{
2451
+		} else{
2452 2452
 			//we can't return a  primary key because there is none. instead return
2453 2453
 			//a unique string indicating this model
2454 2454
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2500,7 +2500,7 @@  discard block
 block discarded – undo
2500 2500
 					//leave the value alone
2501 2501
 			}
2502 2502
 			return $value;
2503
-		}else{
2503
+		} else{
2504 2504
 			return $value;
2505 2505
 		}
2506 2506
 	}
@@ -2669,10 +2669,10 @@  discard block
 block discarded – undo
2669 2669
 					if (! is_array($possibly_array_of_params)){
2670 2670
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2671 2671
 							$param,$possibly_array_of_params));
2672
-					}else{
2672
+					} else{
2673 2673
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2674 2674
 					}
2675
-				}elseif($query_param_type === 0 //ie WHERE
2675
+				} elseif($query_param_type === 0 //ie WHERE
2676 2676
 						&& is_array($possibly_array_of_params)
2677 2677
 						&& isset($possibly_array_of_params[2])
2678 2678
 						&& $possibly_array_of_params[2] == true){
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
 	private function _extract_order($should_be_order_string){
2951 2951
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2952 2952
 			return $should_be_order_string;
2953
-		}else{
2953
+		} else{
2954 2954
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2955 2955
 		}
2956 2956
 	}
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
 		foreach($default_where_conditions as $key => $val){
3030 3030
 			if( isset($provided_where_conditions[$key])){
3031 3031
 				$none_overridden = false;
3032
-			}else{
3032
+			} else{
3033 3033
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3034 3034
 			}
3035 3035
 		}
@@ -3155,7 +3155,7 @@  discard block
 block discarded – undo
3155 3155
 		if(array_key_exists($query_param,$this_model_fields)){
3156 3156
 			if($allow_fields){
3157 3157
 				return;
3158
-			}else{
3158
+			} else{
3159 3159
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3160 3160
 						$query_param,get_class($this),$query_param_type,$original_query_param));
3161 3161
 			}
@@ -3164,7 +3164,7 @@  discard block
 block discarded – undo
3164 3164
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3165 3165
 			if($allow_logic_query_params){
3166 3166
 				return;
3167
-			}else{
3167
+			} else{
3168 3168
 				throw new EE_Error(
3169 3169
 					sprintf(
3170 3170
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -3195,12 +3195,12 @@  discard block
 block discarded – undo
3195 3195
 					//we should actually end in a field name, not a model like this!
3196 3196
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3197 3197
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3198
-				}else{
3198
+				} else{
3199 3199
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3200 3200
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3201 3201
 					return;
3202 3202
 				}
3203
-			}elseif($query_param === $valid_related_model_name){
3203
+			} elseif($query_param === $valid_related_model_name){
3204 3204
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3205 3205
 				return;
3206 3206
 			}
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3266 3266
 		if($SQL){
3267 3267
 			return " WHERE ". $SQL;
3268
-		}else{
3268
+		} else{
3269 3269
 			return '';
3270 3270
 		}
3271 3271
 	}
@@ -3284,7 +3284,7 @@  discard block
 block discarded – undo
3284 3284
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3285 3285
 		if($SQL){
3286 3286
 			return " HAVING ". $SQL;
3287
-		}else{
3287
+		} else{
3288 3288
 			return '';
3289 3289
 		}
3290 3290
 
@@ -3307,7 +3307,7 @@  discard block
 block discarded – undo
3307 3307
 			$model_instance=call_user_func($model_name."::instance");
3308 3308
 			/* @var $model_instance EEM_Base */
3309 3309
 			return $model_instance->field_settings_for($field_name);
3310
-		}else{
3310
+		} else{
3311 3311
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3312 3312
 		}
3313 3313
 	}
@@ -3340,14 +3340,14 @@  discard block
 block discarded – undo
3340 3340
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3341 3341
 						break;
3342 3342
 				}
3343
-			}else{
3343
+			} else{
3344 3344
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3345 3345
 
3346 3346
 				//if it's not a normal field, maybe it's a custom selection?
3347 3347
 				if( ! $field_obj){
3348 3348
 					if(isset( $this->_custom_selections[$query_param][1])){
3349 3349
 						$field_obj = $this->_custom_selections[$query_param][1];
3350
-					}else{
3350
+					} else{
3351 3351
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3352 3352
 					}
3353 3353
 				}
@@ -3372,11 +3372,11 @@  discard block
 block discarded – undo
3372 3372
 		if( $field ){
3373 3373
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3374 3374
 			return $table_alias_prefix . $field->get_qualified_column();
3375
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3375
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
3376 3376
 			//maybe it's custom selection item?
3377 3377
 			//if so, just use it as the "column name"
3378 3378
 			return $query_param;
3379
-		}else{
3379
+		} else{
3380 3380
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3381 3381
 		}
3382 3382
 	}
@@ -3393,7 +3393,7 @@  discard block
 block discarded – undo
3393 3393
 		$pos_of_star = strpos($condition_query_param_key, '*');
3394 3394
 		if($pos_of_star === FALSE){
3395 3395
 			return $condition_query_param_key;
3396
-		}else{
3396
+		} else{
3397 3397
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3398 3398
 			return $condition_query_param_sans_star;
3399 3399
 		}
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
 		global $wpdb;
3579 3579
 		if($field_obj instanceof EE_Model_Field_Base){
3580 3580
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3581
-		}else{//$field_obj should really just be a data type
3581
+		} else{//$field_obj should really just be a data type
3582 3582
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3583 3583
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3584 3584
 			}
@@ -3607,14 +3607,14 @@  discard block
 block discarded – undo
3607 3607
 		if($number_of_parts === 1){
3608 3608
 			$field_name = $last_query_param_part;
3609 3609
 			$model_obj = $this;
3610
-		}else{// $number_of_parts >= 2
3610
+		} else{// $number_of_parts >= 2
3611 3611
 			//the last part is the column name, and there are only 2parts. therefore...
3612 3612
 			$field_name = $last_query_param_part;
3613 3613
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3614 3614
 		}
3615 3615
 		try{
3616 3616
 			return $model_obj->field_settings_for($field_name);
3617
-		}catch(EE_Error $e){
3617
+		} catch(EE_Error $e){
3618 3618
 			return null;
3619 3619
 		}
3620 3620
 	}
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3634 3634
 		if($field){
3635 3635
 			return $field->get_qualified_column();
3636
-		}else{
3636
+		} else{
3637 3637
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3638 3638
 		}
3639 3639
 	}
@@ -3704,7 +3704,7 @@  discard block
 block discarded – undo
3704 3704
 					//the FROM statement, BUT the primary table isn't. So we want
3705 3705
 					//to add the inverse join sql
3706 3706
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3707
-				}else{
3707
+				} else{
3708 3708
 					//just add a regular JOIN to this table from the primary table
3709 3709
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3710 3710
 				}
@@ -3817,7 +3817,7 @@  discard block
 block discarded – undo
3817 3817
 		$fieldSettings = $this->field_settings(true);
3818 3818
 		if( isset($fieldSettings[$fieldName])){
3819 3819
 			return true;
3820
-		}else{
3820
+		} else{
3821 3821
 			return false;
3822 3822
 		}
3823 3823
 	}
@@ -3831,7 +3831,7 @@  discard block
 block discarded – undo
3831 3831
 		$relations = $this->relation_settings();
3832 3832
 		if(isset($relations[$relation_name])){
3833 3833
 			return true;
3834
-		}else{
3834
+		} else{
3835 3835
 			return false;
3836 3836
 		}
3837 3837
 	}
@@ -3882,7 +3882,7 @@  discard block
 block discarded – undo
3882 3882
 			try{
3883 3883
 				$this->get_primary_key_field();
3884 3884
 				$this->_has_primary_key_field = true;
3885
-			}catch(EE_Error $e){
3885
+			} catch(EE_Error $e){
3886 3886
 				$this->_has_primary_key_field = false;
3887 3887
 			}
3888 3888
 		}
@@ -3961,7 +3961,7 @@  discard block
 block discarded – undo
3961 3961
 				}
3962 3962
 			}
3963 3963
 			return $this->_cached_fields;
3964
-		}else{
3964
+		} else{
3965 3965
 			if( $this->_cached_fields_non_db_only === NULL ){
3966 3966
 				$this->_cached_fields_non_db_only = array();
3967 3967
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -4097,7 +4097,7 @@  discard block
 block discarded – undo
4097 4097
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4098 4098
 				return NULL;
4099 4099
 			}
4100
-		}else if($this->unique_indexes()){
4100
+		} else if($this->unique_indexes()){
4101 4101
 			$first_column = reset($this_model_fields_n_values);
4102 4102
 			if(empty($first_column)){
4103 4103
 				return NULL;
@@ -4112,7 +4112,7 @@  discard block
 block discarded – undo
4112 4112
 				// add this new object to the entity map
4113 4113
 				$classInstance = $this->add_to_entity_map( $classInstance );
4114 4114
 			}
4115
-		}else{
4115
+		} else{
4116 4116
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4117 4117
 		}
4118 4118
 
@@ -4199,7 +4199,7 @@  discard block
 block discarded – undo
4199 4199
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4200 4200
 					}
4201 4201
 				}
4202
-			}else{
4202
+			} else{
4203 4203
 				//the table's rows existed. Use their values
4204 4204
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4205 4205
 					if( ! $field_obj->is_db_only_field() ){
@@ -4229,7 +4229,7 @@  discard block
 block discarded – undo
4229 4229
 		//or is it a db-only field? (not relating to the model)
4230 4230
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
4231 4231
 			$value = $cols_n_values[ $qualified_column ];
4232
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4232
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
4233 4233
 			$value = $cols_n_values[ $regular_column ];
4234 4234
 		}
4235 4235
 		return $value;
@@ -4263,7 +4263,7 @@  discard block
 block discarded – undo
4263 4263
 				}
4264 4264
 			}
4265 4265
 			return $obj_in_map;
4266
-		}else{
4266
+		} else{
4267 4267
 			return $this->get_one_by_ID( $id );
4268 4268
 		}
4269 4269
 	}
@@ -4298,7 +4298,7 @@  discard block
 block discarded – undo
4298 4298
 				}
4299 4299
 			}
4300 4300
 			return $obj_in_map;
4301
-		}else{
4301
+		} else{
4302 4302
 			$this->add_to_entity_map( $replacing_model_obj );
4303 4303
 			return $replacing_model_obj;
4304 4304
 		}
@@ -4443,13 +4443,13 @@  discard block
 block discarded – undo
4443 4443
 		if( $base_class_obj_or_id instanceof $className ){
4444 4444
 			/** @var $base_class_obj_or_id EE_Base_Class */
4445 4445
 			$id = $base_class_obj_or_id->ID();
4446
-		}elseif(is_int($base_class_obj_or_id)){
4446
+		} elseif(is_int($base_class_obj_or_id)){
4447 4447
 			//assume it's an ID
4448 4448
 			$id = $base_class_obj_or_id;
4449
-		}elseif(is_string($base_class_obj_or_id)){
4449
+		} elseif(is_string($base_class_obj_or_id)){
4450 4450
 			//assume its a string representation of the object
4451 4451
 			$id = $base_class_obj_or_id;
4452
-		}else{
4452
+		} else{
4453 4453
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4454 4454
 		}
4455 4455
 		return $id;
@@ -4596,9 +4596,9 @@  discard block
 block discarded – undo
4596 4596
 
4597 4597
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4598 4598
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4599
-		}elseif(is_array($model_object_or_attributes_array)){
4599
+		} elseif(is_array($model_object_or_attributes_array)){
4600 4600
 			$attributes_array = $model_object_or_attributes_array;
4601
-		}else{
4601
+		} else{
4602 4602
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4603 4603
 		}
4604 4604
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4608,7 +4608,7 @@  discard block
 block discarded – undo
4608 4608
 		}
4609 4609
 		if(isset($query_params[0])){
4610 4610
 			$query_params[0] = array_merge($attributes_array,$query_params);
4611
-		}else{
4611
+		} else{
4612 4612
 			$query_params[0] = $attributes_array;
4613 4613
 		}
4614 4614
 		return $this->get_all($query_params);
@@ -4633,7 +4633,7 @@  discard block
 block discarded – undo
4633 4633
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4634 4634
 		if(is_array($copies)){
4635 4635
 			return array_shift($copies);
4636
-		}else{
4636
+		} else{
4637 4637
 			return null;
4638 4638
 		}
4639 4639
 	}
@@ -4667,7 +4667,7 @@  discard block
 block discarded – undo
4667 4667
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4668 4668
 		if($sql_operator){
4669 4669
 			return $sql_operator;
4670
-		}else{
4670
+		} else{
4671 4671
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4672 4672
 		}
4673 4673
 	}
@@ -4872,7 +4872,7 @@  discard block
 block discarded – undo
4872 4872
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4873 4873
 		if( in_array( $context, $valid_cap_contexts ) ) {
4874 4874
 			return true;
4875
-		}else{
4875
+		} else{
4876 4876
 			throw new EE_Error(
4877 4877
 				sprintf(
4878 4878
 					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
Please login to merge, or discard this patch.
Doc Comments   +17 added lines, -14 removed lines patch added patch discarded remove patch
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 	 * Returns the name of the field's name that points to the WP_User table
765 765
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
766 766
 	 * foreign key to the WP_User table)
767
-	 * @return string|boolean string on success, boolean false when there is no
767
+	 * @return string|false string on success, boolean false when there is no
768 768
 	 * foreign key to the WP_User table
769 769
 	 */
770 770
 	public function wp_user_field_name() {
@@ -859,6 +859,7 @@  discard block
 block discarded – undo
859 859
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
860 860
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
861 861
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
862
+	 * @param string $columns_to_select
862 863
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
863 864
 	 * @throws \EE_Error
864 865
 	 */
@@ -1203,7 +1204,7 @@  discard block
 block discarded – undo
1203 1204
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1204 1205
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1205 1206
 	 *
1206
-	 * @return array formats in an array with the date format first, and the time format last.
1207
+	 * @return string[] formats in an array with the date format first, and the time format last.
1207 1208
 	 */
1208 1209
 	public function get_formats_for( $field_name, $pretty = false ) {
1209 1210
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1238,7 +1239,7 @@  discard block
 block discarded – undo
1238 1239
 	 *
1239 1240
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1240 1241
 	 *
1241
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1242
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1242 1243
 	 *                    	     exception is triggered.
1243 1244
 	 */
1244 1245
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1549,7 +1550,7 @@  discard block
 block discarded – undo
1549 1550
 	 * Wrapper for EEM_Base::delete_permanently()
1550 1551
 	 *
1551 1552
 	 * @param mixed $id
1552
-	 * @return boolean whether the row got deleted or not
1553
+	 * @return integer whether the row got deleted or not
1553 1554
 	 * @throws \EE_Error
1554 1555
 	 */
1555 1556
 	public function delete_permanently_by_ID( $id ) {
@@ -1568,7 +1569,7 @@  discard block
 block discarded – undo
1568 1569
 	 * Wrapper for EEM_Base::delete()
1569 1570
 	 *
1570 1571
 	 * @param mixed $id
1571
-	 * @return boolean whether the row got deleted or not
1572
+	 * @return integer whether the row got deleted or not
1572 1573
 	 * @throws \EE_Error
1573 1574
 	 */
1574 1575
 	public function delete_by_ID( $id ){
@@ -1964,7 +1965,7 @@  discard block
 block discarded – undo
1964 1965
 	/**
1965 1966
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1966 1967
 	 * EEM_Base::$_db_verification_level
1967
-	 * @param $wpdb_method
1968
+	 * @param string $wpdb_method
1968 1969
 	 * @param $arguments_to_provide
1969 1970
 	 * @return string
1970 1971
 	 */
@@ -2059,6 +2060,7 @@  discard block
 block discarded – undo
2059 2060
 	 * @return boolean of success
2060 2061
 	 * @throws \EE_Error
2061 2062
 	 * @param array  $where_query  This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2063
+	 * @param EE_Base_Class $id_or_obj
2062 2064
 	 */
2063 2065
 	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2064 2066
 		$relation_obj = $this->related_settings_for($relationName);
@@ -2068,7 +2070,7 @@  discard block
 block discarded – undo
2068 2070
 
2069 2071
 
2070 2072
 	/**
2071
-	 * @param mixed           $id_or_obj
2073
+	 * @param EE_Base_Class           $id_or_obj
2072 2074
 	 * @param string          $relationName
2073 2075
 	 * @param array           $where_query_params
2074 2076
 	 * @param EE_Base_Class[] objects to which relations were removed
@@ -2107,7 +2109,7 @@  discard block
 block discarded – undo
2107 2109
 	 * However, if the model objects can't be deleted because of blocking related model objects, then
2108 2110
 	 * they aren't deleted. (Unless the thing that would have been deleted can be soft-deleted, that still happens).
2109 2111
 	 *
2110
-	 * @param EE_Base_Class|int|string $id_or_obj
2112
+	 * @param EE_Base_Class $id_or_obj
2111 2113
 	 * @param string                   $model_name
2112 2114
 	 * @param array                    $query_params
2113 2115
 	 * @return int how many deleted
@@ -2127,7 +2129,7 @@  discard block
 block discarded – undo
2127 2129
 	 * the model objects can't be hard deleted because of blocking related model objects,
2128 2130
 	 * just does a soft-delete on them instead.
2129 2131
 	 *
2130
-	 * @param EE_Base_Class|int|string $id_or_obj
2132
+	 * @param EE_Base_Class $id_or_obj
2131 2133
 	 * @param string                   $model_name
2132 2134
 	 * @param array                    $query_params
2133 2135
 	 * @return int how many deleted
@@ -2176,6 +2178,7 @@  discard block
 block discarded – undo
2176 2178
 	 * @param string $model_name   like 'Event', or 'Registration'
2177 2179
 	 * @param array  $query_params like EEM_Base::get_all's
2178 2180
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2181
+	 * @param EE_Base_Class $id_or_obj
2179 2182
 	 * @return float
2180 2183
 	 * @throws \EE_Error
2181 2184
 	 */
@@ -2581,7 +2584,7 @@  discard block
 block discarded – undo
2581 2584
 	/**
2582 2585
 	 * Finds all the fields that correspond to the given table
2583 2586
 	 * @param string $table_alias, array key in EEM_Base::_tables
2584
-	 * @return EE_Model_Field_Base[]
2587
+	 * @return EE_Model_Field_Base
2585 2588
 	 */
2586 2589
 	public function _get_fields_for_table($table_alias){
2587 2590
 		return $this->_fields[$table_alias];
@@ -3844,8 +3847,8 @@  discard block
 block discarded – undo
3844 3847
 	/**
3845 3848
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3846 3849
 	 * Eg, on EE_Answer that would be ANS_ID field object
3847
-	 * @param $field_obj
3848
-	 * @return EE_Model_Field_Base
3850
+	 * @param EE_Model_Field_Base $field_obj
3851
+	 * @return boolean
3849 3852
 	 */
3850 3853
 	public function is_primary_key_field( $field_obj ){
3851 3854
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3940,7 +3943,7 @@  discard block
 block discarded – undo
3940 3943
 	 * Gets the actual table for the table alias
3941 3944
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3942 3945
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3943
-	 * @return EE_Table_Base
3946
+	 * @return string
3944 3947
 	 */
3945 3948
 	public function get_table_for_alias($table_alias){
3946 3949
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -4483,7 +4486,7 @@  discard block
 block discarded – undo
4483 4486
 	}
4484 4487
 	/**
4485 4488
 	 * Read comments for assume_values_already_prepared_by_model_object()
4486
-	 * @return int
4489
+	 * @return boolean
4487 4490
 	 */
4488 4491
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4489 4492
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -615,11 +615,11 @@  discard block
 block discarded – undo
615 615
 	 * Gets all the EE_Base_Class objects which match the $query_params, by querying the DB.
616 616
 	 *
617 617
 	 * @param array $query_params {
618
-     *	@var array $0 (where) array {
618
+	 *	@var array $0 (where) array {
619 619
 	 *		eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob')
620
-			* becomes
620
+	 * becomes
621 621
 	 *		SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...")
622
-     *		To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name
622
+	 *		To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name
623 623
 	 *		onto the field name. Eg, EEM_Event::instance()->get_all(array(array('Venue.VNU_ID'=>12)));
624 624
 	 *		becomes
625 625
 	 *		SQL >> "SELECT * FROM wp_posts AS Event_CPT
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	 *		SQL >> "...WHERE QST_display_text LIKE '%bob%' AND QST_ID < 34 AND QST_wp_user IN (1,2,7,23)...".
640 640
 	 *        Valid operators so far: =, !=, <, <=, >, >=, LIKE, NOT LIKE, IN (followed by numeric-indexed array),
641 641
 	 *          NOT IN (dido), BETWEEN (followed by an array with exactly 2 date strings), IS NULL, and IS NOT NULL
642
-     *		Values can be a string, int, or float. They can also be arrays IFF the operator is IN.
642
+	 *		Values can be a string, int, or float. They can also be arrays IFF the operator is IN.
643 643
 	 *        Also, values can actually be field names. To indicate the value is a field,
644 644
 	 *          simply provide a third array item (true) to the operator-value array like so:
645 645
 	 *		eg: array( 'DTT_reg_limit' => array('>', 'DTT_sold', TRUE) )
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 *		Note: you can also use related model field names like you would any other field name.
649 649
 	 *		eg: array('Datetime.DTT_reg_limit'=>array('=','Datetime.DTT_sold',TRUE)
650 650
 	 *		could be used if you were querying EEM_Tickets (because Datetime is directly related to tickets)
651
-     *		Also, by default all the where conditions are AND'd together.
651
+	 *		Also, by default all the where conditions are AND'd together.
652 652
 	 *		To override this, add an array key 'OR' (or 'AND') and the array to be OR'd together
653 653
 	 *		eg: array('OR'=>array('TXN_ID' => 23 , 'TXN_timestamp__>' => 345678912))
654 654
 	 *		becomes
@@ -663,17 +663,17 @@  discard block
 block discarded – undo
663 663
 	 *		eg array('OR'=>array('NOT'=>array('TXN_total' => 50, 'TXN_paid'=>23)),AND=>array('TXN_ID'=>1,'STS_ID'=>'TIN')
664 664
 	 *		becomes
665 665
 	 *		SQL >> "...where ! (TXN_total =50 OR TXN_paid =23) AND TXN_ID=1 AND STS_ID='TIN'"
666
-     *		They can be nested indefinitely.
666
+	 *		They can be nested indefinitely.
667 667
 	 *		eg: array('OR'=>array('TXN_total' => 23, 'NOT'=> array( 'TXN_timestamp'=> 345678912, 'AND'=>array('TXN_paid' => 53, 'STS_ID' => 'TIN'))))
668 668
 	 *		becomes
669 669
 	 *		SQL >> "...WHERE TXN_total = 23 OR ! (TXN_timestamp = 345678912 OR (TXN_paid = 53 AND STS_ID = 'TIN'))..."
670
-     *		GOTCHA:
670
+	 *		GOTCHA:
671 671
 	 *		because this is an array, array keys must be unique, making it impossible to place two or more where conditions applying to the same field.
672 672
 	 *		eg: array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp'=>array('<',$end_date),'PAY_timestamp'=>array('!=',$special_date)),
673 673
 	 *		as PHP enforces that the array keys must be unique, thus removing the first two array entries with key 'PAY_timestamp'.
674 674
 	 *		becomes
675 675
 	 *		SQL >> "PAY_timestamp !=  4234232", ignoring the first two PAY_timestamp conditions).
676
-     *		To overcome this, you can add a '*' character to the end of the field's name, followed by anything.
676
+	 *		To overcome this, you can add a '*' character to the end of the field's name, followed by anything.
677 677
 	 *		These will be removed when generating the SQL string, but allow for the array keys to be unique.
678 678
 	 *		eg: you could rewrite the previous query as:
679 679
 	 *		array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp*1st'=>array('<',$end_date),'PAY_timestamp*2nd'=>array('!=',$special_date))
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 *		You will probably only want to do this in hopes of increasing efficiency, as related models which belongs to the current model
707 707
 	 *		(ie, the current model has a foreign key to them, like how Registration belongs to Attendee) can be cached in order
708 708
 	 *		to avoid future queries
709
-     *	@var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out
709
+	 *	@var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out
710 710
 	 *		if you want to include them, set this query param to 'none'. If you want to ONLY disable THIS model's default where conditions
711 711
 	 *		set it to 'other_models_only'. If you only want this model's default where conditions added to the query, use 'this_model_only'.
712 712
 	 *		If you want to use all default where conditions (default), set to 'all'.
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 	 *                                      can indicate just the columns you
1079 1079
 	 *                                      want and a single array indexed by
1080 1080
 	 *                                      the columns will be returned.
1081
- * @return EE_Base_Class|null|array()
1081
+	 * @return EE_Base_Class|null|array()
1082 1082
 	 * @throws EE_Error
1083 1083
 	 */
1084 1084
 	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 				//make sure there's no related objects blocking its deletion (if we're checking)
1727 1727
 				if (
1728 1728
 					$allow_blocking
1729
-				    && $this->delete_is_blocked_by_related_models(
1729
+					&& $this->delete_is_blocked_by_related_models(
1730 1730
 						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1731 1731
 					)
1732 1732
 				) {
@@ -2873,8 +2873,8 @@  discard block
 block discarded – undo
2873 2873
 		}
2874 2874
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2875 2875
 		if ( ! array_key_exists( 'order_by', $query_params )
2876
-		     && array_key_exists( 'order', $query_params )
2877
-		     && ! empty( $query_params['order'] )
2876
+			 && array_key_exists( 'order', $query_params )
2877
+			 && ! empty( $query_params['order'] )
2878 2878
 		) {
2879 2879
 			$pk_field = $this->get_primary_key_field();
2880 2880
 			$order = $this->_extract_order( $query_params['order'] );
@@ -4409,7 +4409,7 @@  discard block
 block discarded – undo
4409 4409
 				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4410 4410
 			} else if (
4411 4411
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4412
-			    && is_string( $base_class_obj_or_id )
4412
+				&& is_string( $base_class_obj_or_id )
4413 4413
 			) {
4414 4414
 				// assume its a string representation of the object
4415 4415
 				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
Please login to merge, or discard this patch.
Spacing   +968 added lines, -968 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Flag indicating whether this model has a primary key or not
244 244
 	 * @var boolean
245 245
 	 */
246
-	protected $_has_primary_key_field=null;
246
+	protected $_has_primary_key_field = null;
247 247
 
248 248
 	/**
249 249
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
306 306
 	 * @var array
307 307
 	 */
308
-	protected $_between_style_operators = array( 'BETWEEN' );
308
+	protected $_between_style_operators = array('BETWEEN');
309 309
 
310 310
 	/**
311 311
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
312 312
 	 * @var array
313 313
 	 */
314
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
314
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
315 315
 
316 316
 	/**
317 317
 	 * Allowed values for $query_params['order'] for ordering in queries
318 318
 	 * @var array
319 319
 	 */
320
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
320
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
321 321
 
322 322
 	/**
323 323
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
332 332
 	 * @var array
333 333
 	 */
334
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
334
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
335 335
 
336 336
 	/**
337 337
 	 * All the data types that can be used in $wpdb->prepare statements.
338 338
 	 * @var array
339 339
 	 */
340
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
340
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
341 341
 
342 342
 	/**
343 343
 	 * 	EE_Registry Object
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
 	/**
371 371
 	 * constant used to show EEM_Base has not yet verified the db on this http request
372 372
 	 */
373
-	const db_verified_none 		= 0;
373
+	const db_verified_none = 0;
374 374
 	/**
375 375
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
376 376
 	 * but not the addons' dbs
377 377
 	 */
378
-	const db_verified_core 		= 1;
378
+	const db_verified_core = 1;
379 379
 	/**
380 380
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
381 381
 	 * the EE core db too)
382 382
 	 */
383
-	const db_verified_addons 	= 2;
383
+	const db_verified_addons = 2;
384 384
 
385 385
 	/**
386 386
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @param null $timezone
412 412
 	 * @throws \EE_Error
413 413
 	 */
414
-	protected function __construct( $timezone = NULL ){
414
+	protected function __construct($timezone = NULL) {
415 415
 		// check that the model has not been loaded too soon
416
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
417
-			throw new EE_Error (
416
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
417
+			throw new EE_Error(
418 418
 				sprintf(
419
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
420
-					get_class( $this )
419
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
420
+					get_class($this)
421 421
 				)
422 422
 			);
423 423
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		/**
426 426
 		 * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set.
427 427
 		 */
428
-		if ( empty( EEM_Base::$_model_query_blog_id ) ) {
428
+		if (empty(EEM_Base::$_model_query_blog_id)) {
429 429
 			EEM_Base::set_model_query_blog_id();
430 430
 		}
431 431
 
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 		 * just use EE_Register_Model_Extension
435 435
 		 * @var EE_Table_Base[] $_tables
436 436
 		 */
437
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
438
-		foreach($this->_tables as $table_alias => $table_obj){
437
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
438
+		foreach ($this->_tables as $table_alias => $table_obj) {
439 439
 			/** @var $table_obj EE_Table_Base */
440 440
 			$table_obj->_construct_finalize_with_alias($table_alias);
441
-			if( $table_obj instanceof EE_Secondary_Table ){
441
+			if ($table_obj instanceof EE_Secondary_Table) {
442 442
 				/** @var $table_obj EE_Secondary_Table */
443 443
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
444 444
 			}
@@ -448,54 +448,54 @@  discard block
 block discarded – undo
448 448
 		 * EE_Register_Model_Extension
449 449
 		 * @param EE_Model_Field_Base[] $_fields
450 450
 		 */
451
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
451
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
452 452
 		$this->_invalidate_field_caches();
453
-		foreach($this->_fields as $table_alias => $fields_for_table){
454
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
455
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
453
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
454
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
455
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
456 456
 			}
457
-			foreach($fields_for_table as $field_name => $field_obj){
457
+			foreach ($fields_for_table as $field_name => $field_obj) {
458 458
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
459 459
 				//primary key field base has a slightly different _construct_finalize
460 460
 				/** @var $field_obj EE_Model_Field_Base */
461
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
461
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
462 462
 			}
463 463
 		}
464 464
 
465 465
 		// everything is related to Extra_Meta
466
-		if( get_class($this) !== 'EEM_Extra_Meta'){
466
+		if (get_class($this) !== 'EEM_Extra_Meta') {
467 467
 			//make extra meta related to everything, but don't block deleting things just
468 468
 			//because they have related extra meta info. For now just orphan those extra meta
469 469
 			//in the future we should automatically delete them
470
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
470
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
471 471
 		}
472 472
 		//and change logs
473
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
474
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
473
+		if (get_class($this) !== 'EEM_Change_Log') {
474
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
475 475
 		}
476 476
 		/**
477 477
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
478 478
 		 * EE_Register_Model_Extension
479 479
 		 * @param EE_Model_Relation_Base[] $_model_relations
480 480
 		 */
481
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
482
-		foreach($this->_model_relations as $model_name => $relation_obj){
481
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
482
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
483 483
 			/** @var $relation_obj EE_Model_Relation_Base */
484 484
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
485 485
 		}
486
-		foreach($this->_indexes as $index_name => $index_obj){
486
+		foreach ($this->_indexes as $index_name => $index_obj) {
487 487
 			/** @var $index_obj EE_Index */
488 488
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
489 489
 		}
490 490
 
491 491
 		$this->set_timezone($timezone);
492 492
 		//finalize default where condition strategy, or set default
493
-		if( ! $this->_default_where_conditions_strategy){
493
+		if ( ! $this->_default_where_conditions_strategy) {
494 494
 			//nothing was set during child constructor, so set default
495 495
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
496 496
 		}
497 497
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
498
-		if( ! $this->_minimum_where_conditions_strategy){
498
+		if ( ! $this->_minimum_where_conditions_strategy) {
499 499
 			//nothing was set during child constructor, so set default
500 500
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
501 501
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 
504 504
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
505 505
 		//to indicate to NOT set it, set it to the logical default
506
-		if( $this->_caps_slug === null ) {
507
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
506
+		if ($this->_caps_slug === null) {
507
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
508 508
 		}
509 509
 		//initialize the standard cap restriction generators if none were specified by the child constructor
510
-		if( $this->_cap_restriction_generators !== false ){
511
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
512
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
513
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
510
+		if ($this->_cap_restriction_generators !== false) {
511
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
512
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
513
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
514 514
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
515 515
 						new EE_Restriction_Generator_Protected(),
516 516
 						$cap_context,
@@ -520,23 +520,23 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 		}
522 522
 		//if there are cap restriction generators, use them to make the default cap restrictions
523
-		if( $this->_cap_restriction_generators !== false ){
524
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
525
-				if( ! $generator_object ){
523
+		if ($this->_cap_restriction_generators !== false) {
524
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
525
+				if ( ! $generator_object) {
526 526
 					continue;
527 527
 				}
528
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
528
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
529 529
 					throw new EE_Error(
530 530
 						sprintf(
531
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
531
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
532 532
 							$context,
533 533
 							$this->get_this_model_name()
534 534
 						)
535 535
 					);
536 536
 				}
537
-				$action = $this->cap_action_for_context( $context );
538
-				if( ! $generator_object->construction_finalized() ){
539
-					$generator_object->_construct_finalize( $this, $action );
537
+				$action = $this->cap_action_for_context($context);
538
+				if ( ! $generator_object->construction_finalized()) {
539
+					$generator_object->_construct_finalize($this, $action);
540 540
 				}
541 541
 
542 542
 			}
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
551 551
 	 * @return EE_Default_Where_Conditions[]
552 552
 	 */
553
-	protected function _generate_cap_restrictions( $context ){
554
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
555
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
556
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
557
-		}else{
553
+	protected function _generate_cap_restrictions($context) {
554
+		if (isset($this->_cap_restriction_generators[$context]) &&
555
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
556
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
557
+		} else {
558 558
 			return array();
559 559
 		}
560 560
 	}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $blog_id  If provided then will set the blog_id for the models to this id.  If not provided then the
567 567
 	 *                      value for get_current_blog_id() will be used.
568 568
 	 */
569
-	public static function set_model_query_blog_id( $blog_id = 0 ) {
569
+	public static function set_model_query_blog_id($blog_id = 0) {
570 570
 		EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id();
571 571
 	}
572 572
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
592 592
 	 *		@return static (as in the concrete child class)
593 593
 	 */
594
-	public static function instance( $timezone = NULL ){
594
+	public static function instance($timezone = NULL) {
595 595
 
596 596
 		// check if instance of Espresso_model already exists
597 597
 		if ( ! static::$_instance instanceof static) {
598 598
 			// instantiate Espresso_model
599
-			static::$_instance = new static( $timezone );
599
+			static::$_instance = new static($timezone);
600 600
 		}
601 601
 
602 602
 		//we might have a timezone set, let set_timezone decide what to do with it
603
-		static::$_instance->set_timezone( $timezone );
603
+		static::$_instance->set_timezone($timezone);
604 604
 
605 605
 		// Espresso_model object
606 606
 		return static::$_instance;
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 	 * @param null | string $timezone
614 614
 	 * @return static
615 615
 	 */
616
-	public static function reset(  $timezone = NULL ){
617
-		if ( ! is_null( static::$_instance ) ) {
616
+	public static function reset($timezone = NULL) {
617
+		if ( ! is_null(static::$_instance)) {
618 618
 			static::$_instance = null;
619 619
 
620
-			return self::instance( $timezone );
620
+			return self::instance($timezone);
621 621
 		}
622 622
 		return null;
623 623
 	}
@@ -631,19 +631,19 @@  discard block
 block discarded – undo
631 631
 	 * @return array
632 632
 	 * @throws \EE_Error
633 633
 	 */
634
-	 public function status_array( $translated = FALSE ) {
635
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
634
+	 public function status_array($translated = FALSE) {
635
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
636 636
 			 return array();
637 637
 		 }
638 638
 		 $model_name = $this->get_this_model_name();
639
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
640
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
639
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
640
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
641 641
 		 $status_array = array();
642
-		 foreach ( $stati as $status ) {
643
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
642
+		 foreach ($stati as $status) {
643
+			 $status_array[$status->ID()] = $status->get('STS_code');
644 644
 		 }
645 645
 		 return $translated
646
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
646
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
647 647
 			 : $status_array;
648 648
 	 }
649 649
 
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 	 *		));
777 777
 	 * @throws \EE_Error
778 778
 	 */
779
-	public function get_all($query_params = array()){
780
-		if( isset( $query_params[ 'limit' ] )
781
-			&& ! isset( $query_params[ 'group_by' ] ) ) {
782
-			$query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() );
779
+	public function get_all($query_params = array()) {
780
+		if (isset($query_params['limit'])
781
+			&& ! isset($query_params['group_by'])) {
782
+			$query_params['group_by'] = array_keys($this->get_combined_primary_key_fields());
783 783
 		}
784 784
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
785 785
 	}
@@ -790,10 +790,10 @@  discard block
 block discarded – undo
790 790
 	 * @param array $query_params @see EEM_Base::get_all()
791 791
 	 * @return array like EEM_Base::get_all
792 792
 	 */
793
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
793
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
794 794
 		$wp_user_field_name = $this->wp_user_field_name();
795
-		if( $wp_user_field_name ){
796
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
795
+		if ($wp_user_field_name) {
796
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
797 797
 		}
798 798
 		return $query_params;
799 799
 	}
@@ -806,19 +806,19 @@  discard block
 block discarded – undo
806 806
 	 * foreign key to the WP_User table
807 807
 	 */
808 808
 	public function wp_user_field_name() {
809
-		try{
810
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
811
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
812
-				$last_model_name = end( $models_to_follow_to_wp_users );
813
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
814
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
815
-			}else{
809
+		try {
810
+			if ( ! empty($this->_model_chain_to_wp_user)) {
811
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
812
+				$last_model_name = end($models_to_follow_to_wp_users);
813
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
814
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
815
+			} else {
816 816
 				$model_with_fk_to_wp_users = $this;
817 817
 				$model_chain_to_wp_user = '';
818 818
 			}
819
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
820
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
821
-		}catch( EE_Error $e ) {
819
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
820
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
821
+		} catch (EE_Error $e) {
822 822
 			return false;
823 823
 		}
824 824
 	}
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 	 * (or transiently-related model)
833 833
 	 * @return string
834 834
 	 */
835
-	public function model_chain_to_wp_user(){
835
+	public function model_chain_to_wp_user() {
836 836
 		return $this->_model_chain_to_wp_user;
837 837
 	}
838 838
 
@@ -844,13 +844,13 @@  discard block
 block discarded – undo
844 844
 	 * @return boolean
845 845
 	 */
846 846
 	public function is_owned() {
847
-		if( $this->model_chain_to_wp_user() ){
847
+		if ($this->model_chain_to_wp_user()) {
848 848
 			return true;
849
-		}else{
850
-			try{
851
-				$this->get_foreign_key_to( 'WP_User' );
849
+		} else {
850
+			try {
851
+				$this->get_foreign_key_to('WP_User');
852 852
 				return true;
853
-			}catch( EE_Error $e ){
853
+			} catch (EE_Error $e) {
854 854
 				return false;
855 855
 			}
856 856
 		}
@@ -872,17 +872,17 @@  discard block
 block discarded – undo
872 872
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
873 873
 	 * @throws \EE_Error
874 874
 	 */
875
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
875
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
876 876
 		// remember the custom selections, if any, and type cast as array
877 877
 		// (unless $columns_to_select is an object, then just set as an empty array)
878 878
 		// Note: (array) 'some string' === array( 'some string' )
879
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
880
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
879
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
880
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
881 881
 		$select_expressions = $columns_to_select !== null
882
-			? $this->_construct_select_from_input( $columns_to_select )
883
-			: $this->_construct_default_select_sql( $model_query_info );
884
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
885
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
882
+			? $this->_construct_select_from_input($columns_to_select)
883
+			: $this->_construct_default_select_sql($model_query_info);
884
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
885
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
886 886
 	}
887 887
 
888 888
 	/**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
901 901
 	 * @throws \EE_Error
902 902
 	 */
903
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
903
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
904 904
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
905 905
 	}
906 906
 
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 	 * @throws EE_Error
913 913
 	 * @return string
914 914
 	 */
915
-	private function _construct_select_from_input($columns_to_select){
916
-		if(is_array($columns_to_select)){
915
+	private function _construct_select_from_input($columns_to_select) {
916
+		if (is_array($columns_to_select)) {
917 917
 			$select_sql_array = array();
918 918
 
919
-			foreach($columns_to_select as $alias => $selection_and_datatype){
920
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
919
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
920
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
921 921
 					throw new EE_Error(
922 922
 						sprintf(
923 923
 							__(
@@ -929,24 +929,24 @@  discard block
 block discarded – undo
929 929
 						)
930 930
 					);
931 931
 				}
932
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
932
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
933 933
 					throw new EE_Error(
934 934
 						sprintf(
935 935
 							__(
936 936
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
937 937
 								"event_espresso"
938 938
 							),
939
-							$selection_and_datatype[ 1 ],
940
-							$selection_and_datatype[ 0 ],
939
+							$selection_and_datatype[1],
940
+							$selection_and_datatype[0],
941 941
 							$alias,
942
-							implode( ",", $this->_valid_wpdb_data_types )
942
+							implode(",", $this->_valid_wpdb_data_types)
943 943
 						)
944 944
 					);
945 945
 				}
946 946
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
947 947
 			}
948
-			$columns_to_select_string = implode(", ",$select_sql_array);
949
-		}else{
948
+			$columns_to_select_string = implode(", ", $select_sql_array);
949
+		} else {
950 950
 			$columns_to_select_string = $columns_to_select;
951 951
 		}
952 952
 		return $columns_to_select_string;
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 	 * @return string
962 962
 	 * @throws \EE_Error
963 963
 	 */
964
-	public function primary_key_name(){
964
+	public function primary_key_name() {
965 965
 		return $this->get_primary_key_field()->get_name();
966 966
 	}
967 967
 
@@ -973,14 +973,14 @@  discard block
 block discarded – undo
973 973
 	 * @param mixed $id int or string, depending on the type of the model's primary key
974 974
 	 * @return EE_Base_Class
975 975
 	 */
976
-	public function get_one_by_ID($id){
977
-		if( $this->get_from_entity_map( $id ) ){
978
-			return $this->get_from_entity_map( $id );
976
+	public function get_one_by_ID($id) {
977
+		if ($this->get_from_entity_map($id)) {
978
+			return $this->get_from_entity_map($id);
979 979
 		}
980 980
 		return $this->get_one(
981 981
 			$this->alter_query_params_to_restrict_by_ID(
982 982
 				$id,
983
-				array( 'default_where_conditions' => 'minimum' )
983
+				array('default_where_conditions' => 'minimum')
984 984
 			)
985 985
 		);
986 986
 	}
@@ -996,15 +996,15 @@  discard block
 block discarded – undo
996 996
 	 * @return array of normal query params, @see EEM_Base::get_all
997 997
 	 * @throws \EE_Error
998 998
 	 */
999
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
1000
-		if( ! isset( $query_params[ 0 ] ) ) {
1001
-			$query_params[ 0 ] = array();
999
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
1000
+		if ( ! isset($query_params[0])) {
1001
+			$query_params[0] = array();
1002 1002
 		}
1003
-		if( $this->has_primary_key_field ( ) ) {
1004
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1005
-		}else{
1003
+		if ($this->has_primary_key_field( )) {
1004
+			$query_params[0][$this->primary_key_name()] = $id;
1005
+		} else {
1006 1006
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1007
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1007
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
1008 1008
 		}
1009 1009
 		return $query_params;
1010 1010
 	}
@@ -1019,16 +1019,16 @@  discard block
 block discarded – undo
1019 1019
 	 * @return EE_Base_Class | NULL
1020 1020
 	 * @throws \EE_Error
1021 1021
 	 */
1022
-	public function get_one($query_params = array()){
1023
-		if( ! is_array( $query_params ) ){
1024
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1022
+	public function get_one($query_params = array()) {
1023
+		if ( ! is_array($query_params)) {
1024
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1025 1025
 			$query_params = array();
1026 1026
 		}
1027 1027
 		$query_params['limit'] = 1;
1028 1028
 		$items = $this->get_all($query_params);
1029
-		if(empty($items)){
1029
+		if (empty($items)) {
1030 1030
 			return null;
1031
-		}else{
1031
+		} else {
1032 1032
 			return array_shift($items);
1033 1033
 		}
1034 1034
 	}
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @return EE_Base_Class[]|array
1052 1052
 	 * @throws \EE_Error
1053 1053
 	 */
1054
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1055
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1054
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1055
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @return EE_Base_Class[]|array
1074 1074
 	 * @throws \EE_Error
1075 1075
 	 */
1076
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1077
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1076
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1077
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1095,9 +1095,9 @@  discard block
 block discarded – undo
1095 1095
 	 * @return EE_Base_Class|null|array()
1096 1096
 	 * @throws \EE_Error
1097 1097
 	 */
1098
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1099
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1100
-		return empty( $results ) ? null : reset( $results );
1098
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1099
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1100
+		return empty($results) ? null : reset($results);
1101 1101
 	}
1102 1102
 
1103 1103
 
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
  * @return EE_Base_Class|null|array()
1120 1120
 	 * @throws EE_Error
1121 1121
 	 */
1122
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1123
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1124
-		return empty( $results ) ? null : reset( $results );
1122
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1123
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1124
+		return empty($results) ? null : reset($results);
1125 1125
 	}
1126 1126
 
1127 1127
 
@@ -1142,42 +1142,42 @@  discard block
 block discarded – undo
1142 1142
 	 * @return EE_Base_Class[]|array
1143 1143
 	 * @throws EE_Error
1144 1144
 	 */
1145
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1145
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1146 1146
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1147
-		if ( empty( $field_to_order_by ) ) {
1148
-			if ( $this->has_primary_key_field() ) {
1147
+		if (empty($field_to_order_by)) {
1148
+			if ($this->has_primary_key_field()) {
1149 1149
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1150 1150
 			} else {
1151 1151
 
1152
-				if ( WP_DEBUG ) {
1153
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1152
+				if (WP_DEBUG) {
1153
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1154 1154
 				}
1155
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1155
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1156 1156
 				return array();
1157 1157
 			}
1158 1158
 		}
1159 1159
 
1160
-		if( ! is_array( $query_params ) ){
1161
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1160
+		if ( ! is_array($query_params)) {
1161
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1162 1162
 			$query_params = array();
1163 1163
 		}
1164 1164
 
1165 1165
 		//let's add the where query param for consecutive look up.
1166
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1166
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1167 1167
 		$query_params['limit'] = $limit;
1168 1168
 
1169 1169
 		//set direction
1170
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1170
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1171 1171
 		$query_params['order_by'] = $operand === '>'
1172
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1173
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1172
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1173
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1174 1174
 
1175 1175
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1176
-		if ( empty( $columns_to_select ) ) {
1177
-			return $this->get_all( $query_params );
1176
+		if (empty($columns_to_select)) {
1177
+			return $this->get_all($query_params);
1178 1178
 		} else {
1179 1179
 			//getting just the fields
1180
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1180
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1181 1181
 		}
1182 1182
 	}
1183 1183
 
@@ -1188,18 +1188,18 @@  discard block
 block discarded – undo
1188 1188
 	 * This sets the _timezone property after model object has been instantiated.
1189 1189
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1190 1190
 	 */
1191
-	public function set_timezone( $timezone ) {
1192
-		if ( $timezone !== null ) {
1191
+	public function set_timezone($timezone) {
1192
+		if ($timezone !== null) {
1193 1193
 			$this->_timezone = $timezone;
1194 1194
 		}
1195 1195
 		//note we need to loop through relations and set the timezone on those objects as well.
1196
-		foreach ( $this->_model_relations as $relation ) {
1197
-			$relation->set_timezone( $timezone );
1196
+		foreach ($this->_model_relations as $relation) {
1197
+			$relation->set_timezone($timezone);
1198 1198
 		}
1199 1199
 		//and finally we do the same for any datetime fields
1200
-		foreach ( $this->_fields as $field ) {
1201
-			if ( $field instanceof EE_Datetime_Field ) {
1202
-				$field->set_timezone( $timezone );
1200
+		foreach ($this->_fields as $field) {
1201
+			if ($field instanceof EE_Datetime_Field) {
1202
+				$field->set_timezone($timezone);
1203 1203
 			}
1204 1204
 		}
1205 1205
 	}
@@ -1214,9 +1214,9 @@  discard block
 block discarded – undo
1214 1214
 	 */
1215 1215
 	public function get_timezone() {
1216 1216
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1217
-		if ( empty( $this->_timezone ) ) {
1218
-			foreach( $this->_fields as $field ) {
1219
-				if ( $field instanceof EE_Datetime_Field ) {
1217
+		if (empty($this->_timezone)) {
1218
+			foreach ($this->_fields as $field) {
1219
+				if ($field instanceof EE_Datetime_Field) {
1220 1220
 					$this->set_timezone($field->get_timezone());
1221 1221
 					break;
1222 1222
 				}
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 		}
1225 1225
 
1226 1226
 		//if timezone STILL empty then return the default timezone for the site.
1227
-		if ( empty( $this->_timezone ) ) {
1228
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1227
+		if (empty($this->_timezone)) {
1228
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1229 1229
 		}
1230 1230
 		return $this->_timezone;
1231 1231
 	}
@@ -1243,19 +1243,19 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 * @return array formats in an array with the date format first, and the time format last.
1245 1245
 	 */
1246
-	public function get_formats_for( $field_name, $pretty = false ) {
1247
-		$field_settings = $this->field_settings_for( $field_name );
1246
+	public function get_formats_for($field_name, $pretty = false) {
1247
+		$field_settings = $this->field_settings_for($field_name);
1248 1248
 
1249 1249
 		//if not a valid EE_Datetime_Field then throw error
1250
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1251
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1250
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1251
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1252 1252
 		}
1253 1253
 
1254 1254
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1255 1255
 		//the field.
1256 1256
 		$this->_timezone = $field_settings->get_timezone();
1257 1257
 
1258
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1258
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1259 1259
 	}
1260 1260
 
1261 1261
 
@@ -1279,25 +1279,25 @@  discard block
 block discarded – undo
1279 1279
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1280 1280
 	 *                    	     exception is triggered.
1281 1281
 	 */
1282
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1283
-		$formats = $this->get_formats_for( $field_name );
1282
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1283
+		$formats = $this->get_formats_for($field_name);
1284 1284
 
1285
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1285
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1286 1286
 
1287
-		if ( $timestamp ) {
1288
-			return $DateTime->format( 'U' );
1287
+		if ($timestamp) {
1288
+			return $DateTime->format('U');
1289 1289
 		}
1290 1290
 
1291 1291
 		//not returning timestamp, so return formatted string in timezone.
1292
-		switch( $what ) {
1292
+		switch ($what) {
1293 1293
 			case 'time' :
1294
-				return $DateTime->format( $formats[1] );
1294
+				return $DateTime->format($formats[1]);
1295 1295
 				break;
1296 1296
 			case 'date' :
1297
-				return $DateTime->format( $formats[0] );
1297
+				return $DateTime->format($formats[0]);
1298 1298
 				break;
1299 1299
 			default :
1300
-				return $DateTime->format( implode( ' ', $formats ) );
1300
+				return $DateTime->format(implode(' ', $formats));
1301 1301
 				break;
1302 1302
 		}
1303 1303
 	}
@@ -1319,17 +1319,17 @@  discard block
 block discarded – undo
1319 1319
 	 * @return DateTime
1320 1320
 	 * @throws \EE_Error
1321 1321
 	 */
1322
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1322
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1323 1323
 
1324 1324
 		//just using this to ensure the timezone is set correctly internally
1325
-		$this->get_formats_for( $field_name );
1325
+		$this->get_formats_for($field_name);
1326 1326
 
1327 1327
 		//load EEH_DTT_Helper
1328
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1328
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1329 1329
 
1330
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1330
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1331 1331
 
1332
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1332
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1333 1333
 	}
1334 1334
 
1335 1335
 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1340 1340
 	 * @return EE_Table_Base[]
1341 1341
 	 */
1342
-	public function get_tables(){
1342
+	public function get_tables() {
1343 1343
 		return $this->_tables;
1344 1344
 	}
1345 1345
 
@@ -1375,9 +1375,9 @@  discard block
 block discarded – undo
1375 1375
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1376 1376
 	 * @throws \EE_Error
1377 1377
 	 */
1378
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1379
-		if( ! is_array( $query_params ) ){
1380
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1378
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1379
+		if ( ! is_array($query_params)) {
1380
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1381 1381
 			$query_params = array();
1382 1382
 		}
1383 1383
 		/**
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 		 * @param array $fields_n_values the updated fields and their new values
1388 1388
 		 * @param array $query_params @see EEM_Base::get_all()
1389 1389
 		 */
1390
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1390
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1391 1391
 		/**
1392 1392
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1393 1393
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1395,10 +1395,10 @@  discard block
 block discarded – undo
1395 1395
 		 * @param EEM_Base $model the model being queried
1396 1396
 		 * @param array $query_params see EEM_Base::get_all()
1397 1397
 		 */
1398
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1398
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1399 1399
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1400 1400
 		//to do that, for each table, verify that it's PK isn't null.
1401
-		$tables= $this->get_tables();
1401
+		$tables = $this->get_tables();
1402 1402
 
1403 1403
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1404 1404
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1408,29 +1408,29 @@  discard block
 block discarded – undo
1408 1408
 			//we want to make sure the default_where strategy is ignored
1409 1409
 			$this->_ignore_where_strategy = TRUE;
1410 1410
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1411
-			foreach( $wpdb_select_results as $wpdb_result ){
1411
+			foreach ($wpdb_select_results as $wpdb_result) {
1412 1412
 				// type cast stdClass as array
1413
-				$wpdb_result = (array)$wpdb_result;
1413
+				$wpdb_result = (array) $wpdb_result;
1414 1414
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1415
-				if( $this->has_primary_key_field() ){
1416
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1417
-				}else{
1415
+				if ($this->has_primary_key_field()) {
1416
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1417
+				} else {
1418 1418
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1419 1419
 					$main_table_pk_value = null;
1420 1420
 				}
1421 1421
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1422 1422
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1423
-				if(count($tables) > 1){
1423
+				if (count($tables) > 1) {
1424 1424
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1425 1425
 					//in that table, and so we'll want to insert one
1426
-					foreach($tables as $table_obj){
1426
+					foreach ($tables as $table_obj) {
1427 1427
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1428 1428
 						//if there is no private key for this table on the results, it means there's no entry
1429 1429
 						//in this table, right? so insert a row in the current table, using any fields available
1430
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1430
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1431 1431
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1432 1432
 							//if we died here, report the error
1433
-							if( ! $success ) {
1433
+							if ( ! $success) {
1434 1434
 								return false;
1435 1435
 							}
1436 1436
 						}
@@ -1450,44 +1450,44 @@  discard block
 block discarded – undo
1450 1450
 		//if this wasn't called from a model object (to update itself)
1451 1451
 		//then we want to make sure we keep all the existing
1452 1452
 		//model objects in sync with the db
1453
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1454
-			if( $this->has_primary_key_field() ){
1455
-				$model_objs_affected_ids = $this->get_col( $query_params );
1456
-			}else{
1453
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1454
+			if ($this->has_primary_key_field()) {
1455
+				$model_objs_affected_ids = $this->get_col($query_params);
1456
+			} else {
1457 1457
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1458
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1458
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1459 1459
 				$model_objs_affected_ids = array();
1460
-				foreach( $models_affected_key_columns as $row ){
1461
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1462
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1460
+				foreach ($models_affected_key_columns as $row) {
1461
+					$combined_index_key = $this->get_index_primary_key_string($row);
1462
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1463 1463
 				}
1464 1464
 
1465 1465
 			}
1466 1466
 
1467
-			if( ! $model_objs_affected_ids ){
1467
+			if ( ! $model_objs_affected_ids) {
1468 1468
 				//wait wait wait- if nothing was affected let's stop here
1469 1469
 				return 0;
1470 1470
 			}
1471
-			foreach( $model_objs_affected_ids as $id ){
1472
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1473
-				if( $model_obj_in_entity_map ){
1474
-					foreach( $fields_n_values as $field => $new_value ){
1475
-						$model_obj_in_entity_map->set( $field, $new_value );
1471
+			foreach ($model_objs_affected_ids as $id) {
1472
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1473
+				if ($model_obj_in_entity_map) {
1474
+					foreach ($fields_n_values as $field => $new_value) {
1475
+						$model_obj_in_entity_map->set($field, $new_value);
1476 1476
 					}
1477 1477
 				}
1478 1478
 			}
1479 1479
 			//if there is a primary key on this model, we can now do a slight optimization
1480
-			if( $this->has_primary_key_field() ){
1480
+			if ($this->has_primary_key_field()) {
1481 1481
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1482 1482
 				$query_params = array(
1483
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1484
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1483
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1484
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1485 1485
 			}
1486 1486
 		}
1487 1487
 
1488
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1489
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1490
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1488
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1489
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1490
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1491 1491
 		/**
1492 1492
 		 * Action called after a model update call has been made.
1493 1493
 		 *
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
 		 * @param array $query_params @see EEM_Base::get_all()
1497 1497
 		 * @param int $rows_affected
1498 1498
 		 */
1499
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1500
-		return $rows_affected;//how many supposedly got updated
1499
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1500
+		return $rows_affected; //how many supposedly got updated
1501 1501
 	}
1502 1502
 
1503 1503
 
@@ -1513,22 +1513,22 @@  discard block
 block discarded – undo
1513 1513
 	 * @return array just like $wpdb->get_col()
1514 1514
 	 * @throws \EE_Error
1515 1515
 	 */
1516
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1516
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1517 1517
 
1518
-		if( $field_to_select ){
1519
-			$field = $this->field_settings_for( $field_to_select );
1520
-		}elseif( $this->has_primary_key_field ( ) ){
1518
+		if ($field_to_select) {
1519
+			$field = $this->field_settings_for($field_to_select);
1520
+		}elseif ($this->has_primary_key_field( )) {
1521 1521
 			$field = $this->get_primary_key_field();
1522
-		}else{
1522
+		} else {
1523 1523
 			//no primary key, just grab the first column
1524
-			$field = reset( $this->field_settings());
1524
+			$field = reset($this->field_settings());
1525 1525
 		}
1526 1526
 
1527 1527
 
1528 1528
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1529 1529
 		$select_expressions = $field->get_qualified_column();
1530
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1530
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
+		return $this->_do_wpdb_query('get_col', array($SQL));
1532 1532
 	}
1533 1533
 
1534 1534
 
@@ -1541,12 +1541,12 @@  discard block
 block discarded – undo
1541 1541
 	 * @return string
1542 1542
 	 * @throws \EE_Error
1543 1543
 	 */
1544
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1545
-		$query_params[ 'limit' ] = 1;
1546
-		$col = $this->get_col( $query_params, $field_to_select );
1547
-		if( ! empty( $col ) ) {
1548
-			return reset( $col );
1549
-		}else{
1544
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1545
+		$query_params['limit'] = 1;
1546
+		$col = $this->get_col($query_params, $field_to_select);
1547
+		if ( ! empty($col)) {
1548
+			return reset($col);
1549
+		} else {
1550 1550
 			return NULL;
1551 1551
 		}
1552 1552
 	}
@@ -1562,19 +1562,19 @@  discard block
 block discarded – undo
1562 1562
 	 * @return string of SQL
1563 1563
 	 * @throws \EE_Error
1564 1564
 	 */
1565
-	public function _construct_update_sql($fields_n_values){
1565
+	public function _construct_update_sql($fields_n_values) {
1566 1566
 		/** @type WPDB $wpdb */
1567 1567
 		global $wpdb;
1568 1568
 		$cols_n_values = array();
1569
-		foreach($fields_n_values as $field_name => $value){
1569
+		foreach ($fields_n_values as $field_name => $value) {
1570 1570
 			$field_obj = $this->field_settings_for($field_name);
1571 1571
 			//if the value is NULL, we want to assign the value to that.
1572 1572
 			//wpdb->prepare doesn't really handle that properly
1573
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1574
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1573
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1574
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1575 1575
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1576 1576
 		}
1577
-		return implode(",",$cols_n_values);
1577
+		return implode(",", $cols_n_values);
1578 1578
 
1579 1579
 	}
1580 1580
 
@@ -1590,10 +1590,10 @@  discard block
 block discarded – undo
1590 1590
 	 * @return boolean whether the row got deleted or not
1591 1591
 	 * @throws \EE_Error
1592 1592
 	 */
1593
-	public function delete_permanently_by_ID( $id ) {
1593
+	public function delete_permanently_by_ID($id) {
1594 1594
 		return $this->delete_permanently(
1595 1595
 			array(
1596
-				array( $this->get_primary_key_field()->get_name() => $id ),
1596
+				array($this->get_primary_key_field()->get_name() => $id),
1597 1597
 				'limit' 	=> 1
1598 1598
 			)
1599 1599
 		);
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
 	 * @return boolean whether the row got deleted or not
1610 1610
 	 * @throws \EE_Error
1611 1611
 	 */
1612
-	public function delete_by_ID( $id ){
1612
+	public function delete_by_ID($id) {
1613 1613
 		return $this->delete(
1614 1614
 			array(
1615
-				array( $this->get_primary_key_field()->get_name() => $id ),
1615
+				array($this->get_primary_key_field()->get_name() => $id),
1616 1616
 				'limit' 	=> 1
1617 1617
 			)
1618 1618
 		);
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	 * @return int how many rows got deleted
1632 1632
 	 * @throws \EE_Error
1633 1633
 	 */
1634
-	public function delete($query_params,$allow_blocking = true){
1634
+	public function delete($query_params, $allow_blocking = true) {
1635 1635
 		return $this->delete_permanently($query_params, $allow_blocking);
1636 1636
 	}
1637 1637
 
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 	 * @return int how many rows got deleted
1650 1650
 	 * @throws \EE_Error
1651 1651
 	 */
1652
-	public function delete_permanently($query_params,$allow_blocking = true){
1652
+	public function delete_permanently($query_params, $allow_blocking = true) {
1653 1653
 		/**
1654 1654
 		 * Action called just before performing a real deletion query. You can use the
1655 1655
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1658,31 +1658,31 @@  discard block
 block discarded – undo
1658 1658
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1659 1659
 		 * to block (prevent) this deletion
1660 1660
 		 */
1661
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1661
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1662 1662
 		//some MySQL databases may be running safe mode, which may restrict
1663 1663
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1664 1664
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1665 1665
 		//to delete them
1666 1666
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1667
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1668
-		if($deletion_where){
1667
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1668
+		if ($deletion_where) {
1669 1669
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1670 1670
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1671
-			$table_aliases = array_keys( $this->_tables );
1672
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1671
+			$table_aliases = array_keys($this->_tables);
1672
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1673 1673
 
1674 1674
 			//		/echo "delete sql:$SQL";
1675
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1676
-		}else{
1675
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1676
+		} else {
1677 1677
 			$rows_deleted = 0;
1678 1678
 		}
1679 1679
 
1680 1680
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1681
-		if( $this->has_primary_key_field() ){
1682
-			foreach($items_for_deletion as $item_for_deletion_row ){
1683
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1684
-				if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){
1685
-					unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] );
1681
+		if ($this->has_primary_key_field()) {
1682
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1683
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1684
+				if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) {
1685
+					unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]);
1686 1686
 				}
1687 1687
 			}
1688 1688
 		}
@@ -1694,8 +1694,8 @@  discard block
 block discarded – undo
1694 1694
 		 * @param array $query_params @see EEM_Base::get_all()
1695 1695
 		 * @param int $rows_deleted
1696 1696
 		 */
1697
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1698
-		return $rows_deleted;//how many supposedly got deleted
1697
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1698
+		return $rows_deleted; //how many supposedly got deleted
1699 1699
 	}
1700 1700
 
1701 1701
 
@@ -1713,28 +1713,28 @@  discard block
 block discarded – undo
1713 1713
 	 * @return boolean
1714 1714
 	 * @throws \EE_Error
1715 1715
 	 */
1716
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1716
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1717 1717
 		//first, if $ignore_this_model_obj was supplied, get its model
1718
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1718
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1719 1719
 			$ignored_model = $ignore_this_model_obj->get_model();
1720
-		}else{
1720
+		} else {
1721 1721
 			$ignored_model = null;
1722 1722
 		}
1723 1723
 		//now check all the relations of $this_model_obj_or_id and see if there
1724 1724
 		//are any related model objects blocking it?
1725 1725
 		$is_blocked = false;
1726
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1727
-			if( $relation_obj->block_delete_if_related_models_exist()){
1726
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1727
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1728 1728
 				//if $ignore_this_model_obj was supplied, then for the query
1729 1729
 				//on that model needs to be told to ignore $ignore_this_model_obj
1730
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1731
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1732
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1733
-				}else{
1730
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1731
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1732
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1733
+				} else {
1734 1734
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1735 1735
 				}
1736 1736
 
1737
-				if($related_model_objects){
1737
+				if ($related_model_objects) {
1738 1738
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1739 1739
 					$is_blocked = true;
1740 1740
 				}
@@ -1754,71 +1754,71 @@  discard block
 block discarded – undo
1754 1754
 	 * @throws EE_Error
1755 1755
 	 * @return string    everything that comes after the WHERE statement.
1756 1756
 	 */
1757
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1758
-		if($this->has_primary_key_field()){
1757
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1758
+		if ($this->has_primary_key_field()) {
1759 1759
 			$primary_table = $this->_get_main_table();
1760 1760
 			$other_tables = $this->_get_other_tables();
1761 1761
 			$deletes = $query = array();
1762
-			foreach ( $objects_for_deletion as $delete_object ) {
1762
+			foreach ($objects_for_deletion as $delete_object) {
1763 1763
 				//before we mark this object for deletion,
1764 1764
 				//make sure there's no related objects blocking its deletion (if we're checking)
1765 1765
 				if (
1766 1766
 					$allow_blocking
1767 1767
 				    && $this->delete_is_blocked_by_related_models(
1768
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1768
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1769 1769
 					)
1770 1770
 				) {
1771 1771
 					continue;
1772 1772
 				}
1773 1773
 				//primary table deletes
1774
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1775
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1774
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1775
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1776 1776
 				}
1777 1777
 				//other tables
1778
-				if ( ! empty( $other_tables ) ) {
1779
-					foreach ( $other_tables as $ot ) {
1778
+				if ( ! empty($other_tables)) {
1779
+					foreach ($other_tables as $ot) {
1780 1780
 						//first check if we've got the foreign key column here.
1781
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1782
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1781
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1782
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1783 1783
 						}
1784 1784
 						// wait! it's entirely possible that we'll have a the primary key
1785 1785
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1786
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1787
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1786
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1787
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1788 1788
 						}
1789 1789
 						// finally, it is possible that the fk for this table is found
1790 1790
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1791
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1792
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1791
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1792
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1793 1793
 						}
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797 1797
 
1798 1798
 			//we should have deletes now, so let's just go through and setup the where statement
1799
-			foreach ( $deletes as $column => $values ) {
1799
+			foreach ($deletes as $column => $values) {
1800 1800
 				//make sure we have unique $values;
1801 1801
 				$values = array_unique($values);
1802
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1802
+				$query[] = $column.' IN('.implode(",", $values).')';
1803 1803
 			}
1804 1804
 
1805
-			return !empty($query) ? implode(' AND ', $query ) : '';
1806
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1805
+			return ! empty($query) ? implode(' AND ', $query) : '';
1806
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1807 1807
 			$ways_to_identify_a_row = array();
1808 1808
 			$fields = $this->get_combined_primary_key_fields();
1809 1809
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1810
-			foreach($objects_for_deletion as  $delete_object){
1810
+			foreach ($objects_for_deletion as  $delete_object) {
1811 1811
 				$values_for_each_cpk_for_a_row = array();
1812
-				foreach($fields as $cpk_field){
1812
+				foreach ($fields as $cpk_field) {
1813 1813
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1814 1814
 				}
1815
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1815
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1816 1816
 			}
1817
-			return implode(" OR ",$ways_to_identify_a_row);
1818
-		}else{
1817
+			return implode(" OR ", $ways_to_identify_a_row);
1818
+		} else {
1819 1819
 			//so there's no primary key and no combined key...
1820 1820
 			//sorry, can't help you
1821
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1821
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1822 1822
 		}
1823 1823
 	}
1824 1824
 
@@ -1834,21 +1834,21 @@  discard block
 block discarded – undo
1834 1834
 	 * @return int
1835 1835
 	 * @throws \EE_Error
1836 1836
 	 */
1837
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1837
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1838 1838
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1839
-		if($field_to_count){
1839
+		if ($field_to_count) {
1840 1840
 			$field_obj = $this->field_settings_for($field_to_count);
1841 1841
 			$column_to_count = $field_obj->get_qualified_column();
1842
-		}elseif($this->has_primary_key_field ()){
1842
+		}elseif ($this->has_primary_key_field()) {
1843 1843
 			$pk_field_obj = $this->get_primary_key_field();
1844 1844
 			$column_to_count = $pk_field_obj->get_qualified_column();
1845
-		}else{//there's no primary key
1845
+		} else {//there's no primary key
1846 1846
 			$column_to_count = '*';
1847 1847
 		}
1848 1848
 
1849
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1850
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1851
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1849
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1850
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1851
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1852 1852
 	}
1853 1853
 
1854 1854
 
@@ -1861,24 +1861,24 @@  discard block
 block discarded – undo
1861 1861
 	 * @return float
1862 1862
 	 * @throws \EE_Error
1863 1863
 	 */
1864
-	public function sum($query_params, $field_to_sum = NULL){
1864
+	public function sum($query_params, $field_to_sum = NULL) {
1865 1865
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1866 1866
 
1867
-		if($field_to_sum){
1867
+		if ($field_to_sum) {
1868 1868
 			$field_obj = $this->field_settings_for($field_to_sum);
1869 1869
 
1870
-		}else{
1870
+		} else {
1871 1871
 			$field_obj = $this->get_primary_key_field();
1872 1872
 		}
1873 1873
 		$column_to_count = $field_obj->get_qualified_column();
1874 1874
 
1875
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1876
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1875
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1876
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1877 1877
 		$data_type = $field_obj->get_wpdb_data_type();
1878
-		if( $data_type === '%d' || $data_type === '%s' ){
1879
-			return (float)$return_value;
1880
-		}else{//must be %f
1881
-			return (float)$return_value;
1878
+		if ($data_type === '%d' || $data_type === '%s') {
1879
+			return (float) $return_value;
1880
+		} else {//must be %f
1881
+			return (float) $return_value;
1882 1882
 		}
1883 1883
 	}
1884 1884
 
@@ -1893,37 +1893,37 @@  discard block
 block discarded – undo
1893 1893
 	 * @global wpdb $wpdb
1894 1894
 	 * @return mixed
1895 1895
 	 */
1896
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1896
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1897 1897
 		//if we're in maintenance mode level 2, DON'T run any queries
1898 1898
 		//because level 2 indicates the database needs updating and
1899 1899
 		//is probably out of sync with the code
1900
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1900
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1901 1901
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1902 1902
 		}
1903 1903
 		/** @type WPDB $wpdb */
1904 1904
 		global $wpdb;
1905
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1906
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1905
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1906
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1907 1907
 		}
1908
-		if( WP_DEBUG ){
1908
+		if (WP_DEBUG) {
1909 1909
 			$old_show_errors_value = $wpdb->show_errors;
1910
-			$wpdb->show_errors( FALSE );
1911
-		}
1912
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1913
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1914
-		if( WP_DEBUG ){
1915
-			$wpdb->show_errors( $old_show_errors_value );
1916
-			if( ! empty( $wpdb->last_error ) ){
1917
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1918
-			}elseif( $result === false ){
1919
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1910
+			$wpdb->show_errors(FALSE);
1911
+		}
1912
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1913
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1914
+		if (WP_DEBUG) {
1915
+			$wpdb->show_errors($old_show_errors_value);
1916
+			if ( ! empty($wpdb->last_error)) {
1917
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1918
+			}elseif ($result === false) {
1919
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1920 1920
 			}
1921
-		}elseif( $result === false ) {
1921
+		}elseif ($result === false) {
1922 1922
 			EE_Error::add_error( 
1923 1923
 				sprintf( 
1924
-					__( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ),
1924
+					__('A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso'),
1925 1925
 					$wpdb_method,
1926
-					var_export( $arguments_to_provide, true ),
1926
+					var_export($arguments_to_provide, true),
1927 1927
 					$wpdb->last_error
1928 1928
 				), 
1929 1929
 				__FILE__, 
@@ -1945,26 +1945,26 @@  discard block
 block discarded – undo
1945 1945
 	 * @param array $arguments_to_provide
1946 1946
 	 * @return mixed
1947 1947
 	 */
1948
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1948
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1949 1949
 		/** @type WPDB $wpdb */
1950 1950
 		global $wpdb;
1951 1951
 		$wpdb->last_error = null;
1952
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1952
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1953 1953
 		// was there an error running the query? but we don't care on new activations
1954 1954
 		// (we're going to setup the DB anyway on new activations)
1955
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1955
+		if (($result === false || ! empty($wpdb->last_error))
1956 1956
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1957 1957
 		) {
1958
-			switch ( EEM_Base::$_db_verification_level ) {
1958
+			switch (EEM_Base::$_db_verification_level) {
1959 1959
 
1960 1960
 				case EEM_Base::db_verified_none :
1961 1961
 					// let's double-check core's DB
1962
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1962
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1963 1963
 					break;
1964 1964
 
1965 1965
 				case EEM_Base::db_verified_core :
1966 1966
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1967
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1967
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1968 1968
 					break;
1969 1969
 
1970 1970
 				case EEM_Base::db_verified_addons :
@@ -1972,11 +1972,11 @@  discard block
 block discarded – undo
1972 1972
 					return $result;
1973 1973
 					break;
1974 1974
 			}
1975
-			if ( ! empty( $error_message ) ) {
1976
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1977
-				trigger_error( $error_message );
1975
+			if ( ! empty($error_message)) {
1976
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1977
+				trigger_error($error_message);
1978 1978
 			}
1979
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1979
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1980 1980
 
1981 1981
 		}
1982 1982
 
@@ -1992,18 +1992,18 @@  discard block
 block discarded – undo
1992 1992
 	 * @param array $arguments_to_provide
1993 1993
 	 * @return string
1994 1994
 	 */
1995
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1995
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1996 1996
 		/** @type WPDB $wpdb */
1997 1997
 		global $wpdb;
1998 1998
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1999 1999
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
2000 2000
 		$error_message = sprintf(
2001
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
2001
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
2002 2002
 			$wpdb->last_error,
2003 2003
 			$wpdb_method,
2004
-			json_encode( $arguments_to_provide )
2004
+			json_encode($arguments_to_provide)
2005 2005
 		);
2006
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
2006
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
2007 2007
 		return $error_message;
2008 2008
 	}
2009 2009
 
@@ -2016,16 +2016,16 @@  discard block
 block discarded – undo
2016 2016
 	 * @param $arguments_to_provide
2017 2017
 	 * @return string
2018 2018
 	 */
2019
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
2019
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
2020 2020
 		/** @type WPDB $wpdb */
2021 2021
 		global $wpdb;
2022 2022
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
2023 2023
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
2024 2024
 		$error_message = sprintf(
2025
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
2025
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
2026 2026
 			$wpdb->last_error,
2027 2027
 			$wpdb_method,
2028
-			json_encode( $arguments_to_provide )
2028
+			json_encode($arguments_to_provide)
2029 2029
 		);
2030 2030
 		EE_System::instance()->initialize_addons();
2031 2031
 		return $error_message;
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2041 2041
 	 * @return string
2042 2042
 	 */
2043
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2043
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2044 2044
 		return " FROM ".$model_query_info->get_full_join_sql().
2045 2045
 				$model_query_info->get_where_sql().
2046 2046
 				$model_query_info->get_group_by_sql().
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 	 * Set to easily debug the next X queries ran from this model.
2054 2054
 	 * @param int $count
2055 2055
 	 */
2056
-	public function show_next_x_db_queries($count = 1){
2056
+	public function show_next_x_db_queries($count = 1) {
2057 2057
 		$this->_show_next_x_db_queries = $count;
2058 2058
 	}
2059 2059
 
@@ -2062,8 +2062,8 @@  discard block
 block discarded – undo
2062 2062
 	/**
2063 2063
 	 * @param $sql_query
2064 2064
 	 */
2065
-	public function show_db_query_if_previously_requested($sql_query){
2066
-		if($this->_show_next_x_db_queries > 0){
2065
+	public function show_db_query_if_previously_requested($sql_query) {
2066
+		if ($this->_show_next_x_db_queries > 0) {
2067 2067
 			echo $sql_query;
2068 2068
 			$this->_show_next_x_db_queries--;
2069 2069
 		}
@@ -2087,9 +2087,9 @@  discard block
 block discarded – undo
2087 2087
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2088 2088
 	 * @throws \EE_Error
2089 2089
 	 */
2090
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2090
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2091 2091
 		$relation_obj = $this->related_settings_for($relationName);
2092
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2092
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2093 2093
 	}
2094 2094
 
2095 2095
 
@@ -2108,9 +2108,9 @@  discard block
 block discarded – undo
2108 2108
 	 * @throws \EE_Error
2109 2109
 	 * @param array  $where_query  This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2110 2110
 	 */
2111
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2111
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2112 2112
 		$relation_obj = $this->related_settings_for($relationName);
2113
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2113
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2114 2114
 	}
2115 2115
 
2116 2116
 
@@ -2123,9 +2123,9 @@  discard block
 block discarded – undo
2123 2123
 	 * @return \EE_Base_Class[]
2124 2124
 	 * @throws \EE_Error
2125 2125
 	 */
2126
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2126
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2127 2127
 		$relation_obj = $this->related_settings_for($relationName);
2128
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2128
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2129 2129
 	}
2130 2130
 
2131 2131
 
@@ -2141,10 +2141,10 @@  discard block
 block discarded – undo
2141 2141
 	 * @return EE_Base_Class[]
2142 2142
 	 * @throws \EE_Error
2143 2143
 	 */
2144
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2144
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2145 2145
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2146 2146
 		$relation_settings = $this->related_settings_for($model_name);
2147
-		return $relation_settings->get_all_related($model_obj,$query_params);
2147
+		return $relation_settings->get_all_related($model_obj, $query_params);
2148 2148
 	}
2149 2149
 
2150 2150
 
@@ -2161,10 +2161,10 @@  discard block
 block discarded – undo
2161 2161
 	 * @return int how many deleted
2162 2162
 	 * @throws \EE_Error
2163 2163
 	 */
2164
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2164
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2165 2165
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2166 2166
 		$relation_settings = $this->related_settings_for($model_name);
2167
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2167
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2168 2168
 	}
2169 2169
 
2170 2170
 
@@ -2181,10 +2181,10 @@  discard block
 block discarded – undo
2181 2181
 	 * @return int how many deleted
2182 2182
 	 * @throws \EE_Error
2183 2183
 	 */
2184
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2184
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2185 2185
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2186 2186
 		$relation_settings = $this->related_settings_for($model_name);
2187
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2187
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2188 2188
 	}
2189 2189
 
2190 2190
 
@@ -2201,17 +2201,17 @@  discard block
 block discarded – undo
2201 2201
 	 * @return int
2202 2202
 	 * @throws \EE_Error
2203 2203
 	 */
2204
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2204
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2205 2205
 		$related_model = $this->get_related_model_obj($model_name);
2206 2206
 		//we're just going to use the query params on the related model's normal get_all query,
2207 2207
 		//except add a condition to say to match the current mod
2208
-		if( ! isset($query_params['default_where_conditions'])){
2209
-			$query_params['default_where_conditions']='none';
2208
+		if ( ! isset($query_params['default_where_conditions'])) {
2209
+			$query_params['default_where_conditions'] = 'none';
2210 2210
 		}
2211 2211
 		$this_model_name = $this->get_this_model_name();
2212 2212
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2213
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2214
-		return $related_model->count($query_params,$field_to_count,$distinct);
2213
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2214
+		return $related_model->count($query_params, $field_to_count, $distinct);
2215 2215
 	}
2216 2216
 
2217 2217
 
@@ -2227,21 +2227,21 @@  discard block
 block discarded – undo
2227 2227
 	 * @return float
2228 2228
 	 * @throws \EE_Error
2229 2229
 	 */
2230
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2230
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2231 2231
 		$related_model = $this->get_related_model_obj($model_name);
2232
-		if( ! is_array( $query_params ) ){
2233
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2232
+		if ( ! is_array($query_params)) {
2233
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2234 2234
 			$query_params = array();
2235 2235
 		}
2236 2236
 		//we're just going to use the query params on the related model's normal get_all query,
2237 2237
 		//except add a condition to say to match the current mod
2238
-		if( ! isset($query_params['default_where_conditions'])){
2239
-			$query_params['default_where_conditions']='none';
2238
+		if ( ! isset($query_params['default_where_conditions'])) {
2239
+			$query_params['default_where_conditions'] = 'none';
2240 2240
 		}
2241 2241
 		$this_model_name = $this->get_this_model_name();
2242 2242
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2243
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2244
-		return $related_model->sum($query_params,$field_to_sum);
2243
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2244
+		return $related_model->sum($query_params, $field_to_sum);
2245 2245
 	}
2246 2246
 
2247 2247
 
@@ -2255,12 +2255,12 @@  discard block
 block discarded – undo
2255 2255
 	 * @return EE_Base_Class
2256 2256
 	 * @throws \EE_Error
2257 2257
 	 */
2258
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2259
-		$query_params['limit']=1;
2260
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2261
-		if( $results ){
2258
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2259
+		$query_params['limit'] = 1;
2260
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2261
+		if ($results) {
2262 2262
 			return array_shift($results);
2263
-		}else{
2263
+		} else {
2264 2264
 			return null;
2265 2265
 		}
2266 2266
 
@@ -2270,8 +2270,8 @@  discard block
 block discarded – undo
2270 2270
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2271 2271
 	 * @return string
2272 2272
 	 */
2273
-	public function get_this_model_name(){
2274
-		return str_replace("EEM_","",get_class($this));
2273
+	public function get_this_model_name() {
2274
+		return str_replace("EEM_", "", get_class($this));
2275 2275
 	}
2276 2276
 
2277 2277
 	/**
@@ -2279,14 +2279,14 @@  discard block
 block discarded – undo
2279 2279
 	 * @return EE_Any_Foreign_Model_Name_Field
2280 2280
 	 * @throws EE_Error
2281 2281
 	 */
2282
-	public function get_field_containing_related_model_name(){
2283
-		foreach($this->field_settings(true) as $field){
2284
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2282
+	public function get_field_containing_related_model_name() {
2283
+		foreach ($this->field_settings(true) as $field) {
2284
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2285 2285
 				$field_with_model_name = $field;
2286 2286
 			}
2287 2287
 		}
2288
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2289
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2288
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2289
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2290 2290
 		}
2291 2291
 		return $field_with_model_name;
2292 2292
 	}
@@ -2307,19 +2307,19 @@  discard block
 block discarded – undo
2307 2307
 	 * @return int new primary key on main table that got inserted
2308 2308
 	 * @throws EE_Error
2309 2309
 	 */
2310
-	public function insert($field_n_values){
2310
+	public function insert($field_n_values) {
2311 2311
 		/**
2312 2312
 		 * Filters the fields and their values before inserting an item using the models
2313 2313
 		 * @param array $fields_n_values keys are the fields and values are their new values
2314 2314
 		 * @param EEM_Base $model the model used
2315 2315
 		 */
2316
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2317
-		if($this->_satisfies_unique_indexes($field_n_values)){
2316
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2317
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2318 2318
 			$main_table = $this->_get_main_table();
2319 2319
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2320
-			if( $new_id !== false ) {
2321
-				foreach($this->_get_other_tables() as $other_table){
2322
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2320
+			if ($new_id !== false) {
2321
+				foreach ($this->_get_other_tables() as $other_table) {
2322
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2323 2323
 				}
2324 2324
 			}
2325 2325
 			/**
@@ -2329,9 +2329,9 @@  discard block
 block discarded – undo
2329 2329
 			 * @param array $fields_n_values fields and their values
2330 2330
 			 * @param int|string the ID of the newly-inserted model object
2331 2331
 			 */
2332
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2332
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2333 2333
 			return $new_id;
2334
-		}else{
2334
+		} else {
2335 2335
 			return FALSE;
2336 2336
 		}
2337 2337
 	}
@@ -2346,10 +2346,10 @@  discard block
 block discarded – undo
2346 2346
 	 * @return boolean
2347 2347
 	 * @throws \EE_Error
2348 2348
 	 */
2349
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2350
-		foreach($this->unique_indexes() as $index_name => $index){
2349
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2350
+		foreach ($this->unique_indexes() as $index_name => $index) {
2351 2351
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2352
-			if($this->exists(array($uniqueness_where_params))){
2352
+			if ($this->exists(array($uniqueness_where_params))) {
2353 2353
 				EE_Error::add_error(
2354 2354
 					sprintf(
2355 2355
 						__(
@@ -2359,8 +2359,8 @@  discard block
 block discarded – undo
2359 2359
 						$action,
2360 2360
 						$this->_get_class_name(),
2361 2361
 						$index_name,
2362
-						implode( ",", $index->field_names() ),
2363
-						http_build_query( $uniqueness_where_params )
2362
+						implode(",", $index->field_names()),
2363
+						http_build_query($uniqueness_where_params)
2364 2364
 					),
2365 2365
 					__FILE__,
2366 2366
 					__FUNCTION__,
@@ -2386,37 +2386,37 @@  discard block
 block discarded – undo
2386 2386
 	 * @throws EE_Error
2387 2387
 	 * @return EE_Base_Class
2388 2388
 	 */
2389
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2390
-		if($obj_or_fields_array instanceof EE_Base_Class){
2389
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2390
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2391 2391
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2392
-		}elseif( is_array($obj_or_fields_array)){
2392
+		}elseif (is_array($obj_or_fields_array)) {
2393 2393
 			$fields_n_values = $obj_or_fields_array;
2394
-		}else{
2394
+		} else {
2395 2395
 			throw new EE_Error(
2396 2396
 				sprintf(
2397 2397
 					__(
2398 2398
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2399 2399
 						"event_espresso"
2400 2400
 					),
2401
-					get_class( $this ),
2401
+					get_class($this),
2402 2402
 					$obj_or_fields_array
2403 2403
 				)
2404 2404
 			);
2405 2405
 		}
2406 2406
 		$query_params = array();
2407
-		if( $this->has_primary_key_field() &&
2408
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2409
-				isset($fields_n_values[$this->primary_key_name()])){
2407
+		if ($this->has_primary_key_field() &&
2408
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2409
+				isset($fields_n_values[$this->primary_key_name()])) {
2410 2410
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2411 2411
 		}
2412
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2412
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2413 2413
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2414 2414
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2415 2415
 		}
2416 2416
 		//if there is nothing to base this search on, then we shouldn't find anything
2417
-		if( empty( $query_params ) ){
2417
+		if (empty($query_params)) {
2418 2418
 			return array();
2419
-		}else{
2419
+		} else {
2420 2420
 			return $this->get_one($query_params);
2421 2421
 		}
2422 2422
 	}
@@ -2430,7 +2430,7 @@  discard block
 block discarded – undo
2430 2430
 	 * @return boolean
2431 2431
 	 * @throws \EE_Error
2432 2432
 	 */
2433
-	public function exists($query_params){
2433
+	public function exists($query_params) {
2434 2434
 		$query_params['limit'] = 1;
2435 2435
 		return $this->count($query_params) > 0;
2436 2436
 	}
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
 	 * @return boolean
2445 2445
 	 * @throws \EE_Error
2446 2446
 	 */
2447
-	public function exists_by_ID($id){
2447
+	public function exists_by_ID($id) {
2448 2448
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2449 2449
 	}
2450 2450
 
@@ -2464,45 +2464,45 @@  discard block
 block discarded – undo
2464 2464
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2465 2465
 	 * @return int ID of new row inserted, or FALSE on failure
2466 2466
 	 */
2467
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2467
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2468 2468
 		global $wpdb;
2469 2469
 		$insertion_col_n_values = array();
2470 2470
 		$format_for_insertion = array();
2471 2471
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2472
-		foreach($fields_on_table as $field_name => $field_obj){
2472
+		foreach ($fields_on_table as $field_name => $field_obj) {
2473 2473
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2474
-			if($field_obj->is_auto_increment()){
2474
+			if ($field_obj->is_auto_increment()) {
2475 2475
 				continue;
2476 2476
 			}
2477 2477
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2478 2478
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2479
-			if( $prepared_value !== NULL ){
2480
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2479
+			if ($prepared_value !== NULL) {
2480
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2481 2481
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2482 2482
 			}
2483 2483
 		}
2484 2484
 
2485
-		if($table instanceof EE_Secondary_Table && $new_id){
2485
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2486 2486
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2487 2487
 			//so add the fk to the main table as a column
2488 2488
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2489
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2489
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2490 2490
 		}
2491 2491
 		//insert the new entry
2492
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2493
-		if( $result === false ) {
2492
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2493
+		if ($result === false) {
2494 2494
 			return false;
2495 2495
 		}
2496 2496
 		//ok, now what do we return for the ID of the newly-inserted thing?
2497
-		if($this->has_primary_key_field()){
2498
-			if($this->get_primary_key_field()->is_auto_increment()){
2497
+		if ($this->has_primary_key_field()) {
2498
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2499 2499
 				return $wpdb->insert_id;
2500
-			}else{
2500
+			} else {
2501 2501
 				//it's not an auto-increment primary key, so
2502 2502
 				//it must have been supplied
2503 2503
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2504 2504
 			}
2505
-		}else{
2505
+		} else {
2506 2506
 			//we can't return a  primary key because there is none. instead return
2507 2507
 			//a unique string indicating this model
2508 2508
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2521,15 +2521,15 @@  discard block
 block discarded – undo
2521 2521
 	 * @return mixed string|int|float depending on what the table column will be expecting
2522 2522
 	 * @throws \EE_Error
2523 2523
 	 */
2524
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2524
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2525 2525
 		//if this field doesn't allow nullable, don't allow it
2526
-		if( ! $field_obj->is_nullable() && (
2527
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2528
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2529
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2526
+		if ( ! $field_obj->is_nullable() && (
2527
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2528
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2529
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2530 2530
 		}
2531
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2532
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2531
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2532
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2533 2533
 	}
2534 2534
 
2535 2535
 
@@ -2541,9 +2541,9 @@  discard block
 block discarded – undo
2541 2541
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2542 2542
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2543 2543
 	 */
2544
-	private function _prepare_value_for_use_in_db($value, $field){
2545
-		if($field && $field instanceof EE_Model_Field_Base){
2546
-			switch( $this->_values_already_prepared_by_model_object ){
2544
+	private function _prepare_value_for_use_in_db($value, $field) {
2545
+		if ($field && $field instanceof EE_Model_Field_Base) {
2546
+			switch ($this->_values_already_prepared_by_model_object) {
2547 2547
 				/** @noinspection PhpMissingBreakStatementInspection */
2548 2548
 				case self::not_prepared_by_model_object:
2549 2549
 					$value = $field->prepare_for_set($value);
@@ -2554,7 +2554,7 @@  discard block
 block discarded – undo
2554 2554
 					//leave the value alone
2555 2555
 			}
2556 2556
 			return $value;
2557
-		}else{
2557
+		} else {
2558 2558
 			return $value;
2559 2559
 		}
2560 2560
 	}
@@ -2564,13 +2564,13 @@  discard block
 block discarded – undo
2564 2564
 	 * @return EE_Primary_Table
2565 2565
 	 * @throws EE_Error
2566 2566
 	 */
2567
-	protected function _get_main_table(){
2568
-		foreach($this->_tables as $table){
2569
-			if($table instanceof EE_Primary_Table){
2567
+	protected function _get_main_table() {
2568
+		foreach ($this->_tables as $table) {
2569
+			if ($table instanceof EE_Primary_Table) {
2570 2570
 				return $table;
2571 2571
 			}
2572 2572
 		}
2573
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2573
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2574 2574
 	}
2575 2575
 
2576 2576
 
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
 	 */
2594 2594
 	public function second_table() {
2595 2595
 		// grab second table from tables array
2596
-		$second_table = end( $this->_tables );
2596
+		$second_table = end($this->_tables);
2597 2597
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2598 2598
 	}
2599 2599
 
@@ -2606,8 +2606,8 @@  discard block
 block discarded – undo
2606 2606
 	 * @param string $table_alias
2607 2607
 	 * @return EE_Primary_Table | EE_Secondary_Table
2608 2608
 	 */
2609
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2610
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2609
+	public function get_table_obj_by_alias($table_alias = '') {
2610
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2611 2611
 	}
2612 2612
 
2613 2613
 
@@ -2616,10 +2616,10 @@  discard block
 block discarded – undo
2616 2616
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2617 2617
 	 * @return EE_Secondary_Table[]
2618 2618
 	 */
2619
-	protected function _get_other_tables(){
2620
-		$other_tables =array();
2621
-		foreach($this->_tables as $table_alias => $table){
2622
-			if($table instanceof EE_Secondary_Table){
2619
+	protected function _get_other_tables() {
2620
+		$other_tables = array();
2621
+		foreach ($this->_tables as $table_alias => $table) {
2622
+			if ($table instanceof EE_Secondary_Table) {
2623 2623
 				$other_tables[$table_alias] = $table;
2624 2624
 			}
2625 2625
 		}
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 	 * @param string $table_alias, array key in EEM_Base::_tables
2632 2632
 	 * @return EE_Model_Field_Base[]
2633 2633
 	 */
2634
-	public function _get_fields_for_table($table_alias){
2634
+	public function _get_fields_for_table($table_alias) {
2635 2635
 		return $this->_fields[$table_alias];
2636 2636
 	}
2637 2637
 
@@ -2647,19 +2647,19 @@  discard block
 block discarded – undo
2647 2647
 	 * @return EE_Model_Query_Info_Carrier
2648 2648
 	 * @throws \EE_Error
2649 2649
 	 */
2650
-	public function _extract_related_models_from_query($query_params){
2650
+	public function _extract_related_models_from_query($query_params) {
2651 2651
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2652
-		if ( array_key_exists( 0, $query_params ) ) {
2653
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2652
+		if (array_key_exists(0, $query_params)) {
2653
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2654 2654
 		}
2655
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2656
-			if ( is_array( $query_params['group_by'] ) ) {
2655
+		if (array_key_exists('group_by', $query_params)) {
2656
+			if (is_array($query_params['group_by'])) {
2657 2657
 				$this->_extract_related_models_from_sub_params_array_values(
2658 2658
 					$query_params['group_by'],
2659 2659
 					$query_info_carrier,
2660 2660
 					'group_by'
2661 2661
 				);
2662
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2662
+			} elseif ( ! empty ($query_params['group_by'])) {
2663 2663
 				$this->_extract_related_model_info_from_query_param(
2664 2664
 					$query_params['group_by'],
2665 2665
 					$query_info_carrier,
@@ -2667,21 +2667,21 @@  discard block
 block discarded – undo
2667 2667
 				);
2668 2668
 			}
2669 2669
 		}
2670
-		if ( array_key_exists( 'having', $query_params ) ) {
2670
+		if (array_key_exists('having', $query_params)) {
2671 2671
 			$this->_extract_related_models_from_sub_params_array_keys(
2672 2672
 				$query_params[0],
2673 2673
 				$query_info_carrier,
2674 2674
 				'having'
2675 2675
 			);
2676 2676
 		}
2677
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2678
-			if ( is_array( $query_params['order_by'] ) ) {
2677
+		if (array_key_exists('order_by', $query_params)) {
2678
+			if (is_array($query_params['order_by'])) {
2679 2679
 				$this->_extract_related_models_from_sub_params_array_keys(
2680 2680
 					$query_params['order_by'],
2681 2681
 					$query_info_carrier,
2682 2682
 					'order_by'
2683 2683
 				);
2684
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2684
+			} elseif ( ! empty($query_params['order_by'])) {
2685 2685
 				$this->_extract_related_model_info_from_query_param(
2686 2686
 					$query_params['order_by'],
2687 2687
 					$query_info_carrier,
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 				);
2690 2690
 			}
2691 2691
 		}
2692
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2692
+		if (array_key_exists('force_join', $query_params)) {
2693 2693
 			$this->_extract_related_models_from_sub_params_array_values(
2694 2694
 				$query_params['force_join'],
2695 2695
 				$query_info_carrier,
@@ -2707,34 +2707,34 @@  discard block
 block discarded – undo
2707 2707
 	 * @throws EE_Error
2708 2708
 	 * @return \EE_Model_Query_Info_Carrier
2709 2709
 	 */
2710
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2711
-		if (!empty($sub_query_params)){
2710
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2711
+		if ( ! empty($sub_query_params)) {
2712 2712
 			$sub_query_params = (array) $sub_query_params;
2713
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2713
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2714 2714
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2715
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2715
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2716 2716
 
2717 2717
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2718 2718
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2719 2719
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2720 2720
 				//of array('Registration.TXN_ID'=>23)
2721 2721
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2722
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2723
-					if (! is_array($possibly_array_of_params)){
2722
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2723
+					if ( ! is_array($possibly_array_of_params)) {
2724 2724
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2725
-							$param,$possibly_array_of_params));
2726
-					}else{
2727
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2725
+							$param, $possibly_array_of_params));
2726
+					} else {
2727
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2728 2728
 					}
2729
-				}elseif($query_param_type === 0 //ie WHERE
2729
+				}elseif ($query_param_type === 0 //ie WHERE
2730 2730
 						&& is_array($possibly_array_of_params)
2731 2731
 						&& isset($possibly_array_of_params[2])
2732
-						&& $possibly_array_of_params[2] == true){
2732
+						&& $possibly_array_of_params[2] == true) {
2733 2733
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2734 2734
 					//indicating that $possible_array_of_params[1] is actually a field name,
2735 2735
 					//from which we should extract query parameters!
2736
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2737
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2736
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2737
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2738 2738
 					}
2739 2739
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2740 2740
 				}
@@ -2753,14 +2753,14 @@  discard block
 block discarded – undo
2753 2753
 	 * @throws EE_Error
2754 2754
 	 * @return \EE_Model_Query_Info_Carrier
2755 2755
 	 */
2756
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2757
-		if (!empty($sub_query_params)){
2758
-			if(!is_array($sub_query_params)){
2759
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2756
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2757
+		if ( ! empty($sub_query_params)) {
2758
+			if ( ! is_array($sub_query_params)) {
2759
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2760 2760
 			}
2761
-			foreach($sub_query_params as $param){
2761
+			foreach ($sub_query_params as $param) {
2762 2762
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2763
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2763
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2764 2764
 			}
2765 2765
 		}
2766 2766
 		return $model_query_info_carrier;
@@ -2779,8 +2779,8 @@  discard block
 block discarded – undo
2779 2779
 	 * @throws EE_Error
2780 2780
 	 * @return EE_Model_Query_Info_Carrier
2781 2781
 	 */
2782
-	public function _create_model_query_info_carrier($query_params){
2783
-		if ( ! is_array( $query_params ) ) {
2782
+	public function _create_model_query_info_carrier($query_params) {
2783
+		if ( ! is_array($query_params)) {
2784 2784
 			EE_Error::doing_it_wrong(
2785 2785
 				'EEM_Base::_create_model_query_info_carrier',
2786 2786
 				sprintf(
@@ -2788,16 +2788,16 @@  discard block
 block discarded – undo
2788 2788
 						'$query_params should be an array, you passed a variable of type %s',
2789 2789
 						'event_espresso'
2790 2790
 					),
2791
-					gettype( $query_params )
2791
+					gettype($query_params)
2792 2792
 				),
2793 2793
 				'4.6.0'
2794 2794
 			);
2795 2795
 			$query_params = array();
2796 2796
 		}
2797
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2797
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2798 2798
 		//first check if we should alter the query to account for caps or not
2799 2799
 		//because the caps might require us to do extra joins
2800
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2800
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2801 2801
 			$query_params[0] = $where_query_params = array_replace_recursive(
2802 2802
 				$where_query_params,
2803 2803
 				$this->caps_where_conditions(
@@ -2805,10 +2805,10 @@  discard block
 block discarded – undo
2805 2805
 				)
2806 2806
 			);
2807 2807
 		}
2808
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2808
+		$query_object = $this->_extract_related_models_from_query($query_params);
2809 2809
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2810
-		foreach ( $where_query_params as $key => $value ) {
2811
-			if ( is_int( $key ) ) {
2810
+		foreach ($where_query_params as $key => $value) {
2811
+			if (is_int($key)) {
2812 2812
 				throw new EE_Error(
2813 2813
 					sprintf(
2814 2814
 						__(
@@ -2816,16 +2816,16 @@  discard block
 block discarded – undo
2816 2816
 							"event_espresso"
2817 2817
 						),
2818 2818
 						$key,
2819
-						var_export( $value, true ),
2820
-						var_export( $query_params, true ),
2821
-						get_class( $this )
2819
+						var_export($value, true),
2820
+						var_export($query_params, true),
2821
+						get_class($this)
2822 2822
 					)
2823 2823
 				);
2824 2824
 			}
2825 2825
 		}
2826 2826
 		if (
2827
-			array_key_exists( 'default_where_conditions', $query_params )
2828
-			&& ! empty( $query_params['default_where_conditions'] )
2827
+			array_key_exists('default_where_conditions', $query_params)
2828
+			&& ! empty($query_params['default_where_conditions'])
2829 2829
 		) {
2830 2830
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2831 2831
 		} else {
@@ -2839,13 +2839,13 @@  discard block
 block discarded – undo
2839 2839
 			),
2840 2840
 			$where_query_params
2841 2841
 		);
2842
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2842
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2843 2843
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2844 2844
 		// So we need to setup a subquery and use that for the main join.
2845 2845
 		// Note for now this only works on the primary table for the model.
2846 2846
 		// So for instance, you could set the limit array like this:
2847 2847
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2848
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2848
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2849 2849
 			$query_object->set_main_model_join_sql(
2850 2850
 				$this->_construct_limit_join_select(
2851 2851
 					$query_params['on_join_limit'][0],
@@ -2854,40 +2854,40 @@  discard block
 block discarded – undo
2854 2854
 			);
2855 2855
 		}
2856 2856
 		//set limit
2857
-		if ( array_key_exists( 'limit', $query_params ) ) {
2858
-			if ( is_array( $query_params['limit'] ) ) {
2859
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2857
+		if (array_key_exists('limit', $query_params)) {
2858
+			if (is_array($query_params['limit'])) {
2859
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2860 2860
 					$e = sprintf(
2861 2861
 						__(
2862 2862
 							"Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)",
2863 2863
 							"event_espresso"
2864 2864
 						),
2865
-						http_build_query( $query_params['limit'] )
2865
+						http_build_query($query_params['limit'])
2866 2866
 					);
2867
-					throw new EE_Error( $e . "|" . $e );
2867
+					throw new EE_Error($e."|".$e);
2868 2868
 				}
2869 2869
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2870
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2871
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2872
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2870
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2871
+			} elseif ( ! empty ($query_params['limit'])) {
2872
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2873 2873
 			}
2874 2874
 		}
2875 2875
 		//set order by
2876
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2877
-			if ( is_array( $query_params['order_by'] ) ) {
2876
+		if (array_key_exists('order_by', $query_params)) {
2877
+			if (is_array($query_params['order_by'])) {
2878 2878
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2879 2879
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2880 2880
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2881
-				if ( array_key_exists( 'order', $query_params ) ) {
2881
+				if (array_key_exists('order', $query_params)) {
2882 2882
 					throw new EE_Error(
2883 2883
 						sprintf(
2884 2884
 							__(
2885 2885
 								"In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ",
2886 2886
 								"event_espresso"
2887 2887
 							),
2888
-							get_class( $this ),
2889
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2890
-							implode( ", ", $query_params['order_by'] ),
2888
+							get_class($this),
2889
+							implode(", ", array_keys($query_params['order_by'])),
2890
+							implode(", ", $query_params['order_by']),
2891 2891
 							$query_params['order']
2892 2892
 						)
2893 2893
 					);
@@ -2899,57 +2899,57 @@  discard block
 block discarded – undo
2899 2899
 				);
2900 2900
 				//assume it's an array of fields to order by
2901 2901
 				$order_array = array();
2902
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2903
-					$order = $this->_extract_order( $order );
2904
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2902
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2903
+					$order = $this->_extract_order($order);
2904
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2905 2905
 				}
2906
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2907
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2906
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2907
+			} elseif ( ! empty ($query_params['order_by'])) {
2908 2908
 				$this->_extract_related_model_info_from_query_param(
2909 2909
 					$query_params['order_by'],
2910 2910
 					$query_object,
2911 2911
 					'order',
2912 2912
 					$query_params['order_by']
2913 2913
 				);
2914
-				$order = isset( $query_params['order'] )
2915
-					? $this->_extract_order( $query_params['order'] )
2914
+				$order = isset($query_params['order'])
2915
+					? $this->_extract_order($query_params['order'])
2916 2916
 					: 'DESC';
2917 2917
 				$query_object->set_order_by_sql(
2918
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2918
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2919 2919
 				);
2920 2920
 			}
2921 2921
 		}
2922 2922
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2923
-		if ( ! array_key_exists( 'order_by', $query_params )
2924
-		     && array_key_exists( 'order', $query_params )
2925
-		     && ! empty( $query_params['order'] )
2923
+		if ( ! array_key_exists('order_by', $query_params)
2924
+		     && array_key_exists('order', $query_params)
2925
+		     && ! empty($query_params['order'])
2926 2926
 		) {
2927 2927
 			$pk_field = $this->get_primary_key_field();
2928
-			$order = $this->_extract_order( $query_params['order'] );
2929
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2928
+			$order = $this->_extract_order($query_params['order']);
2929
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2930 2930
 		}
2931 2931
 		//set group by
2932
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2933
-			if ( is_array( $query_params['group_by'] ) ) {
2932
+		if (array_key_exists('group_by', $query_params)) {
2933
+			if (is_array($query_params['group_by'])) {
2934 2934
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2935 2935
 				$group_by_array = array();
2936
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2937
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2936
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2937
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2938 2938
 				}
2939
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2940
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2939
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2940
+			} elseif ( ! empty ($query_params['group_by'])) {
2941 2941
 				$query_object->set_group_by_sql(
2942
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2942
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2943 2943
 				);
2944 2944
 			}
2945 2945
 		}
2946 2946
 		//set having
2947
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2948
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2947
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2948
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2949 2949
 		}
2950 2950
 		//now, just verify they didn't pass anything wack
2951
-		foreach ( $query_params as $query_key => $query_value ) {
2952
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2951
+		foreach ($query_params as $query_key => $query_value) {
2952
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2953 2953
 				throw new EE_Error(
2954 2954
 					sprintf(
2955 2955
 						__(
@@ -2957,16 +2957,16 @@  discard block
 block discarded – undo
2957 2957
 							'event_espresso'
2958 2958
 						),
2959 2959
 						$query_key,
2960
-						get_class( $this ),
2960
+						get_class($this),
2961 2961
 //						print_r( $this->_allowed_query_params, TRUE )
2962
-						implode( ',', $this->_allowed_query_params )
2962
+						implode(',', $this->_allowed_query_params)
2963 2963
 					)
2964 2964
 				);
2965 2965
 			}
2966 2966
 		}
2967 2967
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2968
-		if ( empty( $main_model_join_sql ) ) {
2969
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2968
+		if (empty($main_model_join_sql)) {
2969
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2970 2970
 		}
2971 2971
 		return $query_object;
2972 2972
 	}
@@ -2981,17 +2981,17 @@  discard block
 block discarded – undo
2981 2981
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2982 2982
 	 * @throws \EE_Error
2983 2983
 	 */
2984
-	public function caps_where_conditions( $context = self::caps_read ) {
2985
-		EEM_Base::verify_is_valid_cap_context( $context );
2984
+	public function caps_where_conditions($context = self::caps_read) {
2985
+		EEM_Base::verify_is_valid_cap_context($context);
2986 2986
 		$cap_where_conditions = array();
2987
-		$cap_restrictions = $this->caps_missing( $context );
2987
+		$cap_restrictions = $this->caps_missing($context);
2988 2988
 		/**
2989 2989
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2990 2990
 		 */
2991
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2992
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2991
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2992
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2993 2993
 		}
2994
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2994
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2995 2995
 	}
2996 2996
 
2997 2997
 	/**
@@ -3001,11 +3001,11 @@  discard block
 block discarded – undo
3001 3001
 	 * @return string either ASC, asc, DESC or desc
3002 3002
 	 * @throws EE_Error
3003 3003
 	 */
3004
-	private function _extract_order($should_be_order_string){
3005
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
3004
+	private function _extract_order($should_be_order_string) {
3005
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
3006 3006
 			return $should_be_order_string;
3007
-		}else{
3008
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
3007
+		} else {
3008
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
3009 3009
 		}
3010 3010
 	}
3011 3011
 
@@ -3023,7 +3023,7 @@  discard block
 block discarded – undo
3023 3023
 	 * @throws EE_Error
3024 3024
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
3025 3025
 	 */
3026
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
3026
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
3027 3027
 		$allowed_used_default_where_conditions_values = array(
3028 3028
 				'all',
3029 3029
 				'this_model_only',
@@ -3031,17 +3031,17 @@  discard block
 block discarded – undo
3031 3031
 				'minimum',
3032 3032
 				'none'
3033 3033
 			);
3034
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
3035
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
3034
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
3035
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
3036 3036
 		}
3037 3037
 		$universal_query_params = array();
3038
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
3038
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
3039 3039
 			$universal_query_params = $this->_get_default_where_conditions();
3040
-		} else if( $use_default_where_conditions === 'minimum' ) {
3040
+		} else if ($use_default_where_conditions === 'minimum') {
3041 3041
 			$universal_query_params = $this->_get_minimum_where_conditions();
3042 3042
 		}
3043
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
3044
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
3043
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
3044
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
3045 3045
 				$related_model = $this->get_related_model_obj($model_name);
3046 3046
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
3047 3047
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3074,20 +3074,20 @@  discard block
 block discarded – undo
3074 3074
 	 * @return array like EEM_Base::get_all's $query_params[0]
3075 3075
 	 * @throws \EE_Error
3076 3076
 	 */
3077
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3077
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3078 3078
 		$null_friendly_where_conditions = array();
3079 3079
 		$none_overridden = true;
3080 3080
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3081 3081
 
3082
-		foreach($default_where_conditions as $key => $val){
3083
-			if( isset($provided_where_conditions[$key])){
3082
+		foreach ($default_where_conditions as $key => $val) {
3083
+			if (isset($provided_where_conditions[$key])) {
3084 3084
 				$none_overridden = false;
3085
-			}else{
3085
+			} else {
3086 3086
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3087 3087
 			}
3088 3088
 		}
3089
-		if( $none_overridden && $default_where_conditions){
3090
-			if($model->has_primary_key_field()){
3089
+		if ($none_overridden && $default_where_conditions) {
3090
+			if ($model->has_primary_key_field()) {
3091 3091
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3092 3092
 			}/*else{
3093 3093
 				//@todo NO PK, use other defaults
@@ -3104,8 +3104,8 @@  discard block
 block discarded – undo
3104 3104
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3105 3105
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3106 3106
 	 */
3107
-	private function _get_default_where_conditions($model_relation_path = null){
3108
-		if ( $this->_ignore_where_strategy ){
3107
+	private function _get_default_where_conditions($model_relation_path = null) {
3108
+		if ($this->_ignore_where_strategy) {
3109 3109
 			return array();
3110 3110
 		}
3111 3111
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3119,8 +3119,8 @@  discard block
 block discarded – undo
3119 3119
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3120 3120
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3121 3121
 	 */
3122
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3123
-		if ( $this->_ignore_where_strategy ){
3122
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3123
+		if ($this->_ignore_where_strategy) {
3124 3124
 			return array();
3125 3125
 		}
3126 3126
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3136,16 +3136,16 @@  discard block
 block discarded – undo
3136 3136
 	 * @return string
3137 3137
 	 * @throws \EE_Error
3138 3138
 	 */
3139
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3139
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3140 3140
 		$selects = $this->_get_columns_to_select_for_this_model();
3141
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3141
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3142 3142
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3143
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3144
-			foreach ( $other_model_selects as $key => $value ) {
3143
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3144
+			foreach ($other_model_selects as $key => $value) {
3145 3145
 				$selects[] = $value;
3146 3146
 			}
3147 3147
 		}
3148
-		return implode(", ",$selects);
3148
+		return implode(", ", $selects);
3149 3149
 	}
3150 3150
 
3151 3151
 	/**
@@ -3154,19 +3154,19 @@  discard block
 block discarded – undo
3154 3154
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3155 3155
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3156 3156
 	 */
3157
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3157
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3158 3158
 		$fields = $this->field_settings();
3159 3159
 		$selects = array();
3160 3160
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
3161
-		foreach($fields as $field_obj){
3162
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3161
+		foreach ($fields as $field_obj) {
3162
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
3163 3163
 		}
3164 3164
 		//make sure we are also getting the PKs of each table
3165 3165
 		$tables = $this->get_tables();
3166
-		if(count($tables) > 1){
3167
-			foreach($tables as $table_obj){
3168
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3169
-				if( ! in_array($qualified_pk_column,$selects)){
3166
+		if (count($tables) > 1) {
3167
+			foreach ($tables as $table_obj) {
3168
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3169
+				if ( ! in_array($qualified_pk_column, $selects)) {
3170 3170
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3171 3171
 				}
3172 3172
 			}
@@ -3196,65 +3196,65 @@  discard block
 block discarded – undo
3196 3196
 		$query_param_type,
3197 3197
 		$original_query_param = null
3198 3198
 	) {
3199
-		if( $original_query_param === null ){
3199
+		if ($original_query_param === null) {
3200 3200
 			$original_query_param = $query_param;
3201 3201
 		}
3202 3202
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3203 3203
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3204
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3205
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3204
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3205
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3206 3206
 		//check to see if we have a field on this model
3207 3207
 		$this_model_fields = $this->field_settings(true);
3208
-		if(array_key_exists($query_param,$this_model_fields)){
3209
-			if($allow_fields){
3208
+		if (array_key_exists($query_param, $this_model_fields)) {
3209
+			if ($allow_fields) {
3210 3210
 				return;
3211
-			}else{
3211
+			} else {
3212 3212
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3213
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3213
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3214 3214
 			}
3215 3215
 		}
3216 3216
 		//check if this is a special logic query param
3217
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3218
-			if($allow_logic_query_params){
3217
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3218
+			if ($allow_logic_query_params) {
3219 3219
 				return;
3220
-			}else{
3220
+			} else {
3221 3221
 				throw new EE_Error(
3222 3222
 					sprintf(
3223
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
3224
-						implode( '", "', $this->_logic_query_param_keys ),
3225
-						$query_param ,
3226
-						get_class( $this ),
3223
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
3224
+						implode('", "', $this->_logic_query_param_keys),
3225
+						$query_param,
3226
+						get_class($this),
3227 3227
 						'<br />',
3228
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
3228
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
3229 3229
 					)
3230 3230
 				);
3231 3231
 			}
3232 3232
 		}
3233 3233
 
3234 3234
 		//check if it's a custom selection
3235
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3235
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3236 3236
 			return;
3237 3237
 		}
3238 3238
 
3239 3239
 		//check if has a model name at the beginning
3240 3240
 		//and
3241 3241
 		//check if it's a field on a related model
3242
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3243
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3244
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3242
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3243
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3244
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3245 3245
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3246
-				if($query_param === ''){
3246
+				if ($query_param === '') {
3247 3247
 					//nothing left to $query_param
3248 3248
 					//we should actually end in a field name, not a model like this!
3249 3249
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3250
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3251
-				}else{
3250
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3251
+				} else {
3252 3252
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3253 3253
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3254 3254
 					return;
3255 3255
 				}
3256
-			}elseif($query_param === $valid_related_model_name){
3257
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3256
+			}elseif ($query_param === $valid_related_model_name) {
3257
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3258 3258
 				return;
3259 3259
 			}
3260 3260
 		}
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3265 3265
 		//it's wack, that's what it is
3266 3266
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3267
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3267
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3268 3268
 
3269 3269
 	}
3270 3270
 
@@ -3283,26 +3283,26 @@  discard block
 block discarded – undo
3283 3283
 	 * @return void
3284 3284
 	 * @throws \EE_Error
3285 3285
 	 */
3286
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3286
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3287 3287
 		$relation_obj = $this->related_settings_for($model_name);
3288 3288
 
3289 3289
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3290 3290
 		//check if the relation is HABTM, because then we're essentially doing two joins
3291 3291
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3292
-		if($relation_obj instanceof EE_HABTM_Relation){
3292
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3293 3293
 			$join_model_obj = $relation_obj->get_join_model();
3294 3294
 			//replace the model specified with the join model for this relation chain, whi
3295 3295
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3296 3296
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3297 3297
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3298 3298
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3299
-			$passed_in_query_info->merge( $new_query_info  );
3299
+			$passed_in_query_info->merge($new_query_info);
3300 3300
 		}
3301 3301
 		//now just join to the other table pointed to by the relation object, and add its data types
3302 3302
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3303 3303
 				array($model_relation_chain=>$model_name),
3304 3304
 				$relation_obj->get_join_statement($model_relation_chain));
3305
-		$passed_in_query_info->merge( $new_query_info  );
3305
+		$passed_in_query_info->merge($new_query_info);
3306 3306
 	}
3307 3307
 
3308 3308
 
@@ -3314,11 +3314,11 @@  discard block
 block discarded – undo
3314 3314
 	 * @return string of SQL
3315 3315
 	 * @throws \EE_Error
3316 3316
 	 */
3317
-	private function _construct_where_clause($where_params){
3317
+	private function _construct_where_clause($where_params) {
3318 3318
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3319
-		if($SQL){
3320
-			return " WHERE ". $SQL;
3321
-		}else{
3319
+		if ($SQL) {
3320
+			return " WHERE ".$SQL;
3321
+		} else {
3322 3322
 			return '';
3323 3323
 		}
3324 3324
 	}
@@ -3333,11 +3333,11 @@  discard block
 block discarded – undo
3333 3333
 	 * @return string
3334 3334
 	 * @throws \EE_Error
3335 3335
 	 */
3336
-	private function _construct_having_clause($having_params){
3336
+	private function _construct_having_clause($having_params) {
3337 3337
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3338
-		if($SQL){
3339
-			return " HAVING ". $SQL;
3340
-		}else{
3338
+		if ($SQL) {
3339
+			return " HAVING ".$SQL;
3340
+		} else {
3341 3341
 			return '';
3342 3342
 		}
3343 3343
 
@@ -3351,16 +3351,16 @@  discard block
 block discarded – undo
3351 3351
 	 * @return EE_Model_Field_Base
3352 3352
 	 * @throws EE_Error
3353 3353
 	 */
3354
-	protected function _get_field_on_model($field_name,$model_name){
3354
+	protected function _get_field_on_model($field_name, $model_name) {
3355 3355
 		$model_class = 'EEM_'.$model_name;
3356 3356
 		$model_filepath = $model_class.".model.php";
3357
-		if ( is_readable($model_filepath)){
3357
+		if (is_readable($model_filepath)) {
3358 3358
 			require_once($model_filepath);
3359
-			$model_instance=call_user_func($model_name."::instance");
3359
+			$model_instance = call_user_func($model_name."::instance");
3360 3360
 			/* @var $model_instance EEM_Base */
3361 3361
 			return $model_instance->field_settings_for($field_name);
3362
-		}else{
3363
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3362
+		} else {
3363
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3364 3364
 		}
3365 3365
 	}
3366 3366
 
@@ -3373,41 +3373,41 @@  discard block
 block discarded – undo
3373 3373
 	 * @throws EE_Error
3374 3374
 	 * @return string of SQL
3375 3375
 	 */
3376
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3377
-		$where_clauses=array();
3378
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3379
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3380
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3381
-				switch($query_param){
3376
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3377
+		$where_clauses = array();
3378
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3379
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3380
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3381
+				switch ($query_param) {
3382 3382
 					case 'not':
3383 3383
 					case 'NOT':
3384
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3384
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3385 3385
 						break;
3386 3386
 					case 'and':
3387 3387
 					case 'AND':
3388
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3388
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3389 3389
 						break;
3390 3390
 					case 'or':
3391 3391
 					case 'OR':
3392
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3392
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3393 3393
 						break;
3394 3394
 				}
3395
-			}else{
3395
+			} else {
3396 3396
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3397 3397
 
3398 3398
 				//if it's not a normal field, maybe it's a custom selection?
3399
-				if( ! $field_obj){
3400
-					if(isset( $this->_custom_selections[$query_param][1])){
3399
+				if ( ! $field_obj) {
3400
+					if (isset($this->_custom_selections[$query_param][1])) {
3401 3401
 						$field_obj = $this->_custom_selections[$query_param][1];
3402
-					}else{
3403
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3402
+					} else {
3403
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3404 3404
 					}
3405 3405
 				}
3406 3406
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3407
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3407
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3408 3408
 			}
3409 3409
 		}
3410
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3410
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3411 3411
 	}
3412 3412
 
3413 3413
 
@@ -3418,18 +3418,18 @@  discard block
 block discarded – undo
3418 3418
 	 * @throws EE_Error
3419 3419
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3420 3420
 	 */
3421
-	private function _deduce_column_name_from_query_param($query_param){
3421
+	private function _deduce_column_name_from_query_param($query_param) {
3422 3422
 		$field = $this->_deduce_field_from_query_param($query_param);
3423 3423
 
3424
-		if( $field ){
3425
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3426
-			return $table_alias_prefix . $field->get_qualified_column();
3427
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3424
+		if ($field) {
3425
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3426
+			return $table_alias_prefix.$field->get_qualified_column();
3427
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3428 3428
 			//maybe it's custom selection item?
3429 3429
 			//if so, just use it as the "column name"
3430 3430
 			return $query_param;
3431
-		}else{
3432
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3431
+		} else {
3432
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3433 3433
 		}
3434 3434
 	}
3435 3435
 
@@ -3441,11 +3441,11 @@  discard block
 block discarded – undo
3441 3441
 	 * @param string $condition_query_param_key
3442 3442
 	 * @return string
3443 3443
 	 */
3444
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3444
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3445 3445
 		$pos_of_star = strpos($condition_query_param_key, '*');
3446
-		if($pos_of_star === FALSE){
3446
+		if ($pos_of_star === FALSE) {
3447 3447
 			return $condition_query_param_key;
3448
-		}else{
3448
+		} else {
3449 3449
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3450 3450
 			return $condition_query_param_sans_star;
3451 3451
 		}
@@ -3460,12 +3460,12 @@  discard block
 block discarded – undo
3460 3460
 	 * @throws EE_Error
3461 3461
 	 * @return string
3462 3462
 	 */
3463
-	private function _construct_op_and_value($op_and_value, $field_obj){
3464
-		if ( is_array( $op_and_value ) ) {
3465
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3466
-			if ( ! $operator ) {
3463
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3464
+		if (is_array($op_and_value)) {
3465
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3466
+			if ( ! $operator) {
3467 3467
 				$php_array_like_string = array();
3468
-				foreach ( $op_and_value as $key => $value ) {
3468
+				foreach ($op_and_value as $key => $value) {
3469 3469
 					$php_array_like_string[] = "$key=>$value";
3470 3470
 				}
3471 3471
 				throw new EE_Error(
@@ -3474,27 +3474,27 @@  discard block
 block discarded – undo
3474 3474
 							"You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))",
3475 3475
 							"event_espresso"
3476 3476
 						),
3477
-						implode( ",", $php_array_like_string )
3477
+						implode(",", $php_array_like_string)
3478 3478
 					)
3479 3479
 				);
3480 3480
 			}
3481
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3481
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3482 3482
 		} else {
3483 3483
 			$operator = '=';
3484 3484
 			$value = $op_and_value;
3485 3485
 		}
3486 3486
 		//check to see if the value is actually another field
3487
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3488
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3489
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3487
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3488
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3489
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3490 3490
 			//in this case, the value should be an array, or at least a comma-separated list
3491 3491
 			//it will need to handle a little differently
3492
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3492
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3493 3493
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3494
-			return $operator . SP . $cleaned_value;
3495
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3494
+			return $operator.SP.$cleaned_value;
3495
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3496 3496
 			//the value should be an array with count of two.
3497
-			if ( count( $value ) !== 2 ) {
3497
+			if (count($value) !== 2) {
3498 3498
 				throw new EE_Error(
3499 3499
 					sprintf(
3500 3500
 						__(
@@ -3505,10 +3505,10 @@  discard block
 block discarded – undo
3505 3505
 					)
3506 3506
 				);
3507 3507
 			}
3508
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3509
-			return $operator . SP . $cleaned_value;
3510
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3511
-			if ( $value !== null ) {
3508
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3509
+			return $operator.SP.$cleaned_value;
3510
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3511
+			if ($value !== null) {
3512 3512
 				throw new EE_Error(
3513 3513
 					sprintf(
3514 3514
 						__(
@@ -3521,13 +3521,13 @@  discard block
 block discarded – undo
3521 3521
 				);
3522 3522
 			}
3523 3523
 			return $operator;
3524
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3524
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3525 3525
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3526 3526
 			//remove other junk. So just treat it as a string.
3527
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3528
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3529
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3530
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3527
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3528
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3529
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3530
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3531 3531
 			throw new EE_Error(
3532 3532
 				sprintf(
3533 3533
 					__(
@@ -3538,7 +3538,7 @@  discard block
 block discarded – undo
3538 3538
 					$operator
3539 3539
 				)
3540 3540
 			);
3541
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3541
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3542 3542
 			throw new EE_Error(
3543 3543
 				sprintf(
3544 3544
 					__(
@@ -3556,7 +3556,7 @@  discard block
 block discarded – undo
3556 3556
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3557 3557
 						"event_espresso"
3558 3558
 					),
3559
-					http_build_query( $op_and_value )
3559
+					http_build_query($op_and_value)
3560 3560
 				)
3561 3561
 			);
3562 3562
 		}
@@ -3572,12 +3572,12 @@  discard block
 block discarded – undo
3572 3572
 	 * @return string
3573 3573
 	 * @throws \EE_Error
3574 3574
 	 */
3575
-	public function _construct_between_value( $values, $field_obj ) {
3575
+	public function _construct_between_value($values, $field_obj) {
3576 3576
 		$cleaned_values = array();
3577
-		foreach ( $values as $value ) {
3578
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3577
+		foreach ($values as $value) {
3578
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3579 3579
 		}
3580
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3580
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3581 3581
 	}
3582 3582
 
3583 3583
 
@@ -3594,26 +3594,26 @@  discard block
 block discarded – undo
3594 3594
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3595 3595
 	 * @throws \EE_Error
3596 3596
 	 */
3597
-	public function _construct_in_value($values,  $field_obj){
3597
+	public function _construct_in_value($values, $field_obj) {
3598 3598
 		//check if the value is a CSV list
3599
-		if(is_string($values)){
3599
+		if (is_string($values)) {
3600 3600
 			//in which case, turn it into an array
3601
-			$values = explode(",",$values);
3601
+			$values = explode(",", $values);
3602 3602
 		}
3603 3603
 		$cleaned_values = array();
3604
-		foreach($values as $value){
3605
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3604
+		foreach ($values as $value) {
3605
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3606 3606
 		}
3607 3607
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3608 3608
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3609 3609
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3610
-		if(empty($cleaned_values)){
3610
+		if (empty($cleaned_values)) {
3611 3611
 			$all_fields = $this->field_settings();
3612 3612
 			$a_field = array_shift($all_fields);
3613 3613
 			$main_table = $this->_get_main_table();
3614 3614
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3615 3615
 		}
3616
-		return "(".implode(",",$cleaned_values).")";
3616
+		return "(".implode(",", $cleaned_values).")";
3617 3617
 	}
3618 3618
 
3619 3619
 
@@ -3625,16 +3625,16 @@  discard block
 block discarded – undo
3625 3625
 	 * @throws EE_Error
3626 3626
 	 * @return false|null|string
3627 3627
 	 */
3628
-	private function _wpdb_prepare_using_field($value,$field_obj){
3628
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3629 3629
 		/** @type WPDB $wpdb */
3630 3630
 		global $wpdb;
3631
-		if($field_obj instanceof EE_Model_Field_Base){
3632
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3633
-		}else{//$field_obj should really just be a data type
3634
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3635
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3631
+		if ($field_obj instanceof EE_Model_Field_Base) {
3632
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3633
+		} else {//$field_obj should really just be a data type
3634
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3635
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3636 3636
 			}
3637
-			return $wpdb->prepare($field_obj,$value);
3637
+			return $wpdb->prepare($field_obj, $value);
3638 3638
 		}
3639 3639
 	}
3640 3640
 
@@ -3646,27 +3646,27 @@  discard block
 block discarded – undo
3646 3646
 	 * @throws EE_Error
3647 3647
 	 * @return EE_Model_Field_Base
3648 3648
 	 */
3649
-	protected function _deduce_field_from_query_param($query_param_name){
3649
+	protected function _deduce_field_from_query_param($query_param_name) {
3650 3650
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3651 3651
 		//which will help us find the database table and column
3652 3652
 
3653
-		$query_param_parts = explode(".",$query_param_name);
3654
-		if(empty($query_param_parts)){
3655
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3653
+		$query_param_parts = explode(".", $query_param_name);
3654
+		if (empty($query_param_parts)) {
3655
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3656 3656
 		}
3657 3657
 		$number_of_parts = count($query_param_parts);
3658
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3659
-		if($number_of_parts === 1){
3658
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3659
+		if ($number_of_parts === 1) {
3660 3660
 			$field_name = $last_query_param_part;
3661 3661
 			$model_obj = $this;
3662
-		}else{// $number_of_parts >= 2
3662
+		} else {// $number_of_parts >= 2
3663 3663
 			//the last part is the column name, and there are only 2parts. therefore...
3664 3664
 			$field_name = $last_query_param_part;
3665
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3665
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3666 3666
 		}
3667
-		try{
3667
+		try {
3668 3668
 			return $model_obj->field_settings_for($field_name);
3669
-		}catch(EE_Error $e){
3669
+		} catch (EE_Error $e) {
3670 3670
 			return null;
3671 3671
 		}
3672 3672
 	}
@@ -3680,13 +3680,13 @@  discard block
 block discarded – undo
3680 3680
 	 * @throws EE_Error
3681 3681
 	 * @return string
3682 3682
 	 */
3683
-	public function _get_qualified_column_for_field($field_name){
3683
+	public function _get_qualified_column_for_field($field_name) {
3684 3684
 		$all_fields = $this->field_settings();
3685 3685
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3686
-		if($field){
3686
+		if ($field) {
3687 3687
 			return $field->get_qualified_column();
3688
-		}else{
3689
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3688
+		} else {
3689
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3690 3690
 		}
3691 3691
 	}
3692 3692
 
@@ -3700,17 +3700,17 @@  discard block
 block discarded – undo
3700 3700
 	 * @param  mixed|string $limit The limit for this select
3701 3701
 	 * @return string                The final select join element for the query.
3702 3702
 	 */
3703
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3703
+	public function _construct_limit_join_select($table_alias, $limit) {
3704 3704
 		$SQL = '';
3705
-		foreach ( $this->_tables as $table_obj ) {
3706
-			if ( $table_obj instanceof EE_Primary_Table ) {
3705
+		foreach ($this->_tables as $table_obj) {
3706
+			if ($table_obj instanceof EE_Primary_Table) {
3707 3707
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3708
-					? $table_obj->get_select_join_limit( $limit )
3709
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3710
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3708
+					? $table_obj->get_select_join_limit($limit)
3709
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3710
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3711 3711
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3712
-					? $table_obj->get_select_join_limit_join( $limit )
3713
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3712
+					? $table_obj->get_select_join_limit_join($limit)
3713
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3714 3714
 			}
3715 3715
 		}
3716 3716
 		return $SQL;
@@ -3725,7 +3725,7 @@  discard block
 block discarded – undo
3725 3725
 	 * @return string SQL
3726 3726
 	 * @throws \EE_Error
3727 3727
 	 */
3728
-	public function _construct_internal_join(){
3728
+	public function _construct_internal_join() {
3729 3729
 		$SQL = $this->_get_main_table()->get_table_sql();
3730 3730
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3731 3731
 		return $SQL;
@@ -3746,17 +3746,17 @@  discard block
 block discarded – undo
3746 3746
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3747 3747
 	 * @return string
3748 3748
 	 */
3749
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3749
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3750 3750
 		$SQL = '';
3751 3751
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3752
-		foreach($this->_tables as $table_obj){
3753
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3754
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3752
+		foreach ($this->_tables as $table_obj) {
3753
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3754
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3755 3755
 					//so we're joining to this table, meaning the table is already in
3756 3756
 					//the FROM statement, BUT the primary table isn't. So we want
3757 3757
 					//to add the inverse join sql
3758 3758
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3759
-				}else{
3759
+				} else {
3760 3760
 					//just add a regular JOIN to this table from the primary table
3761 3761
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3762 3762
 				}
@@ -3770,9 +3770,9 @@  discard block
 block discarded – undo
3770 3770
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3771 3771
 	 * @return array
3772 3772
 	 */
3773
-	public function _get_data_types(){
3773
+	public function _get_data_types() {
3774 3774
 		$data_types = array();
3775
-		foreach( $this->field_settings() as $field_obj){
3775
+		foreach ($this->field_settings() as $field_obj) {
3776 3776
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3777 3777
 			/** @var $field_obj EE_Model_Field_Base */
3778 3778
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3788,10 +3788,10 @@  discard block
 block discarded – undo
3788 3788
 	 * @throws EE_Error
3789 3789
 	 * @return EEM_Base
3790 3790
 	 */
3791
-	public function get_related_model_obj($model_name){
3791
+	public function get_related_model_obj($model_name) {
3792 3792
 		$model_classname = "EEM_".$model_name;
3793
-		if(!class_exists($model_classname)){
3794
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3793
+		if ( ! class_exists($model_classname)) {
3794
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3795 3795
 		}
3796 3796
 		return call_user_func($model_classname."::instance");
3797 3797
 	}
@@ -3801,7 +3801,7 @@  discard block
 block discarded – undo
3801 3801
 	 * Returns the array of EE_ModelRelations for this model.
3802 3802
 	 * @return EE_Model_Relation_Base[]
3803 3803
 	 */
3804
-	public function relation_settings(){
3804
+	public function relation_settings() {
3805 3805
 		return $this->_model_relations;
3806 3806
 	}
3807 3807
 
@@ -3811,10 +3811,10 @@  discard block
 block discarded – undo
3811 3811
 	 * (Eg, without an event, datetimes have little purpose.)
3812 3812
 	 * @return EE_Belongs_To_Relation[]
3813 3813
 	 */
3814
-	public function belongs_to_relations(){
3814
+	public function belongs_to_relations() {
3815 3815
 		$belongs_to_relations = array();
3816
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3817
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3816
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3817
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3818 3818
 				$belongs_to_relations[$model_name] = $relation_obj;
3819 3819
 			}
3820 3820
 		}
@@ -3829,15 +3829,15 @@  discard block
 block discarded – undo
3829 3829
 	 * @throws EE_Error
3830 3830
 	 * @return EE_Model_Relation_Base
3831 3831
 	 */
3832
-	public function related_settings_for($relation_name){
3833
-		$relatedModels=$this->relation_settings();
3834
-		if(!array_key_exists($relation_name,$relatedModels)){
3832
+	public function related_settings_for($relation_name) {
3833
+		$relatedModels = $this->relation_settings();
3834
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3835 3835
 			throw new EE_Error(
3836 3836
 				sprintf(
3837
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3837
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3838 3838
 					$relation_name,
3839 3839
 					$this->_get_class_name(),
3840
-					implode( ', ', array_keys( $relatedModels ))
3840
+					implode(', ', array_keys($relatedModels))
3841 3841
 				)
3842 3842
 			);
3843 3843
 		}
@@ -3852,10 +3852,10 @@  discard block
 block discarded – undo
3852 3852
 	 * @throws EE_Error
3853 3853
 	 * @return EE_Model_Field_Base
3854 3854
 	 */
3855
-	public function field_settings_for($fieldName){
3856
-		$fieldSettings=$this->field_settings(true);
3857
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3858
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3855
+	public function field_settings_for($fieldName) {
3856
+		$fieldSettings = $this->field_settings(true);
3857
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3858
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3859 3859
 		}
3860 3860
 		return $fieldSettings[$fieldName];
3861 3861
 	}
@@ -3865,11 +3865,11 @@  discard block
 block discarded – undo
3865 3865
 	 * @param string $fieldName a key in the model's _field_settings array
3866 3866
 	 * @return boolean
3867 3867
 	 */
3868
-	public function has_field($fieldName){
3868
+	public function has_field($fieldName) {
3869 3869
 		$fieldSettings = $this->field_settings(true);
3870
-		if( isset($fieldSettings[$fieldName])){
3870
+		if (isset($fieldSettings[$fieldName])) {
3871 3871
 			return true;
3872
-		}else{
3872
+		} else {
3873 3873
 			return false;
3874 3874
 		}
3875 3875
 	}
@@ -3879,11 +3879,11 @@  discard block
 block discarded – undo
3879 3879
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3880 3880
 	 * @return boolean
3881 3881
 	 */
3882
-	public function has_relation($relation_name){
3882
+	public function has_relation($relation_name) {
3883 3883
 		$relations = $this->relation_settings();
3884
-		if(isset($relations[$relation_name])){
3884
+		if (isset($relations[$relation_name])) {
3885 3885
 			return true;
3886
-		}else{
3886
+		} else {
3887 3887
 			return false;
3888 3888
 		}
3889 3889
 	}
@@ -3895,7 +3895,7 @@  discard block
 block discarded – undo
3895 3895
 	 * @param $field_obj
3896 3896
 	 * @return EE_Model_Field_Base
3897 3897
 	 */
3898
-	public function is_primary_key_field( $field_obj ){
3898
+	public function is_primary_key_field($field_obj) {
3899 3899
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3900 3900
 	}
3901 3901
 
@@ -3907,16 +3907,16 @@  discard block
 block discarded – undo
3907 3907
 	 * @return EE_Model_Field_Base
3908 3908
 	 * @throws EE_Error
3909 3909
 	 */
3910
-	public function get_primary_key_field(){
3911
-		if( $this->_primary_key_field === NULL ){
3912
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3913
-				if( $this->is_primary_key_field( $field_obj )){
3910
+	public function get_primary_key_field() {
3911
+		if ($this->_primary_key_field === NULL) {
3912
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3913
+				if ($this->is_primary_key_field($field_obj)) {
3914 3914
 					$this->_primary_key_field = $field_obj;
3915 3915
 					break;
3916 3916
 				}
3917 3917
 			}
3918
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3919
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3918
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3919
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3920 3920
 			}
3921 3921
 		}
3922 3922
 		return $this->_primary_key_field;
@@ -3929,12 +3929,12 @@  discard block
 block discarded – undo
3929 3929
 	 * Internally does some caching.
3930 3930
 	 * @return boolean
3931 3931
 	 */
3932
-	public function has_primary_key_field(){
3933
-		if($this->_has_primary_key_field === null){
3934
-			try{
3932
+	public function has_primary_key_field() {
3933
+		if ($this->_has_primary_key_field === null) {
3934
+			try {
3935 3935
 				$this->get_primary_key_field();
3936 3936
 				$this->_has_primary_key_field = true;
3937
-			}catch(EE_Error $e){
3937
+			} catch (EE_Error $e) {
3938 3938
 				$this->_has_primary_key_field = false;
3939 3939
 			}
3940 3940
 		}
@@ -3948,9 +3948,9 @@  discard block
 block discarded – undo
3948 3948
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3949 3949
 	 * @return EE_Model_Field_Base or null if none is found
3950 3950
 	 */
3951
-	public function get_a_field_of_type($field_class_name){
3952
-		foreach($this->field_settings() as $field){
3953
-			if( $field instanceof $field_class_name ){
3951
+	public function get_a_field_of_type($field_class_name) {
3952
+		foreach ($this->field_settings() as $field) {
3953
+			if ($field instanceof $field_class_name) {
3954 3954
 				return $field;
3955 3955
 			}
3956 3956
 		}
@@ -3964,22 +3964,22 @@  discard block
 block discarded – undo
3964 3964
 	 * @return EE_Foreign_Key_Field_Base
3965 3965
 	 * @throws EE_Error
3966 3966
 	 */
3967
-	public function get_foreign_key_to($model_name){
3968
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3969
-			foreach($this->field_settings() as $field){
3970
-				if(
3967
+	public function get_foreign_key_to($model_name) {
3968
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3969
+			foreach ($this->field_settings() as $field) {
3970
+				if (
3971 3971
 					$field instanceof EE_Foreign_Key_Field_Base
3972
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3972
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3973 3973
 				) {
3974
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3974
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3975 3975
 					break;
3976 3976
 				}
3977 3977
 			}
3978
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3979
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3978
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3979
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3980 3980
 			}
3981 3981
 		}
3982
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3982
+		return $this->_cache_foreign_key_to_fields[$model_name];
3983 3983
 	}
3984 3984
 
3985 3985
 
@@ -3990,7 +3990,7 @@  discard block
 block discarded – undo
3990 3990
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3991 3991
 	 * @return EE_Table_Base
3992 3992
 	 */
3993
-	public function get_table_for_alias($table_alias){
3993
+	public function get_table_for_alias($table_alias) {
3994 3994
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3995 3995
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3996 3996
 	}
@@ -4003,25 +4003,25 @@  discard block
 block discarded – undo
4003 4003
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
4004 4004
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
4005 4005
 	 */
4006
-	public function field_settings($include_db_only_fields = false){
4007
-		if( $include_db_only_fields ){
4008
-			if( $this->_cached_fields === NULL ){
4006
+	public function field_settings($include_db_only_fields = false) {
4007
+		if ($include_db_only_fields) {
4008
+			if ($this->_cached_fields === NULL) {
4009 4009
 				$this->_cached_fields = array();
4010
-				foreach($this->_fields as $fields_corresponding_to_table){
4011
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4012
-						$this->_cached_fields[$field_name]=$field_obj;
4010
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4011
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4012
+						$this->_cached_fields[$field_name] = $field_obj;
4013 4013
 					}
4014 4014
 				}
4015 4015
 			}
4016 4016
 			return $this->_cached_fields;
4017
-		}else{
4018
-			if( $this->_cached_fields_non_db_only === NULL ){
4017
+		} else {
4018
+			if ($this->_cached_fields_non_db_only === NULL) {
4019 4019
 				$this->_cached_fields_non_db_only = array();
4020
-				foreach($this->_fields as $fields_corresponding_to_table){
4021
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4020
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4021
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4022 4022
 						/** @var $field_obj EE_Model_Field_Base */
4023
-						if( ! $field_obj->is_db_only_field() ){
4024
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
4023
+						if ( ! $field_obj->is_db_only_field()) {
4024
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
4025 4025
 						}
4026 4026
 					}
4027 4027
 				}
@@ -4040,60 +4040,60 @@  discard block
 block discarded – undo
4040 4040
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
4041 4041
 	 * @throws \EE_Error
4042 4042
 	 */
4043
-	protected function _create_objects( $rows = array() ) {
4044
-		$array_of_objects=array();
4045
-		if(empty($rows)){
4043
+	protected function _create_objects($rows = array()) {
4044
+		$array_of_objects = array();
4045
+		if (empty($rows)) {
4046 4046
 			return array();
4047 4047
 		}
4048 4048
 		$count_if_model_has_no_primary_key = 0;
4049 4049
 		$has_primary_key = $this->has_primary_key_field();
4050 4050
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4051
-		foreach ( (array)$rows as $row ) {
4052
-			if(empty($row)){
4051
+		foreach ((array) $rows as $row) {
4052
+			if (empty($row)) {
4053 4053
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4054 4054
 				return array();
4055 4055
 			}
4056 4056
 			//check if we've already set this object in the results array,
4057 4057
 			//in which case there's no need to process it further (again)
4058
-			if( $has_primary_key ) {
4058
+			if ($has_primary_key) {
4059 4059
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4060 4060
 					$row,
4061 4061
 					$primary_key_field->get_qualified_column(),
4062 4062
 					$primary_key_field->get_table_column()
4063 4063
 				);
4064
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4064
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4065 4065
 					continue;
4066 4066
 				}
4067 4067
 			}
4068 4068
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4069
-			if( ! $classInstance ) {
4069
+			if ( ! $classInstance) {
4070 4070
 				throw new EE_Error(
4071 4071
 					sprintf(
4072
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4072
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4073 4073
 						$this->get_this_model_name(),
4074
-						http_build_query( $row )
4074
+						http_build_query($row)
4075 4075
 					)
4076 4076
 				);
4077 4077
 			}
4078 4078
 			//set the timezone on the instantiated objects
4079
-			$classInstance->set_timezone( $this->_timezone );
4079
+			$classInstance->set_timezone($this->_timezone);
4080 4080
 			//make sure if there is any timezone setting present that we set the timezone for the object
4081 4081
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4082
-			$array_of_objects[ $key ] = $classInstance;
4082
+			$array_of_objects[$key] = $classInstance;
4083 4083
 			//also, for all the relations of type BelongsTo, see if we can cache
4084 4084
 			//those related models
4085 4085
 			//(we could do this for other relations too, but if there are conditions
4086 4086
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4087 4087
 			//so it requires a little more thought than just caching them immediately...)
4088
-			foreach($this->_model_relations as $modelName => $relation_obj){
4089
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4088
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4089
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4090 4090
 					//check if this model's INFO is present. If so, cache it on the model
4091 4091
 					$other_model = $relation_obj->get_other_model();
4092 4092
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4093 4093
 					//if we managed to make a model object from the results, cache it on the main model object
4094
-					if( $other_model_obj_maybe ){
4094
+					if ($other_model_obj_maybe) {
4095 4095
 						//set timezone on these other model objects if they are present
4096
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4096
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4097 4097
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4098 4098
 					}
4099 4099
 				}
@@ -4114,12 +4114,12 @@  discard block
 block discarded – undo
4114 4114
 
4115 4115
 		$this_model_fields_and_values = array();
4116 4116
 		//setup the row using default values;
4117
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4117
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4118 4118
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4119 4119
 		}
4120 4120
 
4121 4121
 		$className = $this->_get_class_name();
4122
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4122
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4123 4123
 
4124 4124
 		return $classInstance;
4125 4125
 	}
@@ -4132,45 +4132,45 @@  discard block
 block discarded – undo
4132 4132
 	 * @return EE_Base_Class
4133 4133
 	 * @throws \EE_Error
4134 4134
 	 */
4135
-	public function instantiate_class_from_array_or_object($cols_n_values){
4136
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4137
-			$cols_n_values = get_object_vars( $cols_n_values );
4135
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4136
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4137
+			$cols_n_values = get_object_vars($cols_n_values);
4138 4138
 		}
4139 4139
 		$primary_key = NULL;
4140 4140
 		//make sure the array only has keys that are fields/columns on this model
4141
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4142
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4143
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4141
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4142
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4143
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4144 4144
 		}
4145
-		$className=$this->_get_class_name();
4145
+		$className = $this->_get_class_name();
4146 4146
 
4147 4147
 		//check we actually found results that we can use to build our model object
4148 4148
 		//if not, return null
4149
-		if( $this->has_primary_key_field()){
4150
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4149
+		if ($this->has_primary_key_field()) {
4150
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4151 4151
 				return NULL;
4152 4152
 			}
4153
-		}else if($this->unique_indexes()){
4153
+		} else if ($this->unique_indexes()) {
4154 4154
 			$first_column = reset($this_model_fields_n_values);
4155
-			if(empty($first_column)){
4155
+			if (empty($first_column)) {
4156 4156
 				return NULL;
4157 4157
 			}
4158 4158
 		}
4159 4159
 
4160 4160
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4161
-		if ( $primary_key){
4162
-			$classInstance = $this->get_from_entity_map( $primary_key );
4163
-			if( ! $classInstance) {
4164
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4161
+		if ($primary_key) {
4162
+			$classInstance = $this->get_from_entity_map($primary_key);
4163
+			if ( ! $classInstance) {
4164
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4165 4165
 				// add this new object to the entity map
4166
-				$classInstance = $this->add_to_entity_map( $classInstance );
4166
+				$classInstance = $this->add_to_entity_map($classInstance);
4167 4167
 			}
4168
-		}else{
4169
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4168
+		} else {
4169
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4170 4170
 		}
4171 4171
 
4172 4172
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
4173
-		$this->set_timezone( $classInstance->get_timezone() );
4173
+		$this->set_timezone($classInstance->get_timezone());
4174 4174
 		return $classInstance;
4175 4175
 	}
4176 4176
 	/**
@@ -4178,8 +4178,8 @@  discard block
 block discarded – undo
4178 4178
 	 * @param int|string $id the ID of the model object
4179 4179
 	 * @return EE_Base_Class
4180 4180
 	 */
4181
-	public function get_from_entity_map( $id ){
4182
-		return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL;
4181
+	public function get_from_entity_map($id) {
4182
+		return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL;
4183 4183
 	}
4184 4184
 
4185 4185
 
@@ -4201,21 +4201,21 @@  discard block
 block discarded – undo
4201 4201
 	 * @throws EE_Error
4202 4202
 	 * @return \EE_Base_Class
4203 4203
 	 */
4204
-	public function add_to_entity_map( EE_Base_Class $object) {
4204
+	public function add_to_entity_map(EE_Base_Class $object) {
4205 4205
 		$className = $this->_get_class_name();
4206
-		if( ! $object instanceof $className ){
4207
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
4206
+		if ( ! $object instanceof $className) {
4207
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
4208 4208
 		}
4209 4209
 		/** @var $object EE_Base_Class */
4210
-		if ( ! $object->ID() ){
4211
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4210
+		if ( ! $object->ID()) {
4211
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4212 4212
 		}
4213 4213
 		// double check it's not already there
4214
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4215
-		if ( $classInstance ) {
4214
+		$classInstance = $this->get_from_entity_map($object->ID());
4215
+		if ($classInstance) {
4216 4216
 			return $classInstance;
4217 4217
 		} else {
4218
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object;
4218
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object;
4219 4219
 			return $object;
4220 4220
 		}
4221 4221
 	}
@@ -4228,8 +4228,8 @@  discard block
 block discarded – undo
4228 4228
 	 * @param array $cols_n_values
4229 4229
 	 * @return array
4230 4230
 	 */
4231
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4232
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4231
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4232
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4233 4233
 	}
4234 4234
 
4235 4235
 
@@ -4242,23 +4242,23 @@  discard block
 block discarded – undo
4242 4242
 	 * @param string $cols_n_values
4243 4243
 	 * @return array
4244 4244
 	 */
4245
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4245
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4246 4246
 		$this_model_fields_n_values = array();
4247
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4248
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
4247
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4248
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
4249 4249
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4250
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4251
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4252
-					if( ! $field_obj->is_db_only_field() ){
4250
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4251
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4252
+					if ( ! $field_obj->is_db_only_field()) {
4253 4253
 						//prepare field as if its coming from db
4254
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4255
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4254
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4255
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4256 4256
 					}
4257 4257
 				}
4258
-			}else{
4258
+			} else {
4259 4259
 				//the table's rows existed. Use their values
4260
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4261
-					if( ! $field_obj->is_db_only_field() ){
4260
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4261
+					if ( ! $field_obj->is_db_only_field()) {
4262 4262
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4263 4263
 							$cols_n_values, $field_obj->get_qualified_column(),
4264 4264
 							$field_obj->get_table_column()
@@ -4278,15 +4278,15 @@  discard block
 block discarded – undo
4278 4278
 	 * @param $regular_column
4279 4279
 	 * @return null
4280 4280
 	 */
4281
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4281
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4282 4282
 		$value = null;
4283 4283
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4284 4284
 		//does the field on the model relate to this column retrieved from the db?
4285 4285
 		//or is it a db-only field? (not relating to the model)
4286
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4287
-			$value = $cols_n_values[ $qualified_column ];
4288
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4289
-			$value = $cols_n_values[ $regular_column ];
4286
+		if (isset($cols_n_values[$qualified_column])) {
4287
+			$value = $cols_n_values[$qualified_column];
4288
+		}elseif (isset($cols_n_values[$regular_column])) {
4289
+			$value = $cols_n_values[$regular_column];
4290 4290
 		}
4291 4291
 		return $value;
4292 4292
 	}
@@ -4302,25 +4302,25 @@  discard block
 block discarded – undo
4302 4302
 	 * @return EE_Base_Class
4303 4303
 	 * @throws \EE_Error
4304 4304
 	 */
4305
-	public function refresh_entity_map_from_db( $id ){
4306
-		$obj_in_map = $this->get_from_entity_map( $id );
4307
-		if( $obj_in_map ){
4305
+	public function refresh_entity_map_from_db($id) {
4306
+		$obj_in_map = $this->get_from_entity_map($id);
4307
+		if ($obj_in_map) {
4308 4308
 			$wpdb_results = $this->_get_all_wpdb_results(
4309
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4309
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4310 4310
 			);
4311
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4312
-				$one_row = reset( $wpdb_results );
4313
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4314
-					$obj_in_map->set_from_db( $field_name, $db_value );
4311
+			if ($wpdb_results && is_array($wpdb_results)) {
4312
+				$one_row = reset($wpdb_results);
4313
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4314
+					$obj_in_map->set_from_db($field_name, $db_value);
4315 4315
 				}
4316 4316
 				//clear the cache of related model objects
4317
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4318
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4317
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4318
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4319 4319
 				}
4320 4320
 			}
4321 4321
 			return $obj_in_map;
4322
-		}else{
4323
-			return $this->get_one_by_ID( $id );
4322
+		} else {
4323
+			return $this->get_one_by_ID($id);
4324 4324
 		}
4325 4325
 	}
4326 4326
 
@@ -4338,24 +4338,24 @@  discard block
 block discarded – undo
4338 4338
 	 * @return \EE_Base_Class
4339 4339
 	 * @throws \EE_Error
4340 4340
 	 */
4341
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4342
-		$obj_in_map = $this->get_from_entity_map( $id );
4343
-		if( $obj_in_map ){
4344
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4345
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4346
-					$obj_in_map->set( $field_name, $value );
4341
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4342
+		$obj_in_map = $this->get_from_entity_map($id);
4343
+		if ($obj_in_map) {
4344
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4345
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4346
+					$obj_in_map->set($field_name, $value);
4347 4347
 				}
4348 4348
 				//make the model object in the entity map's cache match the $replacing_model_obj
4349
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4350
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4351
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4352
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4349
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4350
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4351
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4352
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4353 4353
 					}
4354 4354
 				}
4355 4355
 			}
4356 4356
 			return $obj_in_map;
4357
-		}else{
4358
-			$this->add_to_entity_map( $replacing_model_obj );
4357
+		} else {
4358
+			$this->add_to_entity_map($replacing_model_obj);
4359 4359
 			return $replacing_model_obj;
4360 4360
 		}
4361 4361
 	}
@@ -4368,7 +4368,7 @@  discard block
 block discarded – undo
4368 4368
 	 * require_once($this->_getClassName().".class.php");
4369 4369
 	 * @return string
4370 4370
 	 */
4371
-	private function _get_class_name(){
4371
+	private function _get_class_name() {
4372 4372
 		return "EE_".$this->get_this_model_name();
4373 4373
 	}
4374 4374
 
@@ -4381,8 +4381,8 @@  discard block
 block discarded – undo
4381 4381
 	 * @param int $quantity
4382 4382
 	 * @return string
4383 4383
 	 */
4384
-	public function item_name($quantity = 1){
4385
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4384
+	public function item_name($quantity = 1) {
4385
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4386 4386
 	}
4387 4387
 
4388 4388
 
@@ -4409,13 +4409,13 @@  discard block
 block discarded – undo
4409 4409
 	 * @throws EE_Error
4410 4410
 	 * @return mixed whatever the plugin which calls add_filter decides
4411 4411
 	 */
4412
-	public function __call($methodName,$args){
4413
-		$className=get_class($this);
4414
-		$tagName="FHEE__{$className}__{$methodName}";
4415
-		if(!has_filter($tagName)){
4412
+	public function __call($methodName, $args) {
4413
+		$className = get_class($this);
4414
+		$tagName = "FHEE__{$className}__{$methodName}";
4415
+		if ( ! has_filter($tagName)) {
4416 4416
 			throw new EE_Error(
4417 4417
 				sprintf(
4418
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4418
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4419 4419
 					$methodName,
4420 4420
 					$className,
4421 4421
 					$tagName,
@@ -4424,7 +4424,7 @@  discard block
 block discarded – undo
4424 4424
 			);
4425 4425
 		}
4426 4426
 
4427
-		return apply_filters($tagName,null,$this,$args);
4427
+		return apply_filters($tagName, null, $this, $args);
4428 4428
 	}
4429 4429
 
4430 4430
 
@@ -4442,28 +4442,28 @@  discard block
 block discarded – undo
4442 4442
 	 * @throws EE_Error
4443 4443
 	 * @return EE_Base_Class
4444 4444
 	 */
4445
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4445
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4446 4446
 		$className = $this->_get_class_name();
4447
-		if ( $base_class_obj_or_id instanceof $className ) {
4447
+		if ($base_class_obj_or_id instanceof $className) {
4448 4448
 			$model_object = $base_class_obj_or_id;
4449 4449
 		} else {
4450 4450
 			$primary_key_field = $this->get_primary_key_field();
4451 4451
 			if (
4452 4452
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4453 4453
 				&& (
4454
-					is_int( $base_class_obj_or_id )
4455
-					|| is_string( $base_class_obj_or_id )
4454
+					is_int($base_class_obj_or_id)
4455
+					|| is_string($base_class_obj_or_id)
4456 4456
 				)
4457 4457
 			) {
4458 4458
 				// assume it's an ID.
4459 4459
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4460
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4460
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4461 4461
 			} else if (
4462 4462
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4463
-			    && is_string( $base_class_obj_or_id )
4463
+			    && is_string($base_class_obj_or_id)
4464 4464
 			) {
4465 4465
 				// assume its a string representation of the object
4466
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4466
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4467 4467
 			} else {
4468 4468
 				throw new EE_Error(
4469 4469
 					sprintf(
@@ -4473,12 +4473,12 @@  discard block
 block discarded – undo
4473 4473
 						),
4474 4474
 						$base_class_obj_or_id,
4475 4475
 						$this->_get_class_name(),
4476
-						print_r( $base_class_obj_or_id, true )
4476
+						print_r($base_class_obj_or_id, true)
4477 4477
 					)
4478 4478
 				);
4479 4479
 			}
4480 4480
 		}
4481
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4481
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4482 4482
 			$model_object->save();
4483 4483
 		}
4484 4484
 		return $model_object;
@@ -4494,19 +4494,19 @@  discard block
 block discarded – undo
4494 4494
 	 * @return int|string depending on the type of this model object's ID
4495 4495
 	 * @throws EE_Error
4496 4496
 	 */
4497
-	public function ensure_is_ID($base_class_obj_or_id){
4497
+	public function ensure_is_ID($base_class_obj_or_id) {
4498 4498
 		$className = $this->_get_class_name();
4499
-		if( $base_class_obj_or_id instanceof $className ){
4499
+		if ($base_class_obj_or_id instanceof $className) {
4500 4500
 			/** @var $base_class_obj_or_id EE_Base_Class */
4501 4501
 			$id = $base_class_obj_or_id->ID();
4502
-		}elseif(is_int($base_class_obj_or_id)){
4502
+		}elseif (is_int($base_class_obj_or_id)) {
4503 4503
 			//assume it's an ID
4504 4504
 			$id = $base_class_obj_or_id;
4505
-		}elseif(is_string($base_class_obj_or_id)){
4505
+		}elseif (is_string($base_class_obj_or_id)) {
4506 4506
 			//assume its a string representation of the object
4507 4507
 			$id = $base_class_obj_or_id;
4508
-		}else{
4509
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4508
+		} else {
4509
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4510 4510
 		}
4511 4511
 		return $id;
4512 4512
 	}
@@ -4529,14 +4529,14 @@  discard block
 block discarded – undo
4529 4529
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4530 4530
 	 * @return void
4531 4531
 	 */
4532
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4532
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4533 4533
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4534 4534
 	}
4535 4535
 	/**
4536 4536
 	 * Read comments for assume_values_already_prepared_by_model_object()
4537 4537
 	 * @return int
4538 4538
 	 */
4539
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4539
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4540 4540
 		return $this->_values_already_prepared_by_model_object;
4541 4541
 	}
4542 4542
 
@@ -4544,17 +4544,17 @@  discard block
 block discarded – undo
4544 4544
 	 * Gets all the indexes on this model
4545 4545
 	 * @return EE_Index[]
4546 4546
 	 */
4547
-	public function indexes(){
4547
+	public function indexes() {
4548 4548
 		return $this->_indexes;
4549 4549
 	}
4550 4550
 	/**
4551 4551
 	 * Gets all the Unique Indexes on this model
4552 4552
 	 * @return EE_Unique_Index[]
4553 4553
 	 */
4554
-	public function unique_indexes(){
4554
+	public function unique_indexes() {
4555 4555
 		$unique_indexes = array();
4556
-		foreach($this->_indexes as $name => $index){
4557
-			if($index instanceof EE_Unique_Index){
4556
+		foreach ($this->_indexes as $name => $index) {
4557
+			if ($index instanceof EE_Unique_Index) {
4558 4558
 				$unique_indexes [$name] = $index;
4559 4559
 			}
4560 4560
 		}
@@ -4572,13 +4572,13 @@  discard block
 block discarded – undo
4572 4572
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4573 4573
 	 * @throws \EE_Error
4574 4574
 	 */
4575
-	public function get_combined_primary_key_fields(){
4576
-		foreach($this->indexes() as $index){
4577
-			if($index instanceof EE_Primary_Key_Index){
4575
+	public function get_combined_primary_key_fields() {
4576
+		foreach ($this->indexes() as $index) {
4577
+			if ($index instanceof EE_Primary_Key_Index) {
4578 4578
 				return $index->fields();
4579 4579
 			}
4580 4580
 		}
4581
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4581
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4582 4582
 	}
4583 4583
 	
4584 4584
 
@@ -4592,7 +4592,7 @@  discard block
 block discarded – undo
4592 4592
 	 * @return string
4593 4593
 	 * @throws \EE_Error
4594 4594
 	 */
4595
-	public function get_index_primary_key_string($cols_n_values){
4595
+	public function get_index_primary_key_string($cols_n_values) {
4596 4596
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4597 4597
 		return http_build_query($cols_n_values_for_primary_key_index);
4598 4598
 	}
@@ -4607,13 +4607,13 @@  discard block
 block discarded – undo
4607 4607
 	 * @return null|array
4608 4608
 	 * @throws \EE_Error
4609 4609
 	 */
4610
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4610
+	public function parse_index_primary_key_string($index_primary_key_string) {
4611 4611
 		$key_fields = $this->get_combined_primary_key_fields();
4612 4612
 		//check all of them are in the $id
4613 4613
 		$key_vals_in_combined_pk = array();
4614
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4615
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4616
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4614
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4615
+		foreach ($key_fields as $key_field_name => $field_obj) {
4616
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4617 4617
 				return NULL;
4618 4618
 			}
4619 4619
 		}
@@ -4630,10 +4630,10 @@  discard block
 block discarded – undo
4630 4630
 	 * @return boolean
4631 4631
 	 * @throws \EE_Error
4632 4632
 	 */
4633
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4634
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4635
-		foreach( $keys_it_should_have as $key ){
4636
-			if( ! isset( $key_vals[ $key ] ) ){
4633
+	public function has_all_combined_primary_key_fields($key_vals) {
4634
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4635
+		foreach ($keys_it_should_have as $key) {
4636
+			if ( ! isset($key_vals[$key])) {
4637 4637
 				return false;
4638 4638
 			}
4639 4639
 		}
@@ -4649,23 +4649,23 @@  discard block
 block discarded – undo
4649 4649
 	 * @throws EE_Error
4650 4650
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4651 4651
 	 */
4652
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4652
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4653 4653
 
4654
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4654
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4655 4655
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4656
-		}elseif(is_array($model_object_or_attributes_array)){
4656
+		}elseif (is_array($model_object_or_attributes_array)) {
4657 4657
 			$attributes_array = $model_object_or_attributes_array;
4658
-		}else{
4659
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4658
+		} else {
4659
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4660 4660
 		}
4661 4661
 		//even copies obviously won't have the same ID, so remove the primary key
4662 4662
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4663
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4663
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4664 4664
 			unset($attributes_array[$this->primary_key_name()]);
4665 4665
 		}
4666
-		if(isset($query_params[0])){
4667
-			$query_params[0] = array_merge($attributes_array,$query_params);
4668
-		}else{
4666
+		if (isset($query_params[0])) {
4667
+			$query_params[0] = array_merge($attributes_array, $query_params);
4668
+		} else {
4669 4669
 			$query_params[0] = $attributes_array;
4670 4670
 		}
4671 4671
 		return $this->get_all($query_params);
@@ -4681,16 +4681,16 @@  discard block
 block discarded – undo
4681 4681
 	 * @return EE_Base_Class
4682 4682
 	 * @throws \EE_Error
4683 4683
 	 */
4684
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4685
-		if( ! is_array( $query_params ) ){
4686
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4684
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4685
+		if ( ! is_array($query_params)) {
4686
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4687 4687
 			$query_params = array();
4688 4688
 		}
4689 4689
 		$query_params['limit'] = 1;
4690
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4691
-		if(is_array($copies)){
4690
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4691
+		if (is_array($copies)) {
4692 4692
 			return array_shift($copies);
4693
-		}else{
4693
+		} else {
4694 4694
 			return null;
4695 4695
 		}
4696 4696
 	}
@@ -4706,10 +4706,10 @@  discard block
 block discarded – undo
4706 4706
 	 * @return int number of rows updated
4707 4707
 	 * @throws \EE_Error
4708 4708
 	 */
4709
-	public function update_by_ID($fields_n_values,$id){
4709
+	public function update_by_ID($fields_n_values, $id) {
4710 4710
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4711 4711
 			'default_where_conditions'=>'other_models_only',);
4712
-		return $this->update($fields_n_values,$query_params);
4712
+		return $this->update($fields_n_values, $query_params);
4713 4713
 	}
4714 4714
 
4715 4715
 
@@ -4720,12 +4720,12 @@  discard block
 block discarded – undo
4720 4720
 	 * @return string an operator which can be used in SQL
4721 4721
 	 * @throws EE_Error
4722 4722
 	 */
4723
-	private function _prepare_operator_for_sql($operator_supplied){
4723
+	private function _prepare_operator_for_sql($operator_supplied) {
4724 4724
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4725
-		if($sql_operator){
4725
+		if ($sql_operator) {
4726 4726
 			return $sql_operator;
4727
-		}else{
4728
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4727
+		} else {
4728
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4729 4729
 		}
4730 4730
 	}
4731 4731
 
@@ -4739,10 +4739,10 @@  discard block
 block discarded – undo
4739 4739
 	 * @return string[]
4740 4740
 	 * @throws \EE_Error
4741 4741
 	 */
4742
-	public function get_all_names($query_params = array()){
4742
+	public function get_all_names($query_params = array()) {
4743 4743
 		$objs = $this->get_all($query_params);
4744 4744
 		$names = array();
4745
-		foreach($objs as $obj){
4745
+		foreach ($objs as $obj) {
4746 4746
 			$names[$obj->ID()] = $obj->name();
4747 4747
 		}
4748 4748
 		return $names;
@@ -4761,11 +4761,11 @@  discard block
 block discarded – undo
4761 4761
 	 * @return array
4762 4762
 	 * @throws \EE_Error
4763 4763
 	 */
4764
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4765
-		if( ! $this->has_primary_key_field() ) {
4766
-			if( WP_DEBUG ) {
4764
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4765
+		if ( ! $this->has_primary_key_field()) {
4766
+			if (WP_DEBUG) {
4767 4767
 				EE_Error::add_error(
4768
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4768
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4769 4769
 					__FILE__,
4770 4770
 					__FUNCTION__,
4771 4771
 					__LINE__
@@ -4773,13 +4773,13 @@  discard block
 block discarded – undo
4773 4773
 			}
4774 4774
 		}
4775 4775
 		$IDs = array();
4776
-		foreach( $model_objects as $model_object ) {
4776
+		foreach ($model_objects as $model_object) {
4777 4777
 			$id = $model_object->ID();
4778
-			if( ! $id ) {
4779
-				if( $filter_out_empty_ids ) {
4778
+			if ( ! $id) {
4779
+				if ($filter_out_empty_ids) {
4780 4780
 					continue;
4781 4781
 				}
4782
-				if ( WP_DEBUG ) {
4782
+				if (WP_DEBUG) {
4783 4783
 					EE_Error::add_error(
4784 4784
 						__(
4785 4785
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4801,8 +4801,8 @@  discard block
 block discarded – undo
4801 4801
 	 * are no capabilities that relate to this model returns false
4802 4802
 	 * @return string|false
4803 4803
 	 */
4804
-	public function cap_slug(){
4805
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4804
+	public function cap_slug() {
4805
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4806 4806
 	}
4807 4807
 
4808 4808
 
@@ -4817,34 +4817,34 @@  discard block
 block discarded – undo
4817 4817
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4818 4818
 	 * @throws \EE_Error
4819 4819
 	 */
4820
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4821
-		EEM_Base::verify_is_valid_cap_context( $context );
4820
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4821
+		EEM_Base::verify_is_valid_cap_context($context);
4822 4822
 		//check if we ought to run the restriction generator first
4823
-		if(
4824
-			isset( $this->_cap_restriction_generators[ $context ] )
4825
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4826
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4823
+		if (
4824
+			isset($this->_cap_restriction_generators[$context])
4825
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4826
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4827 4827
 		) {
4828
-			$this->_cap_restrictions[ $context ] = array_merge(
4829
-				$this->_cap_restrictions[ $context ],
4830
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4828
+			$this->_cap_restrictions[$context] = array_merge(
4829
+				$this->_cap_restrictions[$context],
4830
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4831 4831
 			);
4832 4832
 		}
4833 4833
 		//and make sure we've finalized the construction of each restriction
4834
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4835
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4836
-				$where_conditions_obj->_finalize_construct( $this );
4834
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4835
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4836
+				$where_conditions_obj->_finalize_construct($this);
4837 4837
 			}
4838 4838
 		}
4839 4839
 
4840
-		return $this->_cap_restrictions[ $context ];
4840
+		return $this->_cap_restrictions[$context];
4841 4841
 	}
4842 4842
 
4843 4843
 	/**
4844 4844
 	 * Indicating whether or not this model thinks its a wp core model
4845 4845
 	 * @return boolean
4846 4846
 	 */
4847
-	public function is_wp_core_model(){
4847
+	public function is_wp_core_model() {
4848 4848
 		return $this->_wp_core_model;
4849 4849
 	}
4850 4850
 
@@ -4858,12 +4858,12 @@  discard block
 block discarded – undo
4858 4858
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4859 4859
 	 * @throws \EE_Error
4860 4860
 	 */
4861
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4861
+	public function caps_missing($context = EEM_Base::caps_read) {
4862 4862
 		$missing_caps = array();
4863
-		$cap_restrictions = $this->cap_restrictions( $context );
4864
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4865
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4866
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4863
+		$cap_restrictions = $this->cap_restrictions($context);
4864
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4865
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4866
+				$missing_caps[$cap] = $restriction_if_no_cap;
4867 4867
 			}
4868 4868
 		}
4869 4869
 		return $missing_caps;
@@ -4875,7 +4875,7 @@  discard block
 block discarded – undo
4875 4875
 	 * one of 'read', 'edit', or 'delete'
4876 4876
 	 */
4877 4877
 	public function cap_contexts_to_cap_action_map() {
4878
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4878
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4879 4879
 	}
4880 4880
 
4881 4881
 
@@ -4886,19 +4886,19 @@  discard block
 block discarded – undo
4886 4886
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4887 4887
 	 * @throws \EE_Error
4888 4888
 	 */
4889
-	public function cap_action_for_context( $context ) {
4889
+	public function cap_action_for_context($context) {
4890 4890
 		$mapping = $this->cap_contexts_to_cap_action_map();
4891
-		if( isset( $mapping[ $context ] ) ) {
4892
-			return $mapping[ $context ];
4891
+		if (isset($mapping[$context])) {
4892
+			return $mapping[$context];
4893 4893
 		}
4894
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4894
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4895 4895
 			return $action;
4896 4896
 		}
4897 4897
 		throw new EE_Error(
4898 4898
 			sprintf(
4899
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4899
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4900 4900
 				$context,
4901
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4901
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4902 4902
 			)
4903 4903
 		);
4904 4904
 
@@ -4909,7 +4909,7 @@  discard block
 block discarded – undo
4909 4909
 	 * @return array
4910 4910
 	 */
4911 4911
 	static public function valid_cap_contexts() {
4912
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4912
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4913 4913
 			self::caps_read,
4914 4914
 			self::caps_read_admin,
4915 4915
 			self::caps_edit,
@@ -4925,17 +4925,17 @@  discard block
 block discarded – undo
4925 4925
 	 * @return bool
4926 4926
 	 * @throws \EE_Error
4927 4927
 	 */
4928
-	static public function verify_is_valid_cap_context( $context ) {
4928
+	static public function verify_is_valid_cap_context($context) {
4929 4929
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4930
-		if( in_array( $context, $valid_cap_contexts ) ) {
4930
+		if (in_array($context, $valid_cap_contexts)) {
4931 4931
 			return true;
4932
-		}else{
4932
+		} else {
4933 4933
 			throw new EE_Error(
4934 4934
 				sprintf(
4935
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4935
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4936 4936
 					$context,
4937
-					'EEM_Base' ,
4938
-					implode(',', $valid_cap_contexts )
4937
+					'EEM_Base',
4938
+					implode(',', $valid_cap_contexts)
4939 4939
 				)
4940 4940
 			);
4941 4941
 		}
Please login to merge, or discard this patch.
core/entities/GenericAddress.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,6 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param \EE_State | string   $state
43 43
 	 * @param string              $zip
44 44
 	 * @param \EE_Country | string $country
45
+	 * @param integer $state
46
+	 * @param string $country
45 47
 	 * @return GenericAddress
46 48
 	 */
47 49
 	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
@@ -135,7 +137,7 @@  discard block
 block discarded – undo
135 137
 
136 138
 
137 139
 	/**
138
-	 * @return \EE_State
140
+	 * @return string
139 141
 	 */
140 142
 	public function state_obj() {
141 143
 		return $this->_state_obj;
@@ -188,7 +190,7 @@  discard block
 block discarded – undo
188 190
 
189 191
 
190 192
 	/**
191
-	 * @return \EE_Country
193
+	 * @return string
192 194
 	 */
193 195
 	public function country_obj() {
194 196
 		return $this->_country_obj;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\entities;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 	 * @param \EE_Country | string $country
45 45
 	 * @return GenericAddress
46 46
 	 */
47
-	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
47
+	public function __construct($address, $address2, $city, $state, $zip, $country) {
48 48
 		$this->_address = $address;
49 49
 		$this->_address2 = $address2;
50 50
 		$this->_city = $city;
51
-		if ( $state instanceof \EE_State ) {
51
+		if ($state instanceof \EE_State) {
52 52
 			$this->_state_obj = $state;
53 53
 		} else {
54 54
 			$this->_state_ID = $state;
55 55
 			$this->_state_obj = $this->_get_state_obj();
56 56
 		}
57 57
 		$this->_zip = $zip;
58
-		if ( $country instanceof \EE_Country ) {
58
+		if ($country instanceof \EE_Country) {
59 59
 			$this->_country_obj = $country;
60 60
 		} else {
61 61
 			$this->_country_ID = $country;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	private function _get_state_obj() {
99 99
 		return $this->_state_obj instanceof \EE_State
100 100
 			? $this->_state_obj
101
-			: \EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID );
101
+			: \EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
102 102
 	}
103 103
 
104 104
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return string
148 148
 	 */
149 149
 	public function state() {
150
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
150
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
151 151
 			return $this->state_obj()->abbrev();
152 152
 		} else {
153 153
 			return $this->state_name();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	private function _get_country_obj() {
163 163
 		return $this->_country_obj instanceof \EE_Country
164 164
 			? $this->_country_obj
165
-			: \EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID );
165
+			: \EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
166 166
 	}
167 167
 
168 168
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return string
201 201
 	 */
202 202
 	public function country() {
203
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
203
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
204 204
 			return $this->country_ID();
205 205
 		} else {
206 206
 			return $this->country_name();
Please login to merge, or discard this patch.
core/helpers/EEH_Formatter.helper.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -74,6 +74,7 @@
 block discarded – undo
74 74
 	 * [ee_tep_not_null description]
75 75
 	 *
76 76
 	 * @param  string | array $value [description]
77
+	 * @param string $value
77 78
 	 * @return bool       [description]
78 79
 	 */
79 80
 	static public function ee_tep_not_null( $value ) {
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 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
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param  string $content content to format
27 27
 	 * @return string          formatted content
28 28
 	 */
29
-	static public function admin_format_content( $content = '' ) {
30
-		return wpautop( stripslashes_deep( html_entity_decode( $content, ENT_QUOTES, "UTF-8" ) ) );
29
+	static public function admin_format_content($content = '') {
30
+		return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
31 31
 	}
32 32
 
33 33
 
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 	 * @param  boolean $protected true then we run htmlspecialchars and return
44 44
 	 * @return string
45 45
 	 */
46
-	static public function ee_tep_output_string( $string, $translate = false, $protected = false ) {
47
-		if ( $protected === true ) {
48
-			return htmlspecialchars( $string );
46
+	static public function ee_tep_output_string($string, $translate = false, $protected = false) {
47
+		if ($protected === true) {
48
+			return htmlspecialchars($string);
49 49
 		} else {
50
-			if ( $translate === false ) {
51
-				return self::ee_tep_parse_input_field_data( $string, array( '"' => '&quot;' ) );
50
+			if ($translate === false) {
51
+				return self::ee_tep_parse_input_field_data($string, array('"' => '&quot;'));
52 52
 			} else {
53
-				return self::ee_tep_parse_input_field_data( $string, $translate );
53
+				return self::ee_tep_parse_input_field_data($string, $translate);
54 54
 			}
55 55
 		}
56 56
 	}
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param         array ] $parse array in the form array( 'from' => 'to', ... )
65 65
 	 * @return string
66 66
 	 */
67
-	static public function ee_tep_parse_input_field_data( $data, $parse ) {
68
-		return strtr( trim( $data ), $parse );
67
+	static public function ee_tep_parse_input_field_data($data, $parse) {
68
+		return strtr(trim($data), $parse);
69 69
 	}
70 70
 
71 71
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 * @param  string | array $value [description]
77 77
 	 * @return bool       [description]
78 78
 	 */
79
-	static public function ee_tep_not_null( $value ) {
80
-		if ( is_array( $value ) ) {
81
-			if ( count( $value ) > 0 ) {
79
+	static public function ee_tep_not_null($value) {
80
+		if (is_array($value)) {
81
+			if (count($value) > 0) {
82 82
 				return true;
83 83
 			} else {
84 84
 				return false;
85 85
 			}
86 86
 		} else {
87
-			if ( ( $value !== '' ) && ( strtolower( $value ) !== 'null' ) && ( strlen( trim( $value ) ) > 0 ) ) {
87
+			if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) {
88 88
 				return true;
89 89
 			} else {
90 90
 				return false;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return string
105 105
 	 * @deprecated v4.6.21
106 106
 	 */
107
-	static public function event_date_display( $date, $format = '' ) {
107
+	static public function event_date_display($date, $format = '') {
108 108
 		EE_Error::doing_it_wrong(
109 109
 			__METHOD__,
110 110
 			__(
Please login to merge, or discard this patch.
admin/extend/transactions/Extend_Transactions_Admin_Page.core.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 * @param bool $routing
43 43
 	 * @return \Extend_Transactions_Admin_Page
44 44
 	 */
45
-	public function __construct( $routing = TRUE ) {
46
-		parent::__construct( $routing );
47
-		define( 'TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/templates/');
48
-		define( 'TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'transactions/assets/');
49
-		define( 'TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'transactions/assets/');
45
+	public function __construct($routing = TRUE) {
46
+		parent::__construct($routing);
47
+		define('TXN_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'transactions/templates/');
48
+		define('TXN_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'transactions/assets/');
49
+		define('TXN_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'transactions/assets/');
50 50
 	}
51 51
 
52 52
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return void
59 59
 	 */
60 60
 	protected function _extend_page_config() {
61
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'transactions';
61
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'transactions';
62 62
 
63 63
 		$new_page_routes = array(
64 64
 			'reports' => array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			)
68 68
 		);
69 69
 
70
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
70
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
71 71
 
72 72
 		$new_page_config = array(
73 73
 			'reports' => array(
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				'require_nonce' => FALSE
86 86
 			)
87 87
 		);
88
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
88
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
89 89
 	}
90 90
 
91 91
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 * @return void
98 98
 	 */
99 99
 	public function load_scripts_styles_reports() {
100
-		wp_register_script( 'ee-txn-reports-js', TXN_CAF_ASSETS_URL . 'ee-transaction-admin-reports.js', array( 'google-charts' ), EVENT_ESPRESSO_VERSION, true );
101
-		wp_enqueue_script( 'ee-txn-reports-js' );
100
+		wp_register_script('ee-txn-reports-js', TXN_CAF_ASSETS_URL.'ee-transaction-admin-reports.js', array('google-charts'), EVENT_ESPRESSO_VERSION, true);
101
+		wp_enqueue_script('ee-txn-reports-js');
102 102
 		$this->_transaction_reports_js_setup();
103 103
 		EE_Registry::$i18n_js_strings['currency_format'] = EEH_Money::get_format_for_google_charts();
104 104
 	}
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	* @return void
126 126
 	*/
127 127
 	protected function _transaction_reports() {
128
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
128
+		$template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
129 129
 		$this->_admin_page_title = __('Transactions', 'event_espresso');
130
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_reports_template_data, TRUE );
130
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_reports_template_data, TRUE);
131 131
 
132 132
 		// the final template wrapper
133 133
 		$this->display_admin_page_with_no_sidebar();
@@ -142,42 +142,42 @@  discard block
 block discarded – undo
142 142
 	 * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated.
143 143
 	 * @return string
144 144
 	 */
145
-	private function _revenue_per_day_report( $period = '-1 month' ) {
145
+	private function _revenue_per_day_report($period = '-1 month') {
146 146
 
147 147
 		$report_ID = 'txn-admin-revenue-per-day-report-dv';
148 148
 
149 149
 		$TXN = EEM_Transaction::instance();
150 150
 
151
-		$results = $TXN->get_revenue_per_day_report( $period );
151
+		$results = $TXN->get_revenue_per_day_report($period);
152 152
 		$results = (array) $results;
153 153
 		$revenue = array();
154 154
 		$subtitle = '';
155 155
 
156
-		if ( $results ) {
157
-			$revenue[] = array( __( 'Date (only shows dates that have a revenue greater than 1)', 'event_espresso' ), __( 'Total Revenue', 'event_espresso' ) );
158
-			foreach ( $results as $result ) {
159
-				if ( $result->revenue > 1 ) {
160
-					$revenue[] = array( $result->txnDate, (float) $result->revenue );
156
+		if ($results) {
157
+			$revenue[] = array(__('Date (only shows dates that have a revenue greater than 1)', 'event_espresso'), __('Total Revenue', 'event_espresso'));
158
+			foreach ($results as $result) {
159
+				if ($result->revenue > 1) {
160
+					$revenue[] = array($result->txnDate, (float) $result->revenue);
161 161
 				}
162 162
 			}
163 163
 
164 164
 			//setup the date range.
165
-			$beginning_date = new DateTime( 'now' . $period, new DateTimeZone( EEH_DTT_Helper::get_timezone() ) );
166
-			$ending_date = new DateTime( 'now', new DateTimeZone( EEH_DTT_Helper::get_timezone() ) );
167
-			$subtitle = sprintf( _x( 'For the period: %s to %s', 'Used to give date range', 'event_espresso' ), $beginning_date->format( 'Y-m-d' ), $ending_date->format( 'Y-m-d' ) );
165
+			$beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
166
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
167
+			$subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
168 168
 		}
169 169
 
170
-		$report_title = __( 'Total Revenue per Day' );
170
+		$report_title = __('Total Revenue per Day');
171 171
 
172 172
 		$report_params = array(
173 173
 			'title' 		=> $report_title,
174 174
 			'subtitle' => $subtitle,
175 175
 			'id' 			=> $report_ID,
176 176
 			'revenue' => $revenue,
177
-			'noResults' => empty( $revenue ),
178
-			'noTxnMsg'	=> sprintf( __( '%sThere are currently no transaction records in the last month for this report.%s', 'event_espresso' ), '<h2>' . $report_title . '</h2><p>', '</p>' )
177
+			'noResults' => empty($revenue),
178
+			'noTxnMsg'	=> sprintf(__('%sThere are currently no transaction records in the last month for this report.%s', 'event_espresso'), '<h2>'.$report_title.'</h2><p>', '</p>')
179 179
 		);
180
-		wp_localize_script( 'ee-txn-reports-js', 'txnRevPerDay', $report_params );
180
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerDay', $report_params);
181 181
 
182 182
 		return $report_ID;
183 183
 	}
@@ -191,43 +191,43 @@  discard block
 block discarded – undo
191 191
 	 * @param string $period  The period (acceptable by PHP Datetime constructor) for which the report is generated.
192 192
 	 * @return int
193 193
 	 */
194
-	private function _revenue_per_event_report( $period = '-1 month' ) {
194
+	private function _revenue_per_event_report($period = '-1 month') {
195 195
 
196 196
 		$report_ID = 'txn-admin-revenue-per-event-report-dv';
197 197
 
198 198
 		$TXN = EEM_Transaction::instance();
199
-		$results = $TXN->get_revenue_per_event_report( $period );
199
+		$results = $TXN->get_revenue_per_event_report($period);
200 200
 		$results = (array) $results;
201 201
 		$revenue = array();
202 202
 		$subtitle = '';
203 203
 
204
-		if ( $results ) {
205
-			$revenue[] = array( __( 'Event (only events that have a revenue greater than 1 are shown)', 'event_espresso' ), __( 'Total Revenue', 'event_espresso' ) );
206
-			foreach ( $results as $result ) {
207
-				if ( $result->revenue > 1 ) {
208
-					$event_name = stripslashes( html_entity_decode( $result->event_name, ENT_QUOTES, 'UTF-8' ) );
209
-					$event_name = wp_trim_words( $event_name, 5, '...' );
210
-					$revenue[]  = array( $event_name, (float) $result->revenue );
204
+		if ($results) {
205
+			$revenue[] = array(__('Event (only events that have a revenue greater than 1 are shown)', 'event_espresso'), __('Total Revenue', 'event_espresso'));
206
+			foreach ($results as $result) {
207
+				if ($result->revenue > 1) {
208
+					$event_name = stripslashes(html_entity_decode($result->event_name, ENT_QUOTES, 'UTF-8'));
209
+					$event_name = wp_trim_words($event_name, 5, '...');
210
+					$revenue[]  = array($event_name, (float) $result->revenue);
211 211
 				}
212 212
 			}
213 213
 
214 214
 			//setup the date range.
215
-			$beginning_date = new DateTime( 'now' . $period, new DateTimeZone( EEH_DTT_Helper::get_timezone() ) );
216
-			$ending_date = new DateTime( 'now', new DateTimeZone( EEH_DTT_Helper::get_timezone() ) );
217
-			$subtitle = sprintf( _x( 'For the period: %s to %s', 'Used to give date range', 'event_espresso' ), $beginning_date->format( 'Y-m-d' ), $ending_date->format( 'Y-m-d' ) );
215
+			$beginning_date = new DateTime('now'.$period, new DateTimeZone(EEH_DTT_Helper::get_timezone()));
216
+			$ending_date = new DateTime('now', new DateTimeZone(EEH_DTT_Helper::get_timezone()));
217
+			$subtitle = sprintf(_x('For the period: %s to %s', 'Used to give date range', 'event_espresso'), $beginning_date->format('Y-m-d'), $ending_date->format('Y-m-d'));
218 218
 		}
219 219
 
220
-		$report_title = __( 'Total Revenue per Event' );
220
+		$report_title = __('Total Revenue per Event');
221 221
 
222 222
 		$report_params = array(
223 223
 			'title' 		=> $report_title,
224 224
 			'subtitle' => $subtitle,
225 225
 			'id' 			=> $report_ID,
226 226
 			'revenue' => $revenue,
227
-			'noResults' => empty( $revenue ),
228
-			'noTxnMsg'	=> sprintf( __( '%sThere are currently no transaction records in the last month for this report.%s', 'event_espresso' ), '<h2>' . $report_title . '</h2><p>', '</p>' )
227
+			'noResults' => empty($revenue),
228
+			'noTxnMsg'	=> sprintf(__('%sThere are currently no transaction records in the last month for this report.%s', 'event_espresso'), '<h2>'.$report_title.'</h2><p>', '</p>')
229 229
 		);
230
-		wp_localize_script( 'ee-txn-reports-js', 'txnRevPerEvent', $report_params );
230
+		wp_localize_script('ee-txn-reports-js', 'txnRevPerEvent', $report_params);
231 231
 
232 232
 		return $report_ID;
233 233
 	}
Please login to merge, or discard this patch.
admin/extend/registrations/Extend_Registrations_Admin_Page.core.php 1 patch
Spacing   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
 	protected $_reports_template_data = array();
38 38
 
39 39
 
40
-	public function __construct( $routing = TRUE ) {
41
-		parent::__construct( $routing );
42
-		define( 'REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/');
43
-		define( 'REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/');
44
-		define( 'REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/');
40
+	public function __construct($routing = TRUE) {
41
+		parent::__construct($routing);
42
+		define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/');
43
+		define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/');
44
+		define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/');
45 45
 	}
46 46
 
47 47
 
48 48
 	protected function _extend_page_config() {
49
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations';
49
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations';
50 50
 
51
-		$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0;
52
-		$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0;
53
-		$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id;
51
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0;
52
+		$att_id = ! empty($this->_req_data['ATT_ID']) ? ! is_array($this->_req_data['ATT_ID']) : 0;
53
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id;
54 54
 
55 55
 		$new_page_routes = array(
56 56
 			'reports' => array(
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 				)
90 90
 			);
91 91
 
92
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
92
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
93 93
 
94 94
 		$new_page_config = array(
95 95
 			'reports' => array(
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 						'filename' => 'registrations_event_checkin_other'
135 135
 					)
136 136
 				),
137
-				'help_tour' => array( 'Event_Checkin_Help_Tour' ),
138
-				'qtips' => array('Registration_List_Table_Tips' ),
137
+				'help_tour' => array('Event_Checkin_Help_Tour'),
138
+				'qtips' => array('Registration_List_Table_Tips'),
139 139
 				'list_table' => 'EE_Event_Registrations_List_Table',
140 140
 				'metaboxes' => array(),
141 141
 				'require_nonce' => FALSE
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				),
154 154
 			);
155 155
 
156
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
156
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
157 157
 		$this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table';
158 158
 		$this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table';
159 159
 	}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 	protected function _ajax_hooks() {
164 164
 		parent::_ajax_hooks();
165
-		add_action( 'wp_ajax_get_newsletter_form_content', array( $this, 'get_newsletter_form_content' ) );
165
+		add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content'));
166 166
 	}
167 167
 
168 168
 
@@ -171,20 +171,20 @@  discard block
 block discarded – undo
171 171
 		parent::load_scripts_styles();
172 172
 
173 173
 		//if newsletter message type is active then let's add filter and load js for it.
174
-		if ( EEH_MSG_Template::is_mt_active('newsletter') ) {
174
+		if (EEH_MSG_Template::is_mt_active('newsletter')) {
175 175
 			//enqueue newsletter js
176
-			wp_enqueue_script( 'ee-newsletter-trigger', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, TRUE );
177
-			wp_enqueue_style( 'ee-newsletter-trigger-css', REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION );
176
+			wp_enqueue_script('ee-newsletter-trigger', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, TRUE);
177
+			wp_enqueue_style('ee-newsletter-trigger-css', REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', array(), EVENT_ESPRESSO_VERSION);
178 178
 			//hook in buttons for newsletter message type trigger.
179
-			add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array( $this, 'add_newsletter_action_buttons'), 10 );
179
+			add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array($this, 'add_newsletter_action_buttons'), 10);
180 180
 		}
181 181
 	}
182 182
 
183 183
 
184 184
 
185 185
 	public function load_scripts_styles_reports() {
186
-		wp_register_script( 'ee-reg-reports-js', REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', array( 'google-charts' ), EVENT_ESPRESSO_VERSION, true );
187
-		wp_enqueue_script( 'ee-reg-reports-js' );
186
+		wp_register_script('ee-reg-reports-js', REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', array('google-charts'), EVENT_ESPRESSO_VERSION, true);
187
+		wp_enqueue_script('ee-reg-reports-js');
188 188
 		$this->_registration_reports_js_setup();
189 189
 	}
190 190
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 				'slug' => 'all',
217 217
 				'label' => __('All', 'event_espresso'),
218 218
 				'count' => 0,
219
-				'bulk_action' => !isset( $this->_req_data['event_id'] ) ? array() : array(
219
+				'bulk_action' => ! isset($this->_req_data['event_id']) ? array() : array(
220 220
 					'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'),
221 221
 					//'trash_registrations' => __('Trash Registrations', 'event_espresso')
222 222
 					)
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 				'slug' => 'all',
235 235
 				'label' => __('All', 'event_espresso'),
236 236
 				'count' => 0,
237
-				'bulk_action' => array( 'delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso') )
237
+				'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso'))
238 238
 				),
239 239
 			);
240 240
 	}
@@ -250,20 +250,20 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function get_newsletter_form_content() {
252 252
 		//do a nonce check cause we're not coming in from an normal route here.
253
-		$nonce = isset( $this->_req_data['get_newsletter_form_content_nonce'] ) ? sanitize_text_field( $this->_req_data['get_newsletter_form_content_nonce'] ) : '';
253
+		$nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field($this->_req_data['get_newsletter_form_content_nonce']) : '';
254 254
 		$nonce_ref = 'get_newsletter_form_content_nonce';
255 255
 
256
-		$this->_verify_nonce( $nonce, $nonce_ref );
256
+		$this->_verify_nonce($nonce, $nonce_ref);
257 257
 		//let's get the mtp for the incoming MTP_ ID
258
-		if ( !isset( $this->_req_data['GRP_ID'] ) ) {
259
-			EE_Error::add_error( __('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
258
+		if ( ! isset($this->_req_data['GRP_ID'])) {
259
+			EE_Error::add_error(__('There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
260 260
 			$this->_template_args['success'] = FALSE;
261 261
 			$this->_template_args['error'] = TRUE;
262 262
 			$this->_return_json();
263 263
 		}
264
-		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_req_data['GRP_ID'] );
265
-		if ( ! $MTPG instanceof EE_Message_Template_Group ) {
266
-			EE_Error::add_error( sprintf( __('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID'] ), __FILE__, __FUNCTION__, __LINE__  );
264
+		$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']);
265
+		if ( ! $MTPG instanceof EE_Message_Template_Group) {
266
+			EE_Error::add_error(sprintf(__('The GRP_ID given (%d) does not appear to have a corresponding row in the database.', 'event_espresso'), $this->_req_data['GRP_ID']), __FILE__, __FUNCTION__, __LINE__);
267 267
 			$this->_template_args['success'] = FALSE;
268 268
 			$this->_template_args['error'] = TRUE;
269 269
 			$this->_return_json();
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		$MTPs = $MTPG->context_templates();
273 273
 		$MTPs = $MTPs['attendee'];
274 274
 		$template_fields = array();
275
-		foreach ( $MTPs as $MTP ) {
275
+		foreach ($MTPs as $MTP) {
276 276
 			$field = $MTP->get('MTP_template_field');
277
-			if ( $field == 'content'  ) {
277
+			if ($field == 'content') {
278 278
 				$content = $MTP->get('MTP_content');
279
-				if ( !empty( $content['newsletter_content'] ) ) {
279
+				if ( ! empty($content['newsletter_content'])) {
280 280
 					$template_fields['newsletter_content'] = $content['newsletter_content'];
281 281
 					}
282 282
 				continue;
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		$this->_template_args['data'] = array(
290 290
 			'batch_message_from' => isset($template_fields['from']) ? $template_fields['from'] : '',
291 291
 			'batch_message_subject' => isset($template_fields['subject']) ? $template_fields['subject'] : '',
292
-			'batch_message_content' => isset( $template_fields['newsletter_content'] ) ? $template_fields['newsletter_content'] : ''
292
+			'batch_message_content' => isset($template_fields['newsletter_content']) ? $template_fields['newsletter_content'] : ''
293 293
 			);
294 294
 		$this->_return_json();
295 295
 	}
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * @param EE_Admin_List_Table $list_table
306 306
 	 * @return string html string for extra buttons
307 307
 	 */
308
-	public function add_newsletter_action_buttons( EE_Admin_List_Table $list_table ) {
309
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_newsletter_selected_send' ) ) {
308
+	public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) {
309
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_newsletter_selected_send')) {
310 310
 			return '';
311 311
 		}
312 312
 
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 			'event_registrations',
316 316
 			'default'
317 317
 			);
318
-		if ( $this->_current_page == 'espresso_registrations' && in_array( $this->_req_action, $routes_to_add_to )  ) {
319
-			if ( ( $this->_req_action == 'event_registrations' && empty( $this->_req_data['event_id'] ) ) || ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ) ) {
318
+		if ($this->_current_page == 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) {
319
+			if (($this->_req_action == 'event_registrations' && empty($this->_req_data['event_id'])) || (isset($this->_req_data['status']) && $this->_req_data['status'] == 'trash')) {
320 320
 				echo '';
321 321
 			} else {
322
-				$button_text = sprintf( __('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>' );
323
-				echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' . $button_text . '</button>';
324
-				add_action('admin_footer', array( $this, 'newsletter_send_form_skeleton') );
322
+				$button_text = sprintf(__('Send Batch Message (%s selected)', 'event_espresso'), '<span class="send-selected-newsletter-count">0</span>');
323
+				echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>'.$button_text.'</button>';
324
+				add_action('admin_footer', array($this, 'newsletter_send_form_skeleton'));
325 325
 			}
326 326
 		}
327 327
 	}
@@ -333,37 +333,37 @@  discard block
 block discarded – undo
333 333
 		$list_table = $this->_list_table_object;
334 334
 		$codes = array();
335 335
 		//need to templates for the newsletter message type for the template selector.
336
-		$values[] = array( 'text' => __('Select Template to Use', 'event_espresso'), 'id' => 0 );
337
-		$mtps = EEM_Message_Template_Group::instance()->get_all( array( array( 'MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email' ) ) );
338
-		foreach ( $mtps as $mtp ) {
336
+		$values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0);
337
+		$mtps = EEM_Message_Template_Group::instance()->get_all(array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')));
338
+		foreach ($mtps as $mtp) {
339 339
 			$name = $mtp->name();
340 340
 			$values[] = array(
341
-				'text' => empty( $name ) ? __('Global', 'event_espresso') : $name,
341
+				'text' => empty($name) ? __('Global', 'event_espresso') : $name,
342 342
 				'id' => $mtp->ID()
343 343
 				);
344 344
 		}
345 345
 
346 346
 		//need to get a list of shortcodes that are available for the newsletter message type.
347
-		$shortcodes = EEH_MSG_Template::get_shortcodes( 'newsletter', 'email', array(), 'attendee', FALSE );
348
-		foreach ( $shortcodes as $field => $shortcode_array ) {
349
-			$codes[$field] = implode(', ', array_keys($shortcode_array ) );
347
+		$shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', FALSE);
348
+		foreach ($shortcodes as $field => $shortcode_array) {
349
+			$codes[$field] = implode(', ', array_keys($shortcode_array));
350 350
 		}
351 351
 
352 352
 		$shortcodes = $codes;
353 353
 
354
-		$form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php';
354
+		$form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php';
355 355
 		$form_template_args = array(
356 356
 			'form_action' => admin_url('admin.php?page=espresso_registrations'),
357 357
 			'form_route' => 'newsletter_selected_send',
358 358
 			'form_nonce_name' => 'newsletter_selected_send_nonce',
359
-			'form_nonce' => wp_create_nonce( 'newsletter_selected_send_nonce' ),
359
+			'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'),
360 360
 			'redirect_back_to' => $this->_req_action,
361
-			'ajax_nonce' => wp_create_nonce( 'get_newsletter_form_content_nonce'),
362
-			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values ),
361
+			'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'),
362
+			'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values),
363 363
 			'shortcodes' => $shortcodes,
364 364
 			'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration'
365 365
 			);
366
-		EEH_Template::display_template( $form_template, $form_template_args );
366
+		EEH_Template::display_template($form_template, $form_template_args);
367 367
 	}
368 368
 
369 369
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	protected function _newsletter_selected_send() {
379 379
 		$success = TRUE;
380 380
 		//first we need to make sure we have a GRP_ID so we know what template we're sending and updating!
381
-		if ( empty( $this->_req_data['newsletter_mtp_selected'] ) ) {
381
+		if (empty($this->_req_data['newsletter_mtp_selected'])) {
382 382
 			EE_Error::add_error(
383 383
 				__(
384 384
 					'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.',
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			$success = FALSE;
390 390
 		}
391 391
 
392
-		if ( $success ) {
392
+		if ($success) {
393 393
 			//update Message template in case there are any changes
394 394
 			$Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID(
395 395
 				$this->_req_data['newsletter_mtp_selected']
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 			$Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group
398 398
 				? $Message_Template_Group->context_templates()
399 399
 				: array();
400
-			if ( empty( $Message_Templates ) ) {
400
+			if (empty($Message_Templates)) {
401 401
 				EE_Error::add_error(
402 402
 					__(
403 403
 						'Unable to retrieve message template fields from the db. Messages not sent.',
@@ -408,25 +408,25 @@  discard block
 block discarded – undo
408 408
 			}
409 409
 
410 410
 			//let's just update the specific fields
411
-			foreach ( $Message_Templates['attendee'] as $Message_Template ) {
412
-				if ( $Message_Template instanceof EE_Message_Template ) {
413
-					$field = $Message_Template->get( 'MTP_template_field' );
414
-					$content = $Message_Template->get( 'MTP_content' );
411
+			foreach ($Message_Templates['attendee'] as $Message_Template) {
412
+				if ($Message_Template instanceof EE_Message_Template) {
413
+					$field = $Message_Template->get('MTP_template_field');
414
+					$content = $Message_Template->get('MTP_content');
415 415
 					$new_content = $content;
416
-					switch ( $field ) {
416
+					switch ($field) {
417 417
 						case 'from' :
418
-							$new_content = ! empty( $this->_req_data['batch_message']['from'] )
418
+							$new_content = ! empty($this->_req_data['batch_message']['from'])
419 419
 								? $this->_req_data['batch_message']['from']
420 420
 								: $content;
421 421
 							break;
422 422
 						case 'subject' :
423
-							$new_content = ! empty( $this->_req_data['batch_message']['subject'] )
423
+							$new_content = ! empty($this->_req_data['batch_message']['subject'])
424 424
 								? $this->_req_data['batch_message']['subject']
425 425
 								: $content;
426 426
 							break;
427 427
 						case 'content' :
428 428
 							$new_content = $content;
429
-							$new_content['newsletter_content'] = ! empty( $this->_req_data['batch_message']['content'] )
429
+							$new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content'])
430 430
 								? $this->_req_data['batch_message']['content']
431 431
 								: $content['newsletter_content'];
432 432
 							break;
@@ -434,35 +434,35 @@  discard block
 block discarded – undo
434 434
 							continue;
435 435
 							break;
436 436
 					}
437
-					$Message_Template->set( 'MTP_content', $new_content );
437
+					$Message_Template->set('MTP_content', $new_content);
438 438
 					$Message_Template->save();
439 439
 				}
440 440
 			}
441 441
 
442 442
 			//great fields are updated!  now let's make sure we just have contact objects (EE_Attendee).
443
-			$id_type = ! empty( $this->_req_data['batch_message']['id_type'] )
443
+			$id_type = ! empty($this->_req_data['batch_message']['id_type'])
444 444
 				? $this->_req_data['batch_message']['id_type']
445 445
 				: 'registration';
446 446
 
447 447
 			//id_type will affect how we assemble the ids.
448
-			$ids = ! empty( $this->_req_data['batch_message']['ids'] )
449
-				? json_decode( stripslashes($this->_req_data['batch_message']['ids']) )
448
+			$ids = ! empty($this->_req_data['batch_message']['ids'])
449
+				? json_decode(stripslashes($this->_req_data['batch_message']['ids']))
450 450
 				: array();
451 451
 
452 452
 			$registrations_used_for_contact_data = array();
453 453
 			//using switch because eventually we'll have other contexts that will be used for generating messages.
454
-			switch ( $id_type ) {
454
+			switch ($id_type) {
455 455
 				case 'registration' :
456 456
 					$registrations_used_for_contact_data = EEM_Registration::instance()->get_all(
457 457
 						array(
458 458
 							array(
459
-								'REG_ID' => array( 'IN', $ids )
459
+								'REG_ID' => array('IN', $ids)
460 460
 							)
461 461
 						)
462 462
 					);
463 463
 					break;
464 464
 				case 'contact' :
465
-					$registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts( $ids );
465
+					$registrations_used_for_contact_data = EEM_Registration::instance()->get_latest_registration_for_each_of_given_contacts($ids);
466 466
 					break;
467 467
 			}
468 468
 			do_action(
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 			//kept for backward compat, internally we no longer use this action.
474 474
 			//@deprecated 4.8.36.rc.002
475 475
 			$contacts = $id_type == 'registration'
476
-				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids( $ids )
477
-				: EEM_Attendee::instance()->get_all( array( array( 'ATT_ID' => array('in', $ids ) ) ) );
476
+				? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids)
477
+				: EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids))));
478 478
 			do_action(
479 479
 				'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send',
480 480
 				$contacts,
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 			);
483 483
 		}
484 484
 		$query_args = array(
485
-			'action' => !empty( $this->_req_data['redirect_back_to'] )
485
+			'action' => ! empty($this->_req_data['redirect_back_to'])
486 486
 				? $this->_req_data['redirect_back_to']
487 487
 				: 'default'
488 488
 			);
489
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
489
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
490 490
 	}
491 491
 
492 492
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	*		@return void
509 509
 	*/
510 510
 	protected function _registration_reports() {
511
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php';
512
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_reports_template_data, true );
511
+		$template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php';
512
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_reports_template_data, true);
513 513
 		// the final template wrapper
514 514
 		$this->display_admin_page_with_no_sidebar();
515 515
 
@@ -522,28 +522,28 @@  discard block
 block discarded – undo
522 522
 	 *
523 523
 	 * @return string
524 524
 	 */
525
-	private function _registrations_per_day_report( $period = '-1 month' ) {
525
+	private function _registrations_per_day_report($period = '-1 month') {
526 526
 		$report_ID = 'reg-admin-registrations-per-day-report-dv';
527 527
 
528
-		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report( $period );
528
+		$results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period);
529 529
 
530 530
 		$results = (array) $results;
531 531
 		$regs = array();
532 532
 		$subtitle = '';
533 533
 
534
-		if( $results ) {
534
+		if ($results) {
535 535
 			$column_titles = array();
536 536
 			$tracker = 0;
537
-			foreach ( $results as $result ) {
537
+			foreach ($results as $result) {
538 538
 				$report_column_values = array();
539
-				foreach( $result as $property_name => $property_value ) {
539
+				foreach ($result as $property_name => $property_value) {
540 540
 					$property_value = $property_name == 'Registration_REG_date' ? $property_value : (int) $property_value;
541 541
 					$report_column_values[] = $property_value;
542
-					if ( $tracker === 0 ) {
543
-						if ( $property_name == 'Registration_REG_date' ) {
544
-							$column_titles[] = __( 'Date (only days with registrations are shown)', 'event_espresso' );
542
+					if ($tracker === 0) {
543
+						if ($property_name == 'Registration_REG_date') {
544
+							$column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso');
545 545
 						} else {
546
-							$column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' );
546
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
547 547
 						}
548 548
 					}
549 549
 				}
@@ -552,36 +552,36 @@  discard block
 block discarded – undo
552 552
 			}
553 553
 
554 554
 			//make sure the column_titles is pushed to the beginning of the array
555
-			array_unshift( $regs, $column_titles );
555
+			array_unshift($regs, $column_titles);
556 556
 			//setup the date range.
557
-			$DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() );
558
-			$beginning_date = new DateTime( "now " . $period, $DateTimeZone );
559
-			$ending_date = new DateTime( "now", $DateTimeZone );
557
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
558
+			$beginning_date = new DateTime("now ".$period, $DateTimeZone);
559
+			$ending_date = new DateTime("now", $DateTimeZone);
560 560
 			$subtitle = sprintf(
561
-				_x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ),
562
-				$beginning_date->format( 'Y-m-d' ),
563
-				$ending_date->format( 'Y-m-d' )
561
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
562
+				$beginning_date->format('Y-m-d'),
563
+				$ending_date->format('Y-m-d')
564 564
 			);
565 565
 		}
566 566
 
567
-		$report_title = __( 'Total Registrations per Day', 'event_espresso' );
567
+		$report_title = __('Total Registrations per Day', 'event_espresso');
568 568
 
569 569
 		$report_params = array(
570 570
 			'title' 	=> $report_title,
571 571
 			'subtitle' => $subtitle,
572 572
 			'id' 		=> $report_ID,
573 573
 			'regs' 	=> $regs,
574
-			'noResults' => empty( $regs ),
574
+			'noResults' => empty($regs),
575 575
 			'noRegsMsg' => sprintf(
576 576
 				__(
577 577
 					'%sThere are currently no registration records in the last month for this report.%s',
578 578
 					'event_espresso'
579 579
 				),
580
-				'<h2>' . $report_title . '</h2><p>',
580
+				'<h2>'.$report_title.'</h2><p>',
581 581
 				'</p>'
582 582
 			),
583 583
 		);
584
-		wp_localize_script( 'ee-reg-reports-js', 'regPerDay', $report_params );
584
+		wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params);
585 585
 
586 586
 		return $report_ID;
587 587
 	}
@@ -593,29 +593,29 @@  discard block
 block discarded – undo
593 593
 	 *
594 594
 	 * @return string
595 595
 	 */
596
-	private function _registrations_per_event_report( $period = '-1 month' ) {
596
+	private function _registrations_per_event_report($period = '-1 month') {
597 597
 
598 598
 		$report_ID = 'reg-admin-registrations-per-event-report-dv';
599 599
 
600
-		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report( $period );
600
+		$results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period);
601 601
 
602 602
 		$results = (array) $results;
603 603
 		$regs = array();
604 604
 		$subtitle = '';
605 605
 
606
-		if ( $results ) {
606
+		if ($results) {
607 607
 			$column_titles = array();
608 608
 			$tracker = 0;
609
-			foreach ( $results as $result ) {
609
+			foreach ($results as $result) {
610 610
 				$report_column_values = array();
611
-				foreach( $result as $property_name => $property_value ) {
612
-					$property_value = $property_name == 'Registration_Event' ? wp_trim_words( $property_value, 4, '...' ) : (int) $property_value;
611
+				foreach ($result as $property_name => $property_value) {
612
+					$property_value = $property_name == 'Registration_Event' ? wp_trim_words($property_value, 4, '...') : (int) $property_value;
613 613
 					$report_column_values[] = $property_value;
614
-					if ( $tracker === 0 ) {
615
-						if ( $property_name == 'Registration_Event' ) {
616
-							$column_titles[] = __( 'Event', 'event_espresso' );
614
+					if ($tracker === 0) {
615
+						if ($property_name == 'Registration_Event') {
616
+							$column_titles[] = __('Event', 'event_espresso');
617 617
 						} else {
618
-							$column_titles[] = EEH_Template::pretty_status( $property_name, false, 'sentence' );
618
+							$column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence');
619 619
 						}
620 620
 					}
621 621
 				}
@@ -624,37 +624,37 @@  discard block
 block discarded – undo
624 624
 			}
625 625
 
626 626
 			//make sure the column_titles is pushed to the beginning of the array
627
-			array_unshift( $regs, $column_titles );
627
+			array_unshift($regs, $column_titles);
628 628
 
629 629
 			//setup the date range.
630
-			$DateTimeZone = new DateTimeZone( EEH_DTT_Helper::get_timezone() );
631
-			$beginning_date = new DateTime( "now " . $period, $DateTimeZone );
632
-			$ending_date = new DateTime( "now", $DateTimeZone );
630
+			$DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone());
631
+			$beginning_date = new DateTime("now ".$period, $DateTimeZone);
632
+			$ending_date = new DateTime("now", $DateTimeZone);
633 633
 			$subtitle = sprintf(
634
-				_x( 'For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso' ),
635
-				$beginning_date->format( 'Y-m-d' ),
636
-				$ending_date->format( 'Y-m-d' )
634
+				_x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'),
635
+				$beginning_date->format('Y-m-d'),
636
+				$ending_date->format('Y-m-d')
637 637
 			);
638 638
 		}
639 639
 
640
-		$report_title = __( 'Total Registrations per Event', 'event_espresso' );
640
+		$report_title = __('Total Registrations per Event', 'event_espresso');
641 641
 
642 642
 		$report_params = array(
643 643
 			'title' 	=> $report_title,
644 644
 			'subtitle' => $subtitle,
645 645
 			'id' 		=> $report_ID,
646 646
 			'regs' 	=> $regs,
647
-			'noResults' => empty( $regs ),
647
+			'noResults' => empty($regs),
648 648
 			'noRegsMsg' => sprintf(
649 649
 				__(
650 650
 					'%sThere are currently no registration records in the last month for this report.%s',
651 651
 					'event_espresso'
652 652
 				),
653
-				'<h2>' . $report_title . '</h2><p>',
653
+				'<h2>'.$report_title.'</h2><p>',
654 654
 				'</p>'
655 655
 			),
656 656
 		);
657
-		wp_localize_script( 'ee-reg-reports-js', 'regPerEvent', $report_params );
657
+		wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params);
658 658
 
659 659
 		return $report_ID;
660 660
 	}
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @return void
669 669
 	 */
670 670
 	protected function _registration_checkin_list_table() {
671
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
672
-		$reg_id = isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : null;
671
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
672
+		$reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null;
673 673
 		$reg = EEM_Registration::instance()->get_one_by_ID($reg_id);
674 674
 		$this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $reg->event_ID()), 'add-new-h2');
675 675
 
@@ -683,15 +683,15 @@  discard block
 block discarded – undo
683 683
 				'desc' => __('This indicates the attendee has been checked out', 'event_espresso')
684 684
 				)
685 685
 			);
686
-		$this->_template_args['after_list_table'] = $this->_display_legend( $legend_items );
686
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
687 687
 
688 688
 
689
-		$dtt_id = isset(  $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL;
690
-		$go_back_url = !empty( $reg_id )  ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id ), $this->_admin_base_url ) : '';
689
+		$dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL;
690
+		$go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'event_registrations', 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), 'DTT_ID' => $dtt_id), $this->_admin_base_url) : '';
691 691
 
692
-		$this->_template_args['before_list_table'] = !empty( $reg_id ) && !empty( $dtt_id ) ? '<h2>' . sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">' . EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name() . '</span>', '<span id="checkin-dtt"><a href="' . $go_back_url . '">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time() . ' - ' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time() . '</a></span>', '<span id="checkin-event-name">' . EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name') . '</span>' ) . '</h2>' : '';
693
-		$this->_template_args['list_table_hidden_fields'] = !empty( $reg_id ) ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : '';
694
-		$this->_template_args['list_table_hidden_fields'] .= !empty( $dtt_id ) ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : '';
692
+		$this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) ? '<h2>'.sprintf(__("%s's check in records for %s at the event, %s", 'event_espresso'), '<span id="checkin-attendee-name">'.EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Attendee')->full_name().'</span>', '<span id="checkin-dtt"><a href="'.$go_back_url.'">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->start_date_and_time().' - '.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->end_date_and_time().'</a></span>', '<span id="checkin-event-name">'.EEM_Datetime::instance()->get_one_by_ID($dtt_id)->get_first_related('Event')->get('EVT_name').'</span>').'</h2>' : '';
693
+		$this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : '';
694
+		$this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : '';
695 695
 
696 696
 		$this->display_admin_list_table_page_with_no_sidebar();
697 697
 	}
@@ -704,24 +704,24 @@  discard block
 block discarded – undo
704 704
 	 */
705 705
 	public function toggle_checkin_status() {
706 706
 		//first make sure we have the necessary data
707
-		if ( !isset( $this->_req_data['_regid'] ) ) {
708
-			EE_Error::add_error( __('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
707
+		if ( ! isset($this->_req_data['_regid'])) {
708
+			EE_Error::add_error(__('There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
709 709
 			$this->_template_args['success'] = FALSE;
710 710
 			$this->_template_args['error'] = TRUE;
711 711
 			$this->_return_json();
712 712
 		};
713 713
 
714 714
 		//do a nonce check cause we're not coming in from an normal route here.
715
-		$nonce = isset( $this->_req_data['checkinnonce'] ) ? sanitize_text_field( $this->_req_data['checkinnonce'] ) : '';
715
+		$nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) : '';
716 716
 		$nonce_ref = 'checkin_nonce';
717 717
 
718
-		$this->_verify_nonce( $nonce, $nonce_ref );
718
+		$this->_verify_nonce($nonce, $nonce_ref);
719 719
 
720 720
 		//beautiful! Made it this far so let's get the status.
721 721
 		$new_status = $this->_toggle_checkin_status();
722 722
 
723 723
 		//setup new class to return via ajax
724
-		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' . $new_status;
724
+		$this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-'.$new_status;
725 725
 		$this->_template_args['success'] = TRUE;
726 726
 		$this->_return_json();
727 727
 	}
@@ -741,32 +741,32 @@  discard block
 block discarded – undo
741 741
 		//first let's get the query args out of the way for the redirect
742 742
 		$query_args = array(
743 743
 			'action' => 'event_registrations',
744
-			'event_id' => isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : NULL,
745
-			'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL
744
+			'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : NULL,
745
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL
746 746
 			);
747 747
 		$new_status = FALSE;
748 748
 
749 749
 		// bulk action check in toggle
750
-		if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) {
750
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
751 751
 			// cycle thru checkboxes
752
-			while ( list( $REG_ID, $value ) = each($this->_req_data['checkbox'])) {
753
-				$DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL;
752
+			while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) {
753
+				$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL;
754 754
 				$new_status = $this->_toggle_checkin($REG_ID, $DTT_ID);
755 755
 			}
756 756
 
757
-		} elseif ( isset( $this->_req_data['_regid'] ) ) {
757
+		} elseif (isset($this->_req_data['_regid'])) {
758 758
 			//coming from ajax request
759
-			$DTT_ID = isset( $this->_req_data['dttid'] ) ? $this->_req_data['dttid'] : NULL;
759
+			$DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : NULL;
760 760
 			$query_args['DTT_ID'] = $DTT_ID;
761 761
 			$new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID);
762 762
 		} else {
763
-			EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
763
+			EE_Error::add_error(__('Missing some required data to toggle the Check-in', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
764 764
 		}
765 765
 
766
-		if ( defined('DOING_AJAX' ) )
766
+		if (defined('DOING_AJAX'))
767 767
 			return $new_status;
768 768
 
769
-		$this->_redirect_after_action( FALSE,'', '', $query_args, TRUE );
769
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
770 770
 
771 771
 	}
772 772
 
@@ -782,11 +782,11 @@  discard block
 block discarded – undo
782 782
 	 */
783 783
 	private function _toggle_checkin($REG_ID, $DTT_ID) {
784 784
 		$REG = EEM_Registration::instance()->get_one_by_ID($REG_ID);
785
-		$new_status = $REG->toggle_checkin_status( $DTT_ID );
786
-		if ( $new_status !== FALSE ) {
787
-			EE_Error::add_success($REG->get_checkin_msg($DTT_ID) );
785
+		$new_status = $REG->toggle_checkin_status($DTT_ID);
786
+		if ($new_status !== FALSE) {
787
+			EE_Error::add_success($REG->get_checkin_msg($DTT_ID));
788 788
 		} else {
789
-			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__ );
789
+			EE_Error::add_error($REG->get_checkin_msg($DTT_ID, TRUE), __FILE__, __FUNCTION__, __LINE__);
790 790
 			$new_status = FALSE;
791 791
 		}
792 792
 		return $new_status;
@@ -802,28 +802,28 @@  discard block
 block discarded – undo
802 802
 	protected function _delete_checkin_rows() {
803 803
 		$query_args = array(
804 804
 			'action' => 'registration_checkins',
805
-			'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0,
806
-			'_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0
805
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
806
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0
807 807
 			);
808
-		if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) {
809
-			while ( list( $CHK_ID, $value ) = each( $this->_req_data['checkbox'] ) ) {
808
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
809
+			while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) {
810 810
 				$errors = 0;
811
-				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID ) ) {
811
+				if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) {
812 812
 					$errors++;
813 813
 				}
814 814
 			}
815 815
 		} else {
816
-			EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
817
-			$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
816
+			EE_Error::add_error(__('So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
817
+			$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
818 818
 		}
819 819
 
820
-		if ( $errors > 0 ) {
821
-			EE_Error::add_error( sprintf( __('There were %d records that did not delete successfully', 'event_espresso'), $errors ), __FILE__, __FUNCTION__, __LINE__ );
820
+		if ($errors > 0) {
821
+			EE_Error::add_error(sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), __FILE__, __FUNCTION__, __LINE__);
822 822
 		} else {
823
-			EE_Error::add_success( __('Records were successfully deleted', 'event_espresso') );
823
+			EE_Error::add_success(__('Records were successfully deleted', 'event_espresso'));
824 824
 		}
825 825
 
826
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
826
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
827 827
 	}
828 828
 
829 829
 
@@ -835,20 +835,20 @@  discard block
 block discarded – undo
835 835
 	protected function _delete_checkin_row() {
836 836
 		$query_args = array(
837 837
 			'action' => 'registration_checkins',
838
-			'DTT_ID' => isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0,
839
-			'_REGID' => isset( $this->_req_data['_REGID'] ) ? $this->_req_data['_REGID'] : 0
838
+			'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0,
839
+			'_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0
840 840
 			);
841 841
 
842
-		if ( !empty( $this->_req_data['CHK_ID'] ) ) {
843
-			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'] ) ) {
844
-				EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
842
+		if ( ! empty($this->_req_data['CHK_ID'])) {
843
+			if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) {
844
+				EE_Error::add_error(__('Something went wrong and this check-in record was not deleted', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
845 845
 			} else {
846
-				EE_Error::add_success( __('Check-In record successfully deleted', 'event_espresso') );
846
+				EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso'));
847 847
 			}
848 848
 		} else {
849
-			EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
849
+			EE_Error::add_error(__('In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
850 850
 		}
851
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
851
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
852 852
 	}
853 853
 
854 854
 
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	*		@return void
862 862
 	*/
863 863
 	protected function _event_registrations_list_table() {
864
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
865
-		$this->_admin_page_title .= isset( $this->_req_data['event_id'] ) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : '';
864
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
865
+		$this->_admin_page_title .= isset($this->_req_data['event_id']) ? $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $this->_req_data['event_id']), 'add-new-h2') : '';
866 866
 
867 867
 		$legend_items = array(
868 868
 			'star-icon' => array(
@@ -886,31 +886,31 @@  discard block
 block discarded – undo
886 886
 				'desc' => __('View All Check-in Records for this Registrant', 'event_espresso')
887 887
 				),
888 888
 			'approved_status' => array(
889
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
890
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' )
889
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
890
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')
891 891
 				),
892 892
             'cancelled_status' => array(
893
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
894
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' )
893
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
894
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence')
895 895
 				),
896 896
             'declined_status' => array(
897
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
898
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' )
897
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
898
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence')
899 899
 				),
900 900
 			'not_approved' => array(
901
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
902
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' )
901
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
902
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')
903 903
 				),
904 904
 			'pending_status' => array(
905
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
906
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' )
905
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
906
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')
907 907
 				)/**/
908 908
 			);
909
-		$this->_template_args['after_list_table'] = $this->_display_legend( $legend_items );
909
+		$this->_template_args['after_list_table'] = $this->_display_legend($legend_items);
910 910
 
911
-		$event_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null;
912
-		$this->_template_args['before_list_table'] = !empty( $event_id ) ? '<h2>' . sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') ) . '</h2>' : '';
913
-		$this->_template_args['list_table_hidden_fields'] = !empty( $event_id ) ? '<input type="hidden" name="event_id" value="' . $event_id . '">' : '';
911
+		$event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null;
912
+		$this->_template_args['before_list_table'] = ! empty($event_id) ? '<h2>'.sprintf(__('Viewing Registrations for Event: %s', 'event_espresso'), EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name')).'</h2>' : '';
913
+		$this->_template_args['list_table_hidden_fields'] = ! empty($event_id) ? '<input type="hidden" name="event_id" value="'.$event_id.'">' : '';
914 914
 
915 915
 		$this->display_admin_list_table_page_with_no_sidebar();
916 916
 	}
@@ -924,15 +924,15 @@  discard block
 block discarded – undo
924 924
 	*		@access public
925 925
 	*		@return array
926 926
 	*/
927
-	public function get_event_attendees( $per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '' ) {
927
+	public function get_event_attendees($per_page = 10, $count = FALSE, $trash = FALSE, $orderby = '') {
928 928
 
929
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
930
-		require_once(EE_MODELS . 'EEM_Attendee.model.php');
929
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
930
+		require_once(EE_MODELS.'EEM_Attendee.model.php');
931 931
 		//$ATT_MDL = EEM_Attendee::instance();
932 932
 
933
-		$EVT_ID = isset($this->_req_data['event_id']) ? absint( $this->_req_data['event_id'] ) : FALSE;
934
-		$CAT_ID = isset($this->_req_data['category_id']) ? absint( $this->_req_data['category_id'] ) : FALSE;
935
-		$DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL;
933
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE;
934
+		$CAT_ID = isset($this->_req_data['category_id']) ? absint($this->_req_data['category_id']) : FALSE;
935
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL;
936 936
 
937 937
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby;
938 938
 
@@ -945,94 +945,94 @@  discard block
 block discarded – undo
945 945
 //				$orderby = 'reg.REG_final_price';
946 946
 		}
947 947
 
948
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
948
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
949 949
 
950
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
951
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
950
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
951
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
952 952
 
953 953
 
954
-		$offset = ($current_page-1)*$per_page;
955
-		$limit = $count ? NULL : array( $offset, $per_page );
956
-		$query_params = array(array('Event.status'=>array('IN',  array_keys(EEM_Event::instance()->get_status_array()))));
957
-		if ($EVT_ID){
958
-			$query_params[0]['EVT_ID']=$EVT_ID;
954
+		$offset = ($current_page - 1) * $per_page;
955
+		$limit = $count ? NULL : array($offset, $per_page);
956
+		$query_params = array(array('Event.status'=>array('IN', array_keys(EEM_Event::instance()->get_status_array()))));
957
+		if ($EVT_ID) {
958
+			$query_params[0]['EVT_ID'] = $EVT_ID;
959 959
 		}
960
-		if($CAT_ID){
960
+		if ($CAT_ID) {
961 961
 			throw new EE_Error("You specified a Category Id for this query. Thats odd because we are now using terms and taxonomies. So did you mean the term taxonomy id o rthe term id?");
962 962
 		}
963 963
 
964 964
 		//if DTT is included we do multiple datetimes.
965
-		if ( $DTT_ID ) {
965
+		if ($DTT_ID) {
966 966
 			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
967 967
 		}
968 968
 
969 969
 		//make sure we only have default where on the current regs
970 970
 		$query_params['default_where_conditions'] = 'this_model_only';
971 971
 
972
-		$status_ids_array = apply_filters( 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) );
972
+		$status_ids_array = apply_filters('FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved));
973 973
 
974
-		$query_params[0]['STS_ID']= array('IN', $status_ids_array );
974
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
975 975
 
976
-		if($trash){
977
-			$query_params[0]['Attendee.status']=  EEM_CPT_Base::post_status_trashed;
976
+		if ($trash) {
977
+			$query_params[0]['Attendee.status'] = EEM_CPT_Base::post_status_trashed;
978 978
 		}
979 979
 
980
-		if ( isset( $this->_req_data['s'] ) ) {
981
-			$sstr = '%' . $this->_req_data['s'] . '%';
980
+		if (isset($this->_req_data['s'])) {
981
+			$sstr = '%'.$this->_req_data['s'].'%';
982 982
 			$query_params[0]['OR'] = array(
983
-				'Event.EVT_name' => array( 'LIKE', $sstr),
984
-				'Event.EVT_desc' => array( 'LIKE', $sstr ),
985
-				'Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
986
-				'Attendee.ATT_fname' => array( 'LIKE', $sstr ),
987
-				'Attendee.ATT_lname' => array( 'LIKE', $sstr ),
988
-				'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ),
989
-				'Attendee.ATT_email' => array('LIKE', $sstr ),
990
-				'Attendee.ATT_address' => array( 'LIKE', $sstr ),
991
-				'Attendee.ATT_address2' => array( 'LIKE', $sstr ),
992
-				'Attendee.ATT_city' => array( 'LIKE', $sstr ),
993
-				'REG_final_price' => array( 'LIKE', $sstr ),
994
-				'REG_code' => array( 'LIKE', $sstr ),
995
-				'REG_count' => array( 'LIKE' , $sstr ),
996
-				'REG_group_size' => array( 'LIKE' , $sstr ),
997
-				'Ticket.TKT_name' => array( 'LIKE', $sstr ),
998
-				'Ticket.TKT_description' => array( 'LIKE', $sstr )
983
+				'Event.EVT_name' => array('LIKE', $sstr),
984
+				'Event.EVT_desc' => array('LIKE', $sstr),
985
+				'Event.EVT_short_desc' => array('LIKE', $sstr),
986
+				'Attendee.ATT_fname' => array('LIKE', $sstr),
987
+				'Attendee.ATT_lname' => array('LIKE', $sstr),
988
+				'Attendee.ATT_short_bio' => array('LIKE', $sstr),
989
+				'Attendee.ATT_email' => array('LIKE', $sstr),
990
+				'Attendee.ATT_address' => array('LIKE', $sstr),
991
+				'Attendee.ATT_address2' => array('LIKE', $sstr),
992
+				'Attendee.ATT_city' => array('LIKE', $sstr),
993
+				'REG_final_price' => array('LIKE', $sstr),
994
+				'REG_code' => array('LIKE', $sstr),
995
+				'REG_count' => array('LIKE', $sstr),
996
+				'REG_group_size' => array('LIKE', $sstr),
997
+				'Ticket.TKT_name' => array('LIKE', $sstr),
998
+				'Ticket.TKT_description' => array('LIKE', $sstr)
999 999
 				);
1000 1000
 		}
1001 1001
 
1002 1002
 		$query_params['order_by'][$orderby] = $sort;
1003 1003
 		$query_params['limit'] = $limit;
1004
-		$query_params['force_join'] = array('Attendee');//force join to attendee model so that it gets cached, because we're going to need the attendee for each registration
1005
-		if($count){
1006
-			$registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only' ));
1007
-		}else{
1004
+		$query_params['force_join'] = array('Attendee'); //force join to attendee model so that it gets cached, because we're going to need the attendee for each registration
1005
+		if ($count) {
1006
+			$registrations = EEM_Registration::instance()->count(array($query_params[0], 'default_where_conditions' => 'this_model_only'));
1007
+		} else {
1008 1008
 			$registrations = EEM_Registration::instance()->get_all($query_params);
1009 1009
 
1010 1010
 
1011 1011
 	//		$registrations = EEM_Registration::instance();
1012 1012
 	//		$all_attendees = EEM_Attendee::instance()->get_event_attendees( $EVT_ID, $CAT_ID, $reg_status, $trash, $orderby, $sort, $limit, $output );
1013
-			if ( isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration ) {
1013
+			if (isset($registrations[0]) && $registrations[0] instanceof EE_Registration) {
1014 1014
 				//EEH_Debug_Tools::printr( $all_attendees[0], '$all_attendees[0]  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1015 1015
 				// name
1016 1016
 				$first_registration = $registrations[0];
1017 1017
 				$event_obj = $first_registration->event_obj();
1018
-				if($event_obj){
1018
+				if ($event_obj) {
1019 1019
 					$event_name = $first_registration->event_obj()->name();
1020
-					$event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?';//$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1020
+					$event_date = 'TODO: we need to get date from earliest price date or should this be the actual event date?'; //$first_registration->date_obj()->reg_start_date_and_time('l F j, Y,', ' g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1021 1021
 					// edit event link
1022
-					if ( $event_name != '' ) {
1023
-						$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL );
1024
-						$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
1025
-						$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
1022
+					if ($event_name != '') {
1023
+						$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL);
1024
+						$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1025
+						$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1026 1026
 					}
1027 1027
 
1028
-					$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL );
1029
-					$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">&laquo; ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>';
1028
+					$back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL);
1029
+					$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">&laquo; '.__('Back to All Registrations', 'event_espresso').'</a>';
1030 1030
 
1031 1031
 					$this->_template_args['before_admin_page_content'] = '
1032 1032
 				<div id="admin-page-header">
1033
-					<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1>
1034
-					<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3>
1035
-					<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1033
+					<h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1034
+					<h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1035
+					<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1036 1036
 				</div>
1037 1037
 				';
1038 1038
 				}
Please login to merge, or discard this patch.
admin/extend/registrations/EE_Event_Registrations_List_Table.class.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 
18 18
 
19
-	public function __construct( $admin_page ) {
19
+	public function __construct($admin_page) {
20 20
 		parent::__construct($admin_page);
21 21
 		$this->_status = $this->_admin_page->get_registration_status_array();
22 22
 	}
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 	protected function _setup_data() {
28
-		$this->_data = $this->_view != 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page ) : $this->_admin_page->get_event_attendees( $this->_per_page, FALSE, TRUE );
29
-		$this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_event_attendees(  $this->_per_page, TRUE ) : $this->_admin_page->get_event_attendees(  $this->_per_page, TRUE, TRUE);
28
+		$this->_data = $this->_view != 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) : $this->_admin_page->get_event_attendees($this->_per_page, FALSE, TRUE);
29
+		$this->_all_data_count = $this->_view != 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page, TRUE) : $this->_admin_page->get_event_attendees($this->_per_page, TRUE, TRUE);
30 30
 	}
31 31
 
32 32
 
33 33
 
34 34
 
35 35
 	protected function _set_properties() {
36
-		$evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : NULL;
36
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : NULL;
37 37
 
38 38
 		$this->_wp_list_args = array(
39 39
 			'singular' => __('registrant', 'event_espresso'),
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$columns = array();
46 46
 		//$columns['_Reg_Status'] = '';
47
-		if ( !empty( $evt_id ) ) {
47
+		if ( ! empty($evt_id)) {
48 48
 			$columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text
49 49
 			$this->_has_checkbox_column = true;
50 50
 		}
@@ -60,43 +60,43 @@  discard block
 block discarded – undo
60 60
 				'TXN_total' => __('Total', 'event_espresso')
61 61
 			);
62 62
 
63
-		$this->_columns = array_merge( $columns, $this->_columns);
63
+		$this->_columns = array_merge($columns, $this->_columns);
64 64
 
65 65
 		$this->_primary_column = '_REG_att_checked_in';
66 66
 
67
-		if ( !empty( $evt_id ) && EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_registrations_reports', $evt_id )  ) {
67
+		if ( ! empty($evt_id) && EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_registrations_reports', $evt_id)) {
68 68
 			$this->_bottom_buttons = array(
69 69
 				'report'=> array(
70 70
 					'route' => 'registrations_report',
71 71
 					'extra_request' => 
72 72
 						array( 
73 73
 							'EVT_ID'=> $evt_id, 
74
-							'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") )
74
+							'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") )
75 75
 				)
76 76
 			);
77 77
 		}
78 78
 
79 79
 		$this->_sortable_columns = array(
80 80
 			 //true means its already sorted
81
-			'ATT_name' => array( 'ATT_name' => TRUE ),
82
-			'Event' => array( 'Event.EVT.Name' => FALSE )
81
+			'ATT_name' => array('ATT_name' => TRUE),
82
+			'Event' => array('Event.EVT.Name' => FALSE)
83 83
 		);
84 84
 
85 85
 		$this->_hidden_columns = array();
86 86
 
87 87
 		$this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id);
88
-		$this->_dtts_for_event = !empty($evt_id) ? $this->_evt->datetimes_ordered() : array();
88
+		$this->_dtts_for_event = ! empty($evt_id) ? $this->_evt->datetimes_ordered() : array();
89 89
 
90 90
 	}
91 91
 
92 92
 
93 93
 
94 94
 
95
-	protected function _get_row_class( $item ) {
96
-		$class = parent::_get_row_class( $item );
95
+	protected function _get_row_class($item) {
96
+		$class = parent::_get_row_class($item);
97 97
 		//add status class
98
-		$class .= ' ee-status-strip reg-status-' . $item->status_ID();
99
-		if ( $this->_has_checkbox_column ) {
98
+		$class .= ' ee-status-strip reg-status-'.$item->status_ID();
99
+		if ($this->_has_checkbox_column) {
100 100
 			$class .= ' has-checkbox-column';
101 101
 		}
102 102
 		return $class;
@@ -108,42 +108,42 @@  discard block
 block discarded – undo
108 108
 		$filters = $where = array();
109 109
 
110 110
 
111
-		if ( empty( $this->_dtts_for_event ) ) {
111
+		if (empty($this->_dtts_for_event)) {
112 112
 			//this means we don't have an event so let's setup a filter dropdown for all the events to select
113 113
 			//note possible capability restrictions
114
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events') ) {
115
-				$where['status**'] =  array( '!=', 'private' );
114
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
115
+				$where['status**'] = array('!=', 'private');
116 116
 			}
117 117
 
118
-			if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
119
-				$where['EVT_wp_user'] =  get_current_user_id();
118
+			if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
119
+				$where['EVT_wp_user'] = get_current_user_id();
120 120
 			}
121 121
 
122
-			$events = EEM_Event::instance()->get_all(array( $where, 'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ) ) );
123
-			$evts[] = array('id' => 0, 'text' => __('To toggle Check-in status, select an event', 'event_espresso') );
124
-			foreach ( $events as $evt ) {
122
+			$events = EEM_Event::instance()->get_all(array($where, 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC')));
123
+			$evts[] = array('id' => 0, 'text' => __('To toggle Check-in status, select an event', 'event_espresso'));
124
+			foreach ($events as $evt) {
125 125
 				//any registrations for this event?
126
-				if ( ! $evt->get_count_of_all_registrations() )
126
+				if ( ! $evt->get_count_of_all_registrations())
127 127
 					continue;
128 128
 				$evts[] = array(
129 129
 					'id' => $evt->ID(),
130
-					'text' => $evt->get( 'EVT_name' ),
130
+					'text' => $evt->get('EVT_name'),
131 131
 					'class' => $evt->is_expired() ? 'ee-expired-event' : ''
132 132
 				);
133 133
 			}
134 134
 			$event_filter = '<div class="ee-event-filter">';
135
-			$event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts );
136
-			$event_filter .= '<br><span class="ee-event-filter-toggle"><input type="checkbox" id="js-ee-hide-expired-events" checked>' . ' ' . __( 'Hide Expired Events', 'event_espresso' ) . '</span>';
135
+			$event_filter .= EEH_Form_Fields::select_input('event_id', $evts);
136
+			$event_filter .= '<br><span class="ee-event-filter-toggle"><input type="checkbox" id="js-ee-hide-expired-events" checked>'.' '.__('Hide Expired Events', 'event_espresso').'</span>';
137 137
 			$event_filter .= '</div>';
138 138
 			$filters[] = $event_filter;
139 139
 
140 140
 		} else {
141 141
 			//DTT datetimes filter
142
-			$cur_dtt = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : $this->_evt->primary_datetime()->ID();
142
+			$cur_dtt = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : $this->_evt->primary_datetime()->ID();
143 143
 			$dtts = array();
144
-			foreach ( $this->_dtts_for_event as $dtt ) {
145
-				$datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time();
146
-				$dtts[] = array('id' => $dtt->ID(), 'text' => $datetime_string );
144
+			foreach ($this->_dtts_for_event as $dtt) {
145
+				$datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time();
146
+				$dtts[] = array('id' => $dtt->ID(), 'text' => $datetime_string);
147 147
 			}
148 148
 			$filters[] = EEH_Form_Fields::select_input('DTT_ID', $dtts, $cur_dtt);
149 149
 		}
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 
165 165
 
166 166
 	protected function _get_total_event_attendees() {
167
-		$EVT_ID = isset($this->_req_data['event_id']) ? absint( $this->_req_data['event_id'] ) : FALSE;
168
-		$DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL;
167
+		$EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : FALSE;
168
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL;
169 169
 		$query_params = array();
170
-		if ($EVT_ID){
171
-			$query_params[0]['EVT_ID']=$EVT_ID;
170
+		if ($EVT_ID) {
171
+			$query_params[0]['EVT_ID'] = $EVT_ID;
172 172
 		}
173 173
 		//if DTT is included we do multiple datetimes.  Otherwise we just do primary datetime
174
-		if ( $DTT_ID ) {
174
+		if ($DTT_ID) {
175 175
 			$query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID;
176 176
 		}
177
-		$status_ids_array = apply_filters( 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) );
177
+		$status_ids_array = apply_filters('FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved));
178 178
 
179
-		$query_params[0]['STS_ID']= array('IN', $status_ids_array );
179
+		$query_params[0]['STS_ID'] = array('IN', $status_ids_array);
180 180
 
181 181
 		return EEM_Registration::instance()->count($query_params);
182 182
 	}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 
188 188
 
189 189
 
190
-	function column__Reg_Status( EE_Registration $item ) {
191
-		return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>';
190
+	function column__Reg_Status(EE_Registration $item) {
191
+		return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>';
192 192
 	}
193 193
 
194 194
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 	function column_cb($item) {
199
-		return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() );
199
+		return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID());
200 200
 	}
201 201
 
202 202
 
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 	/**
210 210
 	 * 		column_REG_att_checked_in
211 211
 	*/
212
-	function column__REG_att_checked_in(EE_Registration $item){
212
+	function column__REG_att_checked_in(EE_Registration $item) {
213 213
 		$attendee = $item->attendee();
214 214
 		$attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : '';
215
-		$DTT_ID = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0;
215
+		$DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0;
216 216
 		$checkinstatus = $item->check_in_status_for_datetime($DTT_ID);
217 217
 		$nonce = wp_create_nonce('checkin_nonce');
218
-		$evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : NULL;
219
-		$toggle_active = !empty ( $evt_id ) && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_checkin', 'espresso_registrations_toggle_checkin_status', $item->ID() ) ? ' clickable trigger-checkin' : '';
218
+		$evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : NULL;
219
+		$toggle_active = ! empty ($evt_id) && EE_Registry::instance()->CAP->current_user_can('ee_edit_checkin', 'espresso_registrations_toggle_checkin_status', $item->ID()) ? ' clickable trigger-checkin' : '';
220 220
 
221
-		$mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>';
221
+		$mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>';
222 222
 
223
-		 return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '" data-_regid="' . $item->ID() . '" data-dttid="' . $DTT_ID . '" data-nonce="' . $nonce . '"></span>' . $mobile_view_content;
223
+		 return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'" data-_regid="'.$item->ID().'" data-dttid="'.$DTT_ID.'" data-nonce="'.$nonce.'"></span>'.$mobile_view_content;
224 224
 	}
225 225
 
226 226
 
@@ -229,43 +229,43 @@  discard block
 block discarded – undo
229 229
 
230 230
 	function column_ATT_name(EE_Registration $item) {
231 231
 		$attendee = $item->attendee();
232
-		if ( ! $attendee instanceof EE_Attendee ) {
232
+		if ( ! $attendee instanceof EE_Attendee) {
233 233
 			return __('No contact record for this registration.', 'event_espresso');
234 234
 		}
235 235
 
236 236
 		// edit attendee link
237
-		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$item->ID() ), REG_ADMIN_URL );
238
-		$name_link = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_contacts', 'espresso_registrations_edit_attendee' ) ?  '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Contact', 'event_espresso' ) . '">' . $item->attendee()->full_name() . '</a>' : $item->attendee()->full_name();
237
+		$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$item->ID()), REG_ADMIN_URL);
238
+		$name_link = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', 'espresso_registrations_edit_attendee') ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Contact', 'event_espresso').'">'.$item->attendee()->full_name().'</a>' : $item->attendee()->full_name();
239 239
 		$name_link .= $item->count() == 1 ? '&nbsp;<sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>	' : '';
240 240
 
241 241
 		//add group details
242
-		$name_link .= '&nbsp;' . sprintf(__( '(%s of %s)', 'event_espresso' ),$item->count(), $item->group_size());
242
+		$name_link .= '&nbsp;'.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size());
243 243
 
244 244
 		//add regcode
245
-		$link = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), REG_ADMIN_URL );
245
+		$link = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $item->ID()), REG_ADMIN_URL);
246 246
 		$name_link .= '<br>';
247
-		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can('ee_read_registration', 'view_registration', $item->ID() )
248
-			? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') .'">' . $item->reg_code() . '</a>'
247
+		$name_link .= EE_Registry::instance()->instance()->CAP->current_user_can('ee_read_registration', 'view_registration', $item->ID())
248
+			? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$item->reg_code().'</a>'
249 249
 			: $item->reg_code();
250 250
 
251 251
 		//status
252
-		$name_link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>';
252
+		$name_link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>';
253 253
 
254 254
 		$actions = array();
255
-		$DTT_ID = !empty( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : NULL;
256
-		$DTT_ID = empty( $DTT_ID ) && !empty( $this->_req_data['event_id'] ) ? EEM_Event::instance()->get_one_by_ID( $this->_req_data['event_id'] )->primary_datetime()->ID() : $DTT_ID;
255
+		$DTT_ID = ! empty($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : NULL;
256
+		$DTT_ID = empty($DTT_ID) && ! empty($this->_req_data['event_id']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['event_id'])->primary_datetime()->ID() : $DTT_ID;
257 257
 
258
-		if ( !empty($DTT_ID) && EE_Registry::instance()->CAP->current_user_can( 'ee_read_checkins', 'espresso_registrations_registration_checkins' ) ) {
259
-			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID));
260
-			$actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__('View all the check-ins/checkouts for this registrant', 'event_espresso' ) . '">' . __('View', 'event_espresso') . '</a>';
258
+		if ( ! empty($DTT_ID) && EE_Registry::instance()->CAP->current_user_can('ee_read_checkins', 'espresso_registrations_registration_checkins')) {
259
+			$checkin_list_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID));
260
+			$actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__('View all the check-ins/checkouts for this registrant', 'event_espresso').'">'.__('View', 'event_espresso').'</a>';
261 261
 		}
262 262
 
263
-		return !empty( $DTT_ID ) ? sprintf( '%1$s %2$s', $name_link, $this->row_actions($actions) ) : $name_link;
263
+		return ! empty($DTT_ID) ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)) : $name_link;
264 264
 	}
265 265
 
266 266
 
267 267
 
268
-	function column_ATT_email( EE_Registration $item ) {
268
+	function column_ATT_email(EE_Registration $item) {
269 269
 		$attendee = $item->attendee();
270 270
 		return $attendee instanceof EE_Attendee ? $attendee->email() : '';
271 271
 		return $item->get_first_related('Attendee')->email();
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 
278 278
 	function column_Event(EE_Registration $item) {
279 279
 		$event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event();
280
-		$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'event_registrations', 'event_id'=>$event->ID() ), REG_ADMIN_URL );
281
-		$event_label = EE_Registry::instance()->CAP->current_user_can( 'ee_read_checkins', 'espresso_registrations_registration_checkins' ) ?  '<a href="'.$chkin_lnk_url.'" title="' . esc_attr__( 'View Checkins for this Event', 'event_espresso' ) . '">' . $event->name() . '</a>' : $event->name();
280
+		$chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'event_registrations', 'event_id'=>$event->ID()), REG_ADMIN_URL);
281
+		$event_label = EE_Registry::instance()->CAP->current_user_can('ee_read_checkins', 'espresso_registrations_registration_checkins') ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__('View Checkins for this Event', 'event_espresso').'">'.$event->name().'</a>' : $event->name();
282 282
 		return $event_label;
283 283
 	}
284 284
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 
288 288
 
289
-	function column_PRC_name(EE_Registration $item){
289
+	function column_PRC_name(EE_Registration $item) {
290 290
 		return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso");
291 291
 	}
292 292
 
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	/**
299 299
 	 * 		column_REG_final_price
300 300
 	*/
301
-	function column__REG_final_price(EE_Registration $item){
302
-		return '<span class="reg-pad-rght">' .  ' ' . $item->pretty_final_price() . '</span>';
301
+	function column__REG_final_price(EE_Registration $item) {
302
+		return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>';
303 303
 	}
304 304
 
305 305
 
@@ -309,20 +309,20 @@  discard block
 block discarded – undo
309 309
 	/**
310 310
 	 * 		column_TXN_paid
311 311
 	*/
312
-	function column_TXN_paid(EE_Registration $item){
312
+	function column_TXN_paid(EE_Registration $item) {
313 313
 
314
-		if ( $item->count() == 1 ) {
314
+		if ($item->count() == 1) {
315 315
 
316
-			if ( $item->transaction()->paid() >= $item->transaction()->total() ) {
316
+			if ($item->transaction()->paid() >= $item->transaction()->total()) {
317 317
 				return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>';
318 318
 			} else {
319
-				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID() ), TXN_ADMIN_URL );
320
-				return EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?  '
319
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->transaction_ID()), TXN_ADMIN_URL);
320
+				return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '
321 321
 				<span class="reg-pad-rght">
322
-					<a class="status-'. $item->transaction()->status_ID() .'" href="'.$view_txn_lnk_url.'"  title="' . esc_attr__( 'View Transaction', 'event_espresso' ) . '">
323
-						' . $item->transaction()->pretty_paid(). '
322
+					<a class="status-'. $item->transaction()->status_ID().'" href="'.$view_txn_lnk_url.'"  title="'.esc_attr__('View Transaction', 'event_espresso').'">
323
+						' . $item->transaction()->pretty_paid().'
324 324
 					</a>
325
-				<span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>';
325
+				<span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>';
326 326
 			}
327 327
 		} else {
328 328
 			return '<span class="reg-pad-rght"></span>';
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	/**
337 337
 	 * 		column_TXN_total
338 338
 	*/
339
-	function column_TXN_total(EE_Registration $item){
339
+	function column_TXN_total(EE_Registration $item) {
340 340
 		$txn = $item->transaction();
341
-		$view_txn_url = add_query_arg( array('action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL );
342
-		if ( $item->get('REG_count') == 1 ) {
341
+		$view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL);
342
+		if ($item->get('REG_count') == 1) {
343 343
 			$line_total_obj = $txn->total_line_item();
344 344
 			$txn_total = $line_total_obj instanceof EE_Line_Item ? $line_total_obj->get_pretty('LIN_total') : __('View Transaction', 'event_espresso');
345
-			return EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?  '<a href="' . $view_txn_url . '" title="' . esc_attr__('View Transaction', 'event_espresso') . '"><span class="reg-pad-rght">'. $txn_total  .'</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>';
345
+			return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? '<a href="'.$view_txn_url.'" title="'.esc_attr__('View Transaction', 'event_espresso').'"><span class="reg-pad-rght">'.$txn_total.'</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>';
346 346
 		} else {
347 347
 			return '<span class="reg-pad-rght"></span>';
348 348
 		}
Please login to merge, or discard this patch.
event_single_caff/templates/admin-event-single-settings.template.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-add_filter( 'FHEE__EEH_Form_Fields__label_html', '__return_empty_string' );
2
+add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
3 3
 $values = EEH_Form_Fields::prep_answer_options(
4 4
 	array(
5
-		array( 'id' => 1, 'text' => __( 'Yes', 'event_espresso' ) ),
6
-		array( 'id' => 0, 'text' => __( 'No', 'event_espresso' ) )
5
+		array('id' => 1, 'text' => __('Yes', 'event_espresso')),
6
+		array('id' => 0, 'text' => __('No', 'event_espresso'))
7 7
 	)
8 8
 );
9 9
 ?>
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 					</label>
23 23
 				</th>
24 24
 				<td>
25
-					<?php echo EEH_Form_Fields::select( 'display_status_banner_single', $display_status_banner_single, $values, 'display_status_banner_single', 'display_status_banner_single' ); ?>
26
-					<p class="description"><?php _e( 'Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', 'event_espresso' ); ?></p>
25
+					<?php echo EEH_Form_Fields::select('display_status_banner_single', $display_status_banner_single, $values, 'display_status_banner_single', 'display_status_banner_single'); ?>
26
+					<p class="description"><?php _e('Selecting "Yes" will inject an Event Status banner with the title whenever Events are displaying on the single event page.', 'event_espresso'); ?></p>
27 27
 				</td>
28 28
 			</tr>
29 29
 
30 30
 			<tr>
31 31
 				<th>
32 32
 					<label for="display_venue">
33
-						<?php _e( 'Display Venue Details', 'event_espresso' ); ?><?php echo EEH_Template::get_help_tab_link('display_addresses_in_reg_form_info');?>
33
+						<?php _e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link('display_addresses_in_reg_form_info'); ?>
34 34
 					</label>
35 35
 				</th>
36 36
 				<td>
37
-					<?php echo EEH_Form_Fields::select( 'display_venue', $display_venue, $values, 'display_venue', 'display_venue' ); ?>
38
-					<p class="description"><?php _e( 'Do not use this if you are using the venue shortcodes in your event description.', 'event_espresso' ); ?></p>
37
+					<?php echo EEH_Form_Fields::select('display_venue', $display_venue, $values, 'display_venue', 'display_venue'); ?>
38
+					<p class="description"><?php _e('Do not use this if you are using the venue shortcodes in your event description.', 'event_espresso'); ?></p>
39 39
 				</td>
40 40
 			</tr>
41 41
 
42 42
 			<tr>
43 43
 				<th>
44 44
 					<label for="EED_Events_Single_use_sortable_display_order">
45
-						<?php _e( 'Use Custom Display Order?', 'event_espresso' ); ?>
45
+						<?php _e('Use Custom Display Order?', 'event_espresso'); ?>
46 46
 					</label>
47 47
 				</th>
48 48
 				<td>
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 					<p class="description ">
59 59
 						<?php
60 60
 						echo sprintf(
61
-							__( '%1$sPlease Note:%2$s%3$sIf you are currently using filters to customize the display order for elements within the Event Single page display, then you do NOT activate this feature until those filters have been removed or disabled. If this feature is activated while still using such filters, duplicate event content such as the ticket selector, datetimes, or venue information could be displayed on the frontend of the site. Please verify that this is not the case after activating this feature.', 'event_espresso' ),
61
+							__('%1$sPlease Note:%2$s%3$sIf you are currently using filters to customize the display order for elements within the Event Single page display, then you do NOT activate this feature until those filters have been removed or disabled. If this feature is activated while still using such filters, duplicate event content such as the ticket selector, datetimes, or venue information could be displayed on the frontend of the site. Please verify that this is not the case after activating this feature.', 'event_espresso'),
62 62
 							'<span class="important-notice">',
63 63
 							'</span>',
64 64
 							'<br />'
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 
71 71
 			<tr>
72 72
 				<th>
73
-					<?php _e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link('display_addresses_in_reg_form_info');?>
73
+					<?php _e('Display Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link('display_addresses_in_reg_form_info'); ?>
74 74
 				</th>
75 75
 				<td>
76 76
 
77
-					<?php wp_nonce_field( 'espresso_update_event_single_order', 'espresso_update_event_single_order_nonce', false ); ?>
77
+					<?php wp_nonce_field('espresso_update_event_single_order', 'espresso_update_event_single_order_nonce', false); ?>
78 78
 					<?php echo $event_single_display_order; ?>
79 79
 
80 80
 					<p class="description"><?php _e('Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the single event page.', 'event_espresso'); ?></p>
Please login to merge, or discard this patch.