Completed
Branch FET-8365-add-indexes (4b9253)
by
unknown
478:11 queued 466:02
created
core/db_classes/EE_Ticket_Template.class.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @param string $timezone
36 36
 	 * @return EE_Ticket_Template|mixed
37 37
 	 */
38
-	public static function new_instance( $props_n_values = array(), $timezone = '' ) {
39
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
40
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
38
+	public static function new_instance($props_n_values = array(), $timezone = '') {
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
40
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
41 41
 	}
42 42
 
43 43
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param string $timezone
48 48
 	 * @return EE_Ticket_Template
49 49
 	 */
50
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) {
51
-		return new self( $props_n_values, TRUE, $timezone );
50
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '') {
51
+		return new self($props_n_values, TRUE, $timezone);
52 52
 	}
53 53
 
54 54
 
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Management Plugin for WordPress
8
- *
9
- * @ package        Event Espresso
10
- * @ author        Event Espresso
11
- * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
- * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
- * @ link                {@link http://www.eventespresso.com}
14
- * @ since            4.0
15
- *
16
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Management Plugin for WordPress
8
+	 *
9
+	 * @ package        Event Espresso
10
+	 * @ author        Event Espresso
11
+	 * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
+	 * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
+	 * @ link                {@link http://www.eventespresso.com}
14
+	 * @ since            4.0
15
+	 *
16
+	 */
17 17
 
18 18
 
19 19
 
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 4 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -742,11 +742,11 @@
 block discarded – undo
742 742
 		$pm = $this->get_first_related('Payment_Method');
743 743
 		if( $pm instanceof EE_Payment_Method ){
744 744
 			return $pm;
745
-		}else{
745
+		} else{
746 746
 			$last_payment = $this->last_payment();
747 747
 			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
748 748
 				return $last_payment->payment_method();
749
-			}else{
749
+			} else{
750 750
 				return NULL;
751 751
 			}
752 752
 		}
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Management Plugin for WordPress
8
- *
9
- * @ package        Event Espresso
10
- * @ author        Event Espresso
11
- * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
- * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
- * @ link                {@link http://www.eventespresso.com}
14
- * @ since            4.0
15
- *
16
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Management Plugin for WordPress
8
+	 *
9
+	 * @ package        Event Espresso
10
+	 * @ author        Event Espresso
11
+	 * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
+	 * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
+	 * @ link                {@link http://www.eventespresso.com}
14
+	 * @ since            4.0
15
+	 *
16
+	 */
17 17
 
18 18
 
19 19
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	/**
210 210
 	 *        get Transaction Total
211 211
 	 * @access        public
212
-	 * @return float
212
+	 * @return boolean
213 213
 	 */
214 214
 	public function total() {
215 215
 		return $this->get( 'TXN_total' );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	/**
221 221
 	 *        get Total Amount Paid to Date
222 222
 	 * @access        public
223
-	 * @return float
223
+	 * @return boolean
224 224
 	 */
225 225
 	public function paid() {
226 226
 		return $this->get( 'TXN_paid' );
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	/**
323 323
 	 * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function
324 324
 	 * for getting attendees and how many registrations they each have for an event)
325
-	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
325
+	 * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT'
326 326
 	 */
327 327
 	public function attendees() {
328 328
 		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 	/**
568 568
 	 * Gets all the extra meta info on this payment
569 569
 	 * @param array $query_params like EEM_Base::get_all
570
-	 * @return EE_Extra_Meta
570
+	 * @return EE_Base_Class[]
571 571
 	 */
572 572
 	public function extra_meta( $query_params = array() ) {
573 573
 		return $this->get_many_related( 'Extra_Meta', $query_params );
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 
715 715
 	/**
716 716
 	 * Gets PMD_ID
717
-	 * @return int
717
+	 * @return boolean
718 718
 	 */
719 719
 	function payment_method_ID() {
720 720
 		return $this->get('PMD_ID');
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	/**
726 726
 	 * Sets PMD_ID
727 727
 	 * @param int $PMD_ID
728
-	 * @return boolean
728
+	 * @return boolean|null
729 729
 	 */
730 730
 	function set_payment_method_ID($PMD_ID) {
731 731
 		$this->set('PMD_ID', $PMD_ID);
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @subpackage 	includes/classes/EE_Transaction.class.php
27 27
  * @author 				Brent Christensen
28 28
  */
29
-class EE_Transaction extends EE_Base_Class implements EEI_Transaction{
29
+class EE_Transaction extends EE_Base_Class implements EEI_Transaction {
30 30
 
31 31
 
32 32
 	/**
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @param string $timezone
36 36
 	 * @return EE_Transaction
37 37
 	 */
38
-	public static function new_instance( $props_n_values = array(), $timezone = '' ) {
39
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
40
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
38
+	public static function new_instance($props_n_values = array(), $timezone = '') {
39
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
40
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
41 41
 	}
42 42
 
43 43
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 * @param string $timezone
49 49
 	 * @return EE_Transaction
50 50
 	 */
51
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) {
52
-		return new self( $props_n_values, TRUE, $timezone );
51
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '') {
52
+		return new self($props_n_values, TRUE, $timezone);
53 53
 	}
54 54
 
55 55
 
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @return 	void
65 65
 	 */
66 66
 	public function lock() {
67
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
68
-		$locked_transactions[ $this->ID() ] = true;
69
-		update_option( 'ee_locked_transactions', $locked_transactions );
67
+		$locked_transactions = get_option('ee_locked_transactions', array());
68
+		$locked_transactions[$this->ID()] = true;
69
+		update_option('ee_locked_transactions', $locked_transactions);
70 70
 	}
71 71
 
72 72
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return 	void
81 81
 	 */
82 82
 	public function unlock() {
83
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
84
-		unset( $locked_transactions[ $this->ID() ] );
85
-		update_option( 'ee_locked_transactions', $locked_transactions );
83
+		$locked_transactions = get_option('ee_locked_transactions', array());
84
+		unset($locked_transactions[$this->ID()]);
85
+		update_option('ee_locked_transactions', $locked_transactions);
86 86
 	}
87 87
 
88 88
 	/**
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 	 * @return boolean
100 100
 	 */
101 101
 	public function is_locked() {
102
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
103
-		return isset( $locked_transactions[ $this->ID() ] ) ? true : false;
102
+		$locked_transactions = get_option('ee_locked_transactions', array());
103
+		return isset($locked_transactions[$this->ID()]) ? true : false;
104 104
 	}
105 105
 
106 106
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * @access        public
112 112
 	 * @param        float $total total value of transaction
113 113
 	 */
114
-	public function set_total( $total = 0.00 ) {
115
-		$this->set( 'TXN_total', $total );
114
+	public function set_total($total = 0.00) {
115
+		$this->set('TXN_total', $total);
116 116
 	}
117 117
 
118 118
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @access        public
124 124
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
125 125
 	 */
126
-	public function set_paid( $total_paid = 0.00 ) {
127
-		$this->set( 'TXN_paid', $total_paid );
126
+	public function set_paid($total_paid = 0.00) {
127
+		$this->set('TXN_paid', $total_paid);
128 128
 	}
129 129
 
130 130
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @access        public
136 136
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
137 137
 	 */
138
-	public function set_status( $status = '' ) {
139
-		$this->set( 'STS_ID', $status );
138
+	public function set_status($status = '') {
139
+		$this->set('STS_ID', $status);
140 140
 	}
141 141
 
142 142
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
 	 * @access        public
148 148
 	 * @param        string $hash_salt required for some payment gateways
149 149
 	 */
150
-	public function set_hash_salt( $hash_salt = '' ) {
151
-		$this->set( 'TXN_hash_salt', $hash_salt );
150
+	public function set_hash_salt($hash_salt = '') {
151
+		$this->set('TXN_hash_salt', $hash_salt);
152 152
 	}
153 153
 
154 154
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * Sets TXN_reg_steps array
158 158
 	 * @param array $txn_reg_steps
159 159
 	 */
160
-	function set_reg_steps( $txn_reg_steps ) {
161
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
160
+	function set_reg_steps($txn_reg_steps) {
161
+		$this->set('TXN_reg_steps', $txn_reg_steps);
162 162
 	}
163 163
 
164 164
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @return array
169 169
 	 */
170 170
 	function reg_steps() {
171
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
172
-		return is_array( $TXN_reg_steps ) ? $TXN_reg_steps : array();
171
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
172
+		return is_array($TXN_reg_steps) ? $TXN_reg_steps : array();
173 173
 	}
174 174
 
175 175
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @return string of transaction's total cost, with currency symbol and decimal
180 180
 	 */
181 181
 	public function pretty_total() {
182
-		return $this->get_pretty( 'TXN_total' );
182
+		return $this->get_pretty('TXN_total');
183 183
 	}
184 184
 
185 185
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @return string
190 190
 	 */
191 191
 	public function pretty_paid() {
192
-		return $this->get_pretty( 'TXN_paid' );
192
+		return $this->get_pretty('TXN_paid');
193 193
 	}
194 194
 
195 195
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @return float amount remaining
202 202
 	 */
203 203
 	public function remaining() {
204
-		return (float)( $this->total() - $this->paid() );
204
+		return (float) ($this->total() - $this->paid());
205 205
 	}
206 206
 
207 207
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @return float
213 213
 	 */
214 214
 	public function total() {
215
-		return $this->get( 'TXN_total' );
215
+		return $this->get('TXN_total');
216 216
 	}
217 217
 
218 218
 
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * @return float
224 224
 	 */
225 225
 	public function paid() {
226
-		return $this->get( 'TXN_paid' );
226
+		return $this->get('TXN_paid');
227 227
 	}
228 228
 
229 229
 
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @access        public
234 234
 	 */
235 235
 	public function get_cart_session() {
236
-		$session_data = $this->get( 'TXN_session_data' );
237
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart ? $session_data[ 'cart' ] : NULL;
236
+		$session_data = $this->get('TXN_session_data');
237
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart ? $session_data['cart'] : NULL;
238 238
 	}
239 239
 
240 240
 
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 * @access        public
245 245
 	 */
246 246
 	public function session_data() {
247
-		$session_data = $this->get( 'TXN_session_data' );
248
-		if ( empty( $session_data ) ) {
249
-			$session_data = array( 'id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array() );
247
+		$session_data = $this->get('TXN_session_data');
248
+		if (empty($session_data)) {
249
+			$session_data = array('id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array());
250 250
 		}
251 251
 		return $session_data;
252 252
 	}
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	 * @access        public
260 260
 	 * @param        EE_Session|array $session_data
261 261
 	 */
262
-	public function set_txn_session_data( $session_data ) {
263
-		if ( $session_data instanceof EE_Session ) {
264
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
262
+	public function set_txn_session_data($session_data) {
263
+		if ($session_data instanceof EE_Session) {
264
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
265 265
 		} else {
266
-			$this->set( 'TXN_session_data', $session_data );
266
+			$this->set('TXN_session_data', $session_data);
267 267
 		}
268 268
 	}
269 269
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 * @access        public
275 275
 	 */
276 276
 	public function hash_salt_() {
277
-		return $this->get( 'TXN_hash_salt' );
277
+		return $this->get('TXN_hash_salt');
278 278
 	}
279 279
 
280 280
 
@@ -293,13 +293,13 @@  discard block
 block discarded – undo
293 293
 	 * @param 	boolean 	$gmt - whether to return a unix timestamp with UTC offset applied (default) or no UTC offset applied
294 294
 	 * @return 	string | int
295 295
 	 */
296
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
297
-		if ( $format ) {
298
-			return $this->get_pretty( 'TXN_timestamp' );
299
-		} else if ( $gmt ) {
300
-			return $this->get_raw( 'TXN_timestamp' );
296
+	public function datetime($format = FALSE, $gmt = FALSE) {
297
+		if ($format) {
298
+			return $this->get_pretty('TXN_timestamp');
299
+		} else if ($gmt) {
300
+			return $this->get_raw('TXN_timestamp');
301 301
 		} else {
302
-			return $this->get( 'TXN_timestamp' );
302
+			return $this->get('TXN_timestamp');
303 303
 		}
304 304
 	}
305 305
 
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 	 * @param        boolean $get_cached   TRUE to retrieve cached registrations or FALSE to pull from the db
312 312
 	 * @return EE_Registration[]
313 313
 	 */
314
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
315
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) ? array( 'order_by' => array( 'Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC' ) ) : $query_params;
314
+	public function registrations($query_params = array(), $get_cached = FALSE) {
315
+		$query_params = (empty($query_params) || ! is_array($query_params)) ? array('order_by' => array('Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC')) : $query_params;
316 316
 		$query_params = $get_cached ? array() : $query_params;
317
-		return $this->get_many_related( 'Registration', $query_params );
317
+		return $this->get_many_related('Registration', $query_params);
318 318
 	}
319 319
 
320 320
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
326 326
 	 */
327 327
 	public function attendees() {
328
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
328
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
329 329
 	}
330 330
 
331 331
 
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
 	 * @param array $query_params like EEM_Base::get_all
336 336
 	 * @return EE_Payment[]
337 337
 	 */
338
-	public function payments( $query_params = array() ) {
339
-		return $this->get_many_related( 'Payment', $query_params );
338
+	public function payments($query_params = array()) {
339
+		return $this->get_many_related('Payment', $query_params);
340 340
 	}
341 341
 
342 342
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @return EE_Payment[]
347 347
 	 */
348 348
 	public function approved_payments() {
349
-		EE_Registry::instance()->load_model( 'Payment' );
350
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
349
+		EE_Registry::instance()->load_model('Payment');
350
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
351 351
 	}
352 352
 
353 353
 
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 	 * @param bool $show_icons
358 358
 	 * @return string
359 359
 	 */
360
-	public function e_pretty_status( $show_icons = FALSE ) {
361
-		echo $this->pretty_status( $show_icons );
360
+	public function e_pretty_status($show_icons = FALSE) {
361
+		echo $this->pretty_status($show_icons);
362 362
 	}
363 363
 
364 364
 
@@ -368,10 +368,10 @@  discard block
 block discarded – undo
368 368
 	 * @param bool $show_icons
369 369
 	 * @return string
370 370
 	 */
371
-	public function pretty_status( $show_icons = FALSE ) {
372
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
371
+	public function pretty_status($show_icons = FALSE) {
372
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
373 373
 		$icon = '';
374
-		switch ( $this->status_ID() ) {
374
+		switch ($this->status_ID()) {
375 375
 			case EEM_Transaction::complete_status_code:
376 376
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
377 377
 				break;
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
389 389
 				break;
390 390
 		}
391
-		return $icon . $status[ $this->status_ID() ];
391
+		return $icon.$status[$this->status_ID()];
392 392
 	}
393 393
 
394 394
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * @access        public
399 399
 	 */
400 400
 	public function status_ID() {
401
-		return $this->get( 'STS_ID' );
401
+		return $this->get('STS_ID');
402 402
 	}
403 403
 
404 404
 
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 * @return boolean
409 409
 	 */
410 410
 	public function is_free() {
411
-		return (float)$this->get( 'TXN_total' ) == 0 ? TRUE : FALSE;
411
+		return (float) $this->get('TXN_total') == 0 ? TRUE : FALSE;
412 412
 	}
413 413
 
414 414
 
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 	 * @access public
477 477
 	 * @return string
478 478
 	 */
479
-	public function invoice_url( $type = 'html' ) {
479
+	public function invoice_url($type = 'html') {
480 480
 		$REG = $this->primary_registration();
481
-		if ( ! $REG instanceof EE_Registration ) {
481
+		if ( ! $REG instanceof EE_Registration) {
482 482
 			return '';
483 483
 		}
484
-		return $REG->invoice_url( $type );
484
+		return $REG->invoice_url($type);
485 485
 	}
486 486
 
487 487
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 * @return EE_Registration
492 492
 	 */
493 493
 	public function primary_registration() {
494
-		return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) );
494
+		return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
495 495
 	}
496 496
 
497 497
 
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	 * @param string $type 'pdf' or 'html' (default is 'html')
502 502
 	 * @return string
503 503
 	 */
504
-	public function receipt_url( $type = 'html' ) {
504
+	public function receipt_url($type = 'html') {
505 505
 		$REG = $this->primary_registration();
506
-		if ( ! $REG instanceof EE_Registration ) {
506
+		if ( ! $REG instanceof EE_Registration) {
507 507
 			return '';
508 508
 		}
509
-		return $REG->receipt_url( $type );
509
+		return $REG->receipt_url($type);
510 510
 	}
511 511
 
512 512
 
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
 	 * @deprecated
532 532
 	 * @return boolean
533 533
 	 */
534
-	public function update_based_on_payments(){
534
+	public function update_based_on_payments() {
535 535
 		EE_Error::doing_it_wrong(
536
-			__CLASS__ . '::' . __FUNCTION__,
537
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
536
+			__CLASS__.'::'.__FUNCTION__,
537
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
538 538
 			'4.6.0'
539 539
 		);
540 540
 		/** @type EE_Transaction_Processor $transaction_processor */
541
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
542
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this );
541
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
542
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
543 543
 	}
544 544
 
545 545
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 * @return string
549 549
 	 */
550 550
 	public function gateway_response_on_transaction() {
551
-		$payment = $this->get_first_related( 'Payment' );
551
+		$payment = $this->get_first_related('Payment');
552 552
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
553 553
 	}
554 554
 
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	 * @return EE_Status
560 560
 	 */
561 561
 	public function status_obj() {
562
-		return $this->get_first_related( 'Status' );
562
+		return $this->get_first_related('Status');
563 563
 	}
564 564
 
565 565
 
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 	 * @param array $query_params like EEM_Base::get_all
570 570
 	 * @return EE_Extra_Meta
571 571
 	 */
572
-	public function extra_meta( $query_params = array() ) {
573
-		return $this->get_many_related( 'Extra_Meta', $query_params );
572
+	public function extra_meta($query_params = array()) {
573
+		return $this->get_many_related('Extra_Meta', $query_params);
574 574
 	}
575 575
 
576 576
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @param EE_Registration $registration
581 581
 	 * @return EE_Base_Class the relation was added to
582 582
 	 */
583
-	public function add_registration( EE_Registration $registration ) {
584
-		return $this->_add_relation_to( $registration, 'Registration' );
583
+	public function add_registration(EE_Registration $registration) {
584
+		return $this->_add_relation_to($registration, 'Registration');
585 585
 	}
586 586
 
587 587
 
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @param int $registration_or_id
593 593
 	 * @return EE_Base_Class that was removed from being related
594 594
 	 */
595
-	public function remove_registration_with_id( $registration_or_id ) {
596
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
595
+	public function remove_registration_with_id($registration_or_id) {
596
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
597 597
 	}
598 598
 
599 599
 
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 	 * @return EE_Line_Item[]
604 604
 	 */
605 605
 	public function items_purchased() {
606
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
606
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
607 607
 	}
608 608
 
609 609
 
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * @param EE_Line_Item $line_item
614 614
 	 * @return EE_Base_Class the relation was added to
615 615
 	 */
616
-	public function add_line_item( EE_Line_Item $line_item ) {
617
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
616
+	public function add_line_item(EE_Line_Item $line_item) {
617
+		return $this->_add_relation_to($line_item, 'Line_Item');
618 618
 	}
619 619
 
620 620
 
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
 	 * @param array $query_params
625 625
 	 * @return EE_Line_Item[]
626 626
 	 */
627
-	public function line_items( $query_params = array() ) {
628
-		return $this->get_many_related( 'Line_Item', $query_params );
627
+	public function line_items($query_params = array()) {
628
+		return $this->get_many_related('Line_Item', $query_params);
629 629
 	}
630 630
 
631 631
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * @return EE_Line_Item[]
636 636
 	 */
637 637
 	public function tax_items() {
638
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
638
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
639 639
 	}
640 640
 
641 641
 
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 	 * @return EE_Line_Item
647 647
 	 */
648 648
 	public function total_line_item() {
649
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
650
-		if( ! $item ){
651
-			EE_Registry::instance()->load_helper( 'Line_Item' );
649
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
650
+		if ( ! $item) {
651
+			EE_Registry::instance()->load_helper('Line_Item');
652 652
 			$item = EEH_Line_Item::create_default_total_line_item();
653 653
 		}
654 654
 		return $item;
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 */
664 664
 	public function tax_total() {
665 665
 		$tax_line_item = $this->tax_total_line_item();
666
-		if ( $tax_line_item ) {
666
+		if ($tax_line_item) {
667 667
 			return $tax_line_item->total();
668 668
 		} else {
669 669
 			return 0;
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
 	 * @return EE_Line_Item
678 678
 	 */
679 679
 	public function tax_total_line_item() {
680
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax_sub_total ) ) );
681
-		if( ! $item ){
682
-			EE_Registry::instance()->load_helper( 'Line_Item' );
680
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax_sub_total)));
681
+		if ( ! $item) {
682
+			EE_Registry::instance()->load_helper('Line_Item');
683 683
 			$item = EEH_Line_Item::create_default_total_line_item();
684 684
 		}
685 685
 		return $item;
@@ -691,20 +691,20 @@  discard block
 block discarded – undo
691 691
 	 *  Gets the array of billing info for the gateway and for this transaction's primary registration's attendee.
692 692
 	 * @return EE_Form_Section_Proper
693 693
 	 */
694
-	public function billing_info(){
694
+	public function billing_info() {
695 695
 		$payment_method = $this->payment_method();
696
-		if ( !$payment_method){
696
+		if ( ! $payment_method) {
697 697
 			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__);
698 698
 			return false;
699 699
 		}
700 700
 		$primary_reg = $this->primary_registration();
701
-		if ( ! $primary_reg ) {
702
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
701
+		if ( ! $primary_reg) {
702
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
703 703
 			return FALSE;
704 704
 		}
705 705
 		$attendee = $primary_reg->attendee();
706
-		if ( ! $attendee ) {
707
-			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__ );
706
+		if ( ! $attendee) {
707
+			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__);
708 708
 			return FALSE;
709 709
 		}
710 710
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -739,15 +739,15 @@  discard block
 block discarded – undo
739 739
 	 * offline ones, dont' create payments)
740 740
 	 * @return EE_Payment_Method
741 741
 	 */
742
-	function payment_method(){
742
+	function payment_method() {
743 743
 		$pm = $this->get_first_related('Payment_Method');
744
-		if( $pm instanceof EE_Payment_Method ){
744
+		if ($pm instanceof EE_Payment_Method) {
745 745
 			return $pm;
746
-		}else{
746
+		} else {
747 747
 			$last_payment = $this->last_payment();
748
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
748
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
749 749
 				return $last_payment->payment_method();
750
-			}else{
750
+			} else {
751 751
 				return NULL;
752 752
 			}
753 753
 		}
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 * @return EE_Payment
759 759
 	 */
760 760
 	public function last_payment() {
761
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
761
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
762 762
 	}
763 763
 
764 764
 	/**
765 765
 	 * Gets all the line items which are unrelated to tickets on this transaction
766 766
 	 * @return EE_Line_Item[]
767 767
 	 */
768
-	public function non_ticket_line_items(){
769
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
768
+	public function non_ticket_line_items() {
769
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
770 770
 	}
771 771
 
772 772
 
Please login to merge, or discard this patch.
core/db_classes/EE_Venue.class.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Management Plugin for WordPress
8
- *
9
- * @ package        Event Espresso
10
- * @ author        Event Espresso
11
- * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
- * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
- * @ link                {@link http://www.eventespresso.com}
14
- * @ since            4.0
15
- *
16
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Management Plugin for WordPress
8
+	 *
9
+	 * @ package        Event Espresso
10
+	 * @ author        Event Espresso
11
+	 * @ copyright    (c) 2008-2011 Event Espresso  All Rights Reserved.
12
+	 * @ license        {@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
+	 * @ link                {@link http://www.eventespresso.com}
14
+	 * @ since            4.0
15
+	 *
16
+	 */
17 17
 
18 18
 
19 19
 
Please login to merge, or discard this patch.
Doc Comments   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 	/**
55 55
 	 * Gets name
56
-	 * @return string
56
+	 * @return boolean
57 57
 	 */
58 58
 	function name() {
59 59
 		return $this->get( 'VNU_name' );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 
63 63
 	/**
64 64
 	 * Gets phone
65
-	 * @return string
65
+	 * @return boolean
66 66
 	 */
67 67
 	function phone() {
68 68
 		return $this->get( 'VNU_phone' );
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	/**
74 74
 	 * venue_url
75
-	 * @return string
75
+	 * @return boolean
76 76
 	 */
77 77
 	function venue_url() {
78 78
 		return $this->get( 'VNU_url' );
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
 	/**
83 83
 	 * Gets desc
84
-	 * @return string
84
+	 * @return boolean
85 85
 	 */
86 86
 	function description() {
87 87
 		return $this->get( 'VNU_desc' );
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	/**
93 93
 	 * Gets short description (AKA: the excerpt)
94
-	 * @return string
94
+	 * @return boolean
95 95
 	 */
96 96
 	function excerpt() {
97 97
 		return $this->get( 'VNU_short_desc' );
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 	/**
103 103
 	 * Gets identifier
104
-	 * @return string
104
+	 * @return boolean
105 105
 	 */
106 106
 	function identifier() {
107 107
 		return $this->get( 'VNU_identifier' );
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 	/**
113 113
 	 * Gets address
114
-	 * @return string
114
+	 * @return boolean
115 115
 	 */
116 116
 	function address() {
117 117
 		return $this->get( 'VNU_address' );
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 	/**
123 123
 	 * Gets address2
124
-	 * @return string
124
+	 * @return boolean
125 125
 	 */
126 126
 	function address2() {
127 127
 		return $this->get( 'VNU_address2' );
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 	/**
134 134
 	 * Gets city
135
-	 * @return string
135
+	 * @return boolean
136 136
 	 */
137 137
 	function city() {
138 138
 		return $this->get( 'VNU_city' );
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
 	/**
142 142
 	 * Gets state
143
-	 * @return int
143
+	 * @return boolean
144 144
 	 */
145 145
 	function state_ID() {
146 146
 		return $this->get( 'STA_ID' );
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 	/**
196 196
 	 * country_ID
197
-	 * @return string
197
+	 * @return boolean
198 198
 	 */
199 199
 	function country_ID() {
200 200
 		return $this->get( 'CNT_ISO' );
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 	/**
241 241
 	 * Gets zip
242
-	 * @return string
242
+	 * @return boolean
243 243
 	 */
244 244
 	function zip() {
245 245
 		return $this->get( 'VNU_zip' );
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
 	/**
261 261
 	 * Gets created
262
-	 * @return string
262
+	 * @return boolean
263 263
 	 */
264 264
 	function created() {
265 265
 		return $this->get( 'VNU_created' );
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
 	/**
271 271
 	 * Gets modified
272
-	 * @return string
272
+	 * @return boolean
273 273
 	 */
274 274
 	function modified() {
275 275
 		return $this->get( 'VNU_modified' );
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 	/**
281 281
 	 * Gets order
282
-	 * @return int
282
+	 * @return boolean
283 283
 	 */
284 284
 	function order() {
285 285
 		return $this->get( 'VNU_order' );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 	/**
291 291
 	 * Gets wp_user
292
-	 * @return int
292
+	 * @return boolean
293 293
 	 */
294 294
 	function wp_user() {
295 295
 		return $this->get( 'VNU_wp_user' );
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 
299 299
 
300 300
 	/**
301
-	 * @return string
301
+	 * @return boolean
302 302
 	 */
303 303
 	function virtual_phone() {
304 304
 		return $this->get( 'VNU_virtual_phone' );
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
 
309 309
 	/**
310
-	 * @return string
310
+	 * @return boolean
311 311
 	 */
312 312
 	function virtual_url() {
313 313
 		return $this->get( 'VNU_virtual_url' );
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 
327 327
 	/**
328
-	 * @return string
328
+	 * @return boolean
329 329
 	 */
330 330
 	function google_map_link() {
331 331
 		return $this->get( 'VNU_google_map_link' );
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	 * @param array $props_n_values
34 34
 	 * @return EE_Venue
35 35
 	 */
36
-	public static function new_instance( $props_n_values = array() ) {
37
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
38
-		return $has_object ? $has_object : new self( $props_n_values );
36
+	public static function new_instance($props_n_values = array()) {
37
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
38
+		return $has_object ? $has_object : new self($props_n_values);
39 39
 	}
40 40
 
41 41
 
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param array $props_n_values
46 46
 	 * @return EE_Venue
47 47
 	 */
48
-	public static function new_instance_from_db( $props_n_values = array() ) {
49
-		return new self( $props_n_values, TRUE );
48
+	public static function new_instance_from_db($props_n_values = array()) {
49
+		return new self($props_n_values, TRUE);
50 50
 	}
51 51
 
52 52
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 */
58 58
 	function name() {
59
-		return $this->get( 'VNU_name' );
59
+		return $this->get('VNU_name');
60 60
 	}
61 61
 
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @return string
66 66
 	 */
67 67
 	function phone() {
68
-		return $this->get( 'VNU_phone' );
68
+		return $this->get('VNU_phone');
69 69
 	}
70 70
 
71 71
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @return string
76 76
 	 */
77 77
 	function venue_url() {
78
-		return $this->get( 'VNU_url' );
78
+		return $this->get('VNU_url');
79 79
 	}
80 80
 
81 81
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @return string
85 85
 	 */
86 86
 	function description() {
87
-		return $this->get( 'VNU_desc' );
87
+		return $this->get('VNU_desc');
88 88
 	}
89 89
 
90 90
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return string
95 95
 	 */
96 96
 	function excerpt() {
97
-		return $this->get( 'VNU_short_desc' );
97
+		return $this->get('VNU_short_desc');
98 98
 	}
99 99
 
100 100
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return string
105 105
 	 */
106 106
 	function identifier() {
107
-		return $this->get( 'VNU_identifier' );
107
+		return $this->get('VNU_identifier');
108 108
 	}
109 109
 
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return string
115 115
 	 */
116 116
 	function address() {
117
-		return $this->get( 'VNU_address' );
117
+		return $this->get('VNU_address');
118 118
 	}
119 119
 
120 120
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return string
125 125
 	 */
126 126
 	function address2() {
127
-		return $this->get( 'VNU_address2' );
127
+		return $this->get('VNU_address2');
128 128
 	}
129 129
 
130 130
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return string
136 136
 	 */
137 137
 	function city() {
138
-		return $this->get( 'VNU_city' );
138
+		return $this->get('VNU_city');
139 139
 	}
140 140
 
141 141
 	/**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return int
144 144
 	 */
145 145
 	function state_ID() {
146
-		return $this->get( 'STA_ID' );
146
+		return $this->get('STA_ID');
147 147
 	}
148 148
 
149 149
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @return string
153 153
 	 */
154 154
 	public function state_abbrev() {
155
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' );
155
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso');
156 156
 	}
157 157
 
158 158
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @return string
162 162
 	 */
163 163
 	public function state_name() {
164
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() :  __( 'Unknown', 'event_espresso' );
164
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __('Unknown', 'event_espresso');
165 165
 	}
166 166
 
167 167
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @return EE_State
172 172
 	 */
173 173
 	function state_obj() {
174
-		return $this->get_first_related( 'State' );
174
+		return $this->get_first_related('State');
175 175
 	}
176 176
 
177 177
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @return string
184 184
 	 */
185 185
 	public function state() {
186
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
186
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
187 187
 			return $this->state_abbrev();
188 188
 		} else {
189 189
 			return $this->state_name();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @return string
198 198
 	 */
199 199
 	function country_ID() {
200
-		return $this->get( 'CNT_ISO' );
200
+		return $this->get('CNT_ISO');
201 201
 	}
202 202
 
203 203
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @return string
207 207
 	 */
208 208
 	public function country_name() {
209
-		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() :  __( 'Unknown', 'event_espresso' );
209
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __('Unknown', 'event_espresso');
210 210
 	}
211 211
 
212 212
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @return EE_Country
217 217
 	 */
218 218
 	function country_obj() {
219
-		return $this->get_first_related( 'Country' );
219
+		return $this->get_first_related('Country');
220 220
 	}
221 221
 
222 222
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @return string
229 229
 	 */
230 230
 	public function country() {
231
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
231
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
232 232
 			return $this->country_ID();
233 233
 		} else {
234 234
 			return $this->country_name();
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return string
243 243
 	 */
244 244
 	function zip() {
245
-		return $this->get( 'VNU_zip' );
245
+		return $this->get('VNU_zip');
246 246
 	}
247 247
 
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return int
253 253
 	 */
254 254
 	function capacity() {
255
-		return $this->get_pretty( 'VNU_capacity', 'symbol' );
255
+		return $this->get_pretty('VNU_capacity', 'symbol');
256 256
 	}
257 257
 
258 258
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string
263 263
 	 */
264 264
 	function created() {
265
-		return $this->get( 'VNU_created' );
265
+		return $this->get('VNU_created');
266 266
 	}
267 267
 
268 268
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return string
273 273
 	 */
274 274
 	function modified() {
275
-		return $this->get( 'VNU_modified' );
275
+		return $this->get('VNU_modified');
276 276
 	}
277 277
 
278 278
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return int
283 283
 	 */
284 284
 	function order() {
285
-		return $this->get( 'VNU_order' );
285
+		return $this->get('VNU_order');
286 286
 	}
287 287
 
288 288
 
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return int
293 293
 	 */
294 294
 	function wp_user() {
295
-		return $this->get( 'VNU_wp_user' );
295
+		return $this->get('VNU_wp_user');
296 296
 	}
297 297
 
298 298
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @return string
302 302
 	 */
303 303
 	function virtual_phone() {
304
-		return $this->get( 'VNU_virtual_phone' );
304
+		return $this->get('VNU_virtual_phone');
305 305
 	}
306 306
 
307 307
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @return string
311 311
 	 */
312 312
 	function virtual_url() {
313
-		return $this->get( 'VNU_virtual_url' );
313
+		return $this->get('VNU_virtual_url');
314 314
 	}
315 315
 
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return bool
320 320
 	 */
321 321
 	function enable_for_gmap() {
322
-		return $this->get( 'VNU_enable_for_gmap' );
322
+		return $this->get('VNU_enable_for_gmap');
323 323
 	}
324 324
 
325 325
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return string
329 329
 	 */
330 330
 	function google_map_link() {
331
-		return $this->get( 'VNU_google_map_link' );
331
+		return $this->get('VNU_google_map_link');
332 332
 	}
333 333
 
334 334
 
@@ -340,16 +340,16 @@  discard block
 block discarded – undo
340 340
 	 * @param bool  $upcoming
341 341
 	 * @return EE_Event[]
342 342
 	 */
343
-	function events( $query_params = array(), $upcoming = FALSE ) {
344
-		if ( $upcoming ) {
343
+	function events($query_params = array(), $upcoming = FALSE) {
344
+		if ($upcoming) {
345 345
 			$query_params = array(
346 346
 				array(
347 347
 					'status' => 'publish',
348
-					'Datetime.DTT_EVT_start' => array( '>', current_time( 'mysql' ))
348
+					'Datetime.DTT_EVT_start' => array('>', current_time('mysql'))
349 349
 				)
350 350
 			);
351 351
 		}
352
-		return $this->get_many_related( 'Event', $query_params );
352
+		return $this->get_many_related('Event', $query_params);
353 353
 	}
354 354
 
355 355
 
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	/**
368 368
 	 * Sets address
369 369
 	 */
370
-	function set_address( $address = '' ) {
371
-		$this->set( 'VNU_address', $address );
370
+	function set_address($address = '') {
371
+		$this->set('VNU_address', $address);
372 372
 	}
373 373
 
374 374
 
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * @param string $address2
378 378
 	 */
379
-	function set_address2( $address2 = '' ) {
380
-		$this->set( 'VNU_address2', $address2 );
379
+	function set_address2($address2 = '') {
380
+		$this->set('VNU_address2', $address2);
381 381
 	}
382 382
 
383 383
 
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
 	/**
386 386
 	 * @param string $city
387 387
 	 */
388
-	function set_city( $city = '' ) {
389
-		$this->set( 'VNU_city', $city );
388
+	function set_city($city = '') {
389
+		$this->set('VNU_city', $city);
390 390
 	}
391 391
 
392 392
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	/**
395 395
 	 * @param int $state
396 396
 	 */
397
-	function set_state_ID( $state = 0 ) {
398
-		$this->set( 'STA_ID', $state );
397
+	function set_state_ID($state = 0) {
398
+		$this->set('STA_ID', $state);
399 399
 	}
400 400
 
401 401
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	 * @param EE_State /int $state_id_or_obj
407 407
 	 * @return EE_State
408 408
 	 */
409
-	function set_state_obj( $state_id_or_obj ) {
410
-		return $this->_add_relation_to( $state_id_or_obj, 'State' );
409
+	function set_state_obj($state_id_or_obj) {
410
+		return $this->_add_relation_to($state_id_or_obj, 'State');
411 411
 	}
412 412
 
413 413
 
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	/**
416 416
 	 * @param int $country_ID
417 417
 	 */
418
-	function set_country_ID( $country_ID = 0 ) {
419
-		$this->set( 'CNT_ISO', $country_ID );
418
+	function set_country_ID($country_ID = 0) {
419
+		$this->set('CNT_ISO', $country_ID);
420 420
 	}
421 421
 
422 422
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 * @param EE_Country /string $country_id_or_obj
426 426
 	 * @return EE_Country
427 427
 	 */
428
-	function set_country_obj( $country_id_or_obj ) {
428
+	function set_country_obj($country_id_or_obj) {
429 429
 		return $this->_add_relation_to($country_id_or_obj, 'Country');
430 430
 	}
431 431
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	/**
435 435
 	 * @param string $zip
436 436
 	 */
437
-	function set_zip( $zip = '' ) {
438
-		$this->set( 'VNU_zip', $zip );
437
+	function set_zip($zip = '') {
438
+		$this->set('VNU_zip', $zip);
439 439
 	}
440 440
 
441 441
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	/**
444 444
 	 * @param int $capacity
445 445
 	 */
446
-	function set_capacity( $capacity = 0 ) {
447
-		$this->set( 'VNU_capacity', $capacity );
446
+	function set_capacity($capacity = 0) {
447
+		$this->set('VNU_capacity', $capacity);
448 448
 	}
449 449
 
450 450
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	/**
453 453
 	 * @param string $created
454 454
 	 */
455
-	function set_created( $created = '' ) {
456
-		$this->set( 'VNU_created', $created );
455
+	function set_created($created = '') {
456
+		$this->set('VNU_created', $created);
457 457
 	}
458 458
 
459 459
 
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	/**
462 462
 	 * @param string $desc
463 463
 	 */
464
-	function set_description( $desc = '' ) {
465
-		$this->set( 'VNU_desc', $desc );
464
+	function set_description($desc = '') {
465
+		$this->set('VNU_desc', $desc);
466 466
 	}
467 467
 
468 468
 
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 	/**
471 471
 	 * @param string $identifier
472 472
 	 */
473
-	function set_identifier( $identifier = '' ) {
474
-		$this->set( 'VNU_identifier', $identifier );
473
+	function set_identifier($identifier = '') {
474
+		$this->set('VNU_identifier', $identifier);
475 475
 	}
476 476
 
477 477
 
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	/**
480 480
 	 * @param string $modified
481 481
 	 */
482
-	function set_modified( $modified = '' ) {
483
-		$this->set( 'VNU_modified', $modified );
482
+	function set_modified($modified = '') {
483
+		$this->set('VNU_modified', $modified);
484 484
 	}
485 485
 
486 486
 
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 	/**
489 489
 	 * @param string $name
490 490
 	 */
491
-	function set_name( $name = '' ) {
492
-		$this->set( 'VNU_name', $name );
491
+	function set_name($name = '') {
492
+		$this->set('VNU_name', $name);
493 493
 	}
494 494
 
495 495
 
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
 	/**
498 498
 	 * @param int $order
499 499
 	 */
500
-	function set_order( $order = 0 ) {
501
-		$this->set( 'VNU_order', $order );
500
+	function set_order($order = 0) {
501
+		$this->set('VNU_order', $order);
502 502
 	}
503 503
 
504 504
 
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	/**
507 507
 	 * @param string $phone
508 508
 	 */
509
-	function set_phone( $phone = '' ) {
510
-		$this->set( 'VNU_phone', $phone );
509
+	function set_phone($phone = '') {
510
+		$this->set('VNU_phone', $phone);
511 511
 	}
512 512
 
513 513
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
 	/**
516 516
 	 * @param int $wp_user
517 517
 	 */
518
-	function set_wp_user( $wp_user = 1 ) {
519
-		$this->set( 'VNU_wp_user', $wp_user );
518
+	function set_wp_user($wp_user = 1) {
519
+		$this->set('VNU_wp_user', $wp_user);
520 520
 	}
521 521
 
522 522
 
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	/**
525 525
 	 * @param string $url
526 526
 	 */
527
-	function set_venue_url( $url = '' ) {
528
-		$this->set( 'VNU_url', $url );
527
+	function set_venue_url($url = '') {
528
+		$this->set('VNU_url', $url);
529 529
 	}
530 530
 
531 531
 
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 	/**
534 534
 	 * @param string $phone
535 535
 	 */
536
-	function set_virtual_phone( $phone = '' ) {
537
-		$this->set( 'VNU_virtual_phone', $phone );
536
+	function set_virtual_phone($phone = '') {
537
+		$this->set('VNU_virtual_phone', $phone);
538 538
 	}
539 539
 
540 540
 
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 	/**
543 543
 	 * @param string $url
544 544
 	 */
545
-	function set_virtual_url( $url = '' ) {
546
-		$this->set( 'VNU_virtual_url', $url );
545
+	function set_virtual_url($url = '') {
546
+		$this->set('VNU_virtual_url', $url);
547 547
 	}
548 548
 
549 549
 
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	/**
552 552
 	 * @param string $enable
553 553
 	 */
554
-	function set_enable_for_gmap( $enable = '' ) {
555
-		$this->set( 'VNU_enable_for_gmap', $enable );
554
+	function set_enable_for_gmap($enable = '') {
555
+		$this->set('VNU_enable_for_gmap', $enable);
556 556
 	}
557 557
 
558 558
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 	/**
561 561
 	 * @param string $google_map_link
562 562
 	 */
563
-	function set_google_map_link( $google_map_link = '' ) {
564
-		$this->set( 'VNU_google_map_link', $google_map_link );
563
+	function set_google_map_link($google_map_link = '') {
564
+		$this->set('VNU_google_map_link', $google_map_link);
565 565
 	}
566 566
 
567 567
 
Please login to merge, or discard this patch.
core/db_classes/EE_WP_User.class.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,14 +2,14 @@
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * EE_WP_User class
6
- *
7
- * @package 			Event Espresso
8
- * @subpackage 	includes/classes/EE_WP_User.class.php
9
- * @author 				Mike Nelson
10
- *
11
- * ------------------------------------------------------------------------
12
- */
5
+	 * EE_WP_User class
6
+	 *
7
+	 * @package 			Event Espresso
8
+	 * @subpackage 	includes/classes/EE_WP_User.class.php
9
+	 * @author 				Mike Nelson
10
+	 *
11
+	 * ------------------------------------------------------------------------
12
+	 */
13 13
 class EE_WP_User extends EE_Base_Class {
14 14
 
15 15
 	/**
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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_WP_User class
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	 * @param array $props_n_values
23 23
 	 * @return EE_WP_User|mixed
24 24
 	 */
25
-	public static function new_instance( $props_n_values = array() ) {
26
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
27
-		return $has_object ? $has_object : new self( $props_n_values );
25
+	public static function new_instance($props_n_values = array()) {
26
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
27
+		return $has_object ? $has_object : new self($props_n_values);
28 28
 	}
29 29
 
30 30
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @param array $props_n_values
34 34
 	 * @return EE_WP_User
35 35
 	 */
36
-	public static function new_instance_from_db( $props_n_values = array() ) {
37
-		return new self( $props_n_values, TRUE );
36
+	public static function new_instance_from_db($props_n_values = array()) {
37
+		return new self($props_n_values, TRUE);
38 38
 	}
39 39
 
40 40
 	/**
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return WP_User
43 43
 	 */
44 44
 	public function wp_user_obj() {
45
-		if( ! $this->_wp_user_obj ) {
46
-			$this->_wp_user_obj = get_user_by('ID', $this->ID() );
45
+		if ( ! $this->_wp_user_obj) {
46
+			$this->_wp_user_obj = get_user_by('ID', $this->ID());
47 47
 		}
48 48
 		return $this->_wp_user_obj;
49 49
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Answer.model.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * 	constructor
52 52
 	 */
53
-	protected function __construct( $timezone = NULL ){
54
-		$this->singular_item = __('Answer','event_espresso');
55
-		$this->plural_item = __('Answers','event_espresso');
53
+	protected function __construct($timezone = NULL) {
54
+		$this->singular_item = __('Answer', 'event_espresso');
55
+		$this->plural_item = __('Answers', 'event_espresso');
56 56
 		$this->_tables = array(
57 57
 			'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID')
58 58
 		);
59 59
 		$this->_fields = array(
60 60
 			'Answer'=>array(
61
-				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID','event_espresso')),
62
-				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID','event_espresso'), false, 0, 'Registration'),
63
-				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'),
64
-				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value','event_espresso'), false, '')
61
+				'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')),
62
+				'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'),
63
+				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
64
+				'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')
65 65
 			));
66 66
 		$this->_model_relations = array(
67 67
 			'Registration'=>new EE_Belongs_To_Relation(),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		);
70 70
 		$this->_model_chain_to_wp_user = 'Registration.Event';
71 71
 		$this->_caps_slug = 'registrations';
72
-		parent::__construct( $timezone );
72
+		parent::__construct($timezone);
73 73
 	}
74 74
 
75 75
 
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
83 83
 	 * @return string
84 84
 	 */
85
-	public function get_answer_value_to_question( EE_Registration $registration, $question_id = NULL,$pretty_answer = FALSE ){
86
-		$value = $this->get_attendee_property_answer_value( $registration, $question_id, $pretty_answer );
87
-		if (  $value === NULL ){
88
-			$answer_obj = $this->get_registration_question_answer_object( $registration, $question_id, $pretty_answer );
89
-			if( $answer_obj instanceof EE_Answer ){
90
-				if($pretty_answer){
85
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE) {
86
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
87
+		if ($value === NULL) {
88
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id, $pretty_answer);
89
+			if ($answer_obj instanceof EE_Answer) {
90
+				if ($pretty_answer) {
91 91
 					$value = $answer_obj->pretty_value();
92
-				}else{
92
+				} else {
93 93
 					$value = $answer_obj->value();
94 94
 				}
95 95
 			}
96 96
 		}
97
-		return apply_filters( 'FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id );
97
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
98 98
 	}
99 99
 
100 100
 
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @param int $question_id
106 106
 	 * @return EE_Answer
107 107
 	 */
108
-	public function get_registration_question_answer_object( EE_Registration $registration, $question_id = NULL){
109
-		$answer_obj = $this->get_one( array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() )));
110
-		return apply_filters( 'FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id );
108
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = NULL) {
109
+		$answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID())));
110
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
111 111
 	}
112 112
 
113 113
 
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
 	 * @param boolean $pretty_answer
120 120
 	 * @return string
121 121
 	 */
122
-	public function get_attendee_property_answer_value( EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE ){
122
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE) {
123 123
 		$field_name = NULL;
124 124
 		$value = NULL;
125 125
 		//only bother checking if the registration has an attendee
126
-		if( $registration->attendee() instanceof EE_Attendee && isset($this->_question_id_to_att_field_map[$question_id])){
126
+		if ($registration->attendee() instanceof EE_Attendee && isset($this->_question_id_to_att_field_map[$question_id])) {
127 127
 			$field_name = $this->_question_id_to_att_field_map[$question_id];
128
-			if($pretty_answer){
129
-				if($field_name == 'STA_ID'){
128
+			if ($pretty_answer) {
129
+				if ($field_name == 'STA_ID') {
130 130
 					$state = $registration->attendee()->state_obj();
131
-					$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'),$registration->attendee()->state_ID());
132
-				}else if($field_name == 'CNT_ISO'){
131
+					$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
132
+				} else if ($field_name == 'CNT_ISO') {
133 133
 					$country = $registration->attendee()->country_obj();
134
-					$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"),$registration->attendee()->country_ID());
135
-				}else{
134
+					$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
135
+				} else {
136 136
 					$value = $registration->attendee()->get_pretty($field_name);
137 137
 				}
138
-			}else{
138
+			} else {
139 139
 				$value = $registration->attendee()->get($field_name);
140 140
 			}
141 141
 		}
142
-		return apply_filters( 'FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id );
142
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id);
143 143
 	}
144 144
 
145 145
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -89,7 +91,7 @@  discard block
 block discarded – undo
89 91
 			if( $answer_obj instanceof EE_Answer ){
90 92
 				if($pretty_answer){
91 93
 					$value = $answer_obj->pretty_value();
92
-				}else{
94
+				} else{
93 95
 					$value = $answer_obj->value();
94 96
 				}
95 97
 			}
@@ -129,13 +131,13 @@  discard block
 block discarded – undo
129 131
 				if($field_name == 'STA_ID'){
130 132
 					$state = $registration->attendee()->state_obj();
131 133
 					$value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'),$registration->attendee()->state_ID());
132
-				}else if($field_name == 'CNT_ISO'){
134
+				} else if($field_name == 'CNT_ISO'){
133 135
 					$country = $registration->attendee()->country_obj();
134 136
 					$value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"),$registration->attendee()->country_ID());
135
-				}else{
137
+				} else{
136 138
 					$value = $registration->attendee()->get_pretty($field_name);
137 139
 				}
138
-			}else{
140
+			} else{
139 141
 				$value = $registration->attendee()->get($field_name);
140 142
 			}
141 143
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_Attendee.model.php 4 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 
106 106
 
107 107
 	/**
108
-	*		retrieve  a single attendee from db via their ID
109
-	*
110
-	* 		@access		public
111
-	* 		@param		$ATT_ID
112
-	*		@return 		mixed		array on success, FALSE on fail
108
+	 *		retrieve  a single attendee from db via their ID
109
+	 *
110
+	 * 		@access		public
111
+	 * 		@param		$ATT_ID
112
+	 *		@return 		mixed		array on success, FALSE on fail
113 113
 	 * 		@deprecated
114
-	*/
114
+	 */
115 115
 	public function get_attendee_by_ID( $ATT_ID = FALSE ) {
116 116
 		// retrieve a particular EE_Attendee
117 117
 		return $this->get_one_by_ID( $ATT_ID );
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 
122 122
 
123 123
 	/**
124
-	*		retrieve  a single attendee from db via their ID
125
-	*
126
-	* 		@access		public
127
-	* 		@param		array $where_cols_n_values
128
-	*		@return 		mixed		array on success, FALSE on fail
129
-	*/
124
+	 *		retrieve  a single attendee from db via their ID
125
+	 *
126
+	 * 		@access		public
127
+	 * 		@param		array $where_cols_n_values
128
+	 *		@return 		mixed		array on success, FALSE on fail
129
+	 */
130 130
 	public function get_attendee( $where_cols_n_values = array() ) {
131 131
 
132 132
 		if ( empty( $where_cols_n_values )) {
@@ -174,20 +174,20 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	/**
177
-             * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
178
-             * EE_Attendee objects.
179
-             *
180
-             * @since    4.3.0
181
-             * @param  array $ids array of EE_Registration ids
182
-             * @return  EE_Attendee[]
183
-             */
184
-            public function get_array_of_contacts_from_reg_ids( $ids ) {
185
-                $ids = (array) $ids;
186
-                $_where = array(
187
-                    'Registration.REG_ID' => array( 'in', $ids )
188
-                    );
189
-                return $this->get_all( array( $_where ) );
190
-            }
177
+	 * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate
178
+	 * EE_Attendee objects.
179
+	 *
180
+	 * @since    4.3.0
181
+	 * @param  array $ids array of EE_Registration ids
182
+	 * @return  EE_Attendee[]
183
+	 */
184
+			public function get_array_of_contacts_from_reg_ids( $ids ) {
185
+				$ids = (array) $ids;
186
+				$_where = array(
187
+					'Registration.REG_ID' => array( 'in', $ids )
188
+					);
189
+				return $this->get_all( array( $_where ) );
190
+			}
191 191
 
192 192
 
193 193
 }
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 
4 4
 /**
5 5
  *
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 	 * QST_ID and QST_systems that relate to attendee attributes.
20 20
 	 * NOTE: this will be deprecated if we remove system questions
21 21
 	 */
22
-	const fname_question_id=1;
23
-	const lname_question_id=2;
24
-	const email_question_id=3;
25
-	const address_question_id=4;
26
-	const address2_question_id=5;
27
-	const city_question_id=6;
28
-	const state_question_id=7;
29
-	const country_question_id=8;
30
-	const zip_question_id=9;
31
-	const phone_question_id=10;
22
+	const fname_question_id = 1;
23
+	const lname_question_id = 2;
24
+	const email_question_id = 3;
25
+	const address_question_id = 4;
26
+	const address2_question_id = 5;
27
+	const city_question_id = 6;
28
+	const state_question_id = 7;
29
+	const country_question_id = 8;
30
+	const zip_question_id = 9;
31
+	const phone_question_id = 10;
32 32
 
33 33
 
34 34
 
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	 * @access protected
40 40
 	 * @param null $timezone
41 41
 	 */
42
-	protected function __construct( $timezone = NULL ) {
43
-		$this->singular_item = __('Attendee','event_espresso');
44
-		$this->plural_item = __('Attendees','event_espresso');
42
+	protected function __construct($timezone = NULL) {
43
+		$this->singular_item = __('Attendee', 'event_espresso');
44
+		$this->plural_item = __('Attendees', 'event_espresso');
45 45
 		$this->_tables = array(
46 46
 			'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'),
47 47
 			'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID')
@@ -55,36 +55,36 @@  discard block
 block discarded – undo
55 55
 				'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, time()),
56 56
 				'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")),
57 57
 				'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, time()),
58
-				'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ),
58
+				'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false),
59 59
 				'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0),
60
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
60
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'), // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'),
61 61
 				'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish')
62 62
 			),
63 63
 			'Attendee_Meta'=>array(
64
-				'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false),
64
+				'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false),
65 65
 				'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false),
66
-				'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''),
67
-				'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''),
68
-				'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''),
69
-				'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''),
70
-				'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''),
71
-				'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'),
72
-				'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'),
73
-				'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''),
74
-				'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''),
75
-				'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '')
66
+				'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''),
67
+				'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''),
68
+				'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''),
69
+				'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''),
70
+				'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''),
71
+				'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'),
72
+				'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'),
73
+				'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''),
74
+				'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''),
75
+				'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '')
76 76
 			));
77 77
 		$this->_model_relations = array(
78 78
 			'Registration'=>new EE_Has_Many_Relation(),
79 79
 			'State'=>new EE_Belongs_To_Relation(),
80 80
 			'Country'=>new EE_Belongs_To_Relation(),
81
-			'Event'=>new EE_HABTM_Relation('Registration', FALSE ),
81
+			'Event'=>new EE_HABTM_Relation('Registration', FALSE),
82 82
 			'WP_User' => new EE_Belongs_To_Relation(),
83 83
 		);
84 84
 		require_once('strategies/EE_CPT_Where_Conditions.strategy.php');
85 85
 		$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_attendees', 'ATTM_ID');
86 86
 		$this->_caps_slug = 'contacts';
87
-		parent::__construct( $timezone );
87
+		parent::__construct($timezone);
88 88
 
89 89
 	}
90 90
 
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID
97 97
 	 * @return EE_Attendee[]
98 98
 	 */
99
-	public function get_attendees_for_transaction( $transaction_id_or_obj ){
100
-		return $this->get_all( array( array(
99
+	public function get_attendees_for_transaction($transaction_id_or_obj) {
100
+		return $this->get_all(array(array(
101 101
 			  'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj
102 102
 		  )));
103 103
 	}
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	*		@return 		mixed		array on success, FALSE on fail
113 113
 	 * 		@deprecated
114 114
 	*/
115
-	public function get_attendee_by_ID( $ATT_ID = FALSE ) {
115
+	public function get_attendee_by_ID($ATT_ID = FALSE) {
116 116
 		// retrieve a particular EE_Attendee
117
-		return $this->get_one_by_ID( $ATT_ID );
117
+		return $this->get_one_by_ID($ATT_ID);
118 118
 	}
119 119
 
120 120
 
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 	* 		@param		array $where_cols_n_values
128 128
 	*		@return 		mixed		array on success, FALSE on fail
129 129
 	*/
130
-	public function get_attendee( $where_cols_n_values = array() ) {
130
+	public function get_attendee($where_cols_n_values = array()) {
131 131
 
132
-		if ( empty( $where_cols_n_values )) {
132
+		if (empty($where_cols_n_values)) {
133 133
 			return FALSE;
134 134
 		}
135
-		$attendee = $this->get_all( array($where_cols_n_values ));
136
-		if ( ! empty( $attendee )) {
137
-			return array_shift( $attendee );
135
+		$attendee = $this->get_all(array($where_cols_n_values));
136
+		if ( ! empty($attendee)) {
137
+			return array_shift($attendee);
138 138
 		} else {
139 139
 			return FALSE;
140 140
 		}
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 	 * @param array $where_cols_n_values
151 151
 	 * @return bool|mixed
152 152
 	 */
153
-	public function find_existing_attendee( $where_cols_n_values = NULL ) {
153
+	public function find_existing_attendee($where_cols_n_values = NULL) {
154 154
 		// search by combo of first and last names plus the email address
155
-		$attendee_data_keys = array( 'ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email );
155
+		$attendee_data_keys = array('ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email);
156 156
 		// no search params means attendee object already exists.
157
-		$where_cols_n_values = is_array( $where_cols_n_values ) && ! empty( $where_cols_n_values ) ? $where_cols_n_values : $attendee_data_keys;
157
+		$where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values : $attendee_data_keys;
158 158
 		$valid_data = TRUE;
159 159
 		// check for required values
160
-		$valid_data = isset( $where_cols_n_values['ATT_fname'] ) && ! empty( $where_cols_n_values['ATT_fname'] ) ? $valid_data : FALSE;
161
-		$valid_data = isset( $where_cols_n_values['ATT_lname'] ) && ! empty( $where_cols_n_values['ATT_lname'] ) ? $valid_data : FALSE;
162
-		$valid_data = isset( $where_cols_n_values['ATT_email'] ) && ! empty( $where_cols_n_values['ATT_email'] ) ? $valid_data : FALSE;
160
+		$valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) ? $valid_data : FALSE;
161
+		$valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) ? $valid_data : FALSE;
162
+		$valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) ? $valid_data : FALSE;
163 163
 
164
-		if ( $valid_data ) {
165
-			$attendee = $this->get_attendee( $where_cols_n_values );
166
-			if ( $attendee instanceof EE_Attendee ) {
164
+		if ($valid_data) {
165
+			$attendee = $this->get_attendee($where_cols_n_values);
166
+			if ($attendee instanceof EE_Attendee) {
167 167
 				return $attendee;
168 168
 			}
169 169
 		}
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
              * @param  array $ids array of EE_Registration ids
182 182
              * @return  EE_Attendee[]
183 183
              */
184
-            public function get_array_of_contacts_from_reg_ids( $ids ) {
184
+            public function get_array_of_contacts_from_reg_ids($ids) {
185 185
                 $ids = (array) $ids;
186 186
                 $_where = array(
187
-                    'Registration.REG_ID' => array( 'in', $ids )
187
+                    'Registration.REG_ID' => array('in', $ids)
188 188
                     );
189
-                return $this->get_all( array( $_where ) );
189
+                return $this->get_all(array($_where));
190 190
             }
191 191
 
192 192
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@
 block discarded – undo
256 256
 	* 		@param	int	$TXN_ID
257 257
 	* 		@param    int		$ATT_ID
258 258
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
259
-	*		@return 		mixed		array on success, FALSE on fail
259
+	*		@return 		EE_Soft_Delete_Base_Class|null		array on success, FALSE on fail
260 260
 	*/
261 261
 	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
262 262
 		return $this->get_one(array(
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -555,10 +555,10 @@
 block discarded – undo
555 555
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
556 556
 	 	$status_array = array();
557 557
 	 	foreach ( $stati as $status ) {
558
-            $status_array[ $status->ID() ] = $status->get('STS_code');
559
-        }
560
-        return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
561
-    }
558
+			$status_array[ $status->ID() ] = $status->get('STS_code');
559
+		}
560
+		return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
561
+	}
562 562
 
563 563
 
564 564
 
Please login to merge, or discard this patch.
Braces   +129 added lines, -119 removed lines patch added patch discarded remove patch
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
498 498
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
499 499
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
500
-		}else{
500
+		} else{
501 501
 			return array();
502 502
 		}
503 503
 }
@@ -548,8 +548,9 @@  discard block
 block discarded – undo
548 548
 	 * @return array
549 549
 	 */
550 550
 	 public function status_array( $translated = FALSE ) {
551
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
552
-	 		return array();
551
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
552
+	 		 		return array();
553
+	 	}
553 554
 	 	$model_name = $this->get_this_model_name();
554 555
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
555 556
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -728,13 +729,13 @@  discard block
 block discarded – undo
728 729
 				$last_model_name = end( $models_to_follow_to_wp_users );
729 730
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
730 731
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
731
-			}else{
732
+			} else{
732 733
 				$model_with_fk_to_wp_users = $this;
733 734
 				$model_chain_to_wp_user = '';
734 735
 			}
735 736
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
736 737
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
737
-		}catch( EE_Error $e ) {
738
+		} catch( EE_Error $e ) {
738 739
 			return false;
739 740
 		}
740 741
 	}
@@ -762,11 +763,11 @@  discard block
 block discarded – undo
762 763
 	public function is_owned() {
763 764
 		if( $this->model_chain_to_wp_user() ){
764 765
 			return true;
765
-		}else{
766
+		} else{
766 767
 			try{
767 768
 				$this->get_foreign_key_to( 'WP_User' );
768 769
 				return true;
769
-			}catch( EE_Error $e ){
770
+			} catch( EE_Error $e ){
770 771
 				return false;
771 772
 			}
772 773
 		}
@@ -789,9 +790,9 @@  discard block
 block discarded – undo
789 790
 		//remember the custom selections, if any
790 791
 		if(is_array($columns_to_select)){
791 792
 			$this->_custom_selections = $columns_to_select;
792
-		}elseif(is_string($columns_to_select)){
793
+		} elseif(is_string($columns_to_select)){
793 794
 			$this->_custom_selections = array($this->_custom_selections);
794
-		}else{
795
+		} else{
795 796
 			$this->_custom_selections = array();
796 797
 		}
797 798
 
@@ -842,7 +843,7 @@  discard block
 block discarded – undo
842 843
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
843 844
 			}
844 845
 			$columns_to_select_string = implode(", ",$select_sql_array);
845
-		}else{
846
+		} else{
846 847
 			$columns_to_select_string = $columns_to_select;
847 848
 		}
848 849
 		return $columns_to_select_string;
@@ -870,10 +871,10 @@  discard block
 block discarded – undo
870 871
 	function get_one_by_ID($id){
871 872
 		if( $this->get_from_entity_map( $id ) ){
872 873
 			return $this->get_from_entity_map( $id );
873
-		}elseif( $this->has_primary_key_field ( ) ) {
874
+		} elseif( $this->has_primary_key_field ( ) ) {
874 875
 			$primary_key_name = $this->get_primary_key_field()->get_name();
875 876
 			return $this->get_one(array(array($primary_key_name => $id)));
876
-		}else{
877
+		} else{
877 878
 			//no primary key, so the $id must be from the get_index_primary_key_string()
878 879
 			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
879 880
 		}
@@ -895,7 +896,7 @@  discard block
 block discarded – undo
895 896
 		$items = $this->get_all($query_params);
896 897
 		if(empty($items)){
897 898
 			return null;
898
-		}else{
899
+		} else{
899 900
 			return array_shift($items);
900 901
 		}
901 902
 	}
@@ -1290,7 +1291,7 @@  discard block
 block discarded – undo
1290 1291
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1291 1292
 				if( $this->has_primary_key_field() ){
1292 1293
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1293
-				}else{
1294
+				} else{
1294 1295
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work)
1295 1296
 					$main_table_pk_value = null;
1296 1297
 				}
@@ -1329,7 +1330,7 @@  discard block
 block discarded – undo
1329 1330
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1330 1331
 			if( $this->has_primary_key_field() ){
1331 1332
 				$model_objs_affected_ids = $this->get_col( $query_params );
1332
-			}else{
1333
+			} else{
1333 1334
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1334 1335
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1335 1336
 				$model_objs_affected_ids = array();
@@ -1389,9 +1390,9 @@  discard block
 block discarded – undo
1389 1390
 
1390 1391
 		if( $field_to_select ){
1391 1392
 			$field = $this->field_settings_for( $field_to_select );
1392
-		}elseif( $this->has_primary_key_field ( ) ){
1393
+		} elseif( $this->has_primary_key_field ( ) ){
1393 1394
 			$field = $this->get_primary_key_field();
1394
-		}else{
1395
+		} else{
1395 1396
 			//no primary key, just grab the first column
1396 1397
 			$field = reset( $this->field_settings());
1397 1398
 		}
@@ -1415,7 +1416,7 @@  discard block
 block discarded – undo
1415 1416
 		$col = $this->get_col( $query_params, $field_to_select );
1416 1417
 		if( ! empty( $col ) ) {
1417 1418
 			return reset( $col );
1418
-		}else{
1419
+		} else{
1419 1420
 			return NULL;
1420 1421
 		}
1421 1422
 	}
@@ -1499,7 +1500,7 @@  discard block
 block discarded – undo
1499 1500
 
1500 1501
 			//		/echo "delete sql:$SQL";
1501 1502
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1502
-		}else{
1503
+		} else{
1503 1504
 			$rows_deleted = 0;
1504 1505
 		}
1505 1506
 
@@ -1541,7 +1542,7 @@  discard block
 block discarded – undo
1541 1542
 		//first, if $ignore_this_model_obj was supplied, get its model
1542 1543
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1543 1544
 			$ignored_model = $ignore_this_model_obj->get_model();
1544
-		}else{
1545
+		} else{
1545 1546
 			$ignored_model = null;
1546 1547
 		}
1547 1548
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1554,7 +1555,7 @@  discard block
 block discarded – undo
1554 1555
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1555 1556
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1556 1557
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1557
-				}else{
1558
+				} else{
1558 1559
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1559 1560
 				}
1560 1561
 
@@ -1591,24 +1592,28 @@  discard block
 block discarded – undo
1591 1592
 				}
1592 1593
 
1593 1594
 				//primary table deletes
1594
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1595
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1595
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1596
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1597
+				}
1596 1598
 
1597 1599
 				//other tables
1598 1600
 				if ( !empty( $other_tables ) ) {
1599 1601
 					foreach ( $other_tables as $ot ) {
1600 1602
 
1601 1603
 						//first check if we've got the foreign key column here.
1602
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1603
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1604
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1605
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1606
+						}
1604 1607
 
1605 1608
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1606
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1607
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1609
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1610
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1611
+						}
1608 1612
 
1609 1613
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1610
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1611
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1614
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1615
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1616
+						}
1612 1617
 					}
1613 1618
 				}
1614 1619
 			}
@@ -1621,7 +1626,7 @@  discard block
 block discarded – undo
1621 1626
 			}
1622 1627
 
1623 1628
 			return !empty($query) ? implode(' AND ', $query ) : '';
1624
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1629
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1625 1630
 			$ways_to_identify_a_row = array();
1626 1631
 			$fields = $this->get_combined_primary_key_fields();
1627 1632
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1633,7 +1638,7 @@  discard block
 block discarded – undo
1633 1638
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1634 1639
 			}
1635 1640
 			return implode(" OR ",$ways_to_identify_a_row);
1636
-		}else{
1641
+		} else{
1637 1642
 			//so there's no primary key and no combined key...
1638 1643
 			//sorry, can't help you
1639 1644
 			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)));
@@ -1655,10 +1660,10 @@  discard block
 block discarded – undo
1655 1660
 		if($field_to_count){
1656 1661
 			$field_obj = $this->field_settings_for($field_to_count);
1657 1662
 			$column_to_count = $field_obj->get_qualified_column();
1658
-		}elseif($this->has_primary_key_field ()){
1663
+		} elseif($this->has_primary_key_field ()){
1659 1664
 			$pk_field_obj = $this->get_primary_key_field();
1660 1665
 			$column_to_count = $pk_field_obj->get_qualified_column();
1661
-		}else{//there's no primary key
1666
+		} else{//there's no primary key
1662 1667
 			$column_to_count = '*';
1663 1668
 		}
1664 1669
 
@@ -1680,7 +1685,7 @@  discard block
 block discarded – undo
1680 1685
 		if($field_to_sum){
1681 1686
 			$field_obj = $this->field_settings_for($field_to_sum);
1682 1687
 
1683
-		}else{
1688
+		} else{
1684 1689
 			$field_obj = $this->get_primary_key_field();
1685 1690
 		}
1686 1691
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1689,7 +1694,7 @@  discard block
 block discarded – undo
1689 1694
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1690 1695
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1691 1696
 			return (float)$return_value;
1692
-		}else{//must be %f
1697
+		} else{//must be %f
1693 1698
 			return (float)$return_value;
1694 1699
 		}
1695 1700
 	}
@@ -1729,10 +1734,10 @@  discard block
 block discarded – undo
1729 1734
 			$wpdb->show_errors( $old_show_errors_value );
1730 1735
 			if( ! empty( $wpdb->last_error ) ){
1731 1736
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1732
-			}elseif( $result === false ){
1737
+			} elseif( $result === false ){
1733 1738
 				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 ) ) );
1734 1739
 			}
1735
-		}elseif( $result === false ) {
1740
+		} elseif( $result === false ) {
1736 1741
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1737 1742
 		}
1738 1743
 		return $result;
@@ -1946,7 +1951,7 @@  discard block
 block discarded – undo
1946 1951
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1947 1952
 		if( $results ){
1948 1953
 			return array_shift($results);
1949
-		}else{
1954
+		} else{
1950 1955
 			return null;
1951 1956
 		}
1952 1957
 
@@ -2017,7 +2022,7 @@  discard block
 block discarded – undo
2017 2022
 			 */
2018 2023
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2019 2024
 			return $new_id;
2020
-		}else{
2025
+		} else{
2021 2026
 			return FALSE;
2022 2027
 		}
2023 2028
 	}
@@ -2058,9 +2063,9 @@  discard block
 block discarded – undo
2058 2063
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2059 2064
 		if($obj_or_fields_array instanceof EE_Base_Class){
2060 2065
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2061
-		}elseif( is_array($obj_or_fields_array)){
2066
+		} elseif( is_array($obj_or_fields_array)){
2062 2067
 			$fields_n_values = $obj_or_fields_array;
2063
-		}else{
2068
+		} else{
2064 2069
 			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2065 2070
 		}
2066 2071
 		$query_params = array();
@@ -2076,7 +2081,7 @@  discard block
 block discarded – undo
2076 2081
 		//if there is nothing to base this search on, then we shouldn't find anything
2077 2082
 		if( empty( $query_params ) ){
2078 2083
 			return array();
2079
-		}else{
2084
+		} else{
2080 2085
 			return $this->get_one($query_params);
2081 2086
 		}
2082 2087
 	}
@@ -2149,12 +2154,12 @@  discard block
 block discarded – undo
2149 2154
 		if($this->has_primary_key_field()){
2150 2155
 			if($this->get_primary_key_field()->is_auto_increment()){
2151 2156
 				return $wpdb->insert_id;
2152
-			}else{
2157
+			} else{
2153 2158
 				//it's not an auto-increment primary key, so
2154 2159
 				//it must have been supplied
2155 2160
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2156 2161
 			}
2157
-		}else{
2162
+		} else{
2158 2163
 			//we can't return a  primary key because there is none. instead return
2159 2164
 			//a unique string indicating this model
2160 2165
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2202,7 +2207,7 @@  discard block
 block discarded – undo
2202 2207
 					//leave the value alone
2203 2208
 			}
2204 2209
 			return $value;
2205
-		}else{
2210
+		} else{
2206 2211
 			return $value;
2207 2212
 		}
2208 2213
 	}
@@ -2295,7 +2300,7 @@  discard block
 block discarded – undo
2295 2300
 		if(array_key_exists('group_by', $query_params)){
2296 2301
 			if(is_array($query_params['group_by'])){
2297 2302
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2298
-			}elseif( ! empty ( $query_params['group_by'] )){
2303
+			} elseif( ! empty ( $query_params['group_by'] )){
2299 2304
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2300 2305
 			}
2301 2306
 		}
@@ -2303,10 +2308,11 @@  discard block
 block discarded – undo
2303 2308
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2304 2309
 		}
2305 2310
 		if(array_key_exists('order_by', $query_params)){
2306
-			if ( is_array( $query_params['order_by'] ) )
2307
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2308
-			elseif( ! empty( $query_params['order_by'] ))
2309
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2311
+			if ( is_array( $query_params['order_by'] ) ) {
2312
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2313
+			} elseif( ! empty( $query_params['order_by'] )) {
2314
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2315
+			}
2310 2316
 		}
2311 2317
 		if(array_key_exists('force_join', $query_params)){
2312 2318
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -2338,10 +2344,10 @@  discard block
 block discarded – undo
2338 2344
 					if (! is_array($possibly_array_of_params)){
2339 2345
 						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"),
2340 2346
 							$param,$possibly_array_of_params));
2341
-					}else{
2347
+					} else{
2342 2348
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2343 2349
 					}
2344
-				}elseif($query_param_type === 0 //ie WHERE
2350
+				} elseif($query_param_type === 0 //ie WHERE
2345 2351
 						&& is_array($possibly_array_of_params)
2346 2352
 						&& isset($possibly_array_of_params[2])
2347 2353
 						&& $possibly_array_of_params[2] == true){
@@ -2401,7 +2407,7 @@  discard block
 block discarded – undo
2401 2407
 		}
2402 2408
 		if( isset( $query_params[0] ) ) {
2403 2409
 			$where_query_params = $query_params[0];
2404
-		}else{
2410
+		} else{
2405 2411
 			$where_query_params = array();
2406 2412
 		}
2407 2413
 		//first check if we should alter the query to account for caps or not
@@ -2419,7 +2425,7 @@  discard block
 block discarded – undo
2419 2425
 		}
2420 2426
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2421 2427
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2422
-		}else{
2428
+		} else{
2423 2429
 			$use_default_where_conditions = 'all';
2424 2430
 		}
2425 2431
 		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
@@ -2442,7 +2448,7 @@  discard block
 block discarded – undo
2442 2448
 				}
2443 2449
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2444 2450
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2445
-			}elseif( ! empty ( $query_params['limit'] )){
2451
+			} elseif( ! empty ( $query_params['limit'] )){
2446 2452
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2447 2453
 			}
2448 2454
 		}
@@ -2464,11 +2470,11 @@  discard block
 block discarded – undo
2464 2470
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2465 2471
 				}
2466 2472
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2467
-			}elseif( ! empty ( $query_params['order_by'] )){
2473
+			} elseif( ! empty ( $query_params['order_by'] )){
2468 2474
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2469 2475
 				if(isset($query_params['order'])){
2470 2476
 					$order = $this->_extract_order($query_params['order']);
2471
-				}else{
2477
+				} else{
2472 2478
 					$order = 'DESC';
2473 2479
 				}
2474 2480
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2491,7 +2497,7 @@  discard block
 block discarded – undo
2491 2497
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2492 2498
 				}
2493 2499
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2494
-			}elseif( ! empty ( $query_params['group_by'] )){
2500
+			} elseif( ! empty ( $query_params['group_by'] )){
2495 2501
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2496 2502
 			}
2497 2503
 		}
@@ -2515,8 +2521,9 @@  discard block
 block discarded – undo
2515 2521
 			}
2516 2522
 		}
2517 2523
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2518
-		if ( empty( $main_model_join_sql ) )
2519
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2524
+		if ( empty( $main_model_join_sql ) ) {
2525
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2526
+		}
2520 2527
 		return $query_object;
2521 2528
 	}
2522 2529
 
@@ -2549,7 +2556,7 @@  discard block
 block discarded – undo
2549 2556
 	private function _extract_order($should_be_order_string){
2550 2557
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2551 2558
 			return $should_be_order_string;
2552
-		}else{
2559
+		} else{
2553 2560
 			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));
2554 2561
 		}
2555 2562
 	}
@@ -2575,7 +2582,7 @@  discard block
 block discarded – undo
2575 2582
 		}
2576 2583
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2577 2584
 			$universal_query_params = $this->_get_default_where_conditions();
2578
-		}else{
2585
+		} else{
2579 2586
 			$universal_query_params = array();
2580 2587
 		}
2581 2588
 
@@ -2615,14 +2622,14 @@  discard block
 block discarded – undo
2615 2622
 		foreach($default_where_conditions as $key => $val){
2616 2623
 			if( isset($provided_where_conditions[$key])){
2617 2624
 				$none_overridden = false;
2618
-			}else{
2625
+			} else{
2619 2626
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2620 2627
 			}
2621 2628
 		}
2622 2629
 		if( $none_overridden && $default_where_conditions){
2623 2630
 			if($model->has_primary_key_field()){
2624 2631
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2625
-			}else{
2632
+			} else{
2626 2633
 				//@todo NO PK, use other defaults
2627 2634
 			}
2628 2635
 		}
@@ -2638,8 +2645,9 @@  discard block
 block discarded – undo
2638 2645
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2639 2646
 	 */
2640 2647
 	private function _get_default_where_conditions($model_relation_path = null){
2641
-		if ( $this->_ignore_where_strategy )
2642
-			return array();
2648
+		if ( $this->_ignore_where_strategy ) {
2649
+					return array();
2650
+		}
2643 2651
 
2644 2652
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2645 2653
 	}
@@ -2713,7 +2721,7 @@  discard block
 block discarded – undo
2713 2721
 		if(array_key_exists($query_param,$this_model_fields)){
2714 2722
 			if($allow_fields){
2715 2723
 				return;
2716
-			}else{
2724
+			} else{
2717 2725
 				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"),
2718 2726
 						$query_param,get_class($this),$query_param_type,$original_query_param));
2719 2727
 			}
@@ -2722,7 +2730,7 @@  discard block
 block discarded – undo
2722 2730
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2723 2731
 			if($allow_logic_query_params){
2724 2732
 				return;
2725
-			}else{
2733
+			} else{
2726 2734
 				throw new EE_Error(
2727 2735
 					sprintf(
2728 2736
 						__( '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' ),
@@ -2753,12 +2761,12 @@  discard block
 block discarded – undo
2753 2761
 					//we should actually end in a field name, not a model like this!
2754 2762
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2755 2763
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2756
-				}else{
2764
+				} else{
2757 2765
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2758 2766
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2759 2767
 					return;
2760 2768
 				}
2761
-			}elseif($query_param == $valid_related_model_name){
2769
+			} elseif($query_param == $valid_related_model_name){
2762 2770
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2763 2771
 				return;
2764 2772
 			}
@@ -2818,7 +2826,7 @@  discard block
 block discarded – undo
2818 2826
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2819 2827
 		if($SQL){
2820 2828
 			return " WHERE ". $SQL;
2821
-		}else{
2829
+		} else{
2822 2830
 			return '';
2823 2831
 		}
2824 2832
 	}
@@ -2833,7 +2841,7 @@  discard block
 block discarded – undo
2833 2841
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2834 2842
 		if($SQL){
2835 2843
 			return " HAVING ". $SQL;
2836
-		}else{
2844
+		} else{
2837 2845
 			return '';
2838 2846
 		}
2839 2847
 
@@ -2856,7 +2864,7 @@  discard block
 block discarded – undo
2856 2864
 			$model_instance=call_user_func($model_name."::instance");
2857 2865
 			/* @var $model_instance EEM_Base */
2858 2866
 			return $model_instance->field_settings_for($field_name);
2859
-		}else{
2867
+		} else{
2860 2868
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2861 2869
 		}
2862 2870
 	}
@@ -2889,14 +2897,14 @@  discard block
 block discarded – undo
2889 2897
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2890 2898
 						break;
2891 2899
 				}
2892
-			}else{
2900
+			} else{
2893 2901
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2894 2902
 
2895 2903
 				//if it's not a normal field, maybe it's a custom selection?
2896 2904
 				if( ! $field_obj){
2897 2905
 					if(isset( $this->_custom_selections[$query_param][1])){
2898 2906
 						$field_obj = $this->_custom_selections[$query_param][1];
2899
-					}else{
2907
+					} else{
2900 2908
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2901 2909
 					}
2902 2910
 				}
@@ -2906,7 +2914,7 @@  discard block
 block discarded – undo
2906 2914
 		}
2907 2915
 		if($where_clauses){
2908 2916
 			$SQL = implode($glue,$where_clauses);
2909
-		}else{
2917
+		} else{
2910 2918
 			$SQL = '';
2911 2919
 		}
2912 2920
 		return $SQL;
@@ -2926,11 +2934,11 @@  discard block
 block discarded – undo
2926 2934
 		if( $field ){
2927 2935
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2928 2936
 			return $table_alias_prefix . $field->get_qualified_column();
2929
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2937
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
2930 2938
 			//maybe it's custom selection item?
2931 2939
 			//if so, just use it as the "column name"
2932 2940
 			return $query_param;
2933
-		}else{
2941
+		} else{
2934 2942
 			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)));
2935 2943
 		}
2936 2944
 	}
@@ -2947,7 +2955,7 @@  discard block
 block discarded – undo
2947 2955
 		$pos_of_star = strpos($condition_query_param_key, '*');
2948 2956
 		if($pos_of_star === FALSE){
2949 2957
 			return $condition_query_param_key;
2950
-		}else{
2958
+		} else{
2951 2959
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2952 2960
 			return $condition_query_param_sans_star;
2953 2961
 		}
@@ -2973,7 +2981,7 @@  discard block
 block discarded – undo
2973 2981
 				throw new EE_Error(sprintf(__("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))", "event_espresso"), implode(",",$php_array_like_string)));
2974 2982
 			}
2975 2983
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2976
-		}else{
2984
+		} else{
2977 2985
 			$operator = '=';
2978 2986
 			$value = $op_and_value;
2979 2987
 		}
@@ -2981,7 +2989,7 @@  discard block
 block discarded – undo
2981 2989
 		//check to see if the value is actually another field
2982 2990
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2983 2991
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2984
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2992
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2985 2993
 			//in this case, the value should be an array, or at least a comma-separated list
2986 2994
 			//it will need to handle a little differently
2987 2995
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -2989,8 +2997,9 @@  discard block
 block discarded – undo
2989 2997
 			return $operator.SP.$cleaned_value;
2990 2998
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2991 2999
 			//the value should be an array with count of two.
2992
-			if ( count($value) !== 2 )
2993
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3000
+			if ( count($value) !== 2 ) {
3001
+							throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3002
+			}
2994 3003
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2995 3004
 			return $operator.SP.$cleaned_value;
2996 3005
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -2998,17 +3007,17 @@  discard block
 block discarded – undo
2998 3007
 				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
2999 3008
 			}
3000 3009
 			return $operator;
3001
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3010
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
3002 3011
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3003 3012
 			//remove other junk. So just treat it as a string.
3004 3013
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3005
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3014
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3006 3015
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3007
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3016
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3008 3017
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3009
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3018
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3010 3019
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3011
-		}else{
3020
+		} else{
3012 3021
 			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3013 3022
 		}
3014 3023
 	}
@@ -3078,7 +3087,7 @@  discard block
 block discarded – undo
3078 3087
 		global $wpdb;
3079 3088
 		if($field_obj instanceof EE_Model_Field_Base){
3080 3089
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3081
-		}else{//$field_obj should really just be a data type
3090
+		} else{//$field_obj should really just be a data type
3082 3091
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3083 3092
 				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)));
3084 3093
 			}
@@ -3107,14 +3116,14 @@  discard block
 block discarded – undo
3107 3116
 		if($number_of_parts == 1){
3108 3117
 			$field_name = $last_query_param_part;
3109 3118
 			$model_obj = $this;
3110
-		}else{// $number_of_parts >= 2
3119
+		} else{// $number_of_parts >= 2
3111 3120
 			//the last part is the column name, and there are only 2parts. therefore...
3112 3121
 			$field_name = $last_query_param_part;
3113 3122
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3114 3123
 		}
3115 3124
 		try{
3116 3125
 			return $model_obj->field_settings_for($field_name);
3117
-		}catch(EE_Error $e){
3126
+		} catch(EE_Error $e){
3118 3127
 			return null;
3119 3128
 		}
3120 3129
 	}
@@ -3133,7 +3142,7 @@  discard block
 block discarded – undo
3133 3142
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3134 3143
 		if($field){
3135 3144
 			return $field->get_qualified_column();
3136
-		}else{
3145
+		} else{
3137 3146
 			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)));
3138 3147
 		}
3139 3148
 	}
@@ -3199,7 +3208,7 @@  discard block
 block discarded – undo
3199 3208
 					//the FROM statement, BUT the primary table isn't. So we want
3200 3209
 					//to add the inverse join sql
3201 3210
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3202
-				}else{
3211
+				} else{
3203 3212
 					//just add a regular JOIN to this table from the primary table
3204 3213
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3205 3214
 				}
@@ -3314,7 +3323,7 @@  discard block
 block discarded – undo
3314 3323
 		$fieldSettings = $this->field_settings(true);
3315 3324
 		if( isset($fieldSettings[$fieldName])){
3316 3325
 			return true;
3317
-		}else{
3326
+		} else{
3318 3327
 			return false;
3319 3328
 		}
3320 3329
 	}
@@ -3328,7 +3337,7 @@  discard block
 block discarded – undo
3328 3337
 		$relations = $this->relation_settings();
3329 3338
 		if(isset($relations[$relation_name])){
3330 3339
 			return true;
3331
-		}else{
3340
+		} else{
3332 3341
 			return false;
3333 3342
 		}
3334 3343
 	}
@@ -3379,7 +3388,7 @@  discard block
 block discarded – undo
3379 3388
 			try{
3380 3389
 				$this->get_primary_key_field();
3381 3390
 				$this->_has_primary_key_field = true;
3382
-			}catch(EE_Error $e){
3391
+			} catch(EE_Error $e){
3383 3392
 				$this->_has_primary_key_field = false;
3384 3393
 			}
3385 3394
 		}
@@ -3458,7 +3467,7 @@  discard block
 block discarded – undo
3458 3467
 				}
3459 3468
 			}
3460 3469
 			return $this->_cached_fields;
3461
-		}else{
3470
+		} else{
3462 3471
 			if( $this->_cached_fields_non_db_only === NULL ){
3463 3472
 				$this->_cached_fields_non_db_only = array();
3464 3473
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3574,7 +3583,7 @@  discard block
 block discarded – undo
3574 3583
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3575 3584
 				return NULL;
3576 3585
 			}
3577
-		}else if($this->unique_indexes()){
3586
+		} else if($this->unique_indexes()){
3578 3587
 			$first_column = reset($this_model_fields_n_values);
3579 3588
 			if(empty($first_column)){
3580 3589
 				return NULL;
@@ -3589,7 +3598,7 @@  discard block
 block discarded – undo
3589 3598
 				// add this new object to the entity map
3590 3599
 				$classInstance = $this->add_to_entity_map( $classInstance );
3591 3600
 			}
3592
-		}else{
3601
+		} else{
3593 3602
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3594 3603
 		}
3595 3604
 
@@ -3676,11 +3685,12 @@  discard block
 block discarded – undo
3676 3685
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3677 3686
 					}
3678 3687
 				}
3679
-			}else{
3688
+			} else{
3680 3689
 				//the table's rows existed. Use their values
3681 3690
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3682
-					if( ! $field_obj->is_db_only_field() )
3683
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3691
+					if( ! $field_obj->is_db_only_field() ) {
3692
+										$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3693
+					}
3684 3694
 				}
3685 3695
 			}
3686 3696
 		}
@@ -3694,9 +3704,9 @@  discard block
 block discarded – undo
3694 3704
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
3695 3705
 			$value = $cols_n_values[ $qualified_column ];
3696 3706
 
3697
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3707
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
3698 3708
 			$value = $cols_n_values[ $regular_column ];
3699
-		}else{
3709
+		} else{
3700 3710
 			$value = NULL;
3701 3711
 		}
3702 3712
 
@@ -3729,7 +3739,7 @@  discard block
 block discarded – undo
3729 3739
 				}
3730 3740
 			}
3731 3741
 			return $obj_in_map;
3732
-		}else{
3742
+		} else{
3733 3743
 			return $this->get_one_by_ID( $id );
3734 3744
 		}
3735 3745
 	}
@@ -3764,7 +3774,7 @@  discard block
 block discarded – undo
3764 3774
 				}
3765 3775
 			}
3766 3776
 			return $obj_in_map;
3767
-		}else{
3777
+		} else{
3768 3778
 			$this->add_to_entity_map( $replacing_model_obj );
3769 3779
 			return $replacing_model_obj;
3770 3780
 		}
@@ -3794,7 +3804,7 @@  discard block
 block discarded – undo
3794 3804
 	public function item_name($quantity = 1){
3795 3805
 		if($quantity == 1){
3796 3806
 			return $this->singular_item;
3797
-		}else{
3807
+		} else{
3798 3808
 			return $this->plural_item;
3799 3809
 		}
3800 3810
 	}
@@ -3856,14 +3866,14 @@  discard block
 block discarded – undo
3856 3866
 		$primary_key_field = $this->get_primary_key_field();
3857 3867
 		if( $base_class_obj_or_id instanceof $className ){
3858 3868
 			$model_object = $base_class_obj_or_id;
3859
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3869
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3860 3870
 				is_int( $base_class_obj_or_id ) ||
3861 3871
 				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3862 3872
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3863
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3873
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3864 3874
 			//assume its a string representation of the object
3865 3875
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3866
-		}else{
3876
+		} else{
3867 3877
 			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)));
3868 3878
 		}
3869 3879
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -3887,13 +3897,13 @@  discard block
 block discarded – undo
3887 3897
 		if( $base_class_obj_or_id instanceof $className ){
3888 3898
 			/** @var $base_class_obj_or_id EE_Base_Class */
3889 3899
 			$id = $base_class_obj_or_id->ID();
3890
-		}elseif(is_int($base_class_obj_or_id)){
3900
+		} elseif(is_int($base_class_obj_or_id)){
3891 3901
 			//assume it's an ID
3892 3902
 			$id = $base_class_obj_or_id;
3893
-		}elseif(is_string($base_class_obj_or_id)){
3903
+		} elseif(is_string($base_class_obj_or_id)){
3894 3904
 			//assume its a string representation of the object
3895 3905
 			$id = $base_class_obj_or_id;
3896
-		}else{
3906
+		} else{
3897 3907
 			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)));
3898 3908
 		}
3899 3909
 		return $id;
@@ -4024,9 +4034,9 @@  discard block
 block discarded – undo
4024 4034
 
4025 4035
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4026 4036
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4027
-		}elseif(is_array($model_object_or_attributes_array)){
4037
+		} elseif(is_array($model_object_or_attributes_array)){
4028 4038
 			$attributes_array = $model_object_or_attributes_array;
4029
-		}else{
4039
+		} else{
4030 4040
 			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));
4031 4041
 		}
4032 4042
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4036,7 +4046,7 @@  discard block
 block discarded – undo
4036 4046
 		}
4037 4047
 		if(isset($query_params[0])){
4038 4048
 			$query_params[0] = array_merge($attributes_array,$query_params);
4039
-		}else{
4049
+		} else{
4040 4050
 			$query_params[0] = $attributes_array;
4041 4051
 		}
4042 4052
 		return $this->get_all($query_params);
@@ -4059,7 +4069,7 @@  discard block
 block discarded – undo
4059 4069
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4060 4070
 		if(is_array($copies)){
4061 4071
 			return array_shift($copies);
4062
-		}else{
4072
+		} else{
4063 4073
 			return null;
4064 4074
 		}
4065 4075
 	}
@@ -4091,7 +4101,7 @@  discard block
 block discarded – undo
4091 4101
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4092 4102
 		if($sql_operator){
4093 4103
 			return $sql_operator;
4094
-		}else{
4104
+		} else{
4095 4105
 			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))));
4096 4106
 		}
4097 4107
 	}
@@ -4262,7 +4272,7 @@  discard block
 block discarded – undo
4262 4272
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4263 4273
 		if( in_array( $context, $valid_cap_contexts ) ) {
4264 4274
 			return true;
4265
-		}else{
4275
+		} else{
4266 4276
 			throw new EE_Error(
4267 4277
 				sprintf(
4268 4278
 					__( '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
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 	 * Returns the name of the field's name that points to the WP_User table
745 745
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
746 746
 	 * foreign key to the WP_User table)
747
-	 * @return string|boolean string on success, boolean false when there is no
747
+	 * @return string|false string on success, boolean false when there is no
748 748
 	 * foreign key to the WP_User table
749 749
 	 */
750 750
 	function wp_user_field_name() {
@@ -840,6 +840,7 @@  discard block
 block discarded – undo
840 840
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
841 841
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
842 842
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
843
+	 * @param string $columns_to_select
843 844
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
844 845
 	 */
845 846
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1333,7 +1334,7 @@  discard block
 block discarded – undo
1333 1334
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1334 1335
 	 * Wrapper for EEM_Base::delete()
1335 1336
 	 * @param mixed $id
1336
-	 * @return boolean whether the row got deleted or not
1337
+	 * @return integer whether the row got deleted or not
1337 1338
 	 */
1338 1339
 	public function delete_by_ID( $id ){
1339 1340
 		return $this->delete( array(
@@ -1453,7 +1454,7 @@  discard block
 block discarded – undo
1453 1454
 
1454 1455
 	/**
1455 1456
 	 * This sets up our delete where sql and accounts for if we have secondary tables that will have rows deleted as well.
1456
-	 * @param  array  $objects_for_deletion This should be the values returned by $this->_get_all_wpdb_results()
1457
+	 * @param  stdClass[]  $objects_for_deletion This should be the values returned by $this->_get_all_wpdb_results()
1457 1458
 	 * @param boolean $allow_blocking       if TRUE, matched objects will only be deleted if there is no related model info
1458 1459
 	 * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
1459 1460
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
@@ -1666,7 +1667,6 @@  discard block
 block discarded – undo
1666 1667
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1667 1668
 	 * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table
1668 1669
 	 *
1669
-	 * @param EE_Base_Class/int $thisModelObject
1670 1670
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1671 1671
 	 * @param string $relationName, key in EEM_Base::_relations
1672 1672
 	 * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id')
@@ -1688,8 +1688,8 @@  discard block
 block discarded – undo
1688 1688
 	 *
1689 1689
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
1690 1690
 	 *
1691
-	 * @param EE_Base_Class/int $id_or_obj
1692
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1691
+	 * @param EE_CPT_Base $id_or_obj
1692
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1693 1693
 	 * @param string $relationName key in EEM_Base::_relations
1694 1694
 	 * @return boolean of success
1695 1695
 	 * @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.
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 	/**
1766 1766
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
1767 1767
 	 * unless otherwise specified in the $query_params
1768
-	 * @param int/EE_Base_Class $id_or_obj
1768
+	 * @param EE_Event $id_or_obj
1769 1769
 	 * @param string $model_name like 'Event', or 'Registration'
1770 1770
 	 * @param array $query_params like EEM_Base::get_all's
1771 1771
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
 	/**
2154 2154
 	 * Finds all the fields that correspond to the given table
2155 2155
 	 * @param string $table_alias, array key in EEM_Base::_tables
2156
-	 * @return EE_Model_Field_Base[]
2156
+	 * @return EE_Model_Field_Base
2157 2157
 	 */
2158 2158
 	function _get_fields_for_table($table_alias){
2159 2159
 		return $this->_fields[$table_alias];
@@ -3215,8 +3215,8 @@  discard block
 block discarded – undo
3215 3215
 	/**
3216 3216
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3217 3217
 	 * Eg, on EE_Answer that would be ANS_ID field object
3218
-	 * @param $field_obj
3219
-	 * @return EE_Model_Field_Base
3218
+	 * @param EE_Model_Field_Base $field_obj
3219
+	 * @return boolean
3220 3220
 	 */
3221 3221
 	public function is_primary_key_field( $field_obj ){
3222 3222
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3310,7 +3310,7 @@  discard block
 block discarded – undo
3310 3310
 	 * Gets the actual table for the table alias
3311 3311
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3312 3312
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3313
-	 * @return EE_Table_Base
3313
+	 * @return string
3314 3314
 	 */
3315 3315
 	function get_table_for_alias($table_alias){
3316 3316
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3410,7 +3410,7 @@  discard block
 block discarded – undo
3410 3410
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3411 3411
 	 * A typical example of where this is used is when creating a new item and the initial load of a form.  We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!).
3412 3412
 	 *
3413
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3413
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3414 3414
 	 */
3415 3415
 	public function create_default_object() {
3416 3416
 
@@ -3430,7 +3430,7 @@  discard block
 block discarded – undo
3430 3430
 
3431 3431
 	/**
3432 3432
 	 * _get_cached_acceptable_table_columns
3433
-	 * @return EE_Model_Field_Base[]|null
3433
+	 * @return EE_Model_Field_Base[]
3434 3434
 	 */
3435 3435
 	private function _get_cached_acceptable_table_columns(){
3436 3436
 		if( $this->_model_fields_sorted_by_db_col === NULL ){
@@ -3580,6 +3580,9 @@  discard block
 block discarded – undo
3580 3580
 		return $this_model_fields_n_values;
3581 3581
 	}
3582 3582
 
3583
+	/**
3584
+	 * @param string $cols_n_values
3585
+	 */
3583 3586
 	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3584 3587
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3585 3588
 		//does the field on the model relate to this column retrieved from the db?
@@ -3815,7 +3818,7 @@  discard block
 block discarded – undo
3815 3818
 	}
3816 3819
 	/**
3817 3820
 	 * Read comments for assume_values_already_prepared_by_model_object()
3818
-	 * @return int
3821
+	 * @return boolean
3819 3822
 	 */
3820 3823
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
3821 3824
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Spacing   +886 added lines, -886 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
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * Flag indicating whether this model has a primary key or not
229 229
 	 * @var boolean
230 230
 	 */
231
-	protected $_has_primary_key_field=null;
231
+	protected $_has_primary_key_field = null;
232 232
 
233 233
 	/**
234 234
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
284 284
 	 * @var array
285 285
 	 */
286
-	protected $_between_style_operators = array( 'BETWEEN' );
286
+	protected $_between_style_operators = array('BETWEEN');
287 287
 
288 288
 	/**
289 289
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
290 290
 	 * @var array
291 291
 	 */
292
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
292
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
293 293
 
294 294
 	/**
295 295
 	 * Allowed values for $query_params['order'] for ordering in queries
296 296
 	 * @var array
297 297
 	 */
298
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
298
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
299 299
 
300 300
 	/**
301 301
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
310 310
 	 * @var array
311 311
 	 */
312
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
312
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
313 313
 
314 314
 	/**
315 315
 	 * All the data types that can be used in $wpdb->prepare statements.
316 316
 	 * @var array
317 317
 	 */
318
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
318
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
319 319
 
320 320
 	/**
321 321
 	 * 	EE_Registry Object
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 	 * @param null $timezone
374 374
 	 * @throws \EE_Error
375 375
 	 */
376
-	protected function __construct( $timezone = NULL ){
376
+	protected function __construct($timezone = NULL) {
377 377
 		// check that the model has not been loaded too soon
378
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
379
-			throw new EE_Error (
378
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
379
+			throw new EE_Error(
380 380
 				sprintf(
381
-					__( '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' ),
382
-					get_class( $this )
381
+					__('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'),
382
+					get_class($this)
383 383
 				)
384 384
 			);
385 385
 		}
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 		 * just use EE_Register_Model_Extension
390 390
 		 * @var EE_Table_Base[] $_tables
391 391
 		 */
392
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
393
-		foreach($this->_tables as $table_alias => $table_obj){
392
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
393
+		foreach ($this->_tables as $table_alias => $table_obj) {
394 394
 			/** @var $table_obj EE_Table_Base */
395 395
 			$table_obj->_construct_finalize_with_alias($table_alias);
396
-			if( $table_obj instanceof EE_Secondary_Table ){
396
+			if ($table_obj instanceof EE_Secondary_Table) {
397 397
 				/** @var $table_obj EE_Secondary_Table */
398 398
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
399 399
 			}
@@ -403,48 +403,48 @@  discard block
 block discarded – undo
403 403
 		 * EE_Register_Model_Extension
404 404
 		 * @param EE_Model_Field_Base[] $_fields
405 405
 		 */
406
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
407
-		foreach($this->_fields as $table_alias => $fields_for_table){
408
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
409
-				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)));
406
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
407
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
408
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
409
+				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)));
410 410
 			}
411
-			foreach($fields_for_table as $field_name => $field_obj){
411
+			foreach ($fields_for_table as $field_name => $field_obj) {
412 412
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
413 413
 				//primary key field base has a slightly different _construct_finalize
414 414
 				/** @var $field_obj EE_Model_Field_Base */
415
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
415
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
416 416
 			}
417 417
 		}
418 418
 
419 419
 		// everything is related to Extra_Meta
420
-		if( get_class($this) != 'EEM_Extra_Meta'){
420
+		if (get_class($this) != 'EEM_Extra_Meta') {
421 421
 			//make extra meta related to everything, but don't block deleting things just
422 422
 			//because they have related extra meta info. For now just orphan those extra meta
423 423
 			//in the future we should automatically delete them
424
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
424
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
425 425
 		}
426 426
 		//and change logs
427
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
428
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
427
+		if (get_class($this) != 'EEM_Change_Log') {
428
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
429 429
 		}
430 430
 		/**
431 431
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
432 432
 		 * EE_Register_Model_Extension
433 433
 		 * @param EE_Model_Relation_Base[] $_model_relations
434 434
 		 */
435
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
436
-		foreach($this->_model_relations as $model_name => $relation_obj){
435
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
436
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
437 437
 			/** @var $relation_obj EE_Model_Relation_Base */
438 438
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
439 439
 		}
440
-		foreach($this->_indexes as $index_name => $index_obj){
440
+		foreach ($this->_indexes as $index_name => $index_obj) {
441 441
 			/** @var $index_obj EE_Index */
442 442
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
443 443
 		}
444 444
 
445 445
 		$this->set_timezone($timezone);
446 446
 		//finalize default where condition strategy, or set default
447
-		if( ! $this->_default_where_conditions_strategy){
447
+		if ( ! $this->_default_where_conditions_strategy) {
448 448
 			//nothing was set during child constructor, so set default
449 449
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
450 450
 		}
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
 
453 453
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
454 454
 		//to indicate to NOT set it, set it to the logical default
455
-		if( $this->_caps_slug === null ) {
456
-			EE_Registry::instance()->load_helper( 'Inflector' );
457
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
455
+		if ($this->_caps_slug === null) {
456
+			EE_Registry::instance()->load_helper('Inflector');
457
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
458 458
 		}
459 459
 		//initialize the standard cap restriction generators if none were specified by the child constructor
460
-		if( $this->_cap_restriction_generators !== false ){
461
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
462
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
463
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
460
+		if ($this->_cap_restriction_generators !== false) {
461
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
462
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
463
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
464 464
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
465 465
 						new EE_Restriction_Generator_Protected(),
466 466
 						$cap_context,
@@ -470,23 +470,23 @@  discard block
 block discarded – undo
470 470
 			}
471 471
 		}
472 472
 		//if there are cap restriction generators, use them to make the default cap restrictions
473
-		if( $this->_cap_restriction_generators !== false ){
474
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
475
-				if( ! $generator_object ){
473
+		if ($this->_cap_restriction_generators !== false) {
474
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
475
+				if ( ! $generator_object) {
476 476
 					continue;
477 477
 				}
478
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
478
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
479 479
 					throw new EE_Error(
480 480
 						sprintf(
481
-							__( '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' ),
481
+							__('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'),
482 482
 							$context,
483 483
 							$this->get_this_model_name()
484 484
 						)
485 485
 					);
486 486
 				}
487
-				$action = $this->cap_action_for_context( $context );
488
-				if( ! $generator_object->construction_finalized() ){
489
-					$generator_object->_construct_finalize( $this, $action );
487
+				$action = $this->cap_action_for_context($context);
488
+				if ( ! $generator_object->construction_finalized()) {
489
+					$generator_object->_construct_finalize($this, $action);
490 490
 				}
491 491
 
492 492
 			}
@@ -500,11 +500,11 @@  discard block
 block discarded – undo
500 500
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
501 501
 	 * @return EE_Default_Where_Conditions[]
502 502
 	 */
503
-	protected function _generate_cap_restrictions( $context ){
504
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
505
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
506
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
507
-		}else{
503
+	protected function _generate_cap_restrictions($context) {
504
+		if (isset($this->_cap_restriction_generators[$context]) &&
505
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
506
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
507
+		} else {
508 508
 			return array();
509 509
 		}
510 510
 }
@@ -516,20 +516,20 @@  discard block
 block discarded – undo
516 516
 	 * This sets the _timezone property after model object has been instantiated.
517 517
 	 * @param string $timezone valid PHP DateTimeZone timezone string
518 518
 	 */
519
-	public function set_timezone( $timezone ) {
520
-		if($timezone !== NULL){
519
+	public function set_timezone($timezone) {
520
+		if ($timezone !== NULL) {
521 521
 			$this->_timezone = $timezone;
522 522
 		}
523 523
 
524 524
 		//note we need to loop through relations and set the timezone on those objects as well.
525
-		foreach ( $this->_model_relations as $relation ) {
525
+		foreach ($this->_model_relations as $relation) {
526 526
 			$relation->set_timezone($timezone);
527 527
 		}
528 528
 
529 529
 		//and finally we do the same for any datetime fields
530
-		foreach ( $this->_fields as $field ) {
531
-			if ( $field instanceof EE_Datetime_Field ) {
532
-				$field->set_timezone( $timezone );
530
+		foreach ($this->_fields as $field) {
531
+			if ($field instanceof EE_Datetime_Field) {
532
+				$field->set_timezone($timezone);
533 533
 			}
534 534
 		}
535 535
 	}
@@ -541,16 +541,16 @@  discard block
 block discarded – undo
541 541
 	 *		@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)
542 542
 	 *		@return static (as in the concrete child class)
543 543
 	 */
544
-	public static function instance( $timezone = NULL ){
544
+	public static function instance($timezone = NULL) {
545 545
 
546 546
 		// check if instance of Espresso_model already exists
547 547
 		if ( ! static::$_instance instanceof static) {
548 548
 			// instantiate Espresso_model
549
-			static::$_instance = new static( $timezone );
549
+			static::$_instance = new static($timezone);
550 550
 		}
551 551
 
552 552
 		//we might have a timezone set, let set_timezone decide what to do with it
553
-		static::$_instance->set_timezone( $timezone );
553
+		static::$_instance->set_timezone($timezone);
554 554
 
555 555
 		// Espresso_model object
556 556
 		return static::$_instance;
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	 * resets the model and returns it
563 563
 	 * @return static
564 564
 	 */
565
-	public static function reset(  $timezone = NULL ){
566
-		if ( ! is_null( static::$_instance ) ) {
565
+	public static function reset($timezone = NULL) {
566
+		if ( ! is_null(static::$_instance)) {
567 567
 			static::$_instance = null;
568 568
 
569
-			return self::instance( $timezone );
569
+			return self::instance($timezone);
570 570
 		}
571 571
 		return null;
572 572
 	}
@@ -577,15 +577,15 @@  discard block
 block discarded – undo
577 577
 	 * @param  boolean $translated return localized strings or JUST the array.
578 578
 	 * @return array
579 579
 	 */
580
-	 public function status_array( $translated = FALSE ) {
581
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
580
+	 public function status_array($translated = FALSE) {
581
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
582 582
 	 		return array();
583 583
 	 	$model_name = $this->get_this_model_name();
584
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
585
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
584
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
585
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
586 586
 	 	$status_array = array();
587
-	 	foreach ( $stati as $status ) {
588
-            $status_array[ $status->ID() ] = $status->get('STS_code');
587
+	 	foreach ($stati as $status) {
588
+            $status_array[$status->ID()] = $status->get('STS_code');
589 589
         }
590 590
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
591 591
     }
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	 *			'order_by'=>array('ANS_value'=>'ASC')
727 727
 	 *		));
728 728
 	 */
729
-	function get_all($query_params = array()){
729
+	function get_all($query_params = array()) {
730 730
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
731 731
 	}
732 732
 
@@ -736,10 +736,10 @@  discard block
 block discarded – undo
736 736
 	 * @param array $query_parms @see EEM_Base::get_all()
737 737
 	 * @return array like EEM_Base::get_all
738 738
 	 */
739
-	function alter_query_params_to_only_include_mine( $query_parms = array() ) {
739
+	function alter_query_params_to_only_include_mine($query_parms = array()) {
740 740
 		$wp_user_field_name = $this->wp_user_field_name();
741
-		if( $wp_user_field_name ){
742
-			$query_parms[0][ $wp_user_field_name ] = get_current_user_id();
741
+		if ($wp_user_field_name) {
742
+			$query_parms[0][$wp_user_field_name] = get_current_user_id();
743 743
 		}
744 744
 		return $query_parms;
745 745
 	}
@@ -752,19 +752,19 @@  discard block
 block discarded – undo
752 752
 	 * foreign key to the WP_User table
753 753
 	 */
754 754
 	function wp_user_field_name() {
755
-		try{
756
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
757
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
758
-				$last_model_name = end( $models_to_follow_to_wp_users );
759
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
760
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
761
-			}else{
755
+		try {
756
+			if ( ! empty($this->_model_chain_to_wp_user)) {
757
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
758
+				$last_model_name = end($models_to_follow_to_wp_users);
759
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
760
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
761
+			} else {
762 762
 				$model_with_fk_to_wp_users = $this;
763 763
 				$model_chain_to_wp_user = '';
764 764
 			}
765
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
766
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
767
-		}catch( EE_Error $e ) {
765
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
766
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
767
+		} catch (EE_Error $e) {
768 768
 			return false;
769 769
 		}
770 770
 	}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	 * (or transietly-related model)
779 779
 	 * @return string
780 780
 	 */
781
-	public function model_chain_to_wp_user(){
781
+	public function model_chain_to_wp_user() {
782 782
 		return $this->_model_chain_to_wp_user;
783 783
 	}
784 784
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	 * @return boolean
791 791
 	 */
792 792
 	public function is_owned() {
793
-		if( $this->model_chain_to_wp_user() ){
793
+		if ($this->model_chain_to_wp_user()) {
794 794
 			return true;
795
-		}else{
796
-			try{
797
-				$this->get_foreign_key_to( 'WP_User' );
795
+		} else {
796
+			try {
797
+				$this->get_foreign_key_to('WP_User');
798 798
 				return true;
799
-			}catch( EE_Error $e ){
799
+			} catch (EE_Error $e) {
800 800
 				return false;
801 801
 			}
802 802
 		}
@@ -815,21 +815,21 @@  discard block
 block discarded – undo
815 815
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
816 816
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
817 817
 	 */
818
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
818
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
819 819
 		//remember the custom selections, if any
820
-		if(is_array($columns_to_select)){
820
+		if (is_array($columns_to_select)) {
821 821
 			$this->_custom_selections = $columns_to_select;
822
-		}elseif(is_string($columns_to_select)){
822
+		}elseif (is_string($columns_to_select)) {
823 823
 			$this->_custom_selections = array($this->_custom_selections);
824
-		}else{
824
+		} else {
825 825
 			$this->_custom_selections = array();
826 826
 		}
827 827
 
828 828
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
829 829
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
830
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
830
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
831 831
 //		echo "sql:$SQL";
832
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
832
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
833 833
 		return $results;
834 834
 	}
835 835
 
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
847 847
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
848 848
 	 */
849
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
849
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
850 850
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
851 851
 	}
852 852
 
@@ -858,21 +858,21 @@  discard block
 block discarded – undo
858 858
 	 * @throws EE_Error
859 859
 	 * @return string
860 860
 	 */
861
-	private function _construct_select_from_input($columns_to_select){
862
-		if(is_array($columns_to_select)){
861
+	private function _construct_select_from_input($columns_to_select) {
862
+		if (is_array($columns_to_select)) {
863 863
 			$select_sql_array = array();
864 864
 
865
-			foreach($columns_to_select as $alias => $selection_and_datatype){
866
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
867
-					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"),$selection_and_datatype,$alias));
865
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
866
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
867
+					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"), $selection_and_datatype, $alias));
868 868
 				}
869
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
870
-					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"),$selection_and_datatype[1],$selection_and_datatype[0],$alias,implode(",",$this->_valid_wpdb_data_types)));
869
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
870
+					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"), $selection_and_datatype[1], $selection_and_datatype[0], $alias, implode(",", $this->_valid_wpdb_data_types)));
871 871
 				}
872 872
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
873 873
 			}
874
-			$columns_to_select_string = implode(", ",$select_sql_array);
875
-		}else{
874
+			$columns_to_select_string = implode(", ", $select_sql_array);
875
+		} else {
876 876
 			$columns_to_select_string = $columns_to_select;
877 877
 		}
878 878
 		return $columns_to_select_string;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
886 886
 	 * @return string
887 887
 	 */
888
-	function primary_key_name(){
888
+	function primary_key_name() {
889 889
 		return $this->get_primary_key_field()->get_name();
890 890
 	}
891 891
 
@@ -897,15 +897,15 @@  discard block
 block discarded – undo
897 897
 	 * @param mixed $id int or string, depending on the type of the model's primary key
898 898
 	 * @return EE_Base_Class
899 899
 	 */
900
-	function get_one_by_ID($id){
901
-		if( $this->get_from_entity_map( $id ) ){
902
-			return $this->get_from_entity_map( $id );
903
-		}elseif( $this->has_primary_key_field ( ) ) {
900
+	function get_one_by_ID($id) {
901
+		if ($this->get_from_entity_map($id)) {
902
+			return $this->get_from_entity_map($id);
903
+		}elseif ($this->has_primary_key_field( )) {
904 904
 			$primary_key_name = $this->get_primary_key_field()->get_name();
905 905
 			return $this->get_one(array(array($primary_key_name => $id)));
906
-		}else{
906
+		} else {
907 907
 			//no primary key, so the $id must be from the get_index_primary_key_string()
908
-			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
908
+			return $this->get_one(array($this->parse_index_primary_key_string($id)));
909 909
 		}
910 910
 	}
911 911
 
@@ -916,16 +916,16 @@  discard block
 block discarded – undo
916 916
 	 * @param array $query_params like EEM_Base's $query_params variable.
917 917
 	 * @return EE_Base_Class | NULL
918 918
 	 */
919
-	function get_one($query_params = array()){
920
-		if( ! is_array( $query_params ) ){
921
-			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' );
919
+	function get_one($query_params = array()) {
920
+		if ( ! is_array($query_params)) {
921
+			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');
922 922
 			$query_params = array();
923 923
 		}
924 924
 		$query_params['limit'] = 1;
925 925
 		$items = $this->get_all($query_params);
926
-		if(empty($items)){
926
+		if (empty($items)) {
927 927
 			return null;
928
-		}else{
928
+		} else {
929 929
 			return array_shift($items);
930 930
 		}
931 931
 	}
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 *
950 950
 	 * @return EE_Base_Class[]|array
951 951
 	 */
952
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
953
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
952
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
953
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
954 954
 	}
955 955
 
956 956
 
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 	 *
974 974
 	 * @return EE_Base_Class[]|array
975 975
 	 */
976
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
977
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
976
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
977
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
978 978
 	}
979 979
 
980 980
 
@@ -996,9 +996,9 @@  discard block
 block discarded – undo
996 996
 	 *
997 997
 	 * @return EE_Base_Class|null|array()
998 998
 	 */
999
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1000
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1001
-		return empty( $results ) ? null : reset( $results );
999
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1000
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1001
+		return empty($results) ? null : reset($results);
1002 1002
 	}
1003 1003
 
1004 1004
 
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
 	 *
1021 1021
 	 * @return EE_Base_Class|null|array()
1022 1022
 	 */
1023
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1024
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1025
-		return empty( $results ) ? null : reset( $results );
1023
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1024
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1025
+		return empty($results) ? null : reset($results);
1026 1026
 	}
1027 1027
 
1028 1028
 
@@ -1048,40 +1048,40 @@  discard block
 block discarded – undo
1048 1048
 	 * @return EE_Base_Class[]|array
1049 1049
 	 * @throws EE_Error
1050 1050
 	 */
1051
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1051
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1052 1052
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1053
-		if ( empty( $field_to_order_by ) ) {
1054
-			if ( $this->has_primary_key_field() ) {
1053
+		if (empty($field_to_order_by)) {
1054
+			if ($this->has_primary_key_field()) {
1055 1055
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1056 1056
 			} else {
1057 1057
 
1058
-				if ( WP_DEBUG ) {
1059
-					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' ) );
1058
+				if (WP_DEBUG) {
1059
+					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'));
1060 1060
 				}
1061
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1061
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1062 1062
 				return array();
1063 1063
 			}
1064 1064
 		}
1065 1065
 
1066
-		if( ! is_array( $query_params ) ){
1067
-			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' );
1066
+		if ( ! is_array($query_params)) {
1067
+			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');
1068 1068
 			$query_params = array();
1069 1069
 		}
1070 1070
 
1071 1071
 		//let's add the where query param for consecutive look up.
1072
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1072
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1073 1073
 		$query_params['limit'] = $limit;
1074 1074
 
1075 1075
 		//set direction
1076
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1077
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1076
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1077
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1078 1078
 
1079 1079
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1080
-		if ( empty( $columns_to_select ) ) {
1081
-			return $this->get_all( $query_params );
1080
+		if (empty($columns_to_select)) {
1081
+			return $this->get_all($query_params);
1082 1082
 		} else {
1083 1083
 			//getting just the fields
1084
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1084
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1085 1085
 		}
1086 1086
 	}
1087 1087
 
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1105 1105
 	 * @return EE_Table_Base[]
1106 1106
 	 */
1107
-	function get_tables(){
1107
+	function get_tables() {
1108 1108
 		return $this->_tables;
1109 1109
 	}
1110 1110
 
@@ -1138,9 +1138,9 @@  discard block
 block discarded – undo
1138 1138
 	 * be aware that model objects being used could get out-of-sync with the database
1139 1139
 	 * @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)
1140 1140
 	 */
1141
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1142
-		if( ! is_array( $query_params ) ){
1143
-			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' );
1141
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1142
+		if ( ! is_array($query_params)) {
1143
+			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');
1144 1144
 			$query_params = array();
1145 1145
 		}
1146 1146
 		/**
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 		 * @param array $fields_n_values the updated fields and their new values
1151 1151
 		 * @param array $query_params @see EEM_Base::get_all()
1152 1152
 		 */
1153
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1153
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1154 1154
 		/**
1155 1155
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1156 1156
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		 * @param EEM_Base $model the model being queried
1159 1159
 		 * @param array $query_params see EEM_Base::get_all()
1160 1160
 		 */
1161
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1161
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1162 1162
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1163 1163
 		//to do that, for each table, verify that it's PK isn't null.
1164
-		$tables= $this->get_tables();
1164
+		$tables = $this->get_tables();
1165 1165
 
1166 1166
 		//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
1167 1167
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1171,29 +1171,29 @@  discard block
 block discarded – undo
1171 1171
 			//we want to make sure the default_where strategy is ignored
1172 1172
 			$this->_ignore_where_strategy = TRUE;
1173 1173
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1174
-			foreach( $wpdb_select_results as $wpdb_result ){
1174
+			foreach ($wpdb_select_results as $wpdb_result) {
1175 1175
 				// type cast stdClass as array
1176
-				$wpdb_result = (array)$wpdb_result;
1176
+				$wpdb_result = (array) $wpdb_result;
1177 1177
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1178
-				if( $this->has_primary_key_field() ){
1179
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1180
-				}else{
1178
+				if ($this->has_primary_key_field()) {
1179
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1180
+				} else {
1181 1181
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work)
1182 1182
 					$main_table_pk_value = null;
1183 1183
 				}
1184 1184
 				//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
1185 1185
 				//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
1186
-				if(count($tables) > 1){
1186
+				if (count($tables) > 1) {
1187 1187
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1188 1188
 					//in that table, and so we'll want to insert one
1189
-					foreach($tables as $table_obj){
1189
+					foreach ($tables as $table_obj) {
1190 1190
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1191 1191
 						//if there is no private key for this table on the results, it means there's no entry
1192 1192
 						//in this table, right? so insert a row in the current table, using any fields available
1193
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1193
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1194 1194
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1195 1195
 							//if we died here, report the error
1196
-							if( ! $success ) {
1196
+							if ( ! $success) {
1197 1197
 								return false;
1198 1198
 							}
1199 1199
 						}
@@ -1213,44 +1213,44 @@  discard block
 block discarded – undo
1213 1213
 		//if this wasn't called from a model object (to update itself)
1214 1214
 		//then we want to make sure we keep all the existing
1215 1215
 		//model objects in sync with the db
1216
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1217
-			if( $this->has_primary_key_field() ){
1218
-				$model_objs_affected_ids = $this->get_col( $query_params );
1219
-			}else{
1216
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1217
+			if ($this->has_primary_key_field()) {
1218
+				$model_objs_affected_ids = $this->get_col($query_params);
1219
+			} else {
1220 1220
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1221
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1221
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1222 1222
 				$model_objs_affected_ids = array();
1223
-				foreach( $models_affected_key_columns as $row ){
1224
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1225
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1223
+				foreach ($models_affected_key_columns as $row) {
1224
+					$combined_index_key = $this->get_index_primary_key_string($row);
1225
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1226 1226
 				}
1227 1227
 
1228 1228
 			}
1229 1229
 
1230
-			if( ! $model_objs_affected_ids ){
1230
+			if ( ! $model_objs_affected_ids) {
1231 1231
 				//wait wait wait- if nothing was affected let's stop here
1232 1232
 				return 0;
1233 1233
 			}
1234
-			foreach( $model_objs_affected_ids as $id ){
1235
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1236
-				if( $model_obj_in_entity_map ){
1237
-					foreach( $fields_n_values as $field => $new_value ){
1238
-						$model_obj_in_entity_map->set( $field, $new_value );
1234
+			foreach ($model_objs_affected_ids as $id) {
1235
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1236
+				if ($model_obj_in_entity_map) {
1237
+					foreach ($fields_n_values as $field => $new_value) {
1238
+						$model_obj_in_entity_map->set($field, $new_value);
1239 1239
 					}
1240 1240
 				}
1241 1241
 			}
1242 1242
 			//if there is a primary key on this model, we can now do a slight optimization
1243
-			if( $this->has_primary_key_field() ){
1243
+			if ($this->has_primary_key_field()) {
1244 1244
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1245 1245
 				$query_params = array(
1246
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1247
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1246
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1247
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1248 1248
 			}
1249 1249
 		}
1250 1250
 
1251
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1252
-		$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.
1253
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1251
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1252
+		$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.
1253
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1254 1254
 		/**
1255 1255
 		 * Action called after a model update call has been made.
1256 1256
 		 *
@@ -1259,8 +1259,8 @@  discard block
 block discarded – undo
1259 1259
 		 * @param array $query_params @see EEM_Base::get_all()
1260 1260
 		 * @param int $rows_affected
1261 1261
 		 */
1262
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1263
-		return $rows_affected;//how many supposedly got updated
1262
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1263
+		return $rows_affected; //how many supposedly got updated
1264 1264
 	}
1265 1265
 
1266 1266
 	/**
@@ -1272,22 +1272,22 @@  discard block
 block discarded – undo
1272 1272
 	 * @param string $field_to_select
1273 1273
 	 * @return array just like $wpdb->get_col()
1274 1274
 	 */
1275
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1275
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1276 1276
 
1277
-		if( $field_to_select ){
1278
-			$field = $this->field_settings_for( $field_to_select );
1279
-		}elseif( $this->has_primary_key_field ( ) ){
1277
+		if ($field_to_select) {
1278
+			$field = $this->field_settings_for($field_to_select);
1279
+		}elseif ($this->has_primary_key_field( )) {
1280 1280
 			$field = $this->get_primary_key_field();
1281
-		}else{
1281
+		} else {
1282 1282
 			//no primary key, just grab the first column
1283
-			$field = reset( $this->field_settings());
1283
+			$field = reset($this->field_settings());
1284 1284
 		}
1285 1285
 
1286 1286
 
1287 1287
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1288 1288
 		$select_expressions = $field->get_qualified_column();
1289
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1290
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1289
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1290
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1291 1291
 		return $results;
1292 1292
 	}
1293 1293
 
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
 	 * @param string $field_to_select @see EEM_Base::get_col()
1298 1298
 	 * @return string
1299 1299
 	 */
1300
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1301
-		$query_params[ 'limit' ] = 1;
1302
-		$col = $this->get_col( $query_params, $field_to_select );
1303
-		if( ! empty( $col ) ) {
1304
-			return reset( $col );
1305
-		}else{
1300
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1301
+		$query_params['limit'] = 1;
1302
+		$col = $this->get_col($query_params, $field_to_select);
1303
+		if ( ! empty($col)) {
1304
+			return reset($col);
1305
+		} else {
1306 1306
 			return NULL;
1307 1307
 		}
1308 1308
 	}
@@ -1316,18 +1316,18 @@  discard block
 block discarded – undo
1316 1316
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
1317 1317
 	 * @return string of SQL
1318 1318
 	 */
1319
-	function _construct_update_sql($fields_n_values){
1319
+	function _construct_update_sql($fields_n_values) {
1320 1320
 		global $wpdb;
1321 1321
 		$cols_n_values = array();
1322
-		foreach($fields_n_values as $field_name => $value){
1322
+		foreach ($fields_n_values as $field_name => $value) {
1323 1323
 			$field_obj = $this->field_settings_for($field_name);
1324 1324
 			//if the value is NULL, we want to assign the value to that.
1325 1325
 			//wpdb->prepare doesn't really handle that properly
1326
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1327
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1326
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1327
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1328 1328
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1329 1329
 		}
1330
-		return implode(",",$cols_n_values);
1330
+		return implode(",", $cols_n_values);
1331 1331
 
1332 1332
 	}
1333 1333
 
@@ -1339,11 +1339,11 @@  discard block
 block discarded – undo
1339 1339
 	 * @param mixed $id
1340 1340
 	 * @return boolean whether the row got deleted or not
1341 1341
 	 */
1342
-	public function delete_by_ID( $id ){
1343
-		return $this->delete( array(
1344
-			array( $this->get_primary_key_field()->get_name() => $id ),
1342
+	public function delete_by_ID($id) {
1343
+		return $this->delete(array(
1344
+			array($this->get_primary_key_field()->get_name() => $id),
1345 1345
 			'limit' 	=> 1
1346
-		) );
1346
+		));
1347 1347
 	}
1348 1348
 
1349 1349
 
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1359 1359
 	 * @return int how many rows got deleted
1360 1360
 	 */
1361
-	function delete($query_params,$allow_blocking = true){
1361
+	function delete($query_params, $allow_blocking = true) {
1362 1362
 		/**
1363 1363
 		 * Action called just before performing a real deletion query. You can use the
1364 1364
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1367,34 +1367,34 @@  discard block
 block discarded – undo
1367 1367
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1368 1368
 		 * to block (prevent) this deletion
1369 1369
 		 */
1370
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1370
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1371 1371
 		//some MySQL databases may be running safe mode, which may restrict
1372 1372
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1373 1373
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1374 1374
 		//to delete them
1375 1375
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1376
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1377
-		if($deletion_where){
1376
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1377
+		if ($deletion_where) {
1378 1378
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1379 1379
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1380 1380
 			$table_aliases = array();
1381
-			foreach(array_keys($this->_tables) as $table_alias){
1381
+			foreach (array_keys($this->_tables) as $table_alias) {
1382 1382
 				$table_aliases[] = $table_alias;
1383 1383
 			}
1384
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1384
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1385 1385
 
1386 1386
 			//		/echo "delete sql:$SQL";
1387
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1388
-		}else{
1387
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1388
+		} else {
1389 1389
 			$rows_deleted = 0;
1390 1390
 		}
1391 1391
 
1392 1392
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1393
-		if( $this->has_primary_key_field() ){
1394
-			foreach($items_for_deletion as $item_for_deletion_row ){
1395
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1396
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1397
-					unset( $this->_entity_map[ $pk_value ] );
1393
+		if ($this->has_primary_key_field()) {
1394
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1395
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1396
+				if (isset($this->_entity_map[$pk_value])) {
1397
+					unset($this->_entity_map[$pk_value]);
1398 1398
 				}
1399 1399
 			}
1400 1400
 		}
@@ -1406,8 +1406,8 @@  discard block
 block discarded – undo
1406 1406
 		 * @param array $query_params @see EEM_Base::get_all()
1407 1407
 		 * @param int $rows_deleted
1408 1408
 		 */
1409
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1410
-		return $rows_deleted;//how many supposedly got deleted
1409
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1410
+		return $rows_deleted; //how many supposedly got deleted
1411 1411
 	}
1412 1412
 
1413 1413
 
@@ -1423,28 +1423,28 @@  discard block
 block discarded – undo
1423 1423
 	 * blocking its deletion before removing the relation between A and B
1424 1424
 	 * @return boolean
1425 1425
 	 */
1426
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1426
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1427 1427
 		//first, if $ignore_this_model_obj was supplied, get its model
1428
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1428
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1429 1429
 			$ignored_model = $ignore_this_model_obj->get_model();
1430
-		}else{
1430
+		} else {
1431 1431
 			$ignored_model = null;
1432 1432
 		}
1433 1433
 		//now check all the relations of $this_model_obj_or_id and see if there
1434 1434
 		//are any related model objects blocking it?
1435 1435
 		$is_blocked = false;
1436
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1437
-			if( $relation_obj->block_delete_if_related_models_exist()){
1436
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1437
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1438 1438
 				//if $ignore_this_model_obj was supplied, then for the query
1439 1439
 				//on that model needs to be told to ignore $ignore_this_model_obj
1440
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1441
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1442
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1443
-				}else{
1440
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1441
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1442
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1443
+				} else {
1444 1444
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1445 1445
 				}
1446 1446
 
1447
-				if($related_model_objects){
1447
+				if ($related_model_objects) {
1448 1448
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1449 1449
 					$is_blocked = true;
1450 1450
 				}
@@ -1464,65 +1464,65 @@  discard block
 block discarded – undo
1464 1464
 	 * @throws EE_Error
1465 1465
 	 * @return string    everything that comes after the WHERE statement.
1466 1466
 	 */
1467
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1468
-		if($this->has_primary_key_field()){
1467
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1468
+		if ($this->has_primary_key_field()) {
1469 1469
 			$primary_table = $this->_get_main_table();
1470 1470
 			$other_tables = $this->_get_other_tables();
1471 1471
 			$deletes = $query = array();
1472
-			foreach ( $objects_for_deletion as $delete_object ) {
1472
+			foreach ($objects_for_deletion as $delete_object) {
1473 1473
 				//before we mark this object for deletion,
1474 1474
 				//make sure there's no related objects blocking its deletion (if we're checking)
1475
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1475
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1476 1476
 					continue;
1477 1477
 				}
1478 1478
 
1479 1479
 				//primary table deletes
1480
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1480
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1481 1481
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1482 1482
 
1483 1483
 				//other tables
1484
-				if ( !empty( $other_tables ) ) {
1485
-					foreach ( $other_tables as $ot ) {
1484
+				if ( ! empty($other_tables)) {
1485
+					foreach ($other_tables as $ot) {
1486 1486
 
1487 1487
 						//first check if we've got the foreign key column here.
1488
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1488
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1489 1489
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1490 1490
 
1491 1491
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1492
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1492
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1493 1493
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1494 1494
 
1495 1495
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1496
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1496
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1497 1497
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1498 1498
 					}
1499 1499
 				}
1500 1500
 			}
1501 1501
 
1502 1502
 			//we should have deletes now, so let's just go through and setup the where statement
1503
-			foreach ( $deletes as $column => $values ) {
1503
+			foreach ($deletes as $column => $values) {
1504 1504
 				//make sure we have unique $values;
1505 1505
 				$values = array_unique($values);
1506
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1506
+				$query[] = $column.' IN('.implode(",", $values).')';
1507 1507
 			}
1508 1508
 
1509
-			return !empty($query) ? implode(' AND ', $query ) : '';
1510
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1509
+			return ! empty($query) ? implode(' AND ', $query) : '';
1510
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1511 1511
 			$ways_to_identify_a_row = array();
1512 1512
 			$fields = $this->get_combined_primary_key_fields();
1513 1513
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1514
-			foreach($objects_for_deletion as  $delete_object){
1514
+			foreach ($objects_for_deletion as  $delete_object) {
1515 1515
 				$values_for_each_cpk_for_a_row = array();
1516
-				foreach($fields as $cpk_field){
1516
+				foreach ($fields as $cpk_field) {
1517 1517
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1518 1518
 				}
1519
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1519
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1520 1520
 			}
1521
-			return implode(" OR ",$ways_to_identify_a_row);
1522
-		}else{
1521
+			return implode(" OR ", $ways_to_identify_a_row);
1522
+		} else {
1523 1523
 			//so there's no primary key and no combined key...
1524 1524
 			//sorry, can't help you
1525
-			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)));
1525
+			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)));
1526 1526
 		}
1527 1527
 	}
1528 1528
 
@@ -1536,21 +1536,21 @@  discard block
 block discarded – undo
1536 1536
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1537 1537
 	 * @return int
1538 1538
 	 */
1539
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1539
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1540 1540
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1541
-		if($field_to_count){
1541
+		if ($field_to_count) {
1542 1542
 			$field_obj = $this->field_settings_for($field_to_count);
1543 1543
 			$column_to_count = $field_obj->get_qualified_column();
1544
-		}elseif($this->has_primary_key_field ()){
1544
+		}elseif ($this->has_primary_key_field()) {
1545 1545
 			$pk_field_obj = $this->get_primary_key_field();
1546 1546
 			$column_to_count = $pk_field_obj->get_qualified_column();
1547
-		}else{//there's no primary key
1547
+		} else {//there's no primary key
1548 1548
 			$column_to_count = '*';
1549 1549
 		}
1550 1550
 
1551
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1552
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1553
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1551
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1552
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1553
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1554 1554
 	}
1555 1555
 
1556 1556
 	/**
@@ -1560,23 +1560,23 @@  discard block
 block discarded – undo
1560 1560
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1561 1561
 	 * @return int
1562 1562
 	 */
1563
-	function sum($query_params, $field_to_sum = NULL){
1563
+	function sum($query_params, $field_to_sum = NULL) {
1564 1564
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1565 1565
 
1566
-		if($field_to_sum){
1566
+		if ($field_to_sum) {
1567 1567
 			$field_obj = $this->field_settings_for($field_to_sum);
1568 1568
 
1569
-		}else{
1569
+		} else {
1570 1570
 			$field_obj = $this->get_primary_key_field();
1571 1571
 		}
1572 1572
 		$column_to_count = $field_obj->get_qualified_column();
1573 1573
 
1574
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1575
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1576
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1577
-			return (int)$return_value;
1578
-		}else{//must be %f
1579
-			return (float)$return_value;
1574
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1575
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1576
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1577
+			return (int) $return_value;
1578
+		} else {//must be %f
1579
+			return (float) $return_value;
1580 1580
 		}
1581 1581
 	}
1582 1582
 
@@ -1591,34 +1591,34 @@  discard block
 block discarded – undo
1591 1591
 	 * @global wpdb $wpdb
1592 1592
 	 * @return mixed
1593 1593
 	 */
1594
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1594
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1595 1595
 		//if we're in maintenance mode level 2, DON'T run any queries
1596 1596
 		//because level 2 indicates the database needs updating and
1597 1597
 		//is probably out of sync with the code
1598
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1598
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1599 1599
 			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")));
1600 1600
 		}
1601 1601
 		global $wpdb;
1602
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1603
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1602
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1603
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1604 1604
 		}
1605
-		if( WP_DEBUG ){
1605
+		if (WP_DEBUG) {
1606 1606
 			$wpdb->last_error = NULL;
1607 1607
 			$old_show_errors_value = $wpdb->show_errors;
1608
-			$wpdb->show_errors( FALSE );
1608
+			$wpdb->show_errors(FALSE);
1609 1609
 		}
1610 1610
 
1611
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ) , $arguments_to_provide );
1612
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1613
-		if( WP_DEBUG ){
1614
-			$wpdb->show_errors( $old_show_errors_value );
1615
-			if( ! empty( $wpdb->last_error ) ){
1616
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1617
-			}elseif( $result === false ){
1618
-				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 ) ) );
1611
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1612
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1613
+		if (WP_DEBUG) {
1614
+			$wpdb->show_errors($old_show_errors_value);
1615
+			if ( ! empty($wpdb->last_error)) {
1616
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1617
+			}elseif ($result === false) {
1618
+				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)));
1619 1619
 			}
1620
-		}elseif( $result === false ) {
1621
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1620
+		}elseif ($result === false) {
1621
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1622 1622
 		}
1623 1623
 		return $result;
1624 1624
 	}
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1631 1631
 	 * @return string
1632 1632
 	 */
1633
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1633
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1634 1634
 		return " FROM ".$model_query_info->get_full_join_sql().
1635 1635
 				$model_query_info->get_where_sql().
1636 1636
 				$model_query_info->get_group_by_sql().
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
 	 * Set to easily debug the next X queries ran from this model.
1644 1644
 	 * @param int $count
1645 1645
 	 */
1646
-	function show_next_x_db_queries($count = 1){
1646
+	function show_next_x_db_queries($count = 1) {
1647 1647
 		$this->_show_next_x_db_queries = $count;
1648 1648
 	}
1649 1649
 
@@ -1652,8 +1652,8 @@  discard block
 block discarded – undo
1652 1652
 	/**
1653 1653
 	 * @param $sql_query
1654 1654
 	 */
1655
-	function show_db_query_if_previously_requested($sql_query){
1656
-		if($this->_show_next_x_db_queries > 0){
1655
+	function show_db_query_if_previously_requested($sql_query) {
1656
+		if ($this->_show_next_x_db_queries > 0) {
1657 1657
 			echo $sql_query;
1658 1658
 			$this->_show_next_x_db_queries--;
1659 1659
 		}
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
 	 * @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.
1678 1678
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
1679 1679
 	 */
1680
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
1680
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1681 1681
 		$relation_obj = $this->related_settings_for($relationName);
1682 1682
 		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1683 1683
 	}
@@ -1698,9 +1698,9 @@  discard block
 block discarded – undo
1698 1698
 	 * @return boolean of success
1699 1699
 	 * @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.
1700 1700
 	 */
1701
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
1701
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1702 1702
 		$relation_obj = $this->related_settings_for($relationName);
1703
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
1703
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1704 1704
 	}
1705 1705
 
1706 1706
 
@@ -1713,9 +1713,9 @@  discard block
 block discarded – undo
1713 1713
 	 * @param EE_Base_Class[] objects to which relations were removed
1714 1714
 	 * @return \EE_Base_Class[]
1715 1715
 	 */
1716
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
1716
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
1717 1717
 		$relation_obj = $this->related_settings_for($relationName);
1718
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
1718
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
1719 1719
 	}
1720 1720
 
1721 1721
 
@@ -1728,10 +1728,10 @@  discard block
 block discarded – undo
1728 1728
 	 * @param array $query_params like EEM_Base::get_all
1729 1729
 	 * @return EE_Base_Class[]
1730 1730
 	 */
1731
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
1731
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
1732 1732
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1733 1733
 		$relation_settings = $this->related_settings_for($model_name);
1734
-		return $relation_settings->get_all_related($model_obj,$query_params);
1734
+		return $relation_settings->get_all_related($model_obj, $query_params);
1735 1735
 	}
1736 1736
 
1737 1737
 	/**
@@ -1744,10 +1744,10 @@  discard block
 block discarded – undo
1744 1744
 	 * @param array $query_params
1745 1745
 	 * @return int how many deleted
1746 1746
 	 */
1747
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
1747
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
1748 1748
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1749 1749
 		$relation_settings = $this->related_settings_for($model_name);
1750
-		return $relation_settings->delete_all_related($model_obj,$query_params);
1750
+		return $relation_settings->delete_all_related($model_obj, $query_params);
1751 1751
 	}
1752 1752
 
1753 1753
 	/**
@@ -1760,10 +1760,10 @@  discard block
 block discarded – undo
1760 1760
 	 * @param array $query_params
1761 1761
 	 * @return int how many deleted
1762 1762
 	 */
1763
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
1763
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
1764 1764
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1765 1765
 		$relation_settings = $this->related_settings_for($model_name);
1766
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
1766
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
1767 1767
 	}
1768 1768
 
1769 1769
 	/**
@@ -1776,17 +1776,17 @@  discard block
 block discarded – undo
1776 1776
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1777 1777
 	 * @return int
1778 1778
 	 */
1779
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
1779
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
1780 1780
 		$related_model = $this->get_related_model_obj($model_name);
1781 1781
 		//we're just going to use the query params on the related model's normal get_all query,
1782 1782
 		//except add a condition to say to match the current mod
1783
-		if( ! isset($query_params['default_where_conditions'])){
1784
-			$query_params['default_where_conditions']='none';
1783
+		if ( ! isset($query_params['default_where_conditions'])) {
1784
+			$query_params['default_where_conditions'] = 'none';
1785 1785
 		}
1786 1786
 		$this_model_name = $this->get_this_model_name();
1787 1787
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1788
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1789
-		return $related_model->count($query_params,$field_to_count,$distinct);
1788
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1789
+		return $related_model->count($query_params, $field_to_count, $distinct);
1790 1790
 	}
1791 1791
 
1792 1792
 
@@ -1800,21 +1800,21 @@  discard block
 block discarded – undo
1800 1800
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
1801 1801
 	 * @return int
1802 1802
 	 */
1803
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
1803
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
1804 1804
 		$related_model = $this->get_related_model_obj($model_name);
1805
-		if( ! is_array( $query_params ) ){
1806
-			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' );
1805
+		if ( ! is_array($query_params)) {
1806
+			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');
1807 1807
 			$query_params = array();
1808 1808
 		}
1809 1809
 		//we're just going to use the query params on the related model's normal get_all query,
1810 1810
 		//except add a condition to say to match the current mod
1811
-		if( ! isset($query_params['default_where_conditions'])){
1812
-			$query_params['default_where_conditions']='none';
1811
+		if ( ! isset($query_params['default_where_conditions'])) {
1812
+			$query_params['default_where_conditions'] = 'none';
1813 1813
 		}
1814 1814
 		$this_model_name = $this->get_this_model_name();
1815 1815
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1816
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1817
-		return $related_model->sum($query_params,$field_to_sum);
1816
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1817
+		return $related_model->sum($query_params, $field_to_sum);
1818 1818
 	}
1819 1819
 
1820 1820
 
@@ -1826,12 +1826,12 @@  discard block
 block discarded – undo
1826 1826
 	 * @param array $query_params like EEM_Base::get_all's
1827 1827
 	 * @return EE_Base_Class
1828 1828
 	 */
1829
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
1830
-		$query_params['limit']=1;
1831
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1832
-		if( $results ){
1829
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
1830
+		$query_params['limit'] = 1;
1831
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
1832
+		if ($results) {
1833 1833
 			return array_shift($results);
1834
-		}else{
1834
+		} else {
1835 1835
 			return null;
1836 1836
 		}
1837 1837
 
@@ -1841,8 +1841,8 @@  discard block
 block discarded – undo
1841 1841
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
1842 1842
 	 * @return string
1843 1843
 	 */
1844
-	function get_this_model_name(){
1845
-		return str_replace("EEM_","",get_class($this));
1844
+	function get_this_model_name() {
1845
+		return str_replace("EEM_", "", get_class($this));
1846 1846
 	}
1847 1847
 
1848 1848
 	/**
@@ -1850,14 +1850,14 @@  discard block
 block discarded – undo
1850 1850
 	 * @return EE_Any_Foreign_Model_Name_Field
1851 1851
 	 * @throws EE_Error
1852 1852
 	 */
1853
-	public function get_field_containing_related_model_name(){
1854
-		foreach($this->field_settings(true) as $field){
1855
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
1853
+	public function get_field_containing_related_model_name() {
1854
+		foreach ($this->field_settings(true) as $field) {
1855
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
1856 1856
 				$field_with_model_name = $field;
1857 1857
 			}
1858 1858
 		}
1859
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
1860
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
1859
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
1860
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
1861 1861
 		}
1862 1862
 		return $field_with_model_name;
1863 1863
 	}
@@ -1878,19 +1878,19 @@  discard block
 block discarded – undo
1878 1878
 	 * @return int new primary key on main table that got inserted
1879 1879
 	 * @throws EE_Error
1880 1880
 	 */
1881
-	function insert($field_n_values){
1881
+	function insert($field_n_values) {
1882 1882
 		/**
1883 1883
 		 * Filters the fields and their values before inserting an item using the models
1884 1884
 		 * @param array $fields_n_values keys are the fields and values are their new values
1885 1885
 		 * @param EEM_Base $model the model used
1886 1886
 		 */
1887
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
1888
-		if($this->_satisfies_unique_indexes($field_n_values)){
1887
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
1888
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
1889 1889
 			$main_table = $this->_get_main_table();
1890 1890
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
1891
-			if( $new_id !== false ) {
1892
-				foreach($this->_get_other_tables() as $other_table){
1893
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
1891
+			if ($new_id !== false) {
1892
+				foreach ($this->_get_other_tables() as $other_table) {
1893
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
1894 1894
 				}
1895 1895
 			}
1896 1896
 			/**
@@ -1900,9 +1900,9 @@  discard block
 block discarded – undo
1900 1900
 			 * @param array $fields_n_values fields and their values
1901 1901
 			 * @param int|string the ID of the newly-inserted model object
1902 1902
 			 */
1903
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
1903
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
1904 1904
 			return $new_id;
1905
-		}else{
1905
+		} else {
1906 1906
 			return FALSE;
1907 1907
 		}
1908 1908
 	}
@@ -1915,11 +1915,11 @@  discard block
 block discarded – undo
1915 1915
 	 * @param string $action
1916 1916
 	 * @return boolean
1917 1917
 	 */
1918
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
1919
-		foreach($this->unique_indexes() as $index_name => $index){
1918
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
1919
+		foreach ($this->unique_indexes() as $index_name => $index) {
1920 1920
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
1921
-			if($this->exists(array($uniqueness_where_params))){
1922
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
1921
+			if ($this->exists(array($uniqueness_where_params))) {
1922
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
1923 1923
 				return false;
1924 1924
 			}
1925 1925
 		}
@@ -1940,28 +1940,28 @@  discard block
 block discarded – undo
1940 1940
 	 * @throws EE_Error
1941 1941
 	 * @return EE_Base_Class
1942 1942
 	 */
1943
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
1944
-		if($obj_or_fields_array instanceof EE_Base_Class){
1943
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
1944
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
1945 1945
 			$fields_n_values = $obj_or_fields_array->model_field_array();
1946
-		}elseif( is_array($obj_or_fields_array)){
1946
+		}elseif (is_array($obj_or_fields_array)) {
1947 1947
 			$fields_n_values = $obj_or_fields_array;
1948
-		}else{
1949
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
1948
+		} else {
1949
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
1950 1950
 		}
1951 1951
 		$query_params = array();
1952
-		if( $this->has_primary_key_field() &&
1953
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1954
-				isset($fields_n_values[$this->primary_key_name()])){
1952
+		if ($this->has_primary_key_field() &&
1953
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1954
+				isset($fields_n_values[$this->primary_key_name()])) {
1955 1955
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
1956 1956
 		}
1957
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
1957
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
1958 1958
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
1959 1959
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
1960 1960
 		}
1961 1961
 		//if there is nothing to base this search on, then we shouldn't find anything
1962
-		if( empty( $query_params ) ){
1962
+		if (empty($query_params)) {
1963 1963
 			return array();
1964
-		}else{
1964
+		} else {
1965 1965
 			return $this->get_one($query_params);
1966 1966
 		}
1967 1967
 	}
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
 	 * @param array $query_params
1972 1972
 	 * @return boolean
1973 1973
 	 */
1974
-	function exists($query_params){
1974
+	function exists($query_params) {
1975 1975
 		$query_params['limit'] = 1;
1976 1976
 		return $this->count($query_params) > 0;
1977 1977
 	}
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 	 * @param int|string $id
1982 1982
 	 * @return boolean
1983 1983
 	 */
1984
-	function exists_by_ID($id){
1984
+	function exists_by_ID($id) {
1985 1985
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
1986 1986
 	}
1987 1987
 
@@ -2001,45 +2001,45 @@  discard block
 block discarded – undo
2001 2001
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2002 2002
 	 * @return int ID of new row inserted, or FALSE on failure
2003 2003
 	 */
2004
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2004
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2005 2005
 		global $wpdb;
2006 2006
 		$insertion_col_n_values = array();
2007 2007
 		$format_for_insertion = array();
2008 2008
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2009
-		foreach($fields_on_table as $field_name => $field_obj){
2009
+		foreach ($fields_on_table as $field_name => $field_obj) {
2010 2010
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2011
-			if($field_obj->is_auto_increment()){
2011
+			if ($field_obj->is_auto_increment()) {
2012 2012
 				continue;
2013 2013
 			}
2014 2014
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2015 2015
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2016
-			if( $prepared_value !== NULL ){
2017
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2016
+			if ($prepared_value !== NULL) {
2017
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2018 2018
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2019 2019
 			}
2020 2020
 		}
2021 2021
 
2022
-		if($table instanceof EE_Secondary_Table && $new_id){
2022
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2023 2023
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2024 2024
 			//so add the fk to the main table as a column
2025 2025
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2026
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2026
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2027 2027
 		}
2028 2028
 		//insert the new entry
2029
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2030
-		if( $result === false ) {
2029
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2030
+		if ($result === false) {
2031 2031
 			return false;
2032 2032
 		}
2033 2033
 		//ok, now what do we return for the ID of the newly-inserted thing?
2034
-		if($this->has_primary_key_field()){
2035
-			if($this->get_primary_key_field()->is_auto_increment()){
2034
+		if ($this->has_primary_key_field()) {
2035
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2036 2036
 				return $wpdb->insert_id;
2037
-			}else{
2037
+			} else {
2038 2038
 				//it's not an auto-increment primary key, so
2039 2039
 				//it must have been supplied
2040 2040
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2041 2041
 			}
2042
-		}else{
2042
+		} else {
2043 2043
 			//we can't return a  primary key because there is none. instead return
2044 2044
 			//a unique string indicating this model
2045 2045
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2054,15 +2054,15 @@  discard block
 block discarded – undo
2054 2054
 	 * @param array $fields_n_values
2055 2055
 	 * @return mixed string|int|float depending on what the table column will be expecting
2056 2056
 	 */
2057
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2057
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2058 2058
 		//if this field doesn't allow nullable, don't allow it
2059
-		if( ! $field_obj->is_nullable() && (
2060
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2061
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2062
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2059
+		if ( ! $field_obj->is_nullable() && (
2060
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2061
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2062
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2063 2063
 		}
2064
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2065
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2064
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2065
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2066 2066
 	}
2067 2067
 
2068 2068
 
@@ -2074,9 +2074,9 @@  discard block
 block discarded – undo
2074 2074
 	 * @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
2075 2075
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2076 2076
 	 */
2077
-	private function _prepare_value_for_use_in_db($value, $field){
2078
-		if($field && $field instanceof EE_Model_Field_Base){
2079
-			switch( $this->_values_already_prepared_by_model_object ){
2077
+	private function _prepare_value_for_use_in_db($value, $field) {
2078
+		if ($field && $field instanceof EE_Model_Field_Base) {
2079
+			switch ($this->_values_already_prepared_by_model_object) {
2080 2080
 				case self::not_prepared_by_model_object:
2081 2081
 					$value = $field->prepare_for_set($value);
2082 2082
 					//purposefully left out "return"
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 					//leave the value alone
2087 2087
 			}
2088 2088
 			return $value;
2089
-		}else{
2089
+		} else {
2090 2090
 			return $value;
2091 2091
 		}
2092 2092
 	}
@@ -2096,13 +2096,13 @@  discard block
 block discarded – undo
2096 2096
 	 * @return EE_Primary_Table
2097 2097
 	 * @throws EE_Error
2098 2098
 	 */
2099
-	protected function _get_main_table(){
2100
-		foreach($this->_tables as $table){
2101
-			if($table instanceof EE_Primary_Table){
2099
+	protected function _get_main_table() {
2100
+		foreach ($this->_tables as $table) {
2101
+			if ($table instanceof EE_Primary_Table) {
2102 2102
 				return $table;
2103 2103
 			}
2104 2104
 		}
2105
-		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)));
2105
+		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)));
2106 2106
 	}
2107 2107
 
2108 2108
 	/**
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 	 */
2122 2122
 	public function second_table() {
2123 2123
 		// grab second table from tables array
2124
-		$second_table = end( $this->_tables );
2124
+		$second_table = end($this->_tables);
2125 2125
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2126 2126
 	}
2127 2127
 
@@ -2134,8 +2134,8 @@  discard block
 block discarded – undo
2134 2134
 	 * @param string $table_alias
2135 2135
 	 * @return EE_Primary_Table | EE_Secondary_Table
2136 2136
 	 */
2137
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2138
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2137
+	public function get_table_obj_by_alias($table_alias = '') {
2138
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2139 2139
 	}
2140 2140
 
2141 2141
 
@@ -2144,10 +2144,10 @@  discard block
 block discarded – undo
2144 2144
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2145 2145
 	 * @return EE_Secondary_Table[]
2146 2146
 	 */
2147
-	protected function _get_other_tables(){
2148
-		$other_tables =array();
2149
-		foreach($this->_tables as $table_alias => $table){
2150
-			if($table instanceof EE_Secondary_Table){
2147
+	protected function _get_other_tables() {
2148
+		$other_tables = array();
2149
+		foreach ($this->_tables as $table_alias => $table) {
2150
+			if ($table instanceof EE_Secondary_Table) {
2151 2151
 				$other_tables[$table_alias] = $table;
2152 2152
 			}
2153 2153
 		}
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 	 * @param string $table_alias, array key in EEM_Base::_tables
2160 2160
 	 * @return EE_Model_Field_Base[]
2161 2161
 	 */
2162
-	function _get_fields_for_table($table_alias){
2162
+	function _get_fields_for_table($table_alias) {
2163 2163
 		return $this->_fields[$table_alias];
2164 2164
 	}
2165 2165
 
@@ -2171,29 +2171,29 @@  discard block
 block discarded – undo
2171 2171
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2172 2172
 	 * @return EE_Model_Query_Info_Carrier
2173 2173
 	 */
2174
-	function _extract_related_models_from_query($query_params){
2174
+	function _extract_related_models_from_query($query_params) {
2175 2175
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2176
-		if(array_key_exists(0,$query_params)){
2177
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2178
-		}
2179
-		if(array_key_exists('group_by', $query_params)){
2180
-			if(is_array($query_params['group_by'])){
2181
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2182
-			}elseif( ! empty ( $query_params['group_by'] )){
2183
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2176
+		if (array_key_exists(0, $query_params)) {
2177
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2178
+		}
2179
+		if (array_key_exists('group_by', $query_params)) {
2180
+			if (is_array($query_params['group_by'])) {
2181
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2182
+			}elseif ( ! empty ($query_params['group_by'])) {
2183
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2184 2184
 			}
2185 2185
 		}
2186
-		if(array_key_exists('having',$query_params)){
2187
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2186
+		if (array_key_exists('having', $query_params)) {
2187
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2188 2188
 		}
2189
-		if(array_key_exists('order_by', $query_params)){
2190
-			if ( is_array( $query_params['order_by'] ) )
2191
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2192
-			elseif( ! empty( $query_params['order_by'] ))
2193
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2189
+		if (array_key_exists('order_by', $query_params)) {
2190
+			if (is_array($query_params['order_by']))
2191
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2192
+			elseif ( ! empty($query_params['order_by']))
2193
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2194 2194
 		}
2195
-		if(array_key_exists('force_join', $query_params)){
2196
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2195
+		if (array_key_exists('force_join', $query_params)) {
2196
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2197 2197
 		}
2198 2198
 		return $query_info_carrier;
2199 2199
 	}
@@ -2206,34 +2206,34 @@  discard block
 block discarded – undo
2206 2206
 	 * @throws EE_Error
2207 2207
 	 * @return \EE_Model_Query_Info_Carrier
2208 2208
 	 */
2209
-	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){
2210
-		if (!empty($sub_query_params)){
2209
+	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) {
2210
+		if ( ! empty($sub_query_params)) {
2211 2211
 			$sub_query_params = (array) $sub_query_params;
2212
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2212
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2213 2213
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2214
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2214
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2215 2215
 
2216 2216
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2217 2217
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2218 2218
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2219 2219
 				//of array('Registration.TXN_ID'=>23)
2220 2220
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2221
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2222
-					if (! is_array($possibly_array_of_params)){
2221
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2222
+					if ( ! is_array($possibly_array_of_params)) {
2223 2223
 						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"),
2224
-							$param,$possibly_array_of_params));
2225
-					}else{
2226
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2224
+							$param, $possibly_array_of_params));
2225
+					} else {
2226
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2227 2227
 					}
2228
-				}elseif($query_param_type === 0 //ie WHERE
2228
+				}elseif ($query_param_type === 0 //ie WHERE
2229 2229
 						&& is_array($possibly_array_of_params)
2230 2230
 						&& isset($possibly_array_of_params[2])
2231
-						&& $possibly_array_of_params[2] == true){
2231
+						&& $possibly_array_of_params[2] == true) {
2232 2232
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2233 2233
 					//indicating that $possible_array_of_params[1] is actually a field name,
2234 2234
 					//from which we should extract query parameters!
2235
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2236
-						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)));
2235
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2236
+						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)));
2237 2237
 					}
2238 2238
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2239 2239
 				}
@@ -2252,14 +2252,14 @@  discard block
 block discarded – undo
2252 2252
 	 * @throws EE_Error
2253 2253
 	 * @return \EE_Model_Query_Info_Carrier
2254 2254
 	 */
2255
-	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){
2256
-		if (!empty($sub_query_params)){
2257
-			if(!is_array($sub_query_params)){
2258
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2255
+	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) {
2256
+		if ( ! empty($sub_query_params)) {
2257
+			if ( ! is_array($sub_query_params)) {
2258
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2259 2259
 			}
2260
-			foreach($sub_query_params as $param){
2260
+			foreach ($sub_query_params as $param) {
2261 2261
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2262
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2262
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2263 2263
 			}
2264 2264
 		}
2265 2265
 		return $model_query_info_carrier;
@@ -2278,81 +2278,81 @@  discard block
 block discarded – undo
2278 2278
 	 * @throws EE_Error
2279 2279
 	 * @return EE_Model_Query_Info_Carrier
2280 2280
 	 */
2281
-	function _create_model_query_info_carrier($query_params){
2282
-		if( isset( $query_params[0] ) ) {
2281
+	function _create_model_query_info_carrier($query_params) {
2282
+		if (isset($query_params[0])) {
2283 2283
 			$where_query_params = $query_params[0];
2284
-		}else{
2284
+		} else {
2285 2285
 			$where_query_params = array();
2286 2286
 		}
2287 2287
 		//first check if we should alter the query to account for caps or not
2288 2288
 		//because the caps might require us to do extra joins
2289
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2290
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2289
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2290
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2291 2291
 		}
2292
-		if( ! is_array( $query_params ) ){
2293
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2292
+		if ( ! is_array($query_params)) {
2293
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2294 2294
 			$query_params = array();
2295 2295
 		}
2296 2296
 		$query_object = $this->_extract_related_models_from_query($query_params);
2297 2297
 
2298 2298
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2299
-		foreach($where_query_params as $key => $value){
2300
-			if(is_int($key)){
2301
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2299
+		foreach ($where_query_params as $key => $value) {
2300
+			if (is_int($key)) {
2301
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2302 2302
 			}
2303 2303
 		}
2304
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2304
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2305 2305
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2306
-		}else{
2306
+		} else {
2307 2307
 			$use_default_where_conditions = 'all';
2308 2308
 		}
2309
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
2310
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2309
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
2310
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2311 2311
 
2312 2312
 
2313 2313
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
2314 2314
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2315
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2316
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2315
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2316
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2317 2317
 		}
2318 2318
 
2319 2319
 
2320 2320
 		//set limit
2321
-		if(array_key_exists('limit',$query_params)){
2322
-			if(is_array($query_params['limit'])){
2323
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2324
-					$e = sprintf(__("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)", "event_espresso"),  http_build_query($query_params['limit']));
2321
+		if (array_key_exists('limit', $query_params)) {
2322
+			if (is_array($query_params['limit'])) {
2323
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2324
+					$e = sprintf(__("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)", "event_espresso"), http_build_query($query_params['limit']));
2325 2325
 					throw new EE_Error($e."|".$e);
2326 2326
 				}
2327 2327
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2328 2328
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2329
-			}elseif( ! empty ( $query_params['limit'] )){
2329
+			}elseif ( ! empty ($query_params['limit'])) {
2330 2330
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2331 2331
 			}
2332 2332
 		}
2333 2333
 		//set order by
2334
-		if(array_key_exists('order_by',$query_params)){
2335
-			if(is_array($query_params['order_by'])){
2334
+		if (array_key_exists('order_by', $query_params)) {
2335
+			if (is_array($query_params['order_by'])) {
2336 2336
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2337 2337
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2338 2338
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2339
-				if(array_key_exists('order', $query_params)){
2339
+				if (array_key_exists('order', $query_params)) {
2340 2340
 					throw new EE_Error(sprintf(__("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 ", "event_espresso"),
2341
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2341
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2342 2342
 				}
2343
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2343
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2344 2344
 				//assume it's an array of fields to order by
2345 2345
 				$order_array = array();
2346
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2346
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2347 2347
 					$order = $this->_extract_order($order);
2348 2348
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2349 2349
 				}
2350
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2351
-			}elseif( ! empty ( $query_params['order_by'] )){
2352
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2353
-				if(isset($query_params['order'])){
2350
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2351
+			}elseif ( ! empty ($query_params['order_by'])) {
2352
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2353
+				if (isset($query_params['order'])) {
2354 2354
 					$order = $this->_extract_order($query_params['order']);
2355
-				}else{
2355
+				} else {
2356 2356
 					$order = 'DESC';
2357 2357
 				}
2358 2358
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2360,46 +2360,46 @@  discard block
 block discarded – undo
2360 2360
 		}
2361 2361
 
2362 2362
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2363
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2363
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2364 2364
 			$pk_field = $this->get_primary_key_field();
2365 2365
 			$order = $this->_extract_order($query_params['order']);
2366 2366
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2367 2367
 		}
2368 2368
 
2369 2369
 		//set group by
2370
-		if(array_key_exists('group_by',$query_params)){
2371
-			if(is_array($query_params['group_by'])){
2370
+		if (array_key_exists('group_by', $query_params)) {
2371
+			if (is_array($query_params['group_by'])) {
2372 2372
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2373 2373
 				$group_by_array = array();
2374
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2374
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2375 2375
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2376 2376
 				}
2377
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2378
-			}elseif( ! empty ( $query_params['group_by'] )){
2377
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2378
+			}elseif ( ! empty ($query_params['group_by'])) {
2379 2379
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2380 2380
 			}
2381 2381
 		}
2382 2382
 		//set having
2383
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2384
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2383
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2384
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2385 2385
 		}
2386 2386
 
2387 2387
 		//now, just verify they didn't pass anything wack
2388
-		foreach($query_params as $query_key => $query_value){
2389
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2388
+		foreach ($query_params as $query_key => $query_value) {
2389
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2390 2390
 				throw new EE_Error(
2391 2391
 					sprintf(
2392
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2392
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2393 2393
 						$query_key,
2394 2394
 						get_class($this),
2395 2395
 //						print_r( $this->_allowed_query_params, TRUE )
2396
-						implode( ',', $this->_allowed_query_params )
2396
+						implode(',', $this->_allowed_query_params)
2397 2397
 					)
2398 2398
 				);
2399 2399
 			}
2400 2400
 		}
2401 2401
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2402
-		if ( empty( $main_model_join_sql ) )
2402
+		if (empty($main_model_join_sql))
2403 2403
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2404 2404
 		return $query_object;
2405 2405
 	}
@@ -2410,17 +2410,17 @@  discard block
 block discarded – undo
2410 2410
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2411 2411
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2412 2412
 	 */
2413
-	public function caps_where_conditions( $context = self::caps_read ) {
2414
-		EEM_Base::verify_is_valid_cap_context( $context );
2413
+	public function caps_where_conditions($context = self::caps_read) {
2414
+		EEM_Base::verify_is_valid_cap_context($context);
2415 2415
 		$cap_where_conditions = array();
2416
-		$cap_restrictions = $this->caps_missing( $context );
2416
+		$cap_restrictions = $this->caps_missing($context);
2417 2417
 		/**
2418 2418
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2419 2419
 		 */
2420
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2421
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2420
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2421
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2422 2422
 		}
2423
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2423
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2424 2424
 	}
2425 2425
 
2426 2426
 	/**
@@ -2430,11 +2430,11 @@  discard block
 block discarded – undo
2430 2430
 	 * @return string either ASC, asc, DESC or desc
2431 2431
 	 * @throws EE_Error
2432 2432
 	 */
2433
-	private function _extract_order($should_be_order_string){
2434
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2433
+	private function _extract_order($should_be_order_string) {
2434
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2435 2435
 			return $should_be_order_string;
2436
-		}else{
2437
-			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));
2436
+		} else {
2437
+			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));
2438 2438
 		}
2439 2439
 	}
2440 2440
 
@@ -2452,19 +2452,19 @@  discard block
 block discarded – undo
2452 2452
 	 * @throws EE_Error
2453 2453
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2454 2454
 	 */
2455
-	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()){
2456
-		$allowed_used_default_where_conditions_values = array('all','this_model_only', 'other_models_only','none');
2457
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2458
-			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)));
2455
+	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()) {
2456
+		$allowed_used_default_where_conditions_values = array('all', 'this_model_only', 'other_models_only', 'none');
2457
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2458
+			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)));
2459 2459
 		}
2460
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2460
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2461 2461
 			$universal_query_params = $this->_get_default_where_conditions();
2462
-		}else{
2462
+		} else {
2463 2463
 			$universal_query_params = array();
2464 2464
 		}
2465 2465
 
2466
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2467
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2466
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2467
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2468 2468
 				$related_model = $this->get_related_model_obj($model_name);
2469 2469
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2470 2470
 
@@ -2491,22 +2491,22 @@  discard block
 block discarded – undo
2491 2491
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2492 2492
 	 * @return array like EEM_Base::get_all's $query_params[0]
2493 2493
 	 */
2494
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2494
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2495 2495
 		$null_friendly_where_conditions = array();
2496 2496
 		$none_overridden = true;
2497 2497
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2498 2498
 
2499
-		foreach($default_where_conditions as $key => $val){
2500
-			if( isset($provided_where_conditions[$key])){
2499
+		foreach ($default_where_conditions as $key => $val) {
2500
+			if (isset($provided_where_conditions[$key])) {
2501 2501
 				$none_overridden = false;
2502
-			}else{
2502
+			} else {
2503 2503
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2504 2504
 			}
2505 2505
 		}
2506
-		if( $none_overridden && $default_where_conditions){
2507
-			if($model->has_primary_key_field()){
2506
+		if ($none_overridden && $default_where_conditions) {
2507
+			if ($model->has_primary_key_field()) {
2508 2508
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2509
-			}else{
2509
+			} else {
2510 2510
 				//@todo NO PK, use other defaults
2511 2511
 			}
2512 2512
 		}
@@ -2521,8 +2521,8 @@  discard block
 block discarded – undo
2521 2521
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2522 2522
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2523 2523
 	 */
2524
-	private function _get_default_where_conditions($model_relation_path = null){
2525
-		if ( $this->_ignore_where_strategy )
2524
+	private function _get_default_where_conditions($model_relation_path = null) {
2525
+		if ($this->_ignore_where_strategy)
2526 2526
 			return array();
2527 2527
 
2528 2528
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2533,13 +2533,13 @@  discard block
 block discarded – undo
2533 2533
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2534 2534
 	 * @return string
2535 2535
 	 */
2536
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2536
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2537 2537
 		$selects = $this->_get_columns_to_select_for_this_model();
2538
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2538
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2539 2539
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2540 2540
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2541 2541
 		}
2542
-		return implode(", ",$selects);
2542
+		return implode(", ", $selects);
2543 2543
 	}
2544 2544
 
2545 2545
 	/**
@@ -2548,19 +2548,19 @@  discard block
 block discarded – undo
2548 2548
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2549 2549
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2550 2550
 	 */
2551
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2551
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2552 2552
 		$fields = $this->field_settings();
2553 2553
 		$selects = array();
2554 2554
 		$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());
2555
-		foreach($fields as $field_obj){
2556
-			$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()."'";
2555
+		foreach ($fields as $field_obj) {
2556
+			$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()."'";
2557 2557
 		}
2558 2558
 		//make sure we are also getting the PKs of each table
2559 2559
 		$tables = $this->get_tables();
2560
-		if(count($tables) > 1){
2561
-			foreach($tables as $table_obj){
2562
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2563
-				if( ! in_array($qualified_pk_column,$selects)){
2560
+		if (count($tables) > 1) {
2561
+			foreach ($tables as $table_obj) {
2562
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2563
+				if ( ! in_array($qualified_pk_column, $selects)) {
2564 2564
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2565 2565
 				}
2566 2566
 			}
@@ -2584,65 +2584,65 @@  discard block
 block discarded – undo
2584 2584
 	 * @throws EE_Error
2585 2585
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2586 2586
 	 */
2587
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2588
-		if($original_query_param == NULL){
2587
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2588
+		if ($original_query_param == NULL) {
2589 2589
 			$original_query_param = $query_param;
2590 2590
 		}
2591 2591
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2592 2592
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2593
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2594
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2593
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2594
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2595 2595
 		//check to see if we have a field on this model
2596 2596
 		$this_model_fields = $this->field_settings(true);
2597
-		if(array_key_exists($query_param,$this_model_fields)){
2598
-			if($allow_fields){
2597
+		if (array_key_exists($query_param, $this_model_fields)) {
2598
+			if ($allow_fields) {
2599 2599
 				return;
2600
-			}else{
2600
+			} else {
2601 2601
 				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"),
2602
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2602
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2603 2603
 			}
2604 2604
 		}
2605 2605
 		//check if this is a special logic query param
2606
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2607
-			if($allow_logic_query_params){
2606
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2607
+			if ($allow_logic_query_params) {
2608 2608
 				return;
2609
-			}else{
2609
+			} else {
2610 2610
 				throw new EE_Error(
2611 2611
 					sprintf(
2612
-						__( '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' ),
2613
-						implode( '", "', $this->_logic_query_param_keys ),
2614
-						$query_param ,
2615
-						get_class( $this ),
2612
+						__('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'),
2613
+						implode('", "', $this->_logic_query_param_keys),
2614
+						$query_param,
2615
+						get_class($this),
2616 2616
 						'<br />',
2617
-						"\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
2617
+						"\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
2618 2618
 					)
2619 2619
 				);
2620 2620
 			}
2621 2621
 		}
2622 2622
 		//check if it's a custom selection
2623
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2623
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2624 2624
 			return;
2625 2625
 		}
2626 2626
 
2627 2627
 		//check if has a model name at the beginning
2628 2628
 		//and
2629 2629
 		//check if it's a field on a related model
2630
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2631
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2632
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2630
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2631
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2632
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2633 2633
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2634
-				if($query_param == ''){
2634
+				if ($query_param == '') {
2635 2635
 					//nothing left to $query_param
2636 2636
 					//we should actually end in a field name, not a model like this!
2637 2637
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2638
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2639
-				}else{
2638
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2639
+				} else {
2640 2640
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2641 2641
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2642 2642
 					return;
2643 2643
 				}
2644
-			}elseif($query_param == $valid_related_model_name){
2645
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2644
+			}elseif ($query_param == $valid_related_model_name) {
2645
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2646 2646
 				return;
2647 2647
 			}
2648 2648
 		}
@@ -2652,7 +2652,7 @@  discard block
 block discarded – undo
2652 2652
 		//and we previously confirmed it wasn't a logic query param or field on the current model
2653 2653
 		//it's wack, that's what it is
2654 2654
 		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"),
2655
-				$query_param,get_class($this),$query_param_type,$original_query_param));
2655
+				$query_param, get_class($this), $query_param_type, $original_query_param));
2656 2656
 
2657 2657
 	}
2658 2658
 
@@ -2669,26 +2669,26 @@  discard block
 block discarded – undo
2669 2669
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
2670 2670
 	 * @return void
2671 2671
 	 */
2672
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
2672
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
2673 2673
 		$relation_obj = $this->related_settings_for($model_name);
2674 2674
 
2675 2675
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
2676 2676
 		//check if the relation is HABTM, because then we're essentially doing two joins
2677 2677
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
2678
-		if($relation_obj instanceof EE_HABTM_Relation){
2678
+		if ($relation_obj instanceof EE_HABTM_Relation) {
2679 2679
 			$join_model_obj = $relation_obj->get_join_model();
2680 2680
 			//replace the model specified with the join model for this relation chain, whi
2681 2681
 			$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);
2682 2682
 			$new_query_info = new EE_Model_Query_Info_Carrier(
2683 2683
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
2684 2684
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
2685
-			$passed_in_query_info->merge( $new_query_info  );
2685
+			$passed_in_query_info->merge($new_query_info);
2686 2686
 		}
2687 2687
 		//now just join to the other table pointed to by the relation object, and add its data types
2688 2688
 		$new_query_info = new EE_Model_Query_Info_Carrier(
2689 2689
 				array($model_relation_chain=>$model_name),
2690 2690
 				$relation_obj->get_join_statement($model_relation_chain));
2691
-		$passed_in_query_info->merge( $new_query_info  );
2691
+		$passed_in_query_info->merge($new_query_info);
2692 2692
 	}
2693 2693
 
2694 2694
 
@@ -2697,11 +2697,11 @@  discard block
 block discarded – undo
2697 2697
 	 * @param array $where_params like EEM_Base::get_all
2698 2698
 	 * @return string of SQL
2699 2699
 	 */
2700
-	private function _construct_where_clause($where_params){
2700
+	private function _construct_where_clause($where_params) {
2701 2701
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2702
-		if($SQL){
2703
-			return " WHERE ". $SQL;
2704
-		}else{
2702
+		if ($SQL) {
2703
+			return " WHERE ".$SQL;
2704
+		} else {
2705 2705
 			return '';
2706 2706
 		}
2707 2707
 	}
@@ -2712,11 +2712,11 @@  discard block
 block discarded – undo
2712 2712
 	 * @param array $having_params
2713 2713
 	 * @return string
2714 2714
 	 */
2715
-	private function _construct_having_clause($having_params){
2715
+	private function _construct_having_clause($having_params) {
2716 2716
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2717
-		if($SQL){
2718
-			return " HAVING ". $SQL;
2719
-		}else{
2717
+		if ($SQL) {
2718
+			return " HAVING ".$SQL;
2719
+		} else {
2720 2720
 			return '';
2721 2721
 		}
2722 2722
 
@@ -2730,17 +2730,17 @@  discard block
 block discarded – undo
2730 2730
 	 * @return EE_Model_Field_Base
2731 2731
 	 * @throws EE_Error
2732 2732
 	 */
2733
-	protected function _get_field_on_model($field_name,$model_name){
2733
+	protected function _get_field_on_model($field_name, $model_name) {
2734 2734
 		$model_class = 'EEM_'.$model_name;
2735 2735
 		$model_filepath = $model_class.".model.php";
2736
-		EE_Registry::instance()->load_helper( 'File' );
2737
-		if ( is_readable($model_filepath)){
2736
+		EE_Registry::instance()->load_helper('File');
2737
+		if (is_readable($model_filepath)) {
2738 2738
 			require_once($model_filepath);
2739
-			$model_instance=call_user_func($model_name."::instance");
2739
+			$model_instance = call_user_func($model_name."::instance");
2740 2740
 			/* @var $model_instance EEM_Base */
2741 2741
 			return $model_instance->field_settings_for($field_name);
2742
-		}else{
2743
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2742
+		} else {
2743
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
2744 2744
 		}
2745 2745
 	}
2746 2746
 
@@ -2753,43 +2753,43 @@  discard block
 block discarded – undo
2753 2753
 	 * @throws EE_Error
2754 2754
 	 * @return string of SQL
2755 2755
 	 */
2756
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
2757
-		$where_clauses=array();
2758
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
2759
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
2760
-			if(in_array($query_param,$this->_logic_query_param_keys)){
2761
-				switch($query_param){
2756
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
2757
+		$where_clauses = array();
2758
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
2759
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
2760
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
2761
+				switch ($query_param) {
2762 2762
 					case 'not':
2763 2763
 					case 'NOT':
2764
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2764
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2765 2765
 						break;
2766 2766
 					case 'and':
2767 2767
 					case 'AND':
2768
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
2768
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
2769 2769
 						break;
2770 2770
 					case 'or':
2771 2771
 					case 'OR':
2772
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2772
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
2773 2773
 						break;
2774 2774
 				}
2775
-			}else{
2775
+			} else {
2776 2776
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2777 2777
 
2778 2778
 				//if it's not a normal field, maybe it's a custom selection?
2779
-				if( ! $field_obj){
2780
-					if(isset( $this->_custom_selections[$query_param][1])){
2779
+				if ( ! $field_obj) {
2780
+					if (isset($this->_custom_selections[$query_param][1])) {
2781 2781
 						$field_obj = $this->_custom_selections[$query_param][1];
2782
-					}else{
2783
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2782
+					} else {
2783
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
2784 2784
 					}
2785 2785
 				}
2786 2786
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
2787
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2787
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2788 2788
 			}
2789 2789
 		}
2790
-		if($where_clauses){
2791
-			$SQL = implode($glue,$where_clauses);
2792
-		}else{
2790
+		if ($where_clauses) {
2791
+			$SQL = implode($glue, $where_clauses);
2792
+		} else {
2793 2793
 			$SQL = '';
2794 2794
 		}
2795 2795
 		return $SQL;
@@ -2803,18 +2803,18 @@  discard block
 block discarded – undo
2803 2803
 	 * @throws EE_Error
2804 2804
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
2805 2805
 	 */
2806
-	private function _deduce_column_name_from_query_param($query_param){
2806
+	private function _deduce_column_name_from_query_param($query_param) {
2807 2807
 		$field = $this->_deduce_field_from_query_param($query_param);
2808 2808
 
2809
-		if( $field ){
2810
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2811
-			return $table_alias_prefix . $field->get_qualified_column();
2812
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2809
+		if ($field) {
2810
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
2811
+			return $table_alias_prefix.$field->get_qualified_column();
2812
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
2813 2813
 			//maybe it's custom selection item?
2814 2814
 			//if so, just use it as the "column name"
2815 2815
 			return $query_param;
2816
-		}else{
2817
-			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)));
2816
+		} else {
2817
+			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)));
2818 2818
 		}
2819 2819
 	}
2820 2820
 
@@ -2826,11 +2826,11 @@  discard block
 block discarded – undo
2826 2826
 	 * @param string $condition_query_param_key
2827 2827
 	 * @return string
2828 2828
 	 */
2829
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
2829
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
2830 2830
 		$pos_of_star = strpos($condition_query_param_key, '*');
2831
-		if($pos_of_star === FALSE){
2831
+		if ($pos_of_star === FALSE) {
2832 2832
 			return $condition_query_param_key;
2833
-		}else{
2833
+		} else {
2834 2834
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2835 2835
 			return $condition_query_param_sans_star;
2836 2836
 		}
@@ -2845,54 +2845,54 @@  discard block
 block discarded – undo
2845 2845
 	 * @throws EE_Error
2846 2846
 	 * @return string
2847 2847
 	 */
2848
-	private function _construct_op_and_value($op_and_value, $field_obj){
2849
-		if(is_array( $op_and_value )){
2848
+	private function _construct_op_and_value($op_and_value, $field_obj) {
2849
+		if (is_array($op_and_value)) {
2850 2850
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
2851
-			if( ! $operator){
2851
+			if ( ! $operator) {
2852 2852
 				$php_array_like_string = array();
2853
-				foreach($op_and_value as $key => $value){
2853
+				foreach ($op_and_value as $key => $value) {
2854 2854
 					$php_array_like_string[] = "$key=>$value";
2855 2855
 				}
2856
-				throw new EE_Error(sprintf(__("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))", "event_espresso"), implode(",",$php_array_like_string)));
2856
+				throw new EE_Error(sprintf(__("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))", "event_espresso"), implode(",", $php_array_like_string)));
2857 2857
 			}
2858 2858
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2859
-		}else{
2859
+		} else {
2860 2860
 			$operator = '=';
2861 2861
 			$value = $op_and_value;
2862 2862
 		}
2863 2863
 
2864 2864
 		//check to see if the value is actually another field
2865
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2865
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
2866 2866
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2867
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2867
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
2868 2868
 			//in this case, the value should be an array, or at least a comma-separated list
2869 2869
 			//it will need to handle a little differently
2870 2870
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
2871 2871
 			//note: $cleaned_value has already been run through $wpdb->prepare()
2872 2872
 			return $operator.SP.$cleaned_value;
2873
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2873
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
2874 2874
 			//the value should be an array with count of two.
2875
-			if ( count($value) !== 2 )
2876
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
2877
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2875
+			if (count($value) !== 2)
2876
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
2877
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
2878 2878
 			return $operator.SP.$cleaned_value;
2879
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
2880
-			if($value != NULL){
2881
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
2879
+		} elseif (in_array($operator, $this->_null_style_operators)) {
2880
+			if ($value != NULL) {
2881
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
2882 2882
 			}
2883 2883
 			return $operator;
2884
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
2884
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
2885 2885
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
2886 2886
 			//remove other junk. So just treat it as a string.
2887 2887
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
2888
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2889
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
2890
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2891
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
2892
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2893
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
2894
-		}else{
2895
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
2888
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2889
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
2890
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2891
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
2892
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
2893
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
2894
+		} else {
2895
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
2896 2896
 		}
2897 2897
 	}
2898 2898
 
@@ -2904,12 +2904,12 @@  discard block
 block discarded – undo
2904 2904
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
2905 2905
 	 * @return string
2906 2906
 	 */
2907
-	function _construct_between_value( $values, $field_obj ) {
2907
+	function _construct_between_value($values, $field_obj) {
2908 2908
 		$cleaned_values = array();
2909
-		foreach ( $values as $value ) {
2910
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2909
+		foreach ($values as $value) {
2910
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2911 2911
 		}
2912
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
2912
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
2913 2913
 	}
2914 2914
 
2915 2915
 
@@ -2925,26 +2925,26 @@  discard block
 block discarded – undo
2925 2925
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
2926 2926
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
2927 2927
 	 */
2928
-	function _construct_in_value($values,  $field_obj){
2928
+	function _construct_in_value($values, $field_obj) {
2929 2929
 		//check if the value is a CSV list
2930
-		if(is_string($values)){
2930
+		if (is_string($values)) {
2931 2931
 			//in which case, turn it into an array
2932
-			$values = explode(",",$values);
2932
+			$values = explode(",", $values);
2933 2933
 		}
2934 2934
 		$cleaned_values = array();
2935
-		foreach($values as $value){
2936
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2935
+		foreach ($values as $value) {
2936
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2937 2937
 		}
2938 2938
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
2939 2939
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
2940 2940
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
2941
-		if(empty($cleaned_values)){
2941
+		if (empty($cleaned_values)) {
2942 2942
 			$all_fields = $this->field_settings();
2943 2943
 			$a_field = array_shift($all_fields);
2944 2944
 			$main_table = $this->_get_main_table();
2945 2945
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
2946 2946
 		}
2947
-		return "(".implode(",",$cleaned_values).")";
2947
+		return "(".implode(",", $cleaned_values).")";
2948 2948
 	}
2949 2949
 
2950 2950
 
@@ -2956,15 +2956,15 @@  discard block
 block discarded – undo
2956 2956
 	 * @throws EE_Error
2957 2957
 	 * @return false|null|string
2958 2958
 	 */
2959
-	private function _wpdb_prepare_using_field($value,$field_obj){
2959
+	private function _wpdb_prepare_using_field($value, $field_obj) {
2960 2960
 		global $wpdb;
2961
-		if($field_obj instanceof EE_Model_Field_Base){
2962
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
2963
-		}else{//$field_obj should really just be a data type
2964
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
2965
-				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)));
2961
+		if ($field_obj instanceof EE_Model_Field_Base) {
2962
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
2963
+		} else {//$field_obj should really just be a data type
2964
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
2965
+				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)));
2966 2966
 			}
2967
-			return $wpdb->prepare($field_obj,$value);
2967
+			return $wpdb->prepare($field_obj, $value);
2968 2968
 		}
2969 2969
 	}
2970 2970
 
@@ -2976,27 +2976,27 @@  discard block
 block discarded – undo
2976 2976
 	 * @throws EE_Error
2977 2977
 	 * @return EE_Model_Field_Base
2978 2978
 	 */
2979
-	protected function _deduce_field_from_query_param($query_param_name){
2979
+	protected function _deduce_field_from_query_param($query_param_name) {
2980 2980
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
2981 2981
 		//which will help us find the database table and column
2982 2982
 
2983
-		$query_param_parts = explode(".",$query_param_name);
2984
-		if(empty($query_param_parts)){
2985
-			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));
2983
+		$query_param_parts = explode(".", $query_param_name);
2984
+		if (empty($query_param_parts)) {
2985
+			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));
2986 2986
 		}
2987 2987
 		$number_of_parts = count($query_param_parts);
2988
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
2989
-		if($number_of_parts == 1){
2988
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
2989
+		if ($number_of_parts == 1) {
2990 2990
 			$field_name = $last_query_param_part;
2991 2991
 			$model_obj = $this;
2992
-		}else{// $number_of_parts >= 2
2992
+		} else {// $number_of_parts >= 2
2993 2993
 			//the last part is the column name, and there are only 2parts. therefore...
2994 2994
 			$field_name = $last_query_param_part;
2995
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
2995
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
2996 2996
 		}
2997
-		try{
2997
+		try {
2998 2998
 			return $model_obj->field_settings_for($field_name);
2999
-		}catch(EE_Error $e){
2999
+		} catch (EE_Error $e) {
3000 3000
 			return null;
3001 3001
 		}
3002 3002
 	}
@@ -3010,13 +3010,13 @@  discard block
 block discarded – undo
3010 3010
 	 * @throws EE_Error
3011 3011
 	 * @return string
3012 3012
 	 */
3013
-	function _get_qualified_column_for_field($field_name){
3013
+	function _get_qualified_column_for_field($field_name) {
3014 3014
 		$all_fields = $this->field_settings();
3015 3015
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3016
-		if($field){
3016
+		if ($field) {
3017 3017
 			return $field->get_qualified_column();
3018
-		}else{
3019
-			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)));
3018
+		} else {
3019
+			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)));
3020 3020
 		}
3021 3021
 	}
3022 3022
 
@@ -3030,14 +3030,14 @@  discard block
 block discarded – undo
3030 3030
 	 * @param  mixed|string $limit The limit for this select
3031 3031
 	 * @return string 				The final select join element for the query.
3032 3032
 	 */
3033
-	function _construct_limit_join_select( $table_alias, $limit ) {
3033
+	function _construct_limit_join_select($table_alias, $limit) {
3034 3034
 		$SQL = '';
3035 3035
 
3036
-		foreach ( $this->_tables as $table_obj ) {
3037
-			if ( $table_obj instanceof EE_Primary_Table ) {
3038
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3039
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3040
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
3036
+		foreach ($this->_tables as $table_obj) {
3037
+			if ($table_obj instanceof EE_Primary_Table) {
3038
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3039
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3040
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
3041 3041
 			}
3042 3042
 		}
3043 3043
 		return $SQL;
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3051 3051
 	 * @return string SQL
3052 3052
 	 */
3053
-	function _construct_internal_join(){
3053
+	function _construct_internal_join() {
3054 3054
 		$SQL = $this->_get_main_table()->get_table_sql();
3055 3055
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3056 3056
 		return $SQL;
@@ -3071,17 +3071,17 @@  discard block
 block discarded – undo
3071 3071
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3072 3072
 	 * @return string
3073 3073
 	 */
3074
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3074
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3075 3075
 		$SQL = '';
3076 3076
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3077
-		foreach($this->_tables as $table_obj){
3078
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3079
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3077
+		foreach ($this->_tables as $table_obj) {
3078
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3079
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3080 3080
 					//so we're joining to this table, meaning the table is already in
3081 3081
 					//the FROM statement, BUT the primary table isn't. So we want
3082 3082
 					//to add the inverse join sql
3083 3083
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3084
-				}else{
3084
+				} else {
3085 3085
 					//just add a regular JOIN to this table from the primary table
3086 3086
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3087 3087
 				}
@@ -3095,9 +3095,9 @@  discard block
 block discarded – undo
3095 3095
 	 * 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)
3096 3096
 	 * @return array
3097 3097
 	 */
3098
-	function _get_data_types(){
3098
+	function _get_data_types() {
3099 3099
 		$data_types = array();
3100
-		foreach(array_values($this->field_settings()) as $field_obj){
3100
+		foreach (array_values($this->field_settings()) as $field_obj) {
3101 3101
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3102 3102
 			/** @var $field_obj EE_Model_Field_Base */
3103 3103
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3113,11 +3113,11 @@  discard block
 block discarded – undo
3113 3113
 	 * @throws EE_Error
3114 3114
 	 * @return EEM_Base
3115 3115
 	 */
3116
-	function get_related_model_obj($model_name){
3116
+	function get_related_model_obj($model_name) {
3117 3117
 
3118 3118
 		$model_classname = "EEM_".$model_name;
3119
-		if(!class_exists($model_classname)){
3120
-			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));
3119
+		if ( ! class_exists($model_classname)) {
3120
+			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));
3121 3121
 		}
3122 3122
 		$model_obj = call_user_func($model_classname."::instance");
3123 3123
 		return $model_obj;
@@ -3128,7 +3128,7 @@  discard block
 block discarded – undo
3128 3128
 	 * Returns the array of EE_ModelRelations for this model.
3129 3129
 	 * @return EE_Model_Relation_Base[]
3130 3130
 	 */
3131
-	public function relation_settings(){
3131
+	public function relation_settings() {
3132 3132
 		return $this->_model_relations;
3133 3133
 	}
3134 3134
 
@@ -3138,10 +3138,10 @@  discard block
 block discarded – undo
3138 3138
 	 * (Eg, without an event, datetimes have little purpose.)
3139 3139
 	 * @return EE_Belongs_To_Relation[]
3140 3140
 	 */
3141
-	public function belongs_to_relations(){
3141
+	public function belongs_to_relations() {
3142 3142
 		$belongs_to_relations = array();
3143
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3144
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3143
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3144
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3145 3145
 				$belongs_to_relations[$model_name] = $relation_obj;
3146 3146
 			}
3147 3147
 		}
@@ -3156,15 +3156,15 @@  discard block
 block discarded – undo
3156 3156
 	 * @throws EE_Error
3157 3157
 	 * @return EE_Model_Relation_Base
3158 3158
 	 */
3159
-	public function related_settings_for($relation_name){
3160
-		$relatedModels=$this->relation_settings();
3161
-		if(!array_key_exists($relation_name,$relatedModels)){
3159
+	public function related_settings_for($relation_name) {
3160
+		$relatedModels = $this->relation_settings();
3161
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3162 3162
 			throw new EE_Error(
3163 3163
 				sprintf(
3164
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3164
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3165 3165
 					$relation_name,
3166 3166
 					$this->_get_class_name(),
3167
-					implode( ', ', array_keys( $relatedModels ))
3167
+					implode(', ', array_keys($relatedModels))
3168 3168
 				)
3169 3169
 			);
3170 3170
 		}
@@ -3179,10 +3179,10 @@  discard block
 block discarded – undo
3179 3179
 	 * @throws EE_Error
3180 3180
 	 * @return EE_Model_Field_Base
3181 3181
 	 */
3182
-	public function field_settings_for($fieldName){
3183
-		$fieldSettings=$this->field_settings(true);
3184
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3185
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3182
+	public function field_settings_for($fieldName) {
3183
+		$fieldSettings = $this->field_settings(true);
3184
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3185
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3186 3186
 		}
3187 3187
 		return $fieldSettings[$fieldName];
3188 3188
 	}
@@ -3192,11 +3192,11 @@  discard block
 block discarded – undo
3192 3192
 	 * @param string $fieldName a key in the model's _field_settings array
3193 3193
 	 * @return boolean
3194 3194
 	 */
3195
-	public function has_field($fieldName){
3195
+	public function has_field($fieldName) {
3196 3196
 		$fieldSettings = $this->field_settings(true);
3197
-		if( isset($fieldSettings[$fieldName])){
3197
+		if (isset($fieldSettings[$fieldName])) {
3198 3198
 			return true;
3199
-		}else{
3199
+		} else {
3200 3200
 			return false;
3201 3201
 		}
3202 3202
 	}
@@ -3206,11 +3206,11 @@  discard block
 block discarded – undo
3206 3206
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3207 3207
 	 * @return boolean
3208 3208
 	 */
3209
-	public function has_relation($relation_name){
3209
+	public function has_relation($relation_name) {
3210 3210
 		$relations = $this->relation_settings();
3211
-		if(isset($relations[$relation_name])){
3211
+		if (isset($relations[$relation_name])) {
3212 3212
 			return true;
3213
-		}else{
3213
+		} else {
3214 3214
 			return false;
3215 3215
 		}
3216 3216
 	}
@@ -3222,7 +3222,7 @@  discard block
 block discarded – undo
3222 3222
 	 * @param $field_obj
3223 3223
 	 * @return EE_Model_Field_Base
3224 3224
 	 */
3225
-	public function is_primary_key_field( $field_obj ){
3225
+	public function is_primary_key_field($field_obj) {
3226 3226
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3227 3227
 	}
3228 3228
 
@@ -3234,16 +3234,16 @@  discard block
 block discarded – undo
3234 3234
 	 * @return EE_Model_Field_Base
3235 3235
 	 * @throws EE_Error
3236 3236
 	 */
3237
-	public function get_primary_key_field(){
3238
-		if( $this->_primary_key_field === NULL ){
3239
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3240
-				if( $this->is_primary_key_field( $field_obj )){
3237
+	public function get_primary_key_field() {
3238
+		if ($this->_primary_key_field === NULL) {
3239
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3240
+				if ($this->is_primary_key_field($field_obj)) {
3241 3241
 					$this->_primary_key_field = $field_obj;
3242 3242
 					break;
3243 3243
 				}
3244 3244
 			}
3245
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3246
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3245
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3246
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3247 3247
 			}
3248 3248
 		}
3249 3249
 		return $this->_primary_key_field;
@@ -3256,12 +3256,12 @@  discard block
 block discarded – undo
3256 3256
 	 * Internally does some caching.
3257 3257
 	 * @return boolean
3258 3258
 	 */
3259
-	public function has_primary_key_field(){
3260
-		if($this->_has_primary_key_field === null){
3261
-			try{
3259
+	public function has_primary_key_field() {
3260
+		if ($this->_has_primary_key_field === null) {
3261
+			try {
3262 3262
 				$this->get_primary_key_field();
3263 3263
 				$this->_has_primary_key_field = true;
3264
-			}catch(EE_Error $e){
3264
+			} catch (EE_Error $e) {
3265 3265
 				$this->_has_primary_key_field = false;
3266 3266
 			}
3267 3267
 		}
@@ -3275,9 +3275,9 @@  discard block
 block discarded – undo
3275 3275
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3276 3276
 	 * @return EE_Model_Field_Base or null if none is found
3277 3277
 	 */
3278
-	public function get_a_field_of_type($field_class_name){
3279
-		foreach($this->field_settings() as $field){
3280
-			if( $field instanceof $field_class_name ){
3278
+	public function get_a_field_of_type($field_class_name) {
3279
+		foreach ($this->field_settings() as $field) {
3280
+			if ($field instanceof $field_class_name) {
3281 3281
 				return $field;
3282 3282
 			}
3283 3283
 		}
@@ -3291,21 +3291,21 @@  discard block
 block discarded – undo
3291 3291
 	 * @return EE_Foreign_Key_Field_Base
3292 3292
 	 * @throws EE_Error
3293 3293
 	 */
3294
-	public function get_foreign_key_to($model_name){
3295
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3296
-			foreach($this->field_settings() as $field){
3294
+	public function get_foreign_key_to($model_name) {
3295
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3296
+			foreach ($this->field_settings() as $field) {
3297 3297
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3298
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3299
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3300
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3298
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3299
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3300
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3301 3301
 					}
3302 3302
 				}
3303 3303
 			}
3304
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3305
-				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)));
3304
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3305
+				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)));
3306 3306
 			}
3307 3307
 		}
3308
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3308
+		return $this->_cache_foreign_key_to_fields[$model_name];
3309 3309
 	}
3310 3310
 
3311 3311
 
@@ -3316,7 +3316,7 @@  discard block
 block discarded – undo
3316 3316
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3317 3317
 	 * @return EE_Table_Base
3318 3318
 	 */
3319
-	function get_table_for_alias($table_alias){
3319
+	function get_table_for_alias($table_alias) {
3320 3320
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3321 3321
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3322 3322
 	}
@@ -3329,25 +3329,25 @@  discard block
 block discarded – undo
3329 3329
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3330 3330
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3331 3331
 	 */
3332
-	public function field_settings($include_db_only_fields = false){
3333
-		if( $include_db_only_fields ){
3334
-			if( $this->_cached_fields === NULL ){
3332
+	public function field_settings($include_db_only_fields = false) {
3333
+		if ($include_db_only_fields) {
3334
+			if ($this->_cached_fields === NULL) {
3335 3335
 				$this->_cached_fields = array();
3336
-				foreach($this->_fields as $fields_corresponding_to_table){
3337
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3338
-						$this->_cached_fields[$field_name]=$field_obj;
3336
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3337
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3338
+						$this->_cached_fields[$field_name] = $field_obj;
3339 3339
 					}
3340 3340
 				}
3341 3341
 			}
3342 3342
 			return $this->_cached_fields;
3343
-		}else{
3344
-			if( $this->_cached_fields_non_db_only === NULL ){
3343
+		} else {
3344
+			if ($this->_cached_fields_non_db_only === NULL) {
3345 3345
 				$this->_cached_fields_non_db_only = array();
3346
-				foreach($this->_fields as $fields_corresponding_to_table){
3347
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3346
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3347
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3348 3348
 						/** @var $field_obj EE_Model_Field_Base */
3349
-						if( ! $field_obj->is_db_only_field() ){
3350
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3349
+						if ( ! $field_obj->is_db_only_field()) {
3350
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3351 3351
 						}
3352 3352
 					}
3353 3353
 				}
@@ -3366,40 +3366,40 @@  discard block
 block discarded – undo
3366 3366
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3367 3367
 	 * @throws \EE_Error
3368 3368
 	 */
3369
-	protected function _create_objects( $rows = array() ) {
3370
-		$array_of_objects=array();
3371
-		if(empty($rows)){
3369
+	protected function _create_objects($rows = array()) {
3370
+		$array_of_objects = array();
3371
+		if (empty($rows)) {
3372 3372
 			return array();
3373 3373
 		}
3374 3374
 		$count_if_model_has_no_primary_key = 0;
3375
-		foreach ( $rows as $row ) {
3376
-			if(empty($row)){//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3375
+		foreach ($rows as $row) {
3376
+			if (empty($row)) {//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3377 3377
 				return array();
3378 3378
 			}
3379
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3380
-			if( ! $classInstance ) {
3381
-				throw new EE_Error( sprintf( __( 'Could not create instance of class %s from row %s', 'event_espresso' ), $this->get_this_model_name(), http_build_query( $row ) ) );
3379
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3380
+			if ( ! $classInstance) {
3381
+				throw new EE_Error(sprintf(__('Could not create instance of class %s from row %s', 'event_espresso'), $this->get_this_model_name(), http_build_query($row)));
3382 3382
 			}
3383 3383
 			//set the timezone on the instantiated objects
3384
-			$classInstance->set_timezone( $this->_timezone );
3384
+			$classInstance->set_timezone($this->_timezone);
3385 3385
 			//make sure if there is any timezone setting present that we set the timezone for the object
3386
-			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++]=$classInstance;
3386
+			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++] = $classInstance;
3387 3387
 			//also, for all the relations of type BelongsTo, see if we can cache
3388 3388
 			//those related models
3389 3389
 			//(we could do this for other relations too, but if there are conditions
3390 3390
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3391 3391
 			//so it requires a little more thought than just caching them immediately...)
3392
-			foreach($this->_model_relations as $modelName => $relation_obj){
3393
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3392
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3393
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3394 3394
 					//check if this model's INFO is present. If so, cache it on the model
3395 3395
 					$other_model = $relation_obj->get_other_model();
3396 3396
 
3397 3397
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3398 3398
 
3399 3399
 					//if we managed to make a model object from the results, cache it on the main model object
3400
-					if( $other_model_obj_maybe ){
3400
+					if ($other_model_obj_maybe) {
3401 3401
 						//set timezone on these other model objects if they are present
3402
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3402
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3403 3403
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3404 3404
 					}
3405 3405
 				}
@@ -3420,12 +3420,12 @@  discard block
 block discarded – undo
3420 3420
 
3421 3421
 		$this_model_fields_and_values = array();
3422 3422
 		//setup the row using default values;
3423
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3423
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3424 3424
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3425 3425
 		}
3426 3426
 
3427 3427
 		$className = $this->_get_class_name();
3428
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3428
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3429 3429
 
3430 3430
 		return $classInstance;
3431 3431
 	}
@@ -3436,13 +3436,13 @@  discard block
 block discarded – undo
3436 3436
 	 * _get_cached_acceptable_table_columns
3437 3437
 	 * @return EE_Model_Field_Base[]|null
3438 3438
 	 */
3439
-	private function _get_cached_acceptable_table_columns(){
3440
-		if( $this->_model_fields_sorted_by_db_col === NULL ){
3441
-			foreach( $this->field_settings() as $field_obj ){
3442
-				if( ! $field_obj->is_db_only_field() ){
3443
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_qualified_column() ] = $field_obj;
3439
+	private function _get_cached_acceptable_table_columns() {
3440
+		if ($this->_model_fields_sorted_by_db_col === NULL) {
3441
+			foreach ($this->field_settings() as $field_obj) {
3442
+				if ( ! $field_obj->is_db_only_field()) {
3443
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_qualified_column()] = $field_obj;
3444 3444
 //					$this->_model_fields_sorted_by_db_col[ $field->get_table_column() ] = $field_obj;
3445
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_table_column() ] = $field_obj;
3445
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_table_column()] = $field_obj;
3446 3446
 				}
3447 3447
 			}
3448 3448
 		}
@@ -3455,45 +3455,45 @@  discard block
 block discarded – undo
3455 3455
 	 * or an stdClass where each property is the name of a column,
3456 3456
 	 * @return EE_Base_Class
3457 3457
 	 */
3458
-	public function instantiate_class_from_array_or_object($cols_n_values){
3459
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3460
-			$cols_n_values = get_object_vars( $cols_n_values );
3458
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3459
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3460
+			$cols_n_values = get_object_vars($cols_n_values);
3461 3461
 		}
3462 3462
 		$primary_key = NULL;
3463 3463
 		//make sure the array only has keys that are fields/columns on this model
3464
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3465
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3466
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3464
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3465
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3466
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3467 3467
 		}
3468
-		$className=$this->_get_class_name();
3468
+		$className = $this->_get_class_name();
3469 3469
 
3470 3470
 		//check we actually found results that we can use to build our model object
3471 3471
 		//if not, return null
3472
-		if( $this->has_primary_key_field()){
3473
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3472
+		if ($this->has_primary_key_field()) {
3473
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3474 3474
 				return NULL;
3475 3475
 			}
3476
-		}else if($this->unique_indexes()){
3476
+		} else if ($this->unique_indexes()) {
3477 3477
 			$first_column = reset($this_model_fields_n_values);
3478
-			if(empty($first_column)){
3478
+			if (empty($first_column)) {
3479 3479
 				return NULL;
3480 3480
 			}
3481 3481
 		}
3482 3482
 
3483 3483
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3484
-		if ( $primary_key){
3485
-			$classInstance = $this->get_from_entity_map( $primary_key );
3486
-			if( ! $classInstance) {
3487
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3484
+		if ($primary_key) {
3485
+			$classInstance = $this->get_from_entity_map($primary_key);
3486
+			if ( ! $classInstance) {
3487
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3488 3488
 				// add this new object to the entity map
3489
-				$classInstance = $this->add_to_entity_map( $classInstance );
3489
+				$classInstance = $this->add_to_entity_map($classInstance);
3490 3490
 			}
3491
-		}else{
3492
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3491
+		} else {
3492
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3493 3493
 		}
3494 3494
 
3495 3495
 			//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.
3496
-		$this->set_timezone( $classInstance->get_timezone() );
3496
+		$this->set_timezone($classInstance->get_timezone());
3497 3497
 		return $classInstance;
3498 3498
 	}
3499 3499
 	/**
@@ -3501,8 +3501,8 @@  discard block
 block discarded – undo
3501 3501
 	 * @param int|string $id the ID of the model object
3502 3502
 	 * @return EE_Base_Class
3503 3503
 	 */
3504
-	public function get_from_entity_map( $id ){
3505
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3504
+	public function get_from_entity_map($id) {
3505
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3506 3506
 	}
3507 3507
 
3508 3508
 
@@ -3521,21 +3521,21 @@  discard block
 block discarded – undo
3521 3521
 	 * @throws EE_Error
3522 3522
 	 * @return \EE_Base_Class
3523 3523
 	 */
3524
-	public function add_to_entity_map( EE_Base_Class $object) {
3524
+	public function add_to_entity_map(EE_Base_Class $object) {
3525 3525
 		$className = $this->_get_class_name();
3526
-		if( ! $object instanceof $className ){
3527
-			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 ) );
3526
+		if ( ! $object instanceof $className) {
3527
+			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));
3528 3528
 		}
3529 3529
 		/** @var $object EE_Base_Class */
3530
-		if ( ! $object->ID() ){
3531
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3530
+		if ( ! $object->ID()) {
3531
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3532 3532
 		}
3533 3533
 		// double check it's not already there
3534
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3535
-		if ( $classInstance ) {
3534
+		$classInstance = $this->get_from_entity_map($object->ID());
3535
+		if ($classInstance) {
3536 3536
 			return $classInstance;
3537 3537
 		} else {
3538
-			$this->_entity_map[ $object->ID() ] = $object;
3538
+			$this->_entity_map[$object->ID()] = $object;
3539 3539
 			return $object;
3540 3540
 		}
3541 3541
 	}
@@ -3548,8 +3548,8 @@  discard block
 block discarded – undo
3548 3548
 	 * @param array $cols_n_values
3549 3549
 	 * @return array
3550 3550
 	 */
3551
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3552
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3551
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3552
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3553 3553
 	}
3554 3554
 
3555 3555
 
@@ -3562,38 +3562,38 @@  discard block
 block discarded – undo
3562 3562
 	 * @param string $cols_n_values
3563 3563
 	 * @return array
3564 3564
 	 */
3565
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3565
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3566 3566
 		$this_model_fields_n_values = array();
3567
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3568
-			$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() );
3567
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3568
+			$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());
3569 3569
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3570
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3571
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3572
-					if( ! $field_obj->is_db_only_field() ){
3570
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3571
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3572
+					if ( ! $field_obj->is_db_only_field()) {
3573 3573
 						$this_model_fields_n_values[$field_name] = $field_obj->get_default_value();
3574 3574
 					}
3575 3575
 				}
3576
-			}else{
3576
+			} else {
3577 3577
 				//the table's rows existed. Use their values
3578
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3579
-					if( ! $field_obj->is_db_only_field() )
3580
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3578
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3579
+					if ( ! $field_obj->is_db_only_field())
3580
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
3581 3581
 				}
3582 3582
 			}
3583 3583
 		}
3584 3584
 		return $this_model_fields_n_values;
3585 3585
 	}
3586 3586
 
3587
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3587
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3588 3588
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3589 3589
 		//does the field on the model relate to this column retrieved from the db?
3590 3590
 		//or is it a db-only field? (not relating to the model)
3591
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3592
-			$value = $cols_n_values[ $qualified_column ];
3591
+		if (isset($cols_n_values[$qualified_column])) {
3592
+			$value = $cols_n_values[$qualified_column];
3593 3593
 
3594
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3595
-			$value = $cols_n_values[ $regular_column ];
3596
-		}else{
3594
+		}elseif (isset($cols_n_values[$regular_column])) {
3595
+			$value = $cols_n_values[$regular_column];
3596
+		} else {
3597 3597
 			$value = NULL;
3598 3598
 		}
3599 3599
 
@@ -3611,23 +3611,23 @@  discard block
 block discarded – undo
3611 3611
 	 * @param int|string $id
3612 3612
 	 * @return EE_Base_Class
3613 3613
 	 */
3614
-	public function refresh_entity_map_from_db( $id ){
3615
-		$obj_in_map = $this->get_from_entity_map( $id );
3616
-		if( $obj_in_map ){
3617
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3618
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3619
-				$one_row = reset( $wpdb_results );
3620
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3621
-					$obj_in_map->set_from_db( $field_name, $db_value );
3614
+	public function refresh_entity_map_from_db($id) {
3615
+		$obj_in_map = $this->get_from_entity_map($id);
3616
+		if ($obj_in_map) {
3617
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3618
+			if ($wpdb_results && is_array($wpdb_results)) {
3619
+				$one_row = reset($wpdb_results);
3620
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3621
+					$obj_in_map->set_from_db($field_name, $db_value);
3622 3622
 				}
3623 3623
 				//clear the cache of related model objects
3624
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3625
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3624
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3625
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3626 3626
 				}
3627 3627
 			}
3628 3628
 			return $obj_in_map;
3629
-		}else{
3630
-			return $this->get_one_by_ID( $id );
3629
+		} else {
3630
+			return $this->get_one_by_ID($id);
3631 3631
 		}
3632 3632
 	}
3633 3633
 
@@ -3645,24 +3645,24 @@  discard block
 block discarded – undo
3645 3645
 	 * @param EE_Base_Class $replacing_model_obj
3646 3646
 	 * @return \EE_Base_Class
3647 3647
 	 */
3648
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
3649
-		$obj_in_map = $this->get_from_entity_map( $id );
3650
-		if( $obj_in_map ){
3651
-			if( $replacing_model_obj instanceof EE_Base_Class ){
3652
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
3653
-					$obj_in_map->set( $field_name, $value );
3648
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
3649
+		$obj_in_map = $this->get_from_entity_map($id);
3650
+		if ($obj_in_map) {
3651
+			if ($replacing_model_obj instanceof EE_Base_Class) {
3652
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
3653
+					$obj_in_map->set($field_name, $value);
3654 3654
 				}
3655 3655
 				//make the model object in the entity map's cache match the $replacing_model_obj
3656
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3657
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3658
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
3659
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
3656
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3657
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3658
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
3659
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
3660 3660
 					}
3661 3661
 				}
3662 3662
 			}
3663 3663
 			return $obj_in_map;
3664
-		}else{
3665
-			$this->add_to_entity_map( $replacing_model_obj );
3664
+		} else {
3665
+			$this->add_to_entity_map($replacing_model_obj);
3666 3666
 			return $replacing_model_obj;
3667 3667
 		}
3668 3668
 	}
@@ -3675,7 +3675,7 @@  discard block
 block discarded – undo
3675 3675
 	 * require_once($this->_getClassName().".class.php");
3676 3676
 	 * @return string
3677 3677
 	 */
3678
-	private function _get_class_name(){
3678
+	private function _get_class_name() {
3679 3679
 		return "EE_".$this->get_this_model_name();
3680 3680
 	}
3681 3681
 
@@ -3688,10 +3688,10 @@  discard block
 block discarded – undo
3688 3688
 	 * @param int $quantity
3689 3689
 	 * @return string
3690 3690
 	 */
3691
-	public function item_name($quantity = 1){
3692
-		if($quantity == 1){
3691
+	public function item_name($quantity = 1) {
3692
+		if ($quantity == 1) {
3693 3693
 			return $this->singular_item;
3694
-		}else{
3694
+		} else {
3695 3695
 			return $this->plural_item;
3696 3696
 		}
3697 3697
 	}
@@ -3720,13 +3720,13 @@  discard block
 block discarded – undo
3720 3720
 	 * @throws EE_Error
3721 3721
 	 * @return mixed whatever the plugin which calls add_filter decides
3722 3722
 	 */
3723
-	public function __call($methodName,$args){
3724
-		$className=get_class($this);
3725
-		$tagName="FHEE__{$className}__{$methodName}";
3726
-		if(!has_filter($tagName)){
3723
+	public function __call($methodName, $args) {
3724
+		$className = get_class($this);
3725
+		$tagName = "FHEE__{$className}__{$methodName}";
3726
+		if ( ! has_filter($tagName)) {
3727 3727
 			throw new EE_Error(
3728 3728
 				sprintf(
3729
-					__( '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' ),
3729
+					__('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'),
3730 3730
 					$methodName,
3731 3731
 					$className,
3732 3732
 					$tagName,
@@ -3735,7 +3735,7 @@  discard block
 block discarded – undo
3735 3735
 			);
3736 3736
 		}
3737 3737
 
3738
-		return apply_filters($tagName,null,$this,$args);
3738
+		return apply_filters($tagName, null, $this, $args);
3739 3739
 	}
3740 3740
 
3741 3741
 
@@ -3748,22 +3748,22 @@  discard block
 block discarded – undo
3748 3748
 	 * @throws EE_Error
3749 3749
 	 * @return EE_Base_Class
3750 3750
 	 */
3751
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
3751
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
3752 3752
 		$className = $this->_get_class_name();
3753 3753
 		$primary_key_field = $this->get_primary_key_field();
3754
-		if( $base_class_obj_or_id instanceof $className ){
3754
+		if ($base_class_obj_or_id instanceof $className) {
3755 3755
 			$model_object = $base_class_obj_or_id;
3756
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3757
-				is_int( $base_class_obj_or_id ) ||
3758
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3756
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
3757
+				is_int($base_class_obj_or_id) ||
3758
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3759 3759
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3760
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3760
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
3761 3761
 			//assume its a string representation of the object
3762 3762
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3763
-		}else{
3764
-			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)));
3763
+		} else {
3764
+			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)));
3765 3765
 		}
3766
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
3766
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
3767 3767
 			$model_object->save();
3768 3768
 		}
3769 3769
 		return $model_object;
@@ -3779,19 +3779,19 @@  discard block
 block discarded – undo
3779 3779
 	 * @return int|string depending on the type of this model object's ID
3780 3780
 	 * @throws EE_Error
3781 3781
 	 */
3782
-	public function ensure_is_ID($base_class_obj_or_id){
3782
+	public function ensure_is_ID($base_class_obj_or_id) {
3783 3783
 		$className = $this->_get_class_name();
3784
-		if( $base_class_obj_or_id instanceof $className ){
3784
+		if ($base_class_obj_or_id instanceof $className) {
3785 3785
 			/** @var $base_class_obj_or_id EE_Base_Class */
3786 3786
 			$id = $base_class_obj_or_id->ID();
3787
-		}elseif(is_int($base_class_obj_or_id)){
3787
+		}elseif (is_int($base_class_obj_or_id)) {
3788 3788
 			//assume it's an ID
3789 3789
 			$id = $base_class_obj_or_id;
3790
-		}elseif(is_string($base_class_obj_or_id)){
3790
+		}elseif (is_string($base_class_obj_or_id)) {
3791 3791
 			//assume its a string representation of the object
3792 3792
 			$id = $base_class_obj_or_id;
3793
-		}else{
3794
-			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)));
3793
+		} else {
3794
+			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)));
3795 3795
 		}
3796 3796
 		return $id;
3797 3797
 	}
@@ -3814,14 +3814,14 @@  discard block
 block discarded – undo
3814 3814
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
3815 3815
 	 * @return void
3816 3816
 	 */
3817
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
3817
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
3818 3818
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
3819 3819
 	}
3820 3820
 	/**
3821 3821
 	 * Read comments for assume_values_already_prepared_by_model_object()
3822 3822
 	 * @return int
3823 3823
 	 */
3824
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
3824
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
3825 3825
 		return $this->_values_already_prepared_by_model_object;
3826 3826
 	}
3827 3827
 
@@ -3829,17 +3829,17 @@  discard block
 block discarded – undo
3829 3829
 	 * Gets all the indexes on this model
3830 3830
 	 * @return EE_Index[]
3831 3831
 	 */
3832
-	public function indexes(){
3832
+	public function indexes() {
3833 3833
 		return $this->_indexes;
3834 3834
 	}
3835 3835
 	/**
3836 3836
 	 * Gets all the Unique Indexes on this model
3837 3837
 	 * @return EE_Unique_Index[]
3838 3838
 	 */
3839
-	public function unique_indexes(){
3839
+	public function unique_indexes() {
3840 3840
 		$unique_indexes = array();
3841
-		foreach($this->_indexes as $name => $index){
3842
-			if($index instanceof EE_Unique_Index){
3841
+		foreach ($this->_indexes as $name => $index) {
3842
+			if ($index instanceof EE_Unique_Index) {
3843 3843
 				$unique_indexes [$name] = $index;
3844 3844
 			}
3845 3845
 		}
@@ -3852,9 +3852,9 @@  discard block
 block discarded – undo
3852 3852
 	 * on a primary index
3853 3853
 	 * @return EE_Model_Field_Base[]
3854 3854
 	 */
3855
-	public function get_combined_primary_key_fields(){
3856
-		foreach($this->indexes() as $index){
3857
-			if($index instanceof EE_Primary_Key_Index){
3855
+	public function get_combined_primary_key_fields() {
3856
+		foreach ($this->indexes() as $index) {
3857
+			if ($index instanceof EE_Primary_Key_Index) {
3858 3858
 				return $index->fields();
3859 3859
 			}
3860 3860
 		}
@@ -3867,7 +3867,7 @@  discard block
 block discarded – undo
3867 3867
 	 * @param array $cols_n_values keys are field names, values are their values
3868 3868
 	 * @return string
3869 3869
 	 */
3870
-	public function get_index_primary_key_string($cols_n_values){
3870
+	public function get_index_primary_key_string($cols_n_values) {
3871 3871
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
3872 3872
 		return http_build_query($cols_n_values_for_primary_key_index);
3873 3873
 	}
@@ -3879,13 +3879,13 @@  discard block
 block discarded – undo
3879 3879
 	 * @param string $index_primary_key_string
3880 3880
 	 * @return null|array
3881 3881
 	 */
3882
-	function parse_index_primary_key_string( $index_primary_key_string) {
3882
+	function parse_index_primary_key_string($index_primary_key_string) {
3883 3883
 		$key_fields = $this->get_combined_primary_key_fields();
3884 3884
 		//check all of them are in the $id
3885 3885
 		$key_vals_in_combined_pk = array();
3886
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
3887
-		foreach( $key_fields as $key_field_name => $field_obj ) {
3888
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
3886
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
3887
+		foreach ($key_fields as $key_field_name => $field_obj) {
3888
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
3889 3889
 				return NULL;
3890 3890
 			}
3891 3891
 		}
@@ -3898,10 +3898,10 @@  discard block
 block discarded – undo
3898 3898
 	 * @param array $key_vals
3899 3899
 	 * @return boolean
3900 3900
 	 */
3901
-	function has_all_combined_primary_key_fields( $key_vals ) {
3902
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
3903
-		foreach( $keys_it_should_have as $key ){
3904
-			if( ! isset( $key_vals[ $key ] ) ){
3901
+	function has_all_combined_primary_key_fields($key_vals) {
3902
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
3903
+		foreach ($keys_it_should_have as $key) {
3904
+			if ( ! isset($key_vals[$key])) {
3905 3905
 				return false;
3906 3906
 			}
3907 3907
 		}
@@ -3917,23 +3917,23 @@  discard block
 block discarded – undo
3917 3917
 	 * @throws EE_Error
3918 3918
 	 * @return \EE_Base_Class[]
3919 3919
 	 */
3920
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
3920
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
3921 3921
 
3922
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
3922
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
3923 3923
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
3924
-		}elseif(is_array($model_object_or_attributes_array)){
3924
+		}elseif (is_array($model_object_or_attributes_array)) {
3925 3925
 			$attributes_array = $model_object_or_attributes_array;
3926
-		}else{
3927
-			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));
3926
+		} else {
3927
+			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));
3928 3928
 		}
3929 3929
 		//even copies obviously won't have the same ID, so remove the primary key
3930 3930
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
3931
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
3931
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
3932 3932
 			unset($attributes_array[$this->primary_key_name()]);
3933 3933
 		}
3934
-		if(isset($query_params[0])){
3935
-			$query_params[0] = array_merge($attributes_array,$query_params);
3936
-		}else{
3934
+		if (isset($query_params[0])) {
3935
+			$query_params[0] = array_merge($attributes_array, $query_params);
3936
+		} else {
3937 3937
 			$query_params[0] = $attributes_array;
3938 3938
 		}
3939 3939
 		return $this->get_all($query_params);
@@ -3947,16 +3947,16 @@  discard block
 block discarded – undo
3947 3947
 	 * @param array $query_params
3948 3948
 	 * @return EE_Base_Class
3949 3949
 	 */
3950
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
3951
-		if( ! is_array( $query_params ) ){
3952
-			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' );
3950
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
3951
+		if ( ! is_array($query_params)) {
3952
+			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');
3953 3953
 			$query_params = array();
3954 3954
 		}
3955 3955
 		$query_params['limit'] = 1;
3956
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
3957
-		if(is_array($copies)){
3956
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
3957
+		if (is_array($copies)) {
3958 3958
 			return array_shift($copies);
3959
-		}else{
3959
+		} else {
3960 3960
 			return null;
3961 3961
 		}
3962 3962
 	}
@@ -3970,10 +3970,10 @@  discard block
 block discarded – undo
3970 3970
 	 * @param int|string $id the value of the primary key to update
3971 3971
 	 * @return int number of rows updated
3972 3972
 	 */
3973
-	public function update_by_ID($fields_n_values,$id){
3973
+	public function update_by_ID($fields_n_values, $id) {
3974 3974
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
3975 3975
 			'default_where_conditions'=>'other_models_only',);
3976
-		return $this->update($fields_n_values,$query_params);
3976
+		return $this->update($fields_n_values, $query_params);
3977 3977
 	}
3978 3978
 
3979 3979
 
@@ -3984,12 +3984,12 @@  discard block
 block discarded – undo
3984 3984
 	 * @return string an operator which can be used in SQL
3985 3985
 	 * @throws EE_Error
3986 3986
 	 */
3987
-	private function _prepare_operator_for_sql($operator_supplied){
3987
+	private function _prepare_operator_for_sql($operator_supplied) {
3988 3988
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
3989
-		if($sql_operator){
3989
+		if ($sql_operator) {
3990 3990
 			return $sql_operator;
3991
-		}else{
3992
-			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))));
3991
+		} else {
3992
+			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))));
3993 3993
 		}
3994 3994
 	}
3995 3995
 
@@ -3999,10 +3999,10 @@  discard block
 block discarded – undo
3999 3999
 	 * @param array $query_params like get_all's
4000 4000
 	 * @return string[]
4001 4001
 	 */
4002
-	public function get_all_names($query_params = array()){
4002
+	public function get_all_names($query_params = array()) {
4003 4003
 		$objs = $this->get_all($query_params);
4004 4004
 		$names = array();
4005
-		foreach($objs as $obj){
4005
+		foreach ($objs as $obj) {
4006 4006
 			$names[$obj->ID()] = $obj->name();
4007 4007
 		}
4008 4008
 		return $names;
@@ -4013,8 +4013,8 @@  discard block
 block discarded – undo
4013 4013
 	 * are no capabilities that relate to this model returns false
4014 4014
 	 * @return string|false
4015 4015
 	 */
4016
-	public function cap_slug(){
4017
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4016
+	public function cap_slug() {
4017
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4018 4018
 	}
4019 4019
 
4020 4020
 	/**
@@ -4026,27 +4026,27 @@  discard block
 block discarded – undo
4026 4026
 	 * @param string $context
4027 4027
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4028 4028
 	 */
4029
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4030
-		EEM_Base::verify_is_valid_cap_context( $context );
4029
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4030
+		EEM_Base::verify_is_valid_cap_context($context);
4031 4031
 		//check if we ought to run the restriction generator first
4032
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4033
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4034
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4035
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4032
+		if (isset($this->_cap_restriction_generators[$context]) &&
4033
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4034
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4035
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4036 4036
 		}
4037 4037
 		//and make sure we've finalized the construction of each restriction
4038
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4039
-			$where_conditions_obj->_finalize_construct( $this );
4038
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4039
+			$where_conditions_obj->_finalize_construct($this);
4040 4040
 		}
4041 4041
 
4042
-		return $this->_cap_restrictions[ $context ];
4042
+		return $this->_cap_restrictions[$context];
4043 4043
 	}
4044 4044
 
4045 4045
 	/**
4046 4046
 	 * Indicating whether or not this model thinks its a wp core model
4047 4047
 	 * @return boolean
4048 4048
 	 */
4049
-	public function is_wp_core_model(){
4049
+	public function is_wp_core_model() {
4050 4050
 		return $this->_wp_core_model;
4051 4051
 	}
4052 4052
 
@@ -4056,12 +4056,12 @@  discard block
 block discarded – undo
4056 4056
 	 * @param string $context one of EEM_Base::caps_ constants
4057 4057
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4058 4058
 	 */
4059
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4059
+	public function caps_missing($context = EEM_Base::caps_read) {
4060 4060
 		$missing_caps = array();
4061
-		$cap_restrictions = $this->cap_restrictions( $context );
4062
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4063
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4064
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4061
+		$cap_restrictions = $this->cap_restrictions($context);
4062
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4063
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4064
+				$missing_caps[$cap] = $restriction_if_no_cap;
4065 4065
 			}
4066 4066
 		}
4067 4067
 		return $missing_caps;
@@ -4073,7 +4073,7 @@  discard block
 block discarded – undo
4073 4073
 	 * one of 'read', 'edit', or 'delete'
4074 4074
 	 */
4075 4075
 	public function cap_contexts_to_cap_action_map() {
4076
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4076
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4077 4077
 	}
4078 4078
 
4079 4079
 
@@ -4084,19 +4084,19 @@  discard block
 block discarded – undo
4084 4084
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4085 4085
 	 * @throws \EE_Error
4086 4086
 	 */
4087
-	public function cap_action_for_context( $context ) {
4087
+	public function cap_action_for_context($context) {
4088 4088
 		$mapping = $this->cap_contexts_to_cap_action_map();
4089
-		if( isset( $mapping[ $context ] ) ) {
4090
-			return $mapping[ $context ];
4089
+		if (isset($mapping[$context])) {
4090
+			return $mapping[$context];
4091 4091
 		}
4092
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4092
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4093 4093
 			return $action;
4094 4094
 		}
4095 4095
 		throw new EE_Error(
4096 4096
 			sprintf(
4097
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4097
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4098 4098
 				$context,
4099
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4099
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4100 4100
 			)
4101 4101
 		);
4102 4102
 
@@ -4107,7 +4107,7 @@  discard block
 block discarded – undo
4107 4107
 	 * @return array
4108 4108
 	 */
4109 4109
 	static public function valid_cap_contexts() {
4110
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4110
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4111 4111
 			self::caps_read,
4112 4112
 			self::caps_read_admin,
4113 4113
 			self::caps_edit,
@@ -4123,17 +4123,17 @@  discard block
 block discarded – undo
4123 4123
 	 * @return bool
4124 4124
 	 * @throws \EE_Error
4125 4125
 	 */
4126
-	static public function verify_is_valid_cap_context( $context ) {
4126
+	static public function verify_is_valid_cap_context($context) {
4127 4127
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4128
-		if( in_array( $context, $valid_cap_contexts ) ) {
4128
+		if (in_array($context, $valid_cap_contexts)) {
4129 4129
 			return true;
4130
-		}else{
4130
+		} else {
4131 4131
 			throw new EE_Error(
4132 4132
 				sprintf(
4133
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4133
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4134 4134
 					$context,
4135
-					'EEM_Base' ,
4136
-					implode(',', $valid_cap_contexts )
4135
+					'EEM_Base',
4136
+					implode(',', $valid_cap_contexts)
4137 4137
 				)
4138 4138
 			);
4139 4139
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_CPT_Base.model.php 2 patches
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_trashed - the wp post status for trashed cpts
@@ -44,42 +44,42 @@  discard block
 block discarded – undo
44 44
 	 * @param string $timezone
45 45
 	 * @throws \EE_Error
46 46
 	 */
47
-	protected function __construct( $timezone = NULL ){
47
+	protected function __construct($timezone = NULL) {
48 48
 
49 49
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
50 50
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
51 51
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
52 52
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
53 53
 		//must also be new EE_HABTM_Relation('Term_Relationship');
54
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
54
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
55 55
 		$primary_table_name = NULL;
56 56
 		//add  the common _status field to all CPT primary tables.
57
-		foreach ( $this->_tables as $alias => $table_obj ) {
58
-			if ( $table_obj instanceof EE_Primary_Table ) {
57
+		foreach ($this->_tables as $alias => $table_obj) {
58
+			if ($table_obj instanceof EE_Primary_Table) {
59 59
 				$primary_table_name = $alias;
60 60
 			}
61 61
 		}
62 62
 		//set default wp post statuses if child has not already set.
63
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
63
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
64 64
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
65 65
 		}
66
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
67
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
66
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
67
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
68 68
 		}
69
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
70
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
69
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
70
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
71 71
 		}
72 72
 
73
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
74
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
73
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
74
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
75 75
 		}
76 76
 
77
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
77
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
78 78
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
79 79
 		}
80 80
 
81
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
82
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
81
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
82
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
83 83
 		}
84 84
 		parent::__construct($timezone);
85 85
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 */
93 93
 	public function public_event_stati() {
94 94
 		// @see wp-includes/post.php
95
-		return get_post_stati( array( 'public' => TRUE ));
95
+		return get_post_stati(array('public' => TRUE));
96 96
 	}
97 97
 
98 98
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @return string
104 104
 	 * @throws EE_Error
105 105
 	 */
106
-	public function deleted_field_name(){
106
+	public function deleted_field_name() {
107 107
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
108 108
 	}
109 109
 
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
 	 * @return string
115 115
 	 * @throws EE_Error
116 116
 	 */
117
-	public function post_status_field_name(){
117
+	public function post_status_field_name() {
118 118
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
119
-		if($field){
119
+		if ($field) {
120 120
 			return $field->get_name();
121
-		}else{
122
-			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
121
+		} else {
122
+			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
123 123
 		}
124 124
 	}
125 125
 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @param array $query_params like EEM_Base::get_all's $query_params
131 131
 	 * @return array like EEM_Base::get_all's $query_params
132 132
 	 */
133
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
134
-		$post_status_field_name=$this->post_status_field_name();
135
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
133
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
134
+		$post_status_field_name = $this->post_status_field_name();
135
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
136 136
 		return $query_params;
137 137
 	}
138 138
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 * @param array $query_params
144 144
 	 * @return array
145 145
 	 */
146
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
147
-		$post_status_field_name=$this->post_status_field_name();
148
-		$query_params[0][$post_status_field_name]=array('IN',array_keys($this->get_status_array()));
146
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
147
+		$post_status_field_name = $this->post_status_field_name();
148
+		$query_params[0][$post_status_field_name] = array('IN', array_keys($this->get_status_array()));
149 149
 		return $query_params;
150 150
 	}
151 151
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 * @param array $query_params like EEM_Base::get_all
158 158
 	 * @return boolean success
159 159
 	 */
160
-	function delete_or_restore($delete=true,$query_params = array()){
161
-		$post_status_field_name=$this->post_status_field_name();
160
+	function delete_or_restore($delete = true, $query_params = array()) {
161
+		$post_status_field_name = $this->post_status_field_name();
162 162
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
163 163
 		$new_status = $delete ? self::post_status_trashed : 'draft';
164
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
164
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
165 165
 			return TRUE;
166 166
 		} else {
167 167
 			return FALSE;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	public function meta_table() {
180 180
 		$meta_table = $this->_get_other_tables();
181
-		$meta_table = reset( $meta_table );
181
+		$meta_table = reset($meta_table);
182 182
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
183 183
 	}
184 184
 
@@ -190,16 +190,16 @@  discard block
 block discarded – undo
190 190
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
191 191
 	 * @return array
192 192
 	 */
193
-	public function get_meta_table_fields( $all = FALSE ) {
193
+	public function get_meta_table_fields($all = FALSE) {
194 194
 		$all_fields = $fields_to_return = array();
195
-		foreach ( $this->_tables as $alias => $table_obj ) {
196
-			if ( $table_obj instanceof EE_Secondary_Table )
197
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
195
+		foreach ($this->_tables as $alias => $table_obj) {
196
+			if ($table_obj instanceof EE_Secondary_Table)
197
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
198 198
 		}
199 199
 
200
-		if ( !$all ) {
201
-			foreach ( $all_fields as $name => $obj ) {
202
-				if ( $obj instanceof EE_DB_Only_Field_Base )
200
+		if ( ! $all) {
201
+			foreach ($all_fields as $name => $obj) {
202
+				if ($obj instanceof EE_DB_Only_Field_Base)
203 203
 					continue;
204 204
 				$fields_to_return[] = $name;
205 205
 			}
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 	 * @param int $parent_term_taxonomy_id
223 223
 	 * @return EE_Term_Taxonomy
224 224
 	 */
225
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
225
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
226 226
 		//create term
227
-		require_once( EE_MODELS . 'EEM_Term.model.php');
227
+		require_once(EE_MODELS.'EEM_Term.model.php');
228 228
 		//first, check for a term by the same name or slug
229 229
 		$category_slug = sanitize_title($category_name);
230
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
231
-		if( ! $term ){
230
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
231
+		if ( ! $term) {
232 232
 			$term = EE_Term::new_instance(array(
233 233
 				'name'=>$category_name,
234 234
 				'slug'=>$category_slug
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 			$term->save();
237 237
 		}
238 238
 		//make sure there's a term-taxonomy entry too
239
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
240
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
239
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
240
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
241 241
 		/** @var $term_taxonomy EE_Term_Taxonomy */
242
-		if( ! $term_taxonomy ){
242
+		if ( ! $term_taxonomy) {
243 243
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
244 244
 				'term_id'=>$term->ID(),
245 245
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 				'parent'=>$parent_term_taxonomy_id
249 249
 			));
250 250
 			$term_taxonomy->save();
251
-		}else{
251
+		} else {
252 252
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
253 253
 			$term_taxonomy->save();
254 254
 		}
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 	 * @param string $category_name name of the event category (term)
264 264
 	 * @return bool
265 265
 	 */
266
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
266
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
267 267
 		//find the term_taxonomy by that name
268
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
268
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
269 269
 		/** @var $term_taxonomy EE_Term_Taxonomy */
270
-		if( $term_taxonomy ){
270
+		if ($term_taxonomy) {
271 271
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
272 272
 			$term_taxonomy->save();
273 273
 		}
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param string|array $attr Optional. Query string or array of attributes.
288 288
 	 * @return string HTML image element
289 289
 	 */
290
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
291
-		return get_the_post_thumbnail( $id, $size, $attr );
290
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
291
+		return get_the_post_thumbnail($id, $size, $attr);
292 292
 	}
293 293
 
294 294
 
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
302 302
 	 * @return array
303 303
 	 */
304
-	public function get_post_statuses(){
304
+	public function get_post_statuses() {
305 305
 		global $wp_post_statuses;
306 306
 		$statuses = array();
307
-		foreach($wp_post_statuses as $post_status => $args_object){
307
+		foreach ($wp_post_statuses as $post_status => $args_object) {
308 308
 			$statuses[$post_status] = $args_object->label;
309 309
 		}
310 310
 		return $statuses;
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
 	public function get_status_array() {
320 320
 		$statuses = $this->get_post_statuses();
321 321
 		//first the global filter
322
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
322
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
323 323
 		//now the class specific filter
324
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
324
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
325 325
 		return $statuses;
326 326
 	}
327 327
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 */
334 334
 	public function get_custom_post_statuses() {
335 335
 		$new_stati = array();
336
-		foreach ( $this->_custom_stati as $status => $props ) {
336
+		foreach ($this->_custom_stati as $status => $props) {
337 337
 			$new_stati[$status] = $props['label'];
338 338
 		}
339 339
 		return $new_stati;
@@ -349,24 +349,24 @@  discard block
 block discarded – undo
349 349
 	 * @param WP_Post|array $post
350 350
 	 * @return EE_CPT_Base
351 351
 	 */
352
-	public function instantiate_class_from_post_object_orig($post){
353
-		$post = (array)$post;
352
+	public function instantiate_class_from_post_object_orig($post) {
353
+		$post = (array) $post;
354 354
 		$has_all_necessary_fields_for_table = true;
355 355
 		//check if the post has fields on the meta table already
356
-		foreach($this->_get_other_tables() as $table_obj){
356
+		foreach ($this->_get_other_tables() as $table_obj) {
357 357
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
358
-			foreach($fields_for_that_table as $field_obj){
359
-				if( ! isset($post[$field_obj->get_table_column()])
360
-					&& ! isset($post[$field_obj->get_qualified_column()])){
358
+			foreach ($fields_for_that_table as $field_obj) {
359
+				if ( ! isset($post[$field_obj->get_table_column()])
360
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
361 361
 					$has_all_necessary_fields_for_table = false;
362 362
 				}
363 363
 			}
364 364
 		}
365 365
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
366
-		if( ! $has_all_necessary_fields_for_table){
366
+		if ( ! $has_all_necessary_fields_for_table) {
367 367
 
368 368
 			return $this->get_one_by_ID($post['ID']);
369
-		}else{
369
+		} else {
370 370
 			return $this->instantiate_class_from_array_or_object($post);
371 371
 		}
372 372
 	}
@@ -377,30 +377,30 @@  discard block
 block discarded – undo
377 377
 	 * @param null $post
378 378
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
379 379
 	 */
380
-	public function instantiate_class_from_post_object( $post = NULL ){
381
-		if ( empty( $post )) {
380
+	public function instantiate_class_from_post_object($post = NULL) {
381
+		if (empty($post)) {
382 382
 			global $post;
383 383
 		}
384
-		$post = (array)$post;
384
+		$post = (array) $post;
385 385
 		$tables_needing_to_be_queried = array();
386 386
 		//check if the post has fields on the meta table already
387
-		foreach($this->get_tables() as $table_obj){
387
+		foreach ($this->get_tables() as $table_obj) {
388 388
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
389
-			foreach($fields_for_that_table as $field_obj){
390
-				if( ! isset($post[$field_obj->get_table_column()])
391
-					&& ! isset($post[$field_obj->get_qualified_column()])){
389
+			foreach ($fields_for_that_table as $field_obj) {
390
+				if ( ! isset($post[$field_obj->get_table_column()])
391
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
392 392
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
393 393
 				}
394 394
 			}
395 395
 		}
396 396
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
397
-		if( $tables_needing_to_be_queried){
398
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
397
+		if ($tables_needing_to_be_queried) {
398
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
399 399
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
400 400
 				$table_to_query = reset($tables_needing_to_be_queried);
401
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
402
-				if ( ! empty( $missing_data )) {
403
-					$post = array_merge( $post, $missing_data );
401
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
402
+				if ( ! empty($missing_data)) {
403
+					$post = array_merge($post, $missing_data);
404 404
 				}
405 405
 			} else {
406 406
 				return $this->get_one_by_ID($post['ID']);
@@ -417,15 +417,15 @@  discard block
 block discarded – undo
417 417
 	 * @throws EE_Error
418 418
 	 * @return string
419 419
 	 */
420
-	public function post_type(){
420
+	public function post_type() {
421 421
 		$post_type_field = NULL;
422
-		foreach($this->field_settings(true) as $field_obj){
423
-			if($field_obj instanceof EE_WP_Post_Type_Field){
424
-				$post_type_field = $field_obj;break;
422
+		foreach ($this->field_settings(true) as $field_obj) {
423
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
424
+				$post_type_field = $field_obj; break;
425 425
 			}
426 426
 		}
427
-		if($post_type_field == NULL){
428
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
427
+		if ($post_type_field == NULL) {
428
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
429 429
 		}
430 430
 		return $post_type_field->get_default_value();
431 431
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
119 119
 		if($field){
120 120
 			return $field->get_name();
121
-		}else{
121
+		} else{
122 122
 			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
123 123
 		}
124 124
 	}
@@ -193,14 +193,16 @@  discard block
 block discarded – undo
193 193
 	public function get_meta_table_fields( $all = FALSE ) {
194 194
 		$all_fields = $fields_to_return = array();
195 195
 		foreach ( $this->_tables as $alias => $table_obj ) {
196
-			if ( $table_obj instanceof EE_Secondary_Table )
197
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
196
+			if ( $table_obj instanceof EE_Secondary_Table ) {
197
+							$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
198
+			}
198 199
 		}
199 200
 
200 201
 		if ( !$all ) {
201 202
 			foreach ( $all_fields as $name => $obj ) {
202
-				if ( $obj instanceof EE_DB_Only_Field_Base )
203
-					continue;
203
+				if ( $obj instanceof EE_DB_Only_Field_Base ) {
204
+									continue;
205
+				}
204 206
 				$fields_to_return[] = $name;
205 207
 			}
206 208
 		} else {
@@ -248,7 +250,7 @@  discard block
 block discarded – undo
248 250
 				'parent'=>$parent_term_taxonomy_id
249 251
 			));
250 252
 			$term_taxonomy->save();
251
-		}else{
253
+		} else{
252 254
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
253 255
 			$term_taxonomy->save();
254 256
 		}
@@ -366,7 +368,7 @@  discard block
 block discarded – undo
366 368
 		if( ! $has_all_necessary_fields_for_table){
367 369
 
368 370
 			return $this->get_one_by_ID($post['ID']);
369
-		}else{
371
+		} else{
370 372
 			return $this->instantiate_class_from_array_or_object($post);
371 373
 		}
372 374
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Change_Log.model.php 3 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Change_Log extends EEM_Base{
28
+class EEM_Change_Log extends EEM_Base {
29 29
 
30 30
 	/**
31 31
 	 * the related object was created log type
@@ -68,19 +68,19 @@  discard block
 block discarded – undo
68 68
 	 *	@access protected
69 69
 	 *	@return EEM_Change_Log
70 70
 	 */
71
-	protected function __construct( $timezone = null ){
71
+	protected function __construct($timezone = null) {
72 72
 		global $current_user;
73
-		$this->singular_item = __('Log','event_espresso');
74
-		$this->plural_item = __('Logs','event_espresso');
73
+		$this->singular_item = __('Log', 'event_espresso');
74
+		$this->plural_item = __('Logs', 'event_espresso');
75 75
 		$this->_tables = array(
76 76
 			'Log'=> new EE_Primary_Table('esp_log', 'LOG_ID')
77 77
 		);
78 78
 		$models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models);
79 79
 		$this->_fields = array(
80 80
 			'Log'=>array(
81
-				'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID','event_espresso')),
81
+				'LOG_ID'=> new EE_Primary_Key_Int_Field('LOG_ID', __('Log ID', 'event_espresso')),
82 82
 				'LOG_time'=>new EE_Datetime_Field('LOG_time', __("Log Time", 'event_espresso'), false, time()),
83
-				'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL,$models_this_can_attach_to),
83
+				'OBJ_ID'=>new EE_Foreign_Key_String_Field('OBJ_ID', __("Object ID (int or string)", 'event_espresso'), true, NULL, $models_this_can_attach_to),
84 84
 				'OBJ_type'=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Object Type", 'event_espresso'), true, NULL, $models_this_can_attach_to),
85 85
 				'LOG_type'=>new EE_Enum_Text_Field('LOG_type', __("Type of log entry", "event_espresso"), false, self::type_debug,
86 86
 						array(
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
 							self::type_gateway=> __("Gateway Interaction (IPN or Direct Payment)", 'event_espresso'),
93 93
 							)),
94 94
 				'LOG_message'=>new EE_Maybe_Serialized_Text_Field('LOG_message', __("Log Message (body)", 'event_espresso'), true),
95
-				'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true ),
95
+				'LOG_wp_user' => new EE_WP_User_Field('LOG_wp_user', __("User who was logged in while this occurred", 'event_espresso'), true),
96 96
 
97 97
 			));
98 98
 		$this->_model_relations = array();
99
-		foreach($models_this_can_attach_to as $model){
100
-			if( $model == 'WP_User' ){
101
-				$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
102
-			}elseif( $model != 'Change_Log' ) {
99
+		foreach ($models_this_can_attach_to as $model) {
100
+			if ($model == 'WP_User') {
101
+				$this->_model_relations[$model] = new EE_Belongs_To_Relation();
102
+			}elseif ($model != 'Change_Log') {
103 103
 				$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
104 104
 			}
105 105
 		}
106 106
 		//use completely custom caps for this
107 107
 		$this->_cap_restriction_generators = false;
108 108
 		//caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing
109
-		foreach( $this->_cap_contexts_to_cap_action_map as $cap_context => $action ) {
110
-			$this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] = new EE_Return_None_Where_Conditions();
109
+		foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) {
110
+			$this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] = new EE_Return_None_Where_Conditions();
111 111
 		}
112
-		parent::__construct( $timezone );
112
+		parent::__construct($timezone);
113 113
 	}
114 114
 
115 115
 	/**
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @param EE_Base_Class $related_model_obj
120 120
 	 * @return EE_Change_Log
121 121
 	 */
122
-	public function log($log_type,$message,$related_model_obj){
123
-		if($related_model_obj instanceof EE_Base_Class){
122
+	public function log($log_type, $message, $related_model_obj) {
123
+		if ($related_model_obj instanceof EE_Base_Class) {
124 124
 			$obj_id = $related_model_obj->ID();
125 125
 			$obj_type = $related_model_obj->get_model()->get_this_model_name();
126
-		}else{
126
+		} else {
127 127
 			$obj_id = NULL;
128 128
 			$obj_type = NULL;
129 129
 		}
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @throws EE_Error
148 148
 	 * @return EE_Change_Log
149 149
 	 */
150
-	public function gateway_log( $message, $related_obj_id, $related_obj_type ){
151
-		if( ! EE_Registry::instance()->is_model_name($related_obj_type)){
152
-			throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"),$related_obj_type));
150
+	public function gateway_log($message, $related_obj_id, $related_obj_type) {
151
+		if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) {
152
+			throw new EE_Error(sprintf(__("'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", "event_espresso"), $related_obj_type));
153 153
 		}
154 154
 		$log = EE_Change_Log::new_instance(array(
155 155
 				'LOG_type'=>EEM_Change_Log::type_gateway,
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param array $query_params @see EEM_Base::get_all
169 169
 	 * @return array of arrays
170 170
 	 */
171
-	public function get_all_efficiently($query_params){
171
+	public function get_all_efficiently($query_params) {
172 172
 		return $this->_get_all_wpdb_results($query_params);
173 173
 	}
174 174
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -99,7 +100,7 @@  discard block
 block discarded – undo
99 100
 		foreach($models_this_can_attach_to as $model){
100 101
 			if( $model == 'WP_User' ){
101 102
 				$this->_model_relations[ $model ] = new EE_Belongs_To_Relation();
102
-			}elseif( $model != 'Change_Log' ) {
103
+			} elseif( $model != 'Change_Log' ) {
103 104
 				$this->_model_relations[$model] = new EE_Belongs_To_Any_Relation();
104 105
 			}
105 106
 		}
@@ -123,7 +124,7 @@  discard block
 block discarded – undo
123 124
 		if($related_model_obj instanceof EE_Base_Class){
124 125
 			$obj_id = $related_model_obj->ID();
125 126
 			$obj_type = $related_model_obj->get_model()->get_this_model_name();
126
-		}else{
127
+		} else{
127 128
 			$obj_id = NULL;
128 129
 			$obj_type = NULL;
129 130
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
 	/**
167 167
 	 * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential
168 168
 	 * @param array $query_params @see EEM_Base::get_all
169
-	 * @return array of arrays
169
+	 * @return stdClass[] of arrays
170 170
 	 */
171 171
 	public function get_all_efficiently($query_params){
172 172
 		return $this->_get_all_wpdb_results($query_params);
Please login to merge, or discard this patch.