Completed
Branch FET-7988-evertec-needs (20e248)
by
unknown
1119:58 queued 1106:57
created
templates/attendee_information/auto_copy_attendee_info.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 	<p id="spco-auto-copy-attendee-pg" class="smaller-text lt-grey-text">
2
-		<?php echo apply_filters( 'FHEE__registration_page_attendee_information__auto_copy_attendee_pg', __('The above information will be used for any additional tickets/attendees.', 'event_espresso' ));?>
2
+		<?php echo apply_filters('FHEE__registration_page_attendee_information__auto_copy_attendee_pg', __('The above information will be used for any additional tickets/attendees.', 'event_espresso')); ?>
3 3
 	</p>
4 4
\ No newline at end of file
Please login to merge, or discard this patch.
templates/attendee_information/copy_attendee_info.template.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <div id="spco-copy-attendee-dv" class="hide-if-no-js">
2 2
 
3 3
 	<p class="spco-copy-all-attendee-pg">
4
-		<label class="ee-checkbox-label-before ee-checkbox-label-wide"><?php  _e('Use Attendee #1\'s information for ALL attendees', 'event_espresso');?>
4
+		<label class="ee-checkbox-label-before ee-checkbox-label-wide"><?php  _e('Use Attendee #1\'s information for ALL attendees', 'event_espresso'); ?>
5 5
 			<input id="spco-copy-all-attendee-chk" class="spco-copy-all-attendee-chk ee-do-not-validate" type="checkbox" value="copy-all">
6 6
 		</label>
7 7
 	</p>
8 8
 
9
-	<p class="spco-copy-attendee-pg"><?php echo apply_filters(  'FHEE__registration_page_attendee_information__copy_attendee_pg', sprintf( __('This option allows you to use the above information for all additional attendee question fields. %sPlease note:%s some events may have additional questions that you may still be required to answer in order to complete your registration.', 'event_espresso'), '<strong>', '</strong>' )); ?></p>
9
+	<p class="spco-copy-attendee-pg"><?php echo apply_filters('FHEE__registration_page_attendee_information__copy_attendee_pg', sprintf(__('This option allows you to use the above information for all additional attendee question fields. %sPlease note:%s some events may have additional questions that you may still be required to answer in order to complete your registration.', 'event_espresso'), '<strong>', '</strong>')); ?></p>
10 10
 
11
-	<a id="display-more-attendee-copy-options" class="display-the-hidden smaller-text float-right" rel="more-attendee-copy-options" ><span class="dashicons dashicons-arrow-right"></span><?php  _e('advanced copy options', 'event_espresso');?></a>
12
-	<a id="hide-more-attendee-copy-options" class="hide-the-displayed smaller-text float-right" rel="more-attendee-copy-options" style="display: none;"><span class="dashicons dashicons-arrow-down"></span><?php  _e('basic copy options', 'event_espresso');?></a>
11
+	<a id="display-more-attendee-copy-options" class="display-the-hidden smaller-text float-right" rel="more-attendee-copy-options" ><span class="dashicons dashicons-arrow-right"></span><?php  _e('advanced copy options', 'event_espresso'); ?></a>
12
+	<a id="hide-more-attendee-copy-options" class="hide-the-displayed smaller-text float-right" rel="more-attendee-copy-options" style="display: none;"><span class="dashicons dashicons-arrow-down"></span><?php  _e('basic copy options', 'event_espresso'); ?></a>
13 13
 
14 14
 	<div id="more-attendee-copy-options-dv" class="" style="display: none;">
15 15
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 			<?php _e('Only copy the above information to the following selected additional attendees.', 'event_espresso'); ?>
18 18
 		</p>
19 19
 
20
-		<?php foreach ( $spco_copy_attendee_chk as $spco_copy_chk ) { echo $spco_copy_chk; } ?>
20
+		<?php foreach ($spco_copy_attendee_chk as $spco_copy_chk) { echo $spco_copy_chk; } ?>
21 21
 
22 22
 	</div>
23 23
 	<div class="clear-float"></div>
Please login to merge, or discard this patch.
single_page_checkout/templates/payment_options/sold_out_events.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 
2
-	<h4 class="ee-status sold-out"><b><?php _e('Sold Out', 'event_espresso');?></b></h4>
2
+	<h4 class="ee-status sold-out"><b><?php _e('Sold Out', 'event_espresso'); ?></b></h4>
3 3
 	<ul id="spco-sold-out-events-ul"><?php echo $sold_out_events; ?></ul>
4
-	<h6 class="pink-text"><?php _e("We're Sorry", 'event_espresso');?></h6>
4
+	<h6 class="pink-text"><?php _e("We're Sorry", 'event_espresso'); ?></h6>
5 5
 	<p id="events-requiring-pre-approval-pg" class="small-text drk-grey-text">
6 6
 		<?php echo $sold_out_events_msg; ?>
7 7
 	</p>
8 8
 
9
-	<?php echo $default_hidden_inputs;  ?>
10
-	<?php echo $extra_hidden_inputs;  ?>
9
+	<?php echo $default_hidden_inputs; ?>
10
+	<?php echo $extra_hidden_inputs; ?>
Please login to merge, or discard this patch.
templates/registration_confirmation/confirmation_page.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php 
2 2
 		$x = 1;
3
-		foreach ( $events as $event ){ ?>
3
+		foreach ($events as $event) { ?>
4 4
 			<fieldset class="reg-page-confirmation-wrap-fs">
5 5
 				<legend class="spco-attendee-lgnd smaller-text lt-grey-text"><?php _e('Event #', 'event_espresso'); ?><?php echo $x; ?></legend>
6 6
 				<h4><strong><?php echo $event['name']; ?></strong></h4>
7
-				<b><?php echo $event['date'] . __(' at ', 'event_espresso') . $event['time']; ?></b><br/>
7
+				<b><?php echo $event['date'].__(' at ', 'event_espresso').$event['time']; ?></b><br/>
8 8
 				<b><?php echo $event['ticket-price']; ?></b>
9 9
 				<h5><strong><?php _e('Attendees', 'event_espresso'); ?></strong></h5>
10 10
 				<ol class="confirm-page-attendees-ul">
11
-	<?php	foreach ( $event['attendees'] as $attendee ) { ?>
11
+	<?php	foreach ($event['attendees'] as $attendee) { ?>
12 12
 					<li>
13 13
 						<b><?php echo $attendee['name']; ?></b> - <?php echo $attendee['extra_att_detail']; ?>
14 14
 					</li>
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<fieldset class="reg-page-confirmation-wrap-fs">
24 24
 				<legend class="spco-attendee-lgnd smaller-text lt-grey-text"><?php _e('Billing Details', 'event_espresso'); ?></legend>
25
-<?php foreach ( $billing as $key => $value ){ ?>
25
+<?php foreach ($billing as $key => $value) { ?>
26 26
 					<span class="reg-page-confirmation-billing-info-spn smaller-text lt-grey-text"><?php echo $key; ?></span>&nbsp;&nbsp;<?php echo $value; ?><br />
27 27
 <?php } ?>	
28 28
 					<br/>				
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 4 patches
Doc Comments   +16 added lines, -13 removed lines patch added patch discarded remove patch
@@ -679,6 +679,7 @@  discard block
 block discarded – undo
679 679
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
680 680
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
681 681
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
682
+	 * @param string $columns_to_select
682 683
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
683 684
 	 */
684 685
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1172,7 +1173,7 @@  discard block
 block discarded – undo
1172 1173
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1173 1174
 	 * Wrapper for EEM_Base::delete()
1174 1175
 	 * @param mixed $id
1175
-	 * @return boolean whether the row got deleted or not
1176
+	 * @return integer whether the row got deleted or not
1176 1177
 	 */
1177 1178
 	public function delete_by_ID( $id ){
1178 1179
 		return $this->delete( array(
@@ -1292,7 +1293,7 @@  discard block
 block discarded – undo
1292 1293
 
1293 1294
 	/**
1294 1295
 	 * This sets up our delete where sql and accounts for if we have secondary tables that will have rows deleted as well.
1295
-	 * @param  array  $objects_for_deletion This should be the values returned by $this->_get_all_wpdb_results()
1296
+	 * @param  stdClass[]  $objects_for_deletion This should be the values returned by $this->_get_all_wpdb_results()
1296 1297
 	 * @param boolean $allow_blocking       if TRUE, matched objects will only be deleted if there is no related model info
1297 1298
 	 * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
1298 1299
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
@@ -1505,7 +1506,6 @@  discard block
 block discarded – undo
1505 1506
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1506 1507
 	 * 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
1507 1508
 	 *
1508
-	 * @param EE_Base_Class/int $thisModelObject
1509 1509
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1510 1510
 	 * @param string $relationName, key in EEM_Base::_relations
1511 1511
 	 * 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')
@@ -1527,8 +1527,8 @@  discard block
 block discarded – undo
1527 1527
 	 *
1528 1528
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
1529 1529
 	 *
1530
-	 * @param EE_Base_Class/int $id_or_obj
1531
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1530
+	 * @param EE_CPT_Base $id_or_obj
1531
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1532 1532
 	 * @param string $relationName key in EEM_Base::_relations
1533 1533
 	 * @return boolean of success
1534 1534
 	 * @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.
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 	/**
1605 1605
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
1606 1606
 	 * unless otherwise specified in the $query_params
1607
-	 * @param int/EE_Base_Class $id_or_obj
1607
+	 * @param EE_Event $id_or_obj
1608 1608
 	 * @param string $model_name like 'Event', or 'Registration'
1609 1609
 	 * @param array $query_params like EEM_Base::get_all's
1610 1610
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 	/**
1993 1993
 	 * Finds all the fields that correspond to the given table
1994 1994
 	 * @param string $table_alias, array key in EEM_Base::_tables
1995
-	 * @return EE_Model_Field_Base[]
1995
+	 * @return EE_Model_Field_Base
1996 1996
 	 */
1997 1997
 	function _get_fields_for_table($table_alias){
1998 1998
 		return $this->_fields[$table_alias];
@@ -3031,8 +3031,8 @@  discard block
 block discarded – undo
3031 3031
 	/**
3032 3032
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3033 3033
 	 * Eg, on EE_Answer that would be ANS_ID field object
3034
-	 * @param $field_obj
3035
-	 * @return EE_Model_Field_Base
3034
+	 * @param EE_Model_Field_Base $field_obj
3035
+	 * @return boolean
3036 3036
 	 */
3037 3037
 	public function is_primary_key_field( $field_obj ){
3038 3038
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3126,7 +3126,7 @@  discard block
 block discarded – undo
3126 3126
 	 * Gets the actual table for the table alias
3127 3127
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3128 3128
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3129
-	 * @return EE_Table_Base
3129
+	 * @return string
3130 3130
 	 */
3131 3131
 	function get_table_for_alias($table_alias){
3132 3132
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3225,7 +3225,7 @@  discard block
 block discarded – undo
3225 3225
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3226 3226
 	 * 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!).
3227 3227
 	 *
3228
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3228
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3229 3229
 	 */
3230 3230
 	public function create_default_object() {
3231 3231
 
@@ -3245,7 +3245,7 @@  discard block
 block discarded – undo
3245 3245
 
3246 3246
 	/**
3247 3247
 	 * _get_cached_acceptable_table_columns
3248
-	 * @return EE_Model_Field_Base[]|null
3248
+	 * @return EE_Model_Field_Base[]
3249 3249
 	 */
3250 3250
 	private function _get_cached_acceptable_table_columns(){
3251 3251
 		if( $this->_model_fields_sorted_by_db_col === NULL ){
@@ -3395,6 +3395,9 @@  discard block
 block discarded – undo
3395 3395
 		return $this_model_fields_n_values;
3396 3396
 	}
3397 3397
 
3398
+	/**
3399
+	 * @param string $cols_n_values
3400
+	 */
3398 3401
 	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3399 3402
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3400 3403
 		//does the field on the model relate to this column retrieved from the db?
@@ -3630,7 +3633,7 @@  discard block
 block discarded – undo
3630 3633
 	}
3631 3634
 	/**
3632 3635
 	 * Read comments for assume_values_already_prepared_by_model_object()
3633
-	 * @return int
3636
+	 * @return boolean
3634 3637
 	 */
3635 3638
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
3636 3639
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
438 438
 	 	$status_array = array();
439 439
 	 	foreach ( $stati as $status ) {
440
-            $status_array[ $status->ID() ] = $status->get('STS_code');
441
-        }
442
-        return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443
-    }
440
+			$status_array[ $status->ID() ] = $status->get('STS_code');
441
+		}
442
+		return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443
+	}
444 444
 
445 445
 
446 446
 
@@ -3171,12 +3171,12 @@  discard block
 block discarded – undo
3171 3171
 
3172 3172
 
3173 3173
 	/**
3174
-	*		cycle though array of attendees and create objects out of each item
3175
-	*
3176
-	* 		@access		private
3177
-	* 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
3178
-	*		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3179
-	*/
3174
+	 *		cycle though array of attendees and create objects out of each item
3175
+	 *
3176
+	 * 		@access		private
3177
+	 * 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
3178
+	 *		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3179
+	 */
3180 3180
 	protected function _create_objects( $rows = array() ) {
3181 3181
 		$array_of_objects=array();
3182 3182
 		if(empty($rows)){
Please login to merge, or discard this patch.
Spacing   +816 added lines, -816 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
 	/**
29 29
 	 * Flag to indicate whether the values provided to EEM_Base have already been prepared
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * Flag indicating whether this model has a primary key or not
148 148
 	 * @var boolean
149 149
 	 */
150
-	protected $_has_primary_key_field=null;
150
+	protected $_has_primary_key_field = null;
151 151
 
152 152
 	/**
153 153
 	 *	List of valid operators that can be used for querying.
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
196 196
 	 * @var array
197 197
 	 */
198
-	protected $_between_style_operators = array( 'BETWEEN' );
198
+	protected $_between_style_operators = array('BETWEEN');
199 199
 
200 200
 	/**
201 201
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
202 202
 	 * @var array
203 203
 	 */
204
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
204
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
205 205
 
206 206
 	/**
207 207
 	 * Allowed values for $query_params['order'] for ordering in queries
208 208
 	 * @var array
209 209
 	 */
210
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
210
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
211 211
 
212 212
 	/**
213 213
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
222 222
 	 * @var array
223 223
 	 */
224
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions');
224
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions');
225 225
 
226 226
 	/**
227 227
 	 * All the data types that can be used in $wpdb->prepare statements.
228 228
 	 * @var array
229 229
 	 */
230
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
230
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
231 231
 
232 232
 	/**
233 233
 	 * 	EE_Registry Object
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @param null $timezone
286 286
 	 * @throws \EE_Error
287 287
 	 */
288
-	protected function __construct( $timezone = NULL ){
288
+	protected function __construct($timezone = NULL) {
289 289
 		// check that the model has not been loaded too soon
290
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
291
-			throw new EE_Error (
290
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
291
+			throw new EE_Error(
292 292
 				sprintf(
293
-					__( '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' ),
294
-					get_class( $this )
293
+					__('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'),
294
+					get_class($this)
295 295
 				)
296 296
 			);
297 297
 		}		/**
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 		 * just use EE_Register_Model_Extension
300 300
 		 * @var EE_Table_Base[] $_tables
301 301
 		 */
302
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
303
-		foreach($this->_tables as $table_alias => $table_obj){
302
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
303
+		foreach ($this->_tables as $table_alias => $table_obj) {
304 304
 			/** @var $table_obj EE_Table_Base */
305 305
 			$table_obj->_construct_finalize_with_alias($table_alias);
306
-			if( $table_obj instanceof EE_Secondary_Table ){
306
+			if ($table_obj instanceof EE_Secondary_Table) {
307 307
 				/** @var $table_obj EE_Secondary_Table */
308 308
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
309 309
 			}
@@ -313,48 +313,48 @@  discard block
 block discarded – undo
313 313
 		 * EE_Register_Model_Extension
314 314
 		 * @param EE_Model_Field_Base[] $_fields
315 315
 		 */
316
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
317
-		foreach($this->_fields as $table_alias => $fields_for_table){
318
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
319
-				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)));
316
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
317
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
318
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
319
+				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)));
320 320
 			}
321
-			foreach($fields_for_table as $field_name => $field_obj){
321
+			foreach ($fields_for_table as $field_name => $field_obj) {
322 322
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
323 323
 				//primary key field base has a slightly different _construct_finalize
324 324
 				/** @var $field_obj EE_Model_Field_Base */
325
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
325
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
326 326
 			}
327 327
 		}
328 328
 
329 329
 		// everything is related to Extra_Meta
330
-		if( get_class($this) != 'EEM_Extra_Meta'){
330
+		if (get_class($this) != 'EEM_Extra_Meta') {
331 331
 			//make extra meta related to everything, but don't block deleting things just
332 332
 			//because they have related extra meta info. For now just orphan those extra meta
333 333
 			//in the future we should automatically delete them
334
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
334
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
335 335
 		}
336 336
 		//and change logs
337
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
338
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
337
+		if (get_class($this) != 'EEM_Change_Log') {
338
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
339 339
 		}
340 340
 		/**
341 341
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
342 342
 		 * EE_Register_Model_Extension
343 343
 		 * @param EE_Model_Relation_Base[] $_model_relations
344 344
 		 */
345
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
346
-		foreach($this->_model_relations as $model_name => $relation_obj){
345
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
346
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
347 347
 			/** @var $relation_obj EE_Model_Relation_Base */
348 348
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
349 349
 		}
350
-		foreach($this->_indexes as $index_name => $index_obj){
350
+		foreach ($this->_indexes as $index_name => $index_obj) {
351 351
 			/** @var $index_obj EE_Index */
352 352
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
353 353
 		}
354 354
 
355 355
 		$this->set_timezone($timezone);
356 356
 		//finalize default where condition strategy, or set default
357
-		if( ! $this->_default_where_conditions_strategy){
357
+		if ( ! $this->_default_where_conditions_strategy) {
358 358
 			//nothing was set during child constructor, so set default
359 359
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
360 360
 		}
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 	 * This sets the _timezone property after model object has been instantiated.
371 371
 	 * @param string $timezone valid PHP DateTimeZone timezone string
372 372
 	 */
373
-	public function set_timezone( $timezone ) {
374
-		if($timezone !== NULL){
373
+	public function set_timezone($timezone) {
374
+		if ($timezone !== NULL) {
375 375
 			$this->_timezone = $timezone;
376 376
 		}
377 377
 
378 378
 		//note we need to loop through relations and set the timezone on those objects as well.
379
-		foreach ( $this->_model_relations as $relation ) {
379
+		foreach ($this->_model_relations as $relation) {
380 380
 			$relation->set_timezone($timezone);
381 381
 		}
382 382
 
383 383
 		//and finally we do the same for any datetime fields
384
-		foreach ( $this->_fields as $field ) {
385
-			if ( $field instanceof EE_Datetime_Field ) {
386
-				$field->set_timezone( $timezone );
384
+		foreach ($this->_fields as $field) {
385
+			if ($field instanceof EE_Datetime_Field) {
386
+				$field->set_timezone($timezone);
387 387
 			}
388 388
 		}
389 389
 	}
@@ -395,16 +395,16 @@  discard block
 block discarded – undo
395 395
 	 *		@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)
396 396
 	 *		@return static (as in the concrete child class)
397 397
 	 */
398
-	public static function instance( $timezone = NULL ){
398
+	public static function instance($timezone = NULL) {
399 399
 
400 400
 		// check if instance of Espresso_model already exists
401 401
 		if ( ! static::$_instance instanceof static) {
402 402
 			// instantiate Espresso_model
403
-			static::$_instance = new static( $timezone );
403
+			static::$_instance = new static($timezone);
404 404
 		}
405 405
 
406 406
 		//we might have a timezone set, let set_timezone decide what to do with it
407
-		static::$_instance->set_timezone( $timezone );
407
+		static::$_instance->set_timezone($timezone);
408 408
 
409 409
 		// Espresso_model object
410 410
 		return static::$_instance;
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 	 * resets the model and returns it
417 417
 	 * @return static
418 418
 	 */
419
-	public static function reset(  $timezone = NULL ){
419
+	public static function reset($timezone = NULL) {
420 420
 		static::$_instance = NULL;
421
-		return self::instance( $timezone );
421
+		return self::instance($timezone);
422 422
 	}
423 423
 
424 424
 
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
 	 * @param  boolean $translated return localized strings or JUST the array.
430 430
 	 * @return array
431 431
 	 */
432
-	 public function status_array( $translated = FALSE ) {
433
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
432
+	 public function status_array($translated = FALSE) {
433
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
434 434
 	 		return array();
435 435
 	 	$model_name = $this->get_this_model_name();
436
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
437
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
436
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
437
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
438 438
 	 	$status_array = array();
439
-	 	foreach ( $stati as $status ) {
440
-            $status_array[ $status->ID() ] = $status->get('STS_code');
439
+	 	foreach ($stati as $status) {
440
+            $status_array[$status->ID()] = $status->get('STS_code');
441 441
         }
442 442
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443 443
     }
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 *			'order_by'=>array('ANS_value'=>'ASC')
575 575
 	 *		));
576 576
 	 */
577
-	function get_all($query_params = array()){
577
+	function get_all($query_params = array()) {
578 578
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
579 579
 	}
580 580
 
@@ -584,21 +584,21 @@  discard block
 block discarded – undo
584 584
 	 * @param array $query_parms @see EEM_Base::get_all()
585 585
 	 * @return array like EEM_Base::get_all
586 586
 	 */
587
-	function alter_query_params_to_only_include_mine( $query_parms = array() ) {
587
+	function alter_query_params_to_only_include_mine($query_parms = array()) {
588 588
 		try {
589
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
590
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
591
-				$last_model_name = end( $models_to_follow_to_wp_users );
592
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
593
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
594
-			}else{
589
+			if ( ! empty($this->_model_chain_to_wp_user)) {
590
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
591
+				$last_model_name = end($models_to_follow_to_wp_users);
592
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
593
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
594
+			} else {
595 595
 				$model_with_fk_to_wp_users = $this;
596 596
 				$model_chain_to_wp_user = '';
597 597
 			}
598
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
599
-			$query_parms[0][ $model_chain_to_wp_user . $wp_user_field->get_name() ] = get_current_user_id();
598
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
599
+			$query_parms[0][$model_chain_to_wp_user.$wp_user_field->get_name()] = get_current_user_id();
600 600
 			return $query_parms;
601
-		} catch( EE_Error $e ) {
601
+		} catch (EE_Error $e) {
602 602
 			//if there's no foreign key to WP_User, then they own all of them?
603 603
 			return $query_parms;
604 604
 		}
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	 * (or transietly-related model)
614 614
 	 * @return string
615 615
 	 */
616
-	public function model_chain_to_wp_user(){
616
+	public function model_chain_to_wp_user() {
617 617
 		return $this->_model_chain_to_wp_user;
618 618
 	}
619 619
 
@@ -625,13 +625,13 @@  discard block
 block discarded – undo
625 625
 	 * @return boolean
626 626
 	 */
627 627
 	public function is_owned() {
628
-		if( $this->model_chain_to_wp_user() ){
628
+		if ($this->model_chain_to_wp_user()) {
629 629
 			return true;
630
-		}else{
631
-			try{
632
-				$this->get_foreign_key_to( 'WP_User' );
630
+		} else {
631
+			try {
632
+				$this->get_foreign_key_to('WP_User');
633 633
 				return true;
634
-			}catch( EE_Error $e ){
634
+			} catch (EE_Error $e) {
635 635
 				return false;
636 636
 			}
637 637
 		}
@@ -650,21 +650,21 @@  discard block
 block discarded – undo
650 650
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
651 651
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
652 652
 	 */
653
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
653
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
654 654
 		//remember the custom selections, if any
655
-		if(is_array($columns_to_select)){
655
+		if (is_array($columns_to_select)) {
656 656
 			$this->_custom_selections = $columns_to_select;
657
-		}elseif(is_string($columns_to_select)){
657
+		}elseif (is_string($columns_to_select)) {
658 658
 			$this->_custom_selections = array($this->_custom_selections);
659
-		}else{
659
+		} else {
660 660
 			$this->_custom_selections = array();
661 661
 		}
662 662
 
663 663
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
664 664
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
665
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
665
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
666 666
 //		echo "sql:$SQL";
667
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
667
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
668 668
 		return $results;
669 669
 	}
670 670
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
682 682
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
683 683
 	 */
684
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
684
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
685 685
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
686 686
 	}
687 687
 
@@ -693,21 +693,21 @@  discard block
 block discarded – undo
693 693
 	 * @throws EE_Error
694 694
 	 * @return string
695 695
 	 */
696
-	private function _construct_select_from_input($columns_to_select){
697
-		if(is_array($columns_to_select)){
696
+	private function _construct_select_from_input($columns_to_select) {
697
+		if (is_array($columns_to_select)) {
698 698
 			$select_sql_array = array();
699 699
 
700
-			foreach($columns_to_select as $alias => $selection_and_datatype){
701
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
702
-					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));
700
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
701
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
702
+					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));
703 703
 				}
704
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
705
-					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)));
704
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
705
+					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)));
706 706
 				}
707 707
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
708 708
 			}
709
-			$columns_to_select_string = implode(", ",$select_sql_array);
710
-		}else{
709
+			$columns_to_select_string = implode(", ", $select_sql_array);
710
+		} else {
711 711
 			$columns_to_select_string = $columns_to_select;
712 712
 		}
713 713
 		return $columns_to_select_string;
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
721 721
 	 * @return string
722 722
 	 */
723
-	function primary_key_name(){
723
+	function primary_key_name() {
724 724
 		return $this->get_primary_key_field()->get_name();
725 725
 	}
726 726
 
@@ -732,15 +732,15 @@  discard block
 block discarded – undo
732 732
 	 * @param mixed $id int or string, depending on the type of the model's primary key
733 733
 	 * @return EE_Base_Class
734 734
 	 */
735
-	function get_one_by_ID($id){
736
-		if( $this->get_from_entity_map( $id ) ){
737
-			return $this->get_from_entity_map( $id );
738
-		}elseif( $this->has_primary_key_field ( ) ) {
735
+	function get_one_by_ID($id) {
736
+		if ($this->get_from_entity_map($id)) {
737
+			return $this->get_from_entity_map($id);
738
+		}elseif ($this->has_primary_key_field( )) {
739 739
 			$primary_key_name = $this->get_primary_key_field()->get_name();
740 740
 			return $this->get_one(array(array($primary_key_name => $id)));
741
-		}else{
741
+		} else {
742 742
 			//no primary key, so the $id must be from the get_index_primary_key_string()
743
-			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
743
+			return $this->get_one(array($this->parse_index_primary_key_string($id)));
744 744
 		}
745 745
 	}
746 746
 
@@ -751,16 +751,16 @@  discard block
 block discarded – undo
751 751
 	 * @param array $query_params like EEM_Base's $query_params variable.
752 752
 	 * @return EE_Base_Class | NULL
753 753
 	 */
754
-	function get_one($query_params = array()){
755
-		if( ! is_array( $query_params ) ){
756
-			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' );
754
+	function get_one($query_params = array()) {
755
+		if ( ! is_array($query_params)) {
756
+			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');
757 757
 			$query_params = array();
758 758
 		}
759 759
 		$query_params['limit'] = 1;
760 760
 		$items = $this->get_all($query_params);
761
-		if(empty($items)){
761
+		if (empty($items)) {
762 762
 			return null;
763
-		}else{
763
+		} else {
764 764
 			return array_shift($items);
765 765
 		}
766 766
 	}
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	 *
785 785
 	 * @return EE_Base_Class[]|array
786 786
 	 */
787
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
788
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
787
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
788
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
789 789
 	}
790 790
 
791 791
 
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 *
809 809
 	 * @return EE_Base_Class[]|array
810 810
 	 */
811
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
812
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
811
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
812
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
813 813
 	}
814 814
 
815 815
 
@@ -831,9 +831,9 @@  discard block
 block discarded – undo
831 831
 	 *
832 832
 	 * @return EE_Base_Class|null|array()
833 833
 	 */
834
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
835
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
836
-		return empty( $results ) ? null : reset( $results );
834
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
835
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
836
+		return empty($results) ? null : reset($results);
837 837
 	}
838 838
 
839 839
 
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
 	 *
856 856
 	 * @return EE_Base_Class|null|array()
857 857
 	 */
858
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
859
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
860
-		return empty( $results ) ? null : reset( $results );
858
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
859
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
860
+		return empty($results) ? null : reset($results);
861 861
 	}
862 862
 
863 863
 
@@ -883,40 +883,40 @@  discard block
 block discarded – undo
883 883
 	 * @return EE_Base_Class[]|array
884 884
 	 * @throws EE_Error
885 885
 	 */
886
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
886
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
887 887
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
888
-		if ( empty( $field_to_order_by ) ) {
889
-			if ( $this->has_primary_key_field() ) {
888
+		if (empty($field_to_order_by)) {
889
+			if ($this->has_primary_key_field()) {
890 890
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
891 891
 			} else {
892 892
 
893
-				if ( WP_DEBUG ) {
894
-					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' ) );
893
+				if (WP_DEBUG) {
894
+					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'));
895 895
 				}
896
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
896
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
897 897
 				return array();
898 898
 			}
899 899
 		}
900 900
 
901
-		if( ! is_array( $query_params ) ){
902
-			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' );
901
+		if ( ! is_array($query_params)) {
902
+			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');
903 903
 			$query_params = array();
904 904
 		}
905 905
 
906 906
 		//let's add the where query param for consecutive look up.
907
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
907
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
908 908
 		$query_params['limit'] = $limit;
909 909
 
910 910
 		//set direction
911
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
912
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
911
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
912
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
913 913
 
914 914
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
915
-		if ( empty( $columns_to_select ) ) {
916
-			return $this->get_all( $query_params );
915
+		if (empty($columns_to_select)) {
916
+			return $this->get_all($query_params);
917 917
 		} else {
918 918
 			//getting just the fields
919
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
919
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
920 920
 		}
921 921
 	}
922 922
 
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
940 940
 	 * @return EE_Table_Base[]
941 941
 	 */
942
-	function get_tables(){
942
+	function get_tables() {
943 943
 		return $this->_tables;
944 944
 	}
945 945
 
@@ -973,9 +973,9 @@  discard block
 block discarded – undo
973 973
 	 * be aware that model objects being used could get out-of-sync with the database
974 974
 	 * @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)
975 975
 	 */
976
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
977
-		if( ! is_array( $query_params ) ){
978
-			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' );
976
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
977
+		if ( ! is_array($query_params)) {
978
+			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');
979 979
 			$query_params = array();
980 980
 		}
981 981
 		/**
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 		 * @param array $fields_n_values the updated fields and their new values
986 986
 		 * @param array $query_params @see EEM_Base::get_all()
987 987
 		 */
988
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
988
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
989 989
 		/**
990 990
 		 * Filters the fields about to be updated given the query parameters. You can provide the
991 991
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -993,10 +993,10 @@  discard block
 block discarded – undo
993 993
 		 * @param EEM_Base $model the model being queried
994 994
 		 * @param array $query_params see EEM_Base::get_all()
995 995
 		 */
996
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
996
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
997 997
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
998 998
 		//to do that, for each table, verify that it's PK isn't null.
999
-		$tables= $this->get_tables();
999
+		$tables = $this->get_tables();
1000 1000
 
1001 1001
 		//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
1002 1002
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1006,29 +1006,29 @@  discard block
 block discarded – undo
1006 1006
 			//we want to make sure the default_where strategy is ignored
1007 1007
 			$this->_ignore_where_strategy = TRUE;
1008 1008
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1009
-			foreach( $wpdb_select_results as $wpdb_result ){
1009
+			foreach ($wpdb_select_results as $wpdb_result) {
1010 1010
 				// type cast stdClass as array
1011
-				$wpdb_result = (array)$wpdb_result;
1011
+				$wpdb_result = (array) $wpdb_result;
1012 1012
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1013
-				if( $this->has_primary_key_field() ){
1014
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1015
-				}else{
1013
+				if ($this->has_primary_key_field()) {
1014
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1015
+				} else {
1016 1016
 					//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)
1017 1017
 					$main_table_pk_value = null;
1018 1018
 				}
1019 1019
 				//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
1020 1020
 				//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
1021
-				if(count($tables) > 1){
1021
+				if (count($tables) > 1) {
1022 1022
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1023 1023
 					//in that table, and so we'll want to insert one
1024
-					foreach($tables as $table_obj){
1024
+					foreach ($tables as $table_obj) {
1025 1025
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1026 1026
 						//if there is no private key for this table on the results, it means there's no entry
1027 1027
 						//in this table, right? so insert a row in the current table, using any fields available
1028
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1028
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1029 1029
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1030 1030
 							//if we died here, report the error
1031
-							if( ! $success ) {
1031
+							if ( ! $success) {
1032 1032
 								return false;
1033 1033
 							}
1034 1034
 						}
@@ -1048,44 +1048,44 @@  discard block
 block discarded – undo
1048 1048
 		//if this wasn't called from a model object (to update itself)
1049 1049
 		//then we want to make sure we keep all the existing
1050 1050
 		//model objects in sync with the db
1051
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1052
-			if( $this->has_primary_key_field() ){
1053
-				$model_objs_affected_ids = $this->get_col( $query_params );
1054
-			}else{
1051
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1052
+			if ($this->has_primary_key_field()) {
1053
+				$model_objs_affected_ids = $this->get_col($query_params);
1054
+			} else {
1055 1055
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1056
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1056
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1057 1057
 				$model_objs_affected_ids = array();
1058
-				foreach( $models_affected_key_columns as $row ){
1059
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1060
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1058
+				foreach ($models_affected_key_columns as $row) {
1059
+					$combined_index_key = $this->get_index_primary_key_string($row);
1060
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1061 1061
 				}
1062 1062
 
1063 1063
 			}
1064 1064
 
1065
-			if( ! $model_objs_affected_ids ){
1065
+			if ( ! $model_objs_affected_ids) {
1066 1066
 				//wait wait wait- if nothing was affected let's stop here
1067 1067
 				return 0;
1068 1068
 			}
1069
-			foreach( $model_objs_affected_ids as $id ){
1070
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1071
-				if( $model_obj_in_entity_map ){
1072
-					foreach( $fields_n_values as $field => $new_value ){
1073
-						$model_obj_in_entity_map->set( $field, $new_value );
1069
+			foreach ($model_objs_affected_ids as $id) {
1070
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1071
+				if ($model_obj_in_entity_map) {
1072
+					foreach ($fields_n_values as $field => $new_value) {
1073
+						$model_obj_in_entity_map->set($field, $new_value);
1074 1074
 					}
1075 1075
 				}
1076 1076
 			}
1077 1077
 			//if there is a primary key on this model, we can now do a slight optimization
1078
-			if( $this->has_primary_key_field() ){
1078
+			if ($this->has_primary_key_field()) {
1079 1079
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1080 1080
 				$query_params = array(
1081
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1082
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1081
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1082
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1083 1083
 			}
1084 1084
 		}
1085 1085
 
1086
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1087
-		$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.
1088
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1086
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1087
+		$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.
1088
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1089 1089
 		/**
1090 1090
 		 * Action called after a model update call has been made.
1091 1091
 		 *
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 		 * @param array $query_params @see EEM_Base::get_all()
1095 1095
 		 * @param int $rows_affected
1096 1096
 		 */
1097
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1098
-		return $rows_affected;//how many supposedly got updated
1097
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1098
+		return $rows_affected; //how many supposedly got updated
1099 1099
 	}
1100 1100
 
1101 1101
 	/**
@@ -1107,22 +1107,22 @@  discard block
 block discarded – undo
1107 1107
 	 * @param string $field_to_select
1108 1108
 	 * @return array just like $wpdb->get_col()
1109 1109
 	 */
1110
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1110
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1111 1111
 
1112
-		if( $field_to_select ){
1113
-			$field = $this->field_settings_for( $field_to_select );
1114
-		}elseif( $this->has_primary_key_field ( ) ){
1112
+		if ($field_to_select) {
1113
+			$field = $this->field_settings_for($field_to_select);
1114
+		}elseif ($this->has_primary_key_field( )) {
1115 1115
 			$field = $this->get_primary_key_field();
1116
-		}else{
1116
+		} else {
1117 1117
 			//no primary key, just grab the first column
1118
-			$field = reset( $this->field_settings());
1118
+			$field = reset($this->field_settings());
1119 1119
 		}
1120 1120
 
1121 1121
 
1122 1122
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1123 1123
 		$select_expressions = $field->get_qualified_column();
1124
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1125
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1124
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1125
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1126 1126
 		return $results;
1127 1127
 	}
1128 1128
 
@@ -1135,18 +1135,18 @@  discard block
 block discarded – undo
1135 1135
 	 * @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
1136 1136
 	 * @return string of SQL
1137 1137
 	 */
1138
-	function _construct_update_sql($fields_n_values){
1138
+	function _construct_update_sql($fields_n_values) {
1139 1139
 		global $wpdb;
1140 1140
 		$cols_n_values = array();
1141
-		foreach($fields_n_values as $field_name => $value){
1141
+		foreach ($fields_n_values as $field_name => $value) {
1142 1142
 			$field_obj = $this->field_settings_for($field_name);
1143 1143
 			//if the value is NULL, we want to assign the value to that.
1144 1144
 			//wpdb->prepare doesn't really handle that properly
1145
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1146
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1145
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1146
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1147 1147
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1148 1148
 		}
1149
-		return implode(",",$cols_n_values);
1149
+		return implode(",", $cols_n_values);
1150 1150
 
1151 1151
 	}
1152 1152
 
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
 	 * @param mixed $id
1159 1159
 	 * @return boolean whether the row got deleted or not
1160 1160
 	 */
1161
-	public function delete_by_ID( $id ){
1162
-		return $this->delete( array(
1163
-			array( $this->get_primary_key_field()->get_name() => $id ),
1161
+	public function delete_by_ID($id) {
1162
+		return $this->delete(array(
1163
+			array($this->get_primary_key_field()->get_name() => $id),
1164 1164
 			'limit' 	=> 1
1165
-		) );
1165
+		));
1166 1166
 	}
1167 1167
 
1168 1168
 
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1178 1178
 	 * @return int how many rows got deleted
1179 1179
 	 */
1180
-	function delete($query_params,$allow_blocking = true){
1180
+	function delete($query_params, $allow_blocking = true) {
1181 1181
 		/**
1182 1182
 		 * Action called just before performing a real deletion query. You can use the
1183 1183
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1186,34 +1186,34 @@  discard block
 block discarded – undo
1186 1186
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1187 1187
 		 * to block (prevent) this deletion
1188 1188
 		 */
1189
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1189
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1190 1190
 		//some MySQL databases may be running safe mode, which may restrict
1191 1191
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1192 1192
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1193 1193
 		//to delete them
1194 1194
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1195
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1196
-		if($deletion_where){
1195
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1196
+		if ($deletion_where) {
1197 1197
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1198 1198
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1199 1199
 			$table_aliases = array();
1200
-			foreach(array_keys($this->_tables) as $table_alias){
1200
+			foreach (array_keys($this->_tables) as $table_alias) {
1201 1201
 				$table_aliases[] = $table_alias;
1202 1202
 			}
1203
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1203
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1204 1204
 
1205 1205
 			//		/echo "delete sql:$SQL";
1206
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1207
-		}else{
1206
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1207
+		} else {
1208 1208
 			$rows_deleted = 0;
1209 1209
 		}
1210 1210
 
1211 1211
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1212
-		if( $this->has_primary_key_field() ){
1213
-			foreach($items_for_deletion as $item_for_deletion_row ){
1214
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1215
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1216
-					unset( $this->_entity_map[ $pk_value ] );
1212
+		if ($this->has_primary_key_field()) {
1213
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1214
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1215
+				if (isset($this->_entity_map[$pk_value])) {
1216
+					unset($this->_entity_map[$pk_value]);
1217 1217
 				}
1218 1218
 			}
1219 1219
 		}
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
 		 * @param array $query_params @see EEM_Base::get_all()
1226 1226
 		 * @param int $rows_deleted
1227 1227
 		 */
1228
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1229
-		return $rows_deleted;//how many supposedly got deleted
1228
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1229
+		return $rows_deleted; //how many supposedly got deleted
1230 1230
 	}
1231 1231
 
1232 1232
 
@@ -1242,28 +1242,28 @@  discard block
 block discarded – undo
1242 1242
 	 * blocking its deletion before removing the relation between A and B
1243 1243
 	 * @return boolean
1244 1244
 	 */
1245
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1245
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1246 1246
 		//first, if $ignore_this_model_obj was supplied, get its model
1247
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1247
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1248 1248
 			$ignored_model = $ignore_this_model_obj->get_model();
1249
-		}else{
1249
+		} else {
1250 1250
 			$ignored_model = null;
1251 1251
 		}
1252 1252
 		//now check all the relations of $this_model_obj_or_id and see if there
1253 1253
 		//are any related model objects blocking it?
1254 1254
 		$is_blocked = false;
1255
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1256
-			if( $relation_obj->block_delete_if_related_models_exist()){
1255
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1256
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1257 1257
 				//if $ignore_this_model_obj was supplied, then for the query
1258 1258
 				//on that model needs to be told to ignore $ignore_this_model_obj
1259
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1260
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1261
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1262
-				}else{
1259
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1260
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1261
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1262
+				} else {
1263 1263
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1264 1264
 				}
1265 1265
 
1266
-				if($related_model_objects){
1266
+				if ($related_model_objects) {
1267 1267
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1268 1268
 					$is_blocked = true;
1269 1269
 				}
@@ -1283,65 +1283,65 @@  discard block
 block discarded – undo
1283 1283
 	 * @throws EE_Error
1284 1284
 	 * @return string    everything that comes after the WHERE statement.
1285 1285
 	 */
1286
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1287
-		if($this->has_primary_key_field()){
1286
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1287
+		if ($this->has_primary_key_field()) {
1288 1288
 			$primary_table = $this->_get_main_table();
1289 1289
 			$other_tables = $this->_get_other_tables();
1290 1290
 			$deletes = $query = array();
1291
-			foreach ( $objects_for_deletion as $delete_object ) {
1291
+			foreach ($objects_for_deletion as $delete_object) {
1292 1292
 				//before we mark this object for deletion,
1293 1293
 				//make sure there's no related objects blocking its deletion (if we're checking)
1294
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1294
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1295 1295
 					continue;
1296 1296
 				}
1297 1297
 
1298 1298
 				//primary table deletes
1299
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1299
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1300 1300
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1301 1301
 
1302 1302
 				//other tables
1303
-				if ( !empty( $other_tables ) ) {
1304
-					foreach ( $other_tables as $ot ) {
1303
+				if ( ! empty($other_tables)) {
1304
+					foreach ($other_tables as $ot) {
1305 1305
 
1306 1306
 						//first check if we've got the foreign key column here.
1307
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1307
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1308 1308
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1309 1309
 
1310 1310
 						//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
1311
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1311
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1312 1312
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1313 1313
 
1314 1314
 						//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!
1315
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1315
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1316 1316
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1317 1317
 					}
1318 1318
 				}
1319 1319
 			}
1320 1320
 
1321 1321
 			//we should have deletes now, so let's just go through and setup the where statement
1322
-			foreach ( $deletes as $column => $values ) {
1322
+			foreach ($deletes as $column => $values) {
1323 1323
 				//make sure we have unique $values;
1324 1324
 				$values = array_unique($values);
1325
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1325
+				$query[] = $column.' IN('.implode(",", $values).')';
1326 1326
 			}
1327 1327
 
1328
-			return !empty($query) ? implode(' AND ', $query ) : '';
1329
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1328
+			return ! empty($query) ? implode(' AND ', $query) : '';
1329
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1330 1330
 			$ways_to_identify_a_row = array();
1331 1331
 			$fields = $this->get_combined_primary_key_fields();
1332 1332
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1333
-			foreach($objects_for_deletion as  $delete_object){
1333
+			foreach ($objects_for_deletion as  $delete_object) {
1334 1334
 				$values_for_each_cpk_for_a_row = array();
1335
-				foreach($fields as $cpk_field){
1335
+				foreach ($fields as $cpk_field) {
1336 1336
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1337 1337
 				}
1338
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1338
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1339 1339
 			}
1340
-			return implode(" OR ",$ways_to_identify_a_row);
1341
-		}else{
1340
+			return implode(" OR ", $ways_to_identify_a_row);
1341
+		} else {
1342 1342
 			//so there's no primary key and no combined key...
1343 1343
 			//sorry, can't help you
1344
-			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)));
1344
+			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)));
1345 1345
 		}
1346 1346
 	}
1347 1347
 
@@ -1355,21 +1355,21 @@  discard block
 block discarded – undo
1355 1355
 	 * @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;
1356 1356
 	 * @return int
1357 1357
 	 */
1358
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1358
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1359 1359
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1360
-		if($field_to_count){
1360
+		if ($field_to_count) {
1361 1361
 			$field_obj = $this->field_settings_for($field_to_count);
1362 1362
 			$column_to_count = $field_obj->get_qualified_column();
1363
-		}elseif($this->has_primary_key_field ()){
1363
+		}elseif ($this->has_primary_key_field()) {
1364 1364
 			$pk_field_obj = $this->get_primary_key_field();
1365 1365
 			$column_to_count = $pk_field_obj->get_qualified_column();
1366
-		}else{//there's no primary key
1366
+		} else {//there's no primary key
1367 1367
 			$column_to_count = '*';
1368 1368
 		}
1369 1369
 
1370
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1371
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1372
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1370
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1371
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1372
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1373 1373
 	}
1374 1374
 
1375 1375
 	/**
@@ -1379,23 +1379,23 @@  discard block
 block discarded – undo
1379 1379
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1380 1380
 	 * @return int
1381 1381
 	 */
1382
-	function sum($query_params, $field_to_sum = NULL){
1382
+	function sum($query_params, $field_to_sum = NULL) {
1383 1383
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1384 1384
 
1385
-		if($field_to_sum){
1385
+		if ($field_to_sum) {
1386 1386
 			$field_obj = $this->field_settings_for($field_to_sum);
1387 1387
 
1388
-		}else{
1388
+		} else {
1389 1389
 			$field_obj = $this->get_primary_key_field();
1390 1390
 		}
1391 1391
 		$column_to_count = $field_obj->get_qualified_column();
1392 1392
 
1393
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1394
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1395
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1396
-			return (int)$return_value;
1397
-		}else{//must be %f
1398
-			return (float)$return_value;
1393
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1394
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1395
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1396
+			return (int) $return_value;
1397
+		} else {//must be %f
1398
+			return (float) $return_value;
1399 1399
 		}
1400 1400
 	}
1401 1401
 
@@ -1410,34 +1410,34 @@  discard block
 block discarded – undo
1410 1410
 	 * @global wpdb $wpdb
1411 1411
 	 * @return mixed
1412 1412
 	 */
1413
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1413
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1414 1414
 		//if we're in maintenance mode level 2, DON'T run any queries
1415 1415
 		//because level 2 indicates the database needs updating and
1416 1416
 		//is probably out of sync with the code
1417
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1417
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1418 1418
 			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")));
1419 1419
 		}
1420 1420
 		global $wpdb;
1421
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1422
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1421
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1422
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1423 1423
 		}
1424
-		if( WP_DEBUG ){
1424
+		if (WP_DEBUG) {
1425 1425
 			$wpdb->last_error = NULL;
1426 1426
 			$old_show_errors_value = $wpdb->show_errors;
1427
-			$wpdb->show_errors( FALSE );
1427
+			$wpdb->show_errors(FALSE);
1428 1428
 		}
1429 1429
 
1430
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ) , $arguments_to_provide );
1431
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1432
-		if( WP_DEBUG ){
1433
-			$wpdb->show_errors( $old_show_errors_value );
1434
-			if( ! empty( $wpdb->last_error ) ){
1435
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1436
-			}elseif( $result === false ){
1437
-				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 ) ) );
1430
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1431
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1432
+		if (WP_DEBUG) {
1433
+			$wpdb->show_errors($old_show_errors_value);
1434
+			if ( ! empty($wpdb->last_error)) {
1435
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1436
+			}elseif ($result === false) {
1437
+				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)));
1438 1438
 			}
1439
-		}elseif( $result === false ) {
1440
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1439
+		}elseif ($result === false) {
1440
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1441 1441
 		}
1442 1442
 		return $result;
1443 1443
 	}
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1450 1450
 	 * @return string
1451 1451
 	 */
1452
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1452
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1453 1453
 		return " FROM ".$model_query_info->get_full_join_sql().
1454 1454
 				$model_query_info->get_where_sql().
1455 1455
 				$model_query_info->get_group_by_sql().
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 	 * Set to easily debug the next X queries ran from this model.
1463 1463
 	 * @param int $count
1464 1464
 	 */
1465
-	function show_next_x_db_queries($count = 1){
1465
+	function show_next_x_db_queries($count = 1) {
1466 1466
 		$this->_show_next_x_db_queries = $count;
1467 1467
 	}
1468 1468
 
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 	/**
1472 1472
 	 * @param $sql_query
1473 1473
 	 */
1474
-	function show_db_query_if_previously_requested($sql_query){
1475
-		if($this->_show_next_x_db_queries > 0){
1474
+	function show_db_query_if_previously_requested($sql_query) {
1475
+		if ($this->_show_next_x_db_queries > 0) {
1476 1476
 			echo $sql_query;
1477 1477
 			$this->_show_next_x_db_queries--;
1478 1478
 		}
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 	 * @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.
1497 1497
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
1498 1498
 	 */
1499
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
1499
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1500 1500
 		$relation_obj = $this->related_settings_for($relationName);
1501 1501
 		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1502 1502
 	}
@@ -1517,9 +1517,9 @@  discard block
 block discarded – undo
1517 1517
 	 * @return boolean of success
1518 1518
 	 * @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.
1519 1519
 	 */
1520
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
1520
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1521 1521
 		$relation_obj = $this->related_settings_for($relationName);
1522
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
1522
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1523 1523
 	}
1524 1524
 
1525 1525
 
@@ -1532,9 +1532,9 @@  discard block
 block discarded – undo
1532 1532
 	 * @param EE_Base_Class[] objects to which relations were removed
1533 1533
 	 * @return \EE_Base_Class[]
1534 1534
 	 */
1535
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
1535
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
1536 1536
 		$relation_obj = $this->related_settings_for($relationName);
1537
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
1537
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
1538 1538
 	}
1539 1539
 
1540 1540
 
@@ -1547,10 +1547,10 @@  discard block
 block discarded – undo
1547 1547
 	 * @param array $query_params like EEM_Base::get_all
1548 1548
 	 * @return EE_Base_Class[]
1549 1549
 	 */
1550
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
1550
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
1551 1551
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1552 1552
 		$relation_settings = $this->related_settings_for($model_name);
1553
-		return $relation_settings->get_all_related($model_obj,$query_params);
1553
+		return $relation_settings->get_all_related($model_obj, $query_params);
1554 1554
 	}
1555 1555
 
1556 1556
 	/**
@@ -1563,10 +1563,10 @@  discard block
 block discarded – undo
1563 1563
 	 * @param array $query_params
1564 1564
 	 * @return int how many deleted
1565 1565
 	 */
1566
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
1566
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
1567 1567
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1568 1568
 		$relation_settings = $this->related_settings_for($model_name);
1569
-		return $relation_settings->delete_all_related($model_obj,$query_params);
1569
+		return $relation_settings->delete_all_related($model_obj, $query_params);
1570 1570
 	}
1571 1571
 
1572 1572
 	/**
@@ -1579,10 +1579,10 @@  discard block
 block discarded – undo
1579 1579
 	 * @param array $query_params
1580 1580
 	 * @return int how many deleted
1581 1581
 	 */
1582
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
1582
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
1583 1583
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1584 1584
 		$relation_settings = $this->related_settings_for($model_name);
1585
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
1585
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
1586 1586
 	}
1587 1587
 
1588 1588
 	/**
@@ -1595,17 +1595,17 @@  discard block
 block discarded – undo
1595 1595
 	 * @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;
1596 1596
 	 * @return int
1597 1597
 	 */
1598
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
1598
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
1599 1599
 		$related_model = $this->get_related_model_obj($model_name);
1600 1600
 		//we're just going to use the query params on the related model's normal get_all query,
1601 1601
 		//except add a condition to say to match the current mod
1602
-		if( ! isset($query_params['default_where_conditions'])){
1603
-			$query_params['default_where_conditions']='none';
1602
+		if ( ! isset($query_params['default_where_conditions'])) {
1603
+			$query_params['default_where_conditions'] = 'none';
1604 1604
 		}
1605 1605
 		$this_model_name = $this->get_this_model_name();
1606 1606
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1607
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1608
-		return $related_model->count($query_params,$field_to_count,$distinct);
1607
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1608
+		return $related_model->count($query_params, $field_to_count, $distinct);
1609 1609
 	}
1610 1610
 
1611 1611
 
@@ -1619,21 +1619,21 @@  discard block
 block discarded – undo
1619 1619
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
1620 1620
 	 * @return int
1621 1621
 	 */
1622
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
1622
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
1623 1623
 		$related_model = $this->get_related_model_obj($model_name);
1624
-		if( ! is_array( $query_params ) ){
1625
-			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' );
1624
+		if ( ! is_array($query_params)) {
1625
+			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');
1626 1626
 			$query_params = array();
1627 1627
 		}
1628 1628
 		//we're just going to use the query params on the related model's normal get_all query,
1629 1629
 		//except add a condition to say to match the current mod
1630
-		if( ! isset($query_params['default_where_conditions'])){
1631
-			$query_params['default_where_conditions']='none';
1630
+		if ( ! isset($query_params['default_where_conditions'])) {
1631
+			$query_params['default_where_conditions'] = 'none';
1632 1632
 		}
1633 1633
 		$this_model_name = $this->get_this_model_name();
1634 1634
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1635
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1636
-		return $related_model->sum($query_params,$field_to_sum);
1635
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1636
+		return $related_model->sum($query_params, $field_to_sum);
1637 1637
 	}
1638 1638
 
1639 1639
 
@@ -1645,12 +1645,12 @@  discard block
 block discarded – undo
1645 1645
 	 * @param array $query_params like EEM_Base::get_all's
1646 1646
 	 * @return EE_Base_Class
1647 1647
 	 */
1648
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
1649
-		$query_params['limit']=1;
1650
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1651
-		if( $results ){
1648
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
1649
+		$query_params['limit'] = 1;
1650
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
1651
+		if ($results) {
1652 1652
 			return array_shift($results);
1653
-		}else{
1653
+		} else {
1654 1654
 			return null;
1655 1655
 		}
1656 1656
 
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
1661 1661
 	 * @return string
1662 1662
 	 */
1663
-	function get_this_model_name(){
1664
-		return str_replace("EEM_","",get_class($this));
1663
+	function get_this_model_name() {
1664
+		return str_replace("EEM_", "", get_class($this));
1665 1665
 	}
1666 1666
 
1667 1667
 	/**
@@ -1669,14 +1669,14 @@  discard block
 block discarded – undo
1669 1669
 	 * @return EE_Any_Foreign_Model_Name_Field
1670 1670
 	 * @throws EE_Error
1671 1671
 	 */
1672
-	public function get_field_containing_related_model_name(){
1673
-		foreach($this->field_settings(true) as $field){
1674
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
1672
+	public function get_field_containing_related_model_name() {
1673
+		foreach ($this->field_settings(true) as $field) {
1674
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
1675 1675
 				$field_with_model_name = $field;
1676 1676
 			}
1677 1677
 		}
1678
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
1679
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
1678
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
1679
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
1680 1680
 		}
1681 1681
 		return $field_with_model_name;
1682 1682
 	}
@@ -1697,19 +1697,19 @@  discard block
 block discarded – undo
1697 1697
 	 * @return int new primary key on main table that got inserted
1698 1698
 	 * @throws EE_Error
1699 1699
 	 */
1700
-	function insert($field_n_values){
1700
+	function insert($field_n_values) {
1701 1701
 		/**
1702 1702
 		 * Filters the fields and their values before inserting an item using the models
1703 1703
 		 * @param array $fields_n_values keys are the fields and values are their new values
1704 1704
 		 * @param EEM_Base $model the model used
1705 1705
 		 */
1706
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
1707
-		if($this->_satisfies_unique_indexes($field_n_values)){
1706
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
1707
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
1708 1708
 			$main_table = $this->_get_main_table();
1709 1709
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
1710
-			if( $new_id !== false ) {
1711
-				foreach($this->_get_other_tables() as $other_table){
1712
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
1710
+			if ($new_id !== false) {
1711
+				foreach ($this->_get_other_tables() as $other_table) {
1712
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
1713 1713
 				}
1714 1714
 			}
1715 1715
 			/**
@@ -1719,9 +1719,9 @@  discard block
 block discarded – undo
1719 1719
 			 * @param array $fields_n_values fields and their values
1720 1720
 			 * @param int|string the ID of the newly-inserted model object
1721 1721
 			 */
1722
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
1722
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
1723 1723
 			return $new_id;
1724
-		}else{
1724
+		} else {
1725 1725
 			return FALSE;
1726 1726
 		}
1727 1727
 	}
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
 	 * @param string $action
1735 1735
 	 * @return boolean
1736 1736
 	 */
1737
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
1738
-		foreach($this->unique_indexes() as $index_name => $index){
1737
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
1738
+		foreach ($this->unique_indexes() as $index_name => $index) {
1739 1739
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
1740
-			if($this->exists(array($uniqueness_where_params))){
1741
-				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__ );
1740
+			if ($this->exists(array($uniqueness_where_params))) {
1741
+				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__);
1742 1742
 				return false;
1743 1743
 			}
1744 1744
 		}
@@ -1759,28 +1759,28 @@  discard block
 block discarded – undo
1759 1759
 	 * @throws EE_Error
1760 1760
 	 * @return EE_Base_Class
1761 1761
 	 */
1762
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
1763
-		if($obj_or_fields_array instanceof EE_Base_Class){
1762
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
1763
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
1764 1764
 			$fields_n_values = $obj_or_fields_array->model_field_array();
1765
-		}elseif( is_array($obj_or_fields_array)){
1765
+		}elseif (is_array($obj_or_fields_array)) {
1766 1766
 			$fields_n_values = $obj_or_fields_array;
1767
-		}else{
1768
-			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));
1767
+		} else {
1768
+			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));
1769 1769
 		}
1770 1770
 		$query_params = array();
1771
-		if( $this->has_primary_key_field() &&
1772
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1773
-				isset($fields_n_values[$this->primary_key_name()])){
1771
+		if ($this->has_primary_key_field() &&
1772
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1773
+				isset($fields_n_values[$this->primary_key_name()])) {
1774 1774
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
1775 1775
 		}
1776
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
1776
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
1777 1777
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
1778 1778
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
1779 1779
 		}
1780 1780
 		//if there is nothing to base this search on, then we shouldn't find anything
1781
-		if( empty( $query_params ) ){
1781
+		if (empty($query_params)) {
1782 1782
 			return array();
1783
-		}else{
1783
+		} else {
1784 1784
 			return $this->get_one($query_params);
1785 1785
 		}
1786 1786
 	}
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
 	 * @param array $query_params
1791 1791
 	 * @return boolean
1792 1792
 	 */
1793
-	function exists($query_params){
1793
+	function exists($query_params) {
1794 1794
 		$query_params['limit'] = 1;
1795 1795
 		return $this->count($query_params) > 0;
1796 1796
 	}
@@ -1800,7 +1800,7 @@  discard block
 block discarded – undo
1800 1800
 	 * @param int|string $id
1801 1801
 	 * @return boolean
1802 1802
 	 */
1803
-	function exists_by_ID($id){
1803
+	function exists_by_ID($id) {
1804 1804
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
1805 1805
 	}
1806 1806
 
@@ -1820,45 +1820,45 @@  discard block
 block discarded – undo
1820 1820
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
1821 1821
 	 * @return int ID of new row inserted, or FALSE on failure
1822 1822
 	 */
1823
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
1823
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
1824 1824
 		global $wpdb;
1825 1825
 		$insertion_col_n_values = array();
1826 1826
 		$format_for_insertion = array();
1827 1827
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
1828
-		foreach($fields_on_table as $field_name => $field_obj){
1828
+		foreach ($fields_on_table as $field_name => $field_obj) {
1829 1829
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
1830
-			if($field_obj->is_auto_increment()){
1830
+			if ($field_obj->is_auto_increment()) {
1831 1831
 				continue;
1832 1832
 			}
1833 1833
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1834 1834
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
1835
-			if( $prepared_value !== NULL ){
1836
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
1835
+			if ($prepared_value !== NULL) {
1836
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
1837 1837
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
1838 1838
 			}
1839 1839
 		}
1840 1840
 
1841
-		if($table instanceof EE_Secondary_Table && $new_id){
1841
+		if ($table instanceof EE_Secondary_Table && $new_id) {
1842 1842
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
1843 1843
 			//so add the fk to the main table as a column
1844 1844
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
1845
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
1845
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
1846 1846
 		}
1847 1847
 		//insert the new entry
1848
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
1849
-		if( $result === false ) {
1848
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
1849
+		if ($result === false) {
1850 1850
 			return false;
1851 1851
 		}
1852 1852
 		//ok, now what do we return for the ID of the newly-inserted thing?
1853
-		if($this->has_primary_key_field()){
1854
-			if($this->get_primary_key_field()->is_auto_increment()){
1853
+		if ($this->has_primary_key_field()) {
1854
+			if ($this->get_primary_key_field()->is_auto_increment()) {
1855 1855
 				return $wpdb->insert_id;
1856
-			}else{
1856
+			} else {
1857 1857
 				//it's not an auto-increment primary key, so
1858 1858
 				//it must have been supplied
1859 1859
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
1860 1860
 			}
1861
-		}else{
1861
+		} else {
1862 1862
 			//we can't return a  primary key because there is none. instead return
1863 1863
 			//a unique string indicating this model
1864 1864
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -1873,15 +1873,15 @@  discard block
 block discarded – undo
1873 1873
 	 * @param array $fields_n_values
1874 1874
 	 * @return mixed string|int|float depending on what the table column will be expecting
1875 1875
 	 */
1876
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
1876
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
1877 1877
 		//if this field doesn't allow nullable, don't allow it
1878
-		if( ! $field_obj->is_nullable() && (
1879
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
1880
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
1881
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
1878
+		if ( ! $field_obj->is_nullable() && (
1879
+				! isset($fields_n_values[$field_obj->get_name()]) ||
1880
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
1881
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
1882 1882
 		}
1883
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
1884
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
1883
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
1884
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
1885 1885
 	}
1886 1886
 
1887 1887
 
@@ -1893,9 +1893,9 @@  discard block
 block discarded – undo
1893 1893
 	 * @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
1894 1894
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
1895 1895
 	 */
1896
-	private function _prepare_value_for_use_in_db($value, $field){
1897
-		if($field && $field instanceof EE_Model_Field_Base){
1898
-			switch( $this->_values_already_prepared_by_model_object ){
1896
+	private function _prepare_value_for_use_in_db($value, $field) {
1897
+		if ($field && $field instanceof EE_Model_Field_Base) {
1898
+			switch ($this->_values_already_prepared_by_model_object) {
1899 1899
 				case self::not_prepared_by_model_object:
1900 1900
 					$value = $field->prepare_for_set($value);
1901 1901
 					//purposefully left out "return"
@@ -1905,7 +1905,7 @@  discard block
 block discarded – undo
1905 1905
 					//leave the value alone
1906 1906
 			}
1907 1907
 			return $value;
1908
-		}else{
1908
+		} else {
1909 1909
 			return $value;
1910 1910
 		}
1911 1911
 	}
@@ -1915,13 +1915,13 @@  discard block
 block discarded – undo
1915 1915
 	 * @return EE_Primary_Table
1916 1916
 	 * @throws EE_Error
1917 1917
 	 */
1918
-	protected function _get_main_table(){
1919
-		foreach($this->_tables as $table){
1920
-			if($table instanceof EE_Primary_Table){
1918
+	protected function _get_main_table() {
1919
+		foreach ($this->_tables as $table) {
1920
+			if ($table instanceof EE_Primary_Table) {
1921 1921
 				return $table;
1922 1922
 			}
1923 1923
 		}
1924
-		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)));
1924
+		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)));
1925 1925
 	}
1926 1926
 
1927 1927
 	/**
@@ -1940,7 +1940,7 @@  discard block
 block discarded – undo
1940 1940
 	 */
1941 1941
 	public function second_table() {
1942 1942
 		// grab second table from tables array
1943
-		$second_table = end( $this->_tables );
1943
+		$second_table = end($this->_tables);
1944 1944
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
1945 1945
 	}
1946 1946
 
@@ -1953,8 +1953,8 @@  discard block
 block discarded – undo
1953 1953
 	 * @param string $table_alias
1954 1954
 	 * @return EE_Primary_Table | EE_Secondary_Table
1955 1955
 	 */
1956
-	public function get_table_obj_by_alias( $table_alias = '' ) {
1957
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
1956
+	public function get_table_obj_by_alias($table_alias = '') {
1957
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
1958 1958
 	}
1959 1959
 
1960 1960
 
@@ -1963,10 +1963,10 @@  discard block
 block discarded – undo
1963 1963
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
1964 1964
 	 * @return EE_Secondary_Table[]
1965 1965
 	 */
1966
-	protected function _get_other_tables(){
1967
-		$other_tables =array();
1968
-		foreach($this->_tables as $table_alias => $table){
1969
-			if($table instanceof EE_Secondary_Table){
1966
+	protected function _get_other_tables() {
1967
+		$other_tables = array();
1968
+		foreach ($this->_tables as $table_alias => $table) {
1969
+			if ($table instanceof EE_Secondary_Table) {
1970 1970
 				$other_tables[$table_alias] = $table;
1971 1971
 			}
1972 1972
 		}
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 	 * @param string $table_alias, array key in EEM_Base::_tables
1979 1979
 	 * @return EE_Model_Field_Base[]
1980 1980
 	 */
1981
-	function _get_fields_for_table($table_alias){
1981
+	function _get_fields_for_table($table_alias) {
1982 1982
 		return $this->_fields[$table_alias];
1983 1983
 	}
1984 1984
 
@@ -1990,29 +1990,29 @@  discard block
 block discarded – undo
1990 1990
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
1991 1991
 	 * @return EE_Model_Query_Info_Carrier
1992 1992
 	 */
1993
-	function _extract_related_models_from_query($query_params){
1993
+	function _extract_related_models_from_query($query_params) {
1994 1994
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
1995
-		if(array_key_exists(0,$query_params)){
1996
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
1995
+		if (array_key_exists(0, $query_params)) {
1996
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
1997 1997
 		}
1998
-		if(array_key_exists('group_by', $query_params)){
1999
-			if(is_array($query_params['group_by'])){
2000
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2001
-			}elseif( ! empty ( $query_params['group_by'] )){
2002
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
1998
+		if (array_key_exists('group_by', $query_params)) {
1999
+			if (is_array($query_params['group_by'])) {
2000
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2001
+			}elseif ( ! empty ($query_params['group_by'])) {
2002
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2003 2003
 			}
2004 2004
 		}
2005
-		if(array_key_exists('having',$query_params)){
2006
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2005
+		if (array_key_exists('having', $query_params)) {
2006
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2007 2007
 		}
2008
-		if(array_key_exists('order_by', $query_params)){
2009
-			if ( is_array( $query_params['order_by'] ) )
2010
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2011
-			elseif( ! empty( $query_params['order_by'] ))
2012
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2008
+		if (array_key_exists('order_by', $query_params)) {
2009
+			if (is_array($query_params['order_by']))
2010
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2011
+			elseif ( ! empty($query_params['order_by']))
2012
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2013 2013
 		}
2014
-		if(array_key_exists('force_join', $query_params)){
2015
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2014
+		if (array_key_exists('force_join', $query_params)) {
2015
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2016 2016
 		}
2017 2017
 		return $query_info_carrier;
2018 2018
 	}
@@ -2025,34 +2025,34 @@  discard block
 block discarded – undo
2025 2025
 	 * @throws EE_Error
2026 2026
 	 * @return \EE_Model_Query_Info_Carrier
2027 2027
 	 */
2028
-	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){
2029
-		if (!empty($sub_query_params)){
2028
+	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) {
2029
+		if ( ! empty($sub_query_params)) {
2030 2030
 			$sub_query_params = (array) $sub_query_params;
2031
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2031
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2032 2032
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2033
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2033
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2034 2034
 
2035 2035
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2036 2036
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2037 2037
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2038 2038
 				//of array('Registration.TXN_ID'=>23)
2039 2039
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2040
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2041
-					if (! is_array($possibly_array_of_params)){
2040
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2041
+					if ( ! is_array($possibly_array_of_params)) {
2042 2042
 						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"),
2043
-							$param,$possibly_array_of_params));
2044
-					}else{
2045
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2043
+							$param, $possibly_array_of_params));
2044
+					} else {
2045
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2046 2046
 					}
2047
-				}elseif($query_param_type === 0 //ie WHERE
2047
+				}elseif ($query_param_type === 0 //ie WHERE
2048 2048
 						&& is_array($possibly_array_of_params)
2049 2049
 						&& isset($possibly_array_of_params[2])
2050
-						&& $possibly_array_of_params[2] == true){
2050
+						&& $possibly_array_of_params[2] == true) {
2051 2051
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2052 2052
 					//indicating that $possible_array_of_params[1] is actually a field name,
2053 2053
 					//from which we should extract query parameters!
2054
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2055
-						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)));
2054
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2055
+						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)));
2056 2056
 					}
2057 2057
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2058 2058
 				}
@@ -2071,14 +2071,14 @@  discard block
 block discarded – undo
2071 2071
 	 * @throws EE_Error
2072 2072
 	 * @return \EE_Model_Query_Info_Carrier
2073 2073
 	 */
2074
-	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){
2075
-		if (!empty($sub_query_params)){
2076
-			if(!is_array($sub_query_params)){
2077
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2074
+	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) {
2075
+		if ( ! empty($sub_query_params)) {
2076
+			if ( ! is_array($sub_query_params)) {
2077
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2078 2078
 			}
2079
-			foreach($sub_query_params as $param){
2079
+			foreach ($sub_query_params as $param) {
2080 2080
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2081
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2081
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2082 2082
 			}
2083 2083
 		}
2084 2084
 		return $model_query_info_carrier;
@@ -2097,75 +2097,75 @@  discard block
 block discarded – undo
2097 2097
 	 * @throws EE_Error
2098 2098
 	 * @return EE_Model_Query_Info_Carrier
2099 2099
 	 */
2100
-	function _create_model_query_info_carrier($query_params){
2101
-		if( ! is_array( $query_params ) ){
2102
-			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' );
2100
+	function _create_model_query_info_carrier($query_params) {
2101
+		if ( ! is_array($query_params)) {
2102
+			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');
2103 2103
 			$query_params = array();
2104 2104
 		}
2105 2105
 		$query_object = $this->_extract_related_models_from_query($query_params);
2106
-		if(array_key_exists(0,$query_params)){
2106
+		if (array_key_exists(0, $query_params)) {
2107 2107
 			$where_query_params = $query_params[0];
2108
-		}else{
2108
+		} else {
2109 2109
 			$where_query_params = array();
2110 2110
 		}
2111 2111
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2112
-		foreach($where_query_params as $key => $value){
2113
-			if(is_int($key)){
2114
-				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. Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, $value,get_class($this)));
2112
+		foreach ($where_query_params as $key => $value) {
2113
+			if (is_int($key)) {
2114
+				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. Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, $value, get_class($this)));
2115 2115
 			}
2116 2116
 		}
2117
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2117
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2118 2118
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2119
-		}else{
2119
+		} else {
2120 2120
 			$use_default_where_conditions = 'all';
2121 2121
 		}
2122
-		$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 );
2123
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2122
+		$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);
2123
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2124 2124
 
2125 2125
 
2126 2126
 		//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:
2127 2127
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2128
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2129
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2128
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2129
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2130 2130
 		}
2131 2131
 
2132 2132
 
2133 2133
 		//set limit
2134
-		if(array_key_exists('limit',$query_params)){
2135
-			if(is_array($query_params['limit'])){
2136
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2137
-					$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']));
2134
+		if (array_key_exists('limit', $query_params)) {
2135
+			if (is_array($query_params['limit'])) {
2136
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2137
+					$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']));
2138 2138
 					throw new EE_Error($e."|".$e);
2139 2139
 				}
2140 2140
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2141 2141
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2142
-			}elseif( ! empty ( $query_params['limit'] )){
2142
+			}elseif ( ! empty ($query_params['limit'])) {
2143 2143
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2144 2144
 			}
2145 2145
 		}
2146 2146
 		//set order by
2147
-		if(array_key_exists('order_by',$query_params)){
2148
-			if(is_array($query_params['order_by'])){
2147
+		if (array_key_exists('order_by', $query_params)) {
2148
+			if (is_array($query_params['order_by'])) {
2149 2149
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2150 2150
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2151 2151
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2152
-				if(array_key_exists('order', $query_params)){
2152
+				if (array_key_exists('order', $query_params)) {
2153 2153
 					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"),
2154
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2154
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2155 2155
 				}
2156
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2156
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2157 2157
 				//assume it's an array of fields to order by
2158 2158
 				$order_array = array();
2159
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2159
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2160 2160
 					$order = $this->_extract_order($order);
2161 2161
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2162 2162
 				}
2163
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2164
-			}elseif( ! empty ( $query_params['order_by'] )){
2165
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2166
-				if(isset($query_params['order'])){
2163
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2164
+			}elseif ( ! empty ($query_params['order_by'])) {
2165
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2166
+				if (isset($query_params['order'])) {
2167 2167
 					$order = $this->_extract_order($query_params['order']);
2168
-				}else{
2168
+				} else {
2169 2169
 					$order = 'DESC';
2170 2170
 				}
2171 2171
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2173,46 +2173,46 @@  discard block
 block discarded – undo
2173 2173
 		}
2174 2174
 
2175 2175
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2176
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2176
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2177 2177
 			$pk_field = $this->get_primary_key_field();
2178 2178
 			$order = $this->_extract_order($query_params['order']);
2179 2179
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2180 2180
 		}
2181 2181
 
2182 2182
 		//set group by
2183
-		if(array_key_exists('group_by',$query_params)){
2184
-			if(is_array($query_params['group_by'])){
2183
+		if (array_key_exists('group_by', $query_params)) {
2184
+			if (is_array($query_params['group_by'])) {
2185 2185
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2186 2186
 				$group_by_array = array();
2187
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2187
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2188 2188
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2189 2189
 				}
2190
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2191
-			}elseif( ! empty ( $query_params['group_by'] )){
2190
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2191
+			}elseif ( ! empty ($query_params['group_by'])) {
2192 2192
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2193 2193
 			}
2194 2194
 		}
2195 2195
 		//set having
2196
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2197
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2196
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2197
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2198 2198
 		}
2199 2199
 
2200 2200
 		//now, just verify they didn't pass anything wack
2201
-		foreach($query_params as $query_key => $query_value){
2202
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2201
+		foreach ($query_params as $query_key => $query_value) {
2202
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2203 2203
 				throw new EE_Error(
2204 2204
 					sprintf(
2205
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2205
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2206 2206
 						$query_key,
2207 2207
 						get_class($this),
2208 2208
 //						print_r( $this->_allowed_query_params, TRUE )
2209
-						implode( ',', $this->_allowed_query_params )
2209
+						implode(',', $this->_allowed_query_params)
2210 2210
 					)
2211 2211
 				);
2212 2212
 			}
2213 2213
 		}
2214 2214
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2215
-		if ( empty( $main_model_join_sql ) )
2215
+		if (empty($main_model_join_sql))
2216 2216
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2217 2217
 		return $query_object;
2218 2218
 	}
@@ -2226,11 +2226,11 @@  discard block
 block discarded – undo
2226 2226
 	 * @return string either ASC, asc, DESC or desc
2227 2227
 	 * @throws EE_Error
2228 2228
 	 */
2229
-	private function _extract_order($should_be_order_string){
2230
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2229
+	private function _extract_order($should_be_order_string) {
2230
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2231 2231
 			return $should_be_order_string;
2232
-		}else{
2233
-			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));
2232
+		} else {
2233
+			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));
2234 2234
 		}
2235 2235
 	}
2236 2236
 
@@ -2248,19 +2248,19 @@  discard block
 block discarded – undo
2248 2248
 	 * @throws EE_Error
2249 2249
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2250 2250
 	 */
2251
-	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()){
2252
-		$allowed_used_default_where_conditions_values = array('all','this_model_only', 'other_models_only','none');
2253
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2254
-			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)));
2251
+	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()) {
2252
+		$allowed_used_default_where_conditions_values = array('all', 'this_model_only', 'other_models_only', 'none');
2253
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2254
+			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)));
2255 2255
 		}
2256
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2256
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2257 2257
 			$universal_query_params = $this->_get_default_where_conditions();
2258
-		}else{
2258
+		} else {
2259 2259
 			$universal_query_params = array();
2260 2260
 		}
2261 2261
 
2262
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2263
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2262
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2263
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2264 2264
 				$related_model = $this->get_related_model_obj($model_name);
2265 2265
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2266 2266
 
@@ -2287,22 +2287,22 @@  discard block
 block discarded – undo
2287 2287
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2288 2288
 	 * @return array like EEM_Base::get_all's $query_params[0]
2289 2289
 	 */
2290
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2290
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2291 2291
 		$null_friendly_where_conditions = array();
2292 2292
 		$none_overridden = true;
2293 2293
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2294 2294
 
2295
-		foreach($default_where_conditions as $key => $val){
2296
-			if( isset($provided_where_conditions[$key])){
2295
+		foreach ($default_where_conditions as $key => $val) {
2296
+			if (isset($provided_where_conditions[$key])) {
2297 2297
 				$none_overridden = false;
2298
-			}else{
2298
+			} else {
2299 2299
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2300 2300
 			}
2301 2301
 		}
2302
-		if( $none_overridden && $default_where_conditions){
2303
-			if($model->has_primary_key_field()){
2302
+		if ($none_overridden && $default_where_conditions) {
2303
+			if ($model->has_primary_key_field()) {
2304 2304
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2305
-			}else{
2305
+			} else {
2306 2306
 				//@todo NO PK, use other defaults
2307 2307
 			}
2308 2308
 		}
@@ -2317,8 +2317,8 @@  discard block
 block discarded – undo
2317 2317
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2318 2318
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2319 2319
 	 */
2320
-	private function _get_default_where_conditions($model_relation_path = null){
2321
-		if ( $this->_ignore_where_strategy )
2320
+	private function _get_default_where_conditions($model_relation_path = null) {
2321
+		if ($this->_ignore_where_strategy)
2322 2322
 			return array();
2323 2323
 
2324 2324
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2329,13 +2329,13 @@  discard block
 block discarded – undo
2329 2329
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2330 2330
 	 * @return string
2331 2331
 	 */
2332
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2332
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2333 2333
 		$selects = $this->_get_columns_to_select_for_this_model();
2334
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2334
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2335 2335
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2336 2336
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2337 2337
 		}
2338
-		return implode(", ",$selects);
2338
+		return implode(", ", $selects);
2339 2339
 	}
2340 2340
 
2341 2341
 	/**
@@ -2344,19 +2344,19 @@  discard block
 block discarded – undo
2344 2344
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2345 2345
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2346 2346
 	 */
2347
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2347
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2348 2348
 		$fields = $this->field_settings();
2349 2349
 		$selects = array();
2350 2350
 		$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());
2351
-		foreach($fields as $field_obj){
2352
-			$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()."'";
2351
+		foreach ($fields as $field_obj) {
2352
+			$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()."'";
2353 2353
 		}
2354 2354
 		//make sure we are also getting the PKs of each table
2355 2355
 		$tables = $this->get_tables();
2356
-		if(count($tables) > 1){
2357
-			foreach($tables as $table_obj){
2358
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2359
-				if( ! in_array($qualified_pk_column,$selects)){
2356
+		if (count($tables) > 1) {
2357
+			foreach ($tables as $table_obj) {
2358
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2359
+				if ( ! in_array($qualified_pk_column, $selects)) {
2360 2360
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2361 2361
 				}
2362 2362
 			}
@@ -2380,65 +2380,65 @@  discard block
 block discarded – undo
2380 2380
 	 * @throws EE_Error
2381 2381
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2382 2382
 	 */
2383
-	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 ){
2384
-		if($original_query_param == NULL){
2383
+	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) {
2384
+		if ($original_query_param == NULL) {
2385 2385
 			$original_query_param = $query_param;
2386 2386
 		}
2387 2387
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2388 2388
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2389
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2390
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2389
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2390
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2391 2391
 		//check to see if we have a field on this model
2392 2392
 		$this_model_fields = $this->field_settings(true);
2393
-		if(array_key_exists($query_param,$this_model_fields)){
2394
-			if($allow_fields){
2393
+		if (array_key_exists($query_param, $this_model_fields)) {
2394
+			if ($allow_fields) {
2395 2395
 				return;
2396
-			}else{
2396
+			} else {
2397 2397
 				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"),
2398
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2398
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2399 2399
 			}
2400 2400
 		}
2401 2401
 		//check if this is a special logic query param
2402
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2403
-			if($allow_logic_query_params){
2402
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2403
+			if ($allow_logic_query_params) {
2404 2404
 				return;
2405
-			}else{
2405
+			} else {
2406 2406
 				throw new EE_Error(
2407 2407
 					sprintf(
2408
-						__( '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' ),
2409
-						implode( '", "', $this->_logic_query_param_keys ),
2410
-						$query_param ,
2411
-						get_class( $this ),
2408
+						__('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'),
2409
+						implode('", "', $this->_logic_query_param_keys),
2410
+						$query_param,
2411
+						get_class($this),
2412 2412
 						'<br />',
2413
-						"\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
2413
+						"\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
2414 2414
 					)
2415 2415
 				);
2416 2416
 			}
2417 2417
 		}
2418 2418
 		//check if it's a custom selection
2419
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2419
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2420 2420
 			return;
2421 2421
 		}
2422 2422
 
2423 2423
 		//check if has a model name at the beginning
2424 2424
 		//and
2425 2425
 		//check if it's a field on a related model
2426
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2427
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2428
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2426
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2427
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2428
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2429 2429
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2430
-				if($query_param == ''){
2430
+				if ($query_param == '') {
2431 2431
 					//nothing left to $query_param
2432 2432
 					//we should actually end in a field name, not a model like this!
2433 2433
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2434
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2435
-				}else{
2434
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2435
+				} else {
2436 2436
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2437 2437
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2438 2438
 					return;
2439 2439
 				}
2440
-			}elseif($query_param == $valid_related_model_name){
2441
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2440
+			}elseif ($query_param == $valid_related_model_name) {
2441
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2442 2442
 				return;
2443 2443
 			}
2444 2444
 		}
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 		//and we previously confirmed it wasn't a logic query param or field on the current model
2449 2449
 		//it's wack, that's what it is
2450 2450
 		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"),
2451
-				$query_param,get_class($this),$query_param_type,$original_query_param));
2451
+				$query_param, get_class($this), $query_param_type, $original_query_param));
2452 2452
 
2453 2453
 	}
2454 2454
 
@@ -2465,26 +2465,26 @@  discard block
 block discarded – undo
2465 2465
 	 * 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)
2466 2466
 	 * @return void
2467 2467
 	 */
2468
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
2468
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
2469 2469
 		$relation_obj = $this->related_settings_for($model_name);
2470 2470
 
2471 2471
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
2472 2472
 		//check if the relation is HABTM, because then we're essentially doing two joins
2473 2473
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
2474
-		if($relation_obj instanceof EE_HABTM_Relation){
2474
+		if ($relation_obj instanceof EE_HABTM_Relation) {
2475 2475
 			$join_model_obj = $relation_obj->get_join_model();
2476 2476
 			//replace the model specified with the join model for this relation chain, whi
2477 2477
 			$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);
2478 2478
 			$new_query_info = new EE_Model_Query_Info_Carrier(
2479 2479
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
2480 2480
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
2481
-			$passed_in_query_info->merge( $new_query_info  );
2481
+			$passed_in_query_info->merge($new_query_info);
2482 2482
 		}
2483 2483
 		//now just join to the other table pointed to by the relation object, and add its data types
2484 2484
 		$new_query_info = new EE_Model_Query_Info_Carrier(
2485 2485
 				array($model_relation_chain=>$model_name),
2486 2486
 				$relation_obj->get_join_statement($model_relation_chain));
2487
-		$passed_in_query_info->merge( $new_query_info  );
2487
+		$passed_in_query_info->merge($new_query_info);
2488 2488
 	}
2489 2489
 
2490 2490
 
@@ -2493,11 +2493,11 @@  discard block
 block discarded – undo
2493 2493
 	 * @param array $where_params like EEM_Base::get_all
2494 2494
 	 * @return string of SQL
2495 2495
 	 */
2496
-	private function _construct_where_clause($where_params){
2496
+	private function _construct_where_clause($where_params) {
2497 2497
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2498
-		if($SQL){
2499
-			return " WHERE ". $SQL;
2500
-		}else{
2498
+		if ($SQL) {
2499
+			return " WHERE ".$SQL;
2500
+		} else {
2501 2501
 			return '';
2502 2502
 		}
2503 2503
 	}
@@ -2508,11 +2508,11 @@  discard block
 block discarded – undo
2508 2508
 	 * @param array $having_params
2509 2509
 	 * @return string
2510 2510
 	 */
2511
-	private function _construct_having_clause($having_params){
2511
+	private function _construct_having_clause($having_params) {
2512 2512
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2513
-		if($SQL){
2514
-			return " HAVING ". $SQL;
2515
-		}else{
2513
+		if ($SQL) {
2514
+			return " HAVING ".$SQL;
2515
+		} else {
2516 2516
 			return '';
2517 2517
 		}
2518 2518
 
@@ -2526,17 +2526,17 @@  discard block
 block discarded – undo
2526 2526
 	 * @return EE_Model_Field_Base
2527 2527
 	 * @throws EE_Error
2528 2528
 	 */
2529
-	protected function _get_field_on_model($field_name,$model_name){
2529
+	protected function _get_field_on_model($field_name, $model_name) {
2530 2530
 		$model_class = 'EEM_'.$model_name;
2531 2531
 		$model_filepath = $model_class.".model.php";
2532
-		EE_Registry::instance()->load_helper( 'File' );
2533
-		if ( is_readable($model_filepath)){
2532
+		EE_Registry::instance()->load_helper('File');
2533
+		if (is_readable($model_filepath)) {
2534 2534
 			require_once($model_filepath);
2535
-			$model_instance=call_user_func($model_name."::instance");
2535
+			$model_instance = call_user_func($model_name."::instance");
2536 2536
 			/* @var $model_instance EEM_Base */
2537 2537
 			return $model_instance->field_settings_for($field_name);
2538
-		}else{
2539
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2538
+		} else {
2539
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
2540 2540
 		}
2541 2541
 	}
2542 2542
 
@@ -2549,43 +2549,43 @@  discard block
 block discarded – undo
2549 2549
 	 * @throws EE_Error
2550 2550
 	 * @return string of SQL
2551 2551
 	 */
2552
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
2553
-		$where_clauses=array();
2554
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
2555
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
2556
-			if(in_array($query_param,$this->_logic_query_param_keys)){
2557
-				switch($query_param){
2552
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
2553
+		$where_clauses = array();
2554
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
2555
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
2556
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
2557
+				switch ($query_param) {
2558 2558
 					case 'not':
2559 2559
 					case 'NOT':
2560
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2560
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2561 2561
 						break;
2562 2562
 					case 'and':
2563 2563
 					case 'AND':
2564
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
2564
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
2565 2565
 						break;
2566 2566
 					case 'or':
2567 2567
 					case 'OR':
2568
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2568
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
2569 2569
 						break;
2570 2570
 				}
2571
-			}else{
2571
+			} else {
2572 2572
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2573 2573
 
2574 2574
 				//if it's not a normal field, maybe it's a custom selection?
2575
-				if( ! $field_obj){
2576
-					if(isset( $this->_custom_selections[$query_param][1])){
2575
+				if ( ! $field_obj) {
2576
+					if (isset($this->_custom_selections[$query_param][1])) {
2577 2577
 						$field_obj = $this->_custom_selections[$query_param][1];
2578
-					}else{
2579
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2578
+					} else {
2579
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
2580 2580
 					}
2581 2581
 				}
2582 2582
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
2583
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2583
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2584 2584
 			}
2585 2585
 		}
2586
-		if($where_clauses){
2587
-			$SQL = implode($glue,$where_clauses);
2588
-		}else{
2586
+		if ($where_clauses) {
2587
+			$SQL = implode($glue, $where_clauses);
2588
+		} else {
2589 2589
 			$SQL = '';
2590 2590
 		}
2591 2591
 		return $SQL;
@@ -2599,18 +2599,18 @@  discard block
 block discarded – undo
2599 2599
 	 * @throws EE_Error
2600 2600
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
2601 2601
 	 */
2602
-	private function _deduce_column_name_from_query_param($query_param){
2602
+	private function _deduce_column_name_from_query_param($query_param) {
2603 2603
 		$field = $this->_deduce_field_from_query_param($query_param);
2604 2604
 
2605
-		if( $field ){
2606
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2607
-			return $table_alias_prefix . $field->get_qualified_column();
2608
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2605
+		if ($field) {
2606
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
2607
+			return $table_alias_prefix.$field->get_qualified_column();
2608
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
2609 2609
 			//maybe it's custom selection item?
2610 2610
 			//if so, just use it as the "column name"
2611 2611
 			return $query_param;
2612
-		}else{
2613
-			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)));
2612
+		} else {
2613
+			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)));
2614 2614
 		}
2615 2615
 	}
2616 2616
 
@@ -2622,11 +2622,11 @@  discard block
 block discarded – undo
2622 2622
 	 * @param string $condition_query_param_key
2623 2623
 	 * @return string
2624 2624
 	 */
2625
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
2625
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
2626 2626
 		$pos_of_star = strpos($condition_query_param_key, '*');
2627
-		if($pos_of_star === FALSE){
2627
+		if ($pos_of_star === FALSE) {
2628 2628
 			return $condition_query_param_key;
2629
-		}else{
2629
+		} else {
2630 2630
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2631 2631
 			return $condition_query_param_sans_star;
2632 2632
 		}
@@ -2641,54 +2641,54 @@  discard block
 block discarded – undo
2641 2641
 	 * @throws EE_Error
2642 2642
 	 * @return string
2643 2643
 	 */
2644
-	private function _construct_op_and_value($op_and_value, $field_obj){
2645
-		if(is_array( $op_and_value )){
2644
+	private function _construct_op_and_value($op_and_value, $field_obj) {
2645
+		if (is_array($op_and_value)) {
2646 2646
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
2647
-			if( ! $operator){
2647
+			if ( ! $operator) {
2648 2648
 				$php_array_like_string = array();
2649
-				foreach($op_and_value as $key => $value){
2649
+				foreach ($op_and_value as $key => $value) {
2650 2650
 					$php_array_like_string[] = "$key=>$value";
2651 2651
 				}
2652
-				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)));
2652
+				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)));
2653 2653
 			}
2654 2654
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2655
-		}else{
2655
+		} else {
2656 2656
 			$operator = '=';
2657 2657
 			$value = $op_and_value;
2658 2658
 		}
2659 2659
 
2660 2660
 		//check to see if the value is actually another field
2661
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2661
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
2662 2662
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2663
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2663
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
2664 2664
 			//in this case, the value should be an array, or at least a comma-separated list
2665 2665
 			//it will need to handle a little differently
2666 2666
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
2667 2667
 			//note: $cleaned_value has already been run through $wpdb->prepare()
2668 2668
 			return $operator.SP.$cleaned_value;
2669
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2669
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
2670 2670
 			//the value should be an array with count of two.
2671
-			if ( count($value) !== 2 )
2672
-				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" ) );
2673
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2671
+			if (count($value) !== 2)
2672
+				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"));
2673
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
2674 2674
 			return $operator.SP.$cleaned_value;
2675
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
2676
-			if($value != NULL){
2677
-				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));
2675
+		} elseif (in_array($operator, $this->_null_style_operators)) {
2676
+			if ($value != NULL) {
2677
+				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));
2678 2678
 			}
2679 2679
 			return $operator;
2680
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
2680
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
2681 2681
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
2682 2682
 			//remove other junk. So just treat it as a string.
2683 2683
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
2684
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2685
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
2686
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2687
-			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));
2688
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2689
-			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));
2690
-		}else{
2691
-			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)));
2684
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2685
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
2686
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2687
+			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));
2688
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
2689
+			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));
2690
+		} else {
2691
+			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)));
2692 2692
 		}
2693 2693
 	}
2694 2694
 
@@ -2700,12 +2700,12 @@  discard block
 block discarded – undo
2700 2700
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
2701 2701
 	 * @return string
2702 2702
 	 */
2703
-	function _construct_between_value( $values, $field_obj ) {
2703
+	function _construct_between_value($values, $field_obj) {
2704 2704
 		$cleaned_values = array();
2705
-		foreach ( $values as $value ) {
2706
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2705
+		foreach ($values as $value) {
2706
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2707 2707
 		}
2708
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
2708
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
2709 2709
 	}
2710 2710
 
2711 2711
 
@@ -2721,26 +2721,26 @@  discard block
 block discarded – undo
2721 2721
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
2722 2722
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
2723 2723
 	 */
2724
-	function _construct_in_value($values,  $field_obj){
2724
+	function _construct_in_value($values, $field_obj) {
2725 2725
 		//check if the value is a CSV list
2726
-		if(is_string($values)){
2726
+		if (is_string($values)) {
2727 2727
 			//in which case, turn it into an array
2728
-			$values = explode(",",$values);
2728
+			$values = explode(",", $values);
2729 2729
 		}
2730 2730
 		$cleaned_values = array();
2731
-		foreach($values as $value){
2732
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2731
+		foreach ($values as $value) {
2732
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2733 2733
 		}
2734 2734
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
2735 2735
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
2736 2736
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
2737
-		if(empty($cleaned_values)){
2737
+		if (empty($cleaned_values)) {
2738 2738
 			$all_fields = $this->field_settings();
2739 2739
 			$a_field = array_shift($all_fields);
2740 2740
 			$main_table = $this->_get_main_table();
2741 2741
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
2742 2742
 		}
2743
-		return "(".implode(",",$cleaned_values).")";
2743
+		return "(".implode(",", $cleaned_values).")";
2744 2744
 	}
2745 2745
 
2746 2746
 
@@ -2752,15 +2752,15 @@  discard block
 block discarded – undo
2752 2752
 	 * @throws EE_Error
2753 2753
 	 * @return false|null|string
2754 2754
 	 */
2755
-	private function _wpdb_prepare_using_field($value,$field_obj){
2755
+	private function _wpdb_prepare_using_field($value, $field_obj) {
2756 2756
 		global $wpdb;
2757
-		if($field_obj instanceof EE_Model_Field_Base){
2758
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
2759
-		}else{//$field_obj should really just be a data type
2760
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
2761
-				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)));
2757
+		if ($field_obj instanceof EE_Model_Field_Base) {
2758
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
2759
+		} else {//$field_obj should really just be a data type
2760
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
2761
+				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)));
2762 2762
 			}
2763
-			return $wpdb->prepare($field_obj,$value);
2763
+			return $wpdb->prepare($field_obj, $value);
2764 2764
 		}
2765 2765
 	}
2766 2766
 
@@ -2772,27 +2772,27 @@  discard block
 block discarded – undo
2772 2772
 	 * @throws EE_Error
2773 2773
 	 * @return EE_Model_Field_Base
2774 2774
 	 */
2775
-	protected function _deduce_field_from_query_param($query_param_name){
2775
+	protected function _deduce_field_from_query_param($query_param_name) {
2776 2776
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
2777 2777
 		//which will help us find the database table and column
2778 2778
 
2779
-		$query_param_parts = explode(".",$query_param_name);
2780
-		if(empty($query_param_parts)){
2781
-			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));
2779
+		$query_param_parts = explode(".", $query_param_name);
2780
+		if (empty($query_param_parts)) {
2781
+			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));
2782 2782
 		}
2783 2783
 		$number_of_parts = count($query_param_parts);
2784
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
2785
-		if($number_of_parts == 1){
2784
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
2785
+		if ($number_of_parts == 1) {
2786 2786
 			$field_name = $last_query_param_part;
2787 2787
 			$model_obj = $this;
2788
-		}else{// $number_of_parts >= 2
2788
+		} else {// $number_of_parts >= 2
2789 2789
 			//the last part is the column name, and there are only 2parts. therefore...
2790 2790
 			$field_name = $last_query_param_part;
2791
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
2791
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
2792 2792
 		}
2793
-		try{
2793
+		try {
2794 2794
 			return $model_obj->field_settings_for($field_name);
2795
-		}catch(EE_Error $e){
2795
+		} catch (EE_Error $e) {
2796 2796
 			return null;
2797 2797
 		}
2798 2798
 	}
@@ -2806,13 +2806,13 @@  discard block
 block discarded – undo
2806 2806
 	 * @throws EE_Error
2807 2807
 	 * @return string
2808 2808
 	 */
2809
-	function _get_qualified_column_for_field($field_name){
2809
+	function _get_qualified_column_for_field($field_name) {
2810 2810
 		$all_fields = $this->field_settings();
2811 2811
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
2812
-		if($field){
2812
+		if ($field) {
2813 2813
 			return $field->get_qualified_column();
2814
-		}else{
2815
-			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)));
2814
+		} else {
2815
+			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)));
2816 2816
 		}
2817 2817
 	}
2818 2818
 
@@ -2826,14 +2826,14 @@  discard block
 block discarded – undo
2826 2826
 	 * @param  mixed|string $limit The limit for this select
2827 2827
 	 * @return string 				The final select join element for the query.
2828 2828
 	 */
2829
-	function _construct_limit_join_select( $table_alias, $limit ) {
2829
+	function _construct_limit_join_select($table_alias, $limit) {
2830 2830
 		$SQL = '';
2831 2831
 
2832
-		foreach ( $this->_tables as $table_obj ) {
2833
-			if ( $table_obj instanceof EE_Primary_Table ) {
2834
-				$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;
2835
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
2836
-				$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;
2832
+		foreach ($this->_tables as $table_obj) {
2833
+			if ($table_obj instanceof EE_Primary_Table) {
2834
+				$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;
2835
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
2836
+				$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;
2837 2837
 			}
2838 2838
 		}
2839 2839
 		return $SQL;
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
2847 2847
 	 * @return string SQL
2848 2848
 	 */
2849
-	function _construct_internal_join(){
2849
+	function _construct_internal_join() {
2850 2850
 		$SQL = $this->_get_main_table()->get_table_sql();
2851 2851
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
2852 2852
 		return $SQL;
@@ -2867,17 +2867,17 @@  discard block
 block discarded – undo
2867 2867
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
2868 2868
 	 * @return string
2869 2869
 	 */
2870
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
2870
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
2871 2871
 		$SQL = '';
2872 2872
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
2873
-		foreach($this->_tables as $table_obj){
2874
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
2875
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
2873
+		foreach ($this->_tables as $table_obj) {
2874
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
2875
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
2876 2876
 					//so we're joining to this table, meaning the table is already in
2877 2877
 					//the FROM statement, BUT the primary table isn't. So we want
2878 2878
 					//to add the inverse join sql
2879 2879
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
2880
-				}else{
2880
+				} else {
2881 2881
 					//just add a regular JOIN to this table from the primary table
2882 2882
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
2883 2883
 				}
@@ -2891,9 +2891,9 @@  discard block
 block discarded – undo
2891 2891
 	 * 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)
2892 2892
 	 * @return array
2893 2893
 	 */
2894
-	function _get_data_types(){
2894
+	function _get_data_types() {
2895 2895
 		$data_types = array();
2896
-		foreach(array_values($this->field_settings()) as $field_obj){
2896
+		foreach (array_values($this->field_settings()) as $field_obj) {
2897 2897
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
2898 2898
 			/** @var $field_obj EE_Model_Field_Base */
2899 2899
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -2909,11 +2909,11 @@  discard block
 block discarded – undo
2909 2909
 	 * @throws EE_Error
2910 2910
 	 * @return EEM_Base
2911 2911
 	 */
2912
-	function get_related_model_obj($model_name){
2912
+	function get_related_model_obj($model_name) {
2913 2913
 
2914 2914
 		$model_classname = "EEM_".$model_name;
2915
-		if(!class_exists($model_classname)){
2916
-			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));
2915
+		if ( ! class_exists($model_classname)) {
2916
+			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));
2917 2917
 		}
2918 2918
 		$model_obj = call_user_func($model_classname."::instance");
2919 2919
 		return $model_obj;
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
 	 * Returns the array of EE_ModelRelations for this model.
2925 2925
 	 * @return EE_Model_Relation_Base[]
2926 2926
 	 */
2927
-	public function relation_settings(){
2927
+	public function relation_settings() {
2928 2928
 		return $this->_model_relations;
2929 2929
 	}
2930 2930
 
@@ -2934,10 +2934,10 @@  discard block
 block discarded – undo
2934 2934
 	 * (Eg, without an event, datetimes have little purpose.)
2935 2935
 	 * @return EE_Belongs_To_Relation[]
2936 2936
 	 */
2937
-	public function belongs_to_relations(){
2937
+	public function belongs_to_relations() {
2938 2938
 		$belongs_to_relations = array();
2939
-		foreach($this->relation_settings() as $model_name => $relation_obj){
2940
-			if($relation_obj instanceof EE_Belongs_To_Relation){
2939
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
2940
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2941 2941
 				$belongs_to_relations[$model_name] = $relation_obj;
2942 2942
 			}
2943 2943
 		}
@@ -2952,15 +2952,15 @@  discard block
 block discarded – undo
2952 2952
 	 * @throws EE_Error
2953 2953
 	 * @return EE_Model_Relation_Base
2954 2954
 	 */
2955
-	public function related_settings_for($relation_name){
2956
-		$relatedModels=$this->relation_settings();
2957
-		if(!array_key_exists($relation_name,$relatedModels)){
2955
+	public function related_settings_for($relation_name) {
2956
+		$relatedModels = $this->relation_settings();
2957
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
2958 2958
 			throw new EE_Error(
2959 2959
 				sprintf(
2960
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
2960
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
2961 2961
 					$relation_name,
2962 2962
 					$this->_get_class_name(),
2963
-					implode( ', ', array_keys( $relatedModels ))
2963
+					implode(', ', array_keys($relatedModels))
2964 2964
 				)
2965 2965
 			);
2966 2966
 		}
@@ -2975,10 +2975,10 @@  discard block
 block discarded – undo
2975 2975
 	 * @throws EE_Error
2976 2976
 	 * @return EE_Model_Field_Base
2977 2977
 	 */
2978
-	public function field_settings_for($fieldName){
2979
-		$fieldSettings=$this->field_settings(true);
2980
-		if( ! array_key_exists($fieldName,$fieldSettings)){
2981
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
2978
+	public function field_settings_for($fieldName) {
2979
+		$fieldSettings = $this->field_settings(true);
2980
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
2981
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
2982 2982
 		}
2983 2983
 		return $fieldSettings[$fieldName];
2984 2984
 	}
@@ -2988,11 +2988,11 @@  discard block
 block discarded – undo
2988 2988
 	 * @param string $fieldName a key in the model's _field_settings array
2989 2989
 	 * @return boolean
2990 2990
 	 */
2991
-	public function has_field($fieldName){
2991
+	public function has_field($fieldName) {
2992 2992
 		$fieldSettings = $this->field_settings(true);
2993
-		if( isset($fieldSettings[$fieldName])){
2993
+		if (isset($fieldSettings[$fieldName])) {
2994 2994
 			return true;
2995
-		}else{
2995
+		} else {
2996 2996
 			return false;
2997 2997
 		}
2998 2998
 	}
@@ -3002,11 +3002,11 @@  discard block
 block discarded – undo
3002 3002
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3003 3003
 	 * @return boolean
3004 3004
 	 */
3005
-	public function has_relation($relation_name){
3005
+	public function has_relation($relation_name) {
3006 3006
 		$relations = $this->relation_settings();
3007
-		if(isset($relations[$relation_name])){
3007
+		if (isset($relations[$relation_name])) {
3008 3008
 			return true;
3009
-		}else{
3009
+		} else {
3010 3010
 			return false;
3011 3011
 		}
3012 3012
 	}
@@ -3018,7 +3018,7 @@  discard block
 block discarded – undo
3018 3018
 	 * @param $field_obj
3019 3019
 	 * @return EE_Model_Field_Base
3020 3020
 	 */
3021
-	public function is_primary_key_field( $field_obj ){
3021
+	public function is_primary_key_field($field_obj) {
3022 3022
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3023 3023
 	}
3024 3024
 
@@ -3030,16 +3030,16 @@  discard block
 block discarded – undo
3030 3030
 	 * @return EE_Model_Field_Base
3031 3031
 	 * @throws EE_Error
3032 3032
 	 */
3033
-	public function get_primary_key_field(){
3034
-		if( $this->_primary_key_field === NULL ){
3035
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3036
-				if( $this->is_primary_key_field( $field_obj )){
3033
+	public function get_primary_key_field() {
3034
+		if ($this->_primary_key_field === NULL) {
3035
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3036
+				if ($this->is_primary_key_field($field_obj)) {
3037 3037
 					$this->_primary_key_field = $field_obj;
3038 3038
 					break;
3039 3039
 				}
3040 3040
 			}
3041
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3042
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3041
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3042
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3043 3043
 			}
3044 3044
 		}
3045 3045
 		return $this->_primary_key_field;
@@ -3052,12 +3052,12 @@  discard block
 block discarded – undo
3052 3052
 	 * Internally does some caching.
3053 3053
 	 * @return boolean
3054 3054
 	 */
3055
-	public function has_primary_key_field(){
3056
-		if($this->_has_primary_key_field === null){
3057
-			try{
3055
+	public function has_primary_key_field() {
3056
+		if ($this->_has_primary_key_field === null) {
3057
+			try {
3058 3058
 				$this->get_primary_key_field();
3059 3059
 				$this->_has_primary_key_field = true;
3060
-			}catch(EE_Error $e){
3060
+			} catch (EE_Error $e) {
3061 3061
 				$this->_has_primary_key_field = false;
3062 3062
 			}
3063 3063
 		}
@@ -3071,9 +3071,9 @@  discard block
 block discarded – undo
3071 3071
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3072 3072
 	 * @return EE_Model_Field_Base or null if none is found
3073 3073
 	 */
3074
-	public function get_a_field_of_type($field_class_name){
3075
-		foreach($this->field_settings() as $field){
3076
-			if( $field instanceof $field_class_name ){
3074
+	public function get_a_field_of_type($field_class_name) {
3075
+		foreach ($this->field_settings() as $field) {
3076
+			if ($field instanceof $field_class_name) {
3077 3077
 				return $field;
3078 3078
 			}
3079 3079
 		}
@@ -3087,21 +3087,21 @@  discard block
 block discarded – undo
3087 3087
 	 * @return EE_Foreign_Key_Field_Base
3088 3088
 	 * @throws EE_Error
3089 3089
 	 */
3090
-	public function get_foreign_key_to($model_name){
3091
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3092
-			foreach($this->field_settings() as $field){
3090
+	public function get_foreign_key_to($model_name) {
3091
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3092
+			foreach ($this->field_settings() as $field) {
3093 3093
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3094
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3095
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3096
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3094
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3095
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3096
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3097 3097
 					}
3098 3098
 				}
3099 3099
 			}
3100
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3101
-				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)));
3100
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3101
+				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)));
3102 3102
 			}
3103 3103
 		}
3104
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3104
+		return $this->_cache_foreign_key_to_fields[$model_name];
3105 3105
 	}
3106 3106
 
3107 3107
 
@@ -3112,7 +3112,7 @@  discard block
 block discarded – undo
3112 3112
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3113 3113
 	 * @return EE_Table_Base
3114 3114
 	 */
3115
-	function get_table_for_alias($table_alias){
3115
+	function get_table_for_alias($table_alias) {
3116 3116
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3117 3117
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3118 3118
 	}
@@ -3125,25 +3125,25 @@  discard block
 block discarded – undo
3125 3125
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3126 3126
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3127 3127
 	 */
3128
-	public function field_settings($include_db_only_fields = false){
3129
-		if( $include_db_only_fields ){
3130
-			if( $this->_cached_fields === NULL ){
3128
+	public function field_settings($include_db_only_fields = false) {
3129
+		if ($include_db_only_fields) {
3130
+			if ($this->_cached_fields === NULL) {
3131 3131
 				$this->_cached_fields = array();
3132
-				foreach($this->_fields as $fields_corresponding_to_table){
3133
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3134
-						$this->_cached_fields[$field_name]=$field_obj;
3132
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3133
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3134
+						$this->_cached_fields[$field_name] = $field_obj;
3135 3135
 					}
3136 3136
 				}
3137 3137
 			}
3138 3138
 			return $this->_cached_fields;
3139
-		}else{
3140
-			if( $this->_cached_fields_non_db_only === NULL ){
3139
+		} else {
3140
+			if ($this->_cached_fields_non_db_only === NULL) {
3141 3141
 				$this->_cached_fields_non_db_only = array();
3142
-				foreach($this->_fields as $fields_corresponding_to_table){
3143
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3142
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3143
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3144 3144
 						/** @var $field_obj EE_Model_Field_Base */
3145
-						if( ! $field_obj->is_db_only_field() ){
3146
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3145
+						if ( ! $field_obj->is_db_only_field()) {
3146
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3147 3147
 						}
3148 3148
 					}
3149 3149
 				}
@@ -3161,40 +3161,40 @@  discard block
 block discarded – undo
3161 3161
 	* 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
3162 3162
 	*		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3163 3163
 	*/
3164
-	protected function _create_objects( $rows = array() ) {
3165
-		$array_of_objects=array();
3166
-		if(empty($rows)){
3164
+	protected function _create_objects($rows = array()) {
3165
+		$array_of_objects = array();
3166
+		if (empty($rows)) {
3167 3167
 			return array();
3168 3168
 		}
3169 3169
 		$count_if_model_has_no_primary_key = 0;
3170
-		foreach ( $rows as $row ) {
3171
-			if(empty($row)){//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3170
+		foreach ($rows as $row) {
3171
+			if (empty($row)) {//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3172 3172
 				return array();
3173 3173
 			}
3174
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3175
-			if( ! $classInstance ) {
3176
-				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 ) ) );
3174
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3175
+			if ( ! $classInstance) {
3176
+				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)));
3177 3177
 			}
3178 3178
 			//set the timezone on the instantiated objects
3179
-			$classInstance->set_timezone( $this->_timezone );
3179
+			$classInstance->set_timezone($this->_timezone);
3180 3180
 			//make sure if there is any timezone setting present that we set the timezone for the object
3181
-			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++]=$classInstance;
3181
+			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++] = $classInstance;
3182 3182
 			//also, for all the relations of type BelongsTo, see if we can cache
3183 3183
 			//those related models
3184 3184
 			//(we could do this for other relations too, but if there are conditions
3185 3185
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3186 3186
 			//so it requires a little more thought than just caching them immediately...)
3187
-			foreach($this->_model_relations as $modelName => $relation_obj){
3188
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3187
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3188
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3189 3189
 					//check if this model's INFO is present. If so, cache it on the model
3190 3190
 					$other_model = $relation_obj->get_other_model();
3191 3191
 
3192 3192
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3193 3193
 
3194 3194
 					//if we managed to make a model object from the results, cache it on the main model object
3195
-					if( $other_model_obj_maybe ){
3195
+					if ($other_model_obj_maybe) {
3196 3196
 						//set timezone on these other model objects if they are present
3197
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3197
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3198 3198
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3199 3199
 					}
3200 3200
 				}
@@ -3215,12 +3215,12 @@  discard block
 block discarded – undo
3215 3215
 
3216 3216
 		$this_model_fields_and_values = array();
3217 3217
 		//setup the row using default values;
3218
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3218
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3219 3219
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3220 3220
 		}
3221 3221
 
3222 3222
 		$className = $this->_get_class_name();
3223
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3223
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3224 3224
 
3225 3225
 		return $classInstance;
3226 3226
 	}
@@ -3231,13 +3231,13 @@  discard block
 block discarded – undo
3231 3231
 	 * _get_cached_acceptable_table_columns
3232 3232
 	 * @return EE_Model_Field_Base[]|null
3233 3233
 	 */
3234
-	private function _get_cached_acceptable_table_columns(){
3235
-		if( $this->_model_fields_sorted_by_db_col === NULL ){
3236
-			foreach( $this->field_settings() as $field_obj ){
3237
-				if( ! $field_obj->is_db_only_field() ){
3238
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_qualified_column() ] = $field_obj;
3234
+	private function _get_cached_acceptable_table_columns() {
3235
+		if ($this->_model_fields_sorted_by_db_col === NULL) {
3236
+			foreach ($this->field_settings() as $field_obj) {
3237
+				if ( ! $field_obj->is_db_only_field()) {
3238
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_qualified_column()] = $field_obj;
3239 3239
 //					$this->_model_fields_sorted_by_db_col[ $field->get_table_column() ] = $field_obj;
3240
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_table_column() ] = $field_obj;
3240
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_table_column()] = $field_obj;
3241 3241
 				}
3242 3242
 			}
3243 3243
 		}
@@ -3250,45 +3250,45 @@  discard block
 block discarded – undo
3250 3250
 	 * or an stdClass where each property is the name of a column,
3251 3251
 	 * @return EE_Base_Class
3252 3252
 	 */
3253
-	public function instantiate_class_from_array_or_object($cols_n_values){
3254
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3255
-			$cols_n_values = get_object_vars( $cols_n_values );
3253
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3254
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3255
+			$cols_n_values = get_object_vars($cols_n_values);
3256 3256
 		}
3257 3257
 		$primary_key = NULL;
3258 3258
 		//make sure the array only has keys that are fields/columns on this model
3259
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3260
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3261
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3259
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3260
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3261
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3262 3262
 		}
3263
-		$className=$this->_get_class_name();
3263
+		$className = $this->_get_class_name();
3264 3264
 
3265 3265
 		//check we actually found results that we can use to build our model object
3266 3266
 		//if not, return null
3267
-		if( $this->has_primary_key_field()){
3268
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3267
+		if ($this->has_primary_key_field()) {
3268
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3269 3269
 				return NULL;
3270 3270
 			}
3271
-		}else if($this->unique_indexes()){
3271
+		} else if ($this->unique_indexes()) {
3272 3272
 			$first_column = reset($this_model_fields_n_values);
3273
-			if(empty($first_column)){
3273
+			if (empty($first_column)) {
3274 3274
 				return NULL;
3275 3275
 			}
3276 3276
 		}
3277 3277
 
3278 3278
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3279
-		if ( $primary_key){
3280
-			$classInstance = $this->get_from_entity_map( $primary_key );
3281
-			if( ! $classInstance) {
3282
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3279
+		if ($primary_key) {
3280
+			$classInstance = $this->get_from_entity_map($primary_key);
3281
+			if ( ! $classInstance) {
3282
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3283 3283
 				// add this new object to the entity map
3284
-				$classInstance = $this->add_to_entity_map( $classInstance );
3284
+				$classInstance = $this->add_to_entity_map($classInstance);
3285 3285
 			}
3286
-		}else{
3287
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3286
+		} else {
3287
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3288 3288
 		}
3289 3289
 
3290 3290
 			//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.
3291
-		$this->set_timezone( $classInstance->get_timezone() );
3291
+		$this->set_timezone($classInstance->get_timezone());
3292 3292
 		return $classInstance;
3293 3293
 	}
3294 3294
 	/**
@@ -3296,8 +3296,8 @@  discard block
 block discarded – undo
3296 3296
 	 * @param int|string $id the ID of the model object
3297 3297
 	 * @return EE_Base_Class
3298 3298
 	 */
3299
-	public function get_from_entity_map( $id ){
3300
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3299
+	public function get_from_entity_map($id) {
3300
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3301 3301
 	}
3302 3302
 
3303 3303
 
@@ -3316,21 +3316,21 @@  discard block
 block discarded – undo
3316 3316
 	 * @throws EE_Error
3317 3317
 	 * @return \EE_Base_Class
3318 3318
 	 */
3319
-	public function add_to_entity_map( EE_Base_Class $object) {
3319
+	public function add_to_entity_map(EE_Base_Class $object) {
3320 3320
 		$className = $this->_get_class_name();
3321
-		if( ! $object instanceof $className ){
3322
-			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 ) );
3321
+		if ( ! $object instanceof $className) {
3322
+			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));
3323 3323
 		}
3324 3324
 		/** @var $object EE_Base_Class */
3325
-		if ( ! $object->ID() ){
3326
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3325
+		if ( ! $object->ID()) {
3326
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3327 3327
 		}
3328 3328
 		// double check it's not already there
3329
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3330
-		if ( $classInstance ) {
3329
+		$classInstance = $this->get_from_entity_map($object->ID());
3330
+		if ($classInstance) {
3331 3331
 			return $classInstance;
3332 3332
 		} else {
3333
-			$this->_entity_map[ $object->ID() ] = $object;
3333
+			$this->_entity_map[$object->ID()] = $object;
3334 3334
 			return $object;
3335 3335
 		}
3336 3336
 	}
@@ -3343,8 +3343,8 @@  discard block
 block discarded – undo
3343 3343
 	 * @param array $cols_n_values
3344 3344
 	 * @return array
3345 3345
 	 */
3346
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3347
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3346
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3347
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3348 3348
 	}
3349 3349
 
3350 3350
 
@@ -3357,38 +3357,38 @@  discard block
 block discarded – undo
3357 3357
 	 * @param string $cols_n_values
3358 3358
 	 * @return array
3359 3359
 	 */
3360
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3360
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3361 3361
 		$this_model_fields_n_values = array();
3362
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3363
-			$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() );
3362
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3363
+			$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());
3364 3364
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3365
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3366
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3367
-					if( ! $field_obj->is_db_only_field() ){
3365
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3366
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3367
+					if ( ! $field_obj->is_db_only_field()) {
3368 3368
 						$this_model_fields_n_values[$field_name] = $field_obj->get_default_value();
3369 3369
 					}
3370 3370
 				}
3371
-			}else{
3371
+			} else {
3372 3372
 				//the table's rows existed. Use their values
3373
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3374
-					if( ! $field_obj->is_db_only_field() )
3375
-					$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() );
3373
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3374
+					if ( ! $field_obj->is_db_only_field())
3375
+					$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());
3376 3376
 				}
3377 3377
 			}
3378 3378
 		}
3379 3379
 		return $this_model_fields_n_values;
3380 3380
 	}
3381 3381
 
3382
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3382
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3383 3383
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3384 3384
 		//does the field on the model relate to this column retrieved from the db?
3385 3385
 		//or is it a db-only field? (not relating to the model)
3386
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3387
-			$value = $cols_n_values[ $qualified_column ];
3386
+		if (isset($cols_n_values[$qualified_column])) {
3387
+			$value = $cols_n_values[$qualified_column];
3388 3388
 
3389
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3390
-			$value = $cols_n_values[ $regular_column ];
3391
-		}else{
3389
+		}elseif (isset($cols_n_values[$regular_column])) {
3390
+			$value = $cols_n_values[$regular_column];
3391
+		} else {
3392 3392
 			$value = NULL;
3393 3393
 		}
3394 3394
 
@@ -3406,23 +3406,23 @@  discard block
 block discarded – undo
3406 3406
 	 * @param int|string $id
3407 3407
 	 * @return EE_Base_Class
3408 3408
 	 */
3409
-	public function refresh_entity_map_from_db( $id ){
3410
-		$obj_in_map = $this->get_from_entity_map( $id );
3411
-		if( $obj_in_map ){
3412
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3413
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3414
-				$one_row = reset( $wpdb_results );
3415
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3416
-					$obj_in_map->set_from_db( $field_name, $db_value );
3409
+	public function refresh_entity_map_from_db($id) {
3410
+		$obj_in_map = $this->get_from_entity_map($id);
3411
+		if ($obj_in_map) {
3412
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3413
+			if ($wpdb_results && is_array($wpdb_results)) {
3414
+				$one_row = reset($wpdb_results);
3415
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3416
+					$obj_in_map->set_from_db($field_name, $db_value);
3417 3417
 				}
3418 3418
 				//clear the cache of related model objects
3419
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3420
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3419
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3420
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3421 3421
 				}
3422 3422
 			}
3423 3423
 			return $obj_in_map;
3424
-		}else{
3425
-			return $this->get_one_by_ID( $id );
3424
+		} else {
3425
+			return $this->get_one_by_ID($id);
3426 3426
 		}
3427 3427
 	}
3428 3428
 
@@ -3440,24 +3440,24 @@  discard block
 block discarded – undo
3440 3440
 	 * @param EE_Base_Class $replacing_model_obj
3441 3441
 	 * @return \EE_Base_Class
3442 3442
 	 */
3443
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
3444
-		$obj_in_map = $this->get_from_entity_map( $id );
3445
-		if( $obj_in_map ){
3446
-			if( $replacing_model_obj instanceof EE_Base_Class ){
3447
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
3448
-					$obj_in_map->set( $field_name, $value );
3443
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
3444
+		$obj_in_map = $this->get_from_entity_map($id);
3445
+		if ($obj_in_map) {
3446
+			if ($replacing_model_obj instanceof EE_Base_Class) {
3447
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
3448
+					$obj_in_map->set($field_name, $value);
3449 3449
 				}
3450 3450
 				//make the model object in the entity map's cache match the $replacing_model_obj
3451
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3452
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3453
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
3454
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
3451
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3452
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3453
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
3454
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
3455 3455
 					}
3456 3456
 				}
3457 3457
 			}
3458 3458
 			return $obj_in_map;
3459
-		}else{
3460
-			$this->add_to_entity_map( $replacing_model_obj );
3459
+		} else {
3460
+			$this->add_to_entity_map($replacing_model_obj);
3461 3461
 			return $replacing_model_obj;
3462 3462
 		}
3463 3463
 	}
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 	 * require_once($this->_getClassName().".class.php");
3471 3471
 	 * @return string
3472 3472
 	 */
3473
-	private function _get_class_name(){
3473
+	private function _get_class_name() {
3474 3474
 		return "EE_".$this->get_this_model_name();
3475 3475
 	}
3476 3476
 
@@ -3483,10 +3483,10 @@  discard block
 block discarded – undo
3483 3483
 	 * @param int $quantity
3484 3484
 	 * @return string
3485 3485
 	 */
3486
-	public function item_name($quantity = 1){
3487
-		if($quantity == 1){
3486
+	public function item_name($quantity = 1) {
3487
+		if ($quantity == 1) {
3488 3488
 			return $this->singular_item;
3489
-		}else{
3489
+		} else {
3490 3490
 			return $this->plural_item;
3491 3491
 		}
3492 3492
 	}
@@ -3515,13 +3515,13 @@  discard block
 block discarded – undo
3515 3515
 	 * @throws EE_Error
3516 3516
 	 * @return mixed whatever the plugin which calls add_filter decides
3517 3517
 	 */
3518
-	public function __call($methodName,$args){
3519
-		$className=get_class($this);
3520
-		$tagName="FHEE__{$className}__{$methodName}";
3521
-		if(!has_filter($tagName)){
3518
+	public function __call($methodName, $args) {
3519
+		$className = get_class($this);
3520
+		$tagName = "FHEE__{$className}__{$methodName}";
3521
+		if ( ! has_filter($tagName)) {
3522 3522
 			throw new EE_Error(
3523 3523
 				sprintf(
3524
-					__( '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' ),
3524
+					__('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'),
3525 3525
 					$methodName,
3526 3526
 					$className,
3527 3527
 					$tagName,
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
 			);
3531 3531
 		}
3532 3532
 
3533
-		return apply_filters($tagName,null,$this,$args);
3533
+		return apply_filters($tagName, null, $this, $args);
3534 3534
 	}
3535 3535
 
3536 3536
 
@@ -3543,22 +3543,22 @@  discard block
 block discarded – undo
3543 3543
 	 * @throws EE_Error
3544 3544
 	 * @return EE_Base_Class
3545 3545
 	 */
3546
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
3546
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
3547 3547
 		$className = $this->_get_class_name();
3548 3548
 		$primary_key_field = $this->get_primary_key_field();
3549
-		if( $base_class_obj_or_id instanceof $className ){
3549
+		if ($base_class_obj_or_id instanceof $className) {
3550 3550
 			$model_object = $base_class_obj_or_id;
3551
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3552
-				is_int( $base_class_obj_or_id ) ||
3553
-				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)
3551
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
3552
+				is_int($base_class_obj_or_id) ||
3553
+				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)
3554 3554
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3555
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3555
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
3556 3556
 			//assume its a string representation of the object
3557 3557
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3558
-		}else{
3559
-			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)));
3558
+		} else {
3559
+			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)));
3560 3560
 		}
3561
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
3561
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
3562 3562
 			$model_object->save();
3563 3563
 		}
3564 3564
 		return $model_object;
@@ -3574,19 +3574,19 @@  discard block
 block discarded – undo
3574 3574
 	 * @return int|string depending on the type of this model object's ID
3575 3575
 	 * @throws EE_Error
3576 3576
 	 */
3577
-	public function ensure_is_ID($base_class_obj_or_id){
3577
+	public function ensure_is_ID($base_class_obj_or_id) {
3578 3578
 		$className = $this->_get_class_name();
3579
-		if( $base_class_obj_or_id instanceof $className ){
3579
+		if ($base_class_obj_or_id instanceof $className) {
3580 3580
 			/** @var $base_class_obj_or_id EE_Base_Class */
3581 3581
 			$id = $base_class_obj_or_id->ID();
3582
-		}elseif(is_int($base_class_obj_or_id)){
3582
+		}elseif (is_int($base_class_obj_or_id)) {
3583 3583
 			//assume it's an ID
3584 3584
 			$id = $base_class_obj_or_id;
3585
-		}elseif(is_string($base_class_obj_or_id)){
3585
+		}elseif (is_string($base_class_obj_or_id)) {
3586 3586
 			//assume its a string representation of the object
3587 3587
 			$id = $base_class_obj_or_id;
3588
-		}else{
3589
-			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)));
3588
+		} else {
3589
+			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)));
3590 3590
 		}
3591 3591
 		return $id;
3592 3592
 	}
@@ -3609,14 +3609,14 @@  discard block
 block discarded – undo
3609 3609
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
3610 3610
 	 * @return void
3611 3611
 	 */
3612
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
3612
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
3613 3613
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
3614 3614
 	}
3615 3615
 	/**
3616 3616
 	 * Read comments for assume_values_already_prepared_by_model_object()
3617 3617
 	 * @return int
3618 3618
 	 */
3619
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
3619
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
3620 3620
 		return $this->_values_already_prepared_by_model_object;
3621 3621
 	}
3622 3622
 
@@ -3624,17 +3624,17 @@  discard block
 block discarded – undo
3624 3624
 	 * Gets all the indexes on this model
3625 3625
 	 * @return EE_Index[]
3626 3626
 	 */
3627
-	public function indexes(){
3627
+	public function indexes() {
3628 3628
 		return $this->_indexes;
3629 3629
 	}
3630 3630
 	/**
3631 3631
 	 * Gets all the Unique Indexes on this model
3632 3632
 	 * @return EE_Unique_Index[]
3633 3633
 	 */
3634
-	public function unique_indexes(){
3634
+	public function unique_indexes() {
3635 3635
 		$unique_indexes = array();
3636
-		foreach($this->_indexes as $name => $index){
3637
-			if($index instanceof EE_Unique_Index){
3636
+		foreach ($this->_indexes as $name => $index) {
3637
+			if ($index instanceof EE_Unique_Index) {
3638 3638
 				$unique_indexes [$name] = $index;
3639 3639
 			}
3640 3640
 		}
@@ -3647,9 +3647,9 @@  discard block
 block discarded – undo
3647 3647
 	 * on a primary index
3648 3648
 	 * @return EE_Model_Field_Base[]
3649 3649
 	 */
3650
-	public function get_combined_primary_key_fields(){
3651
-		foreach($this->indexes() as $index){
3652
-			if($index instanceof EE_Primary_Key_Index){
3650
+	public function get_combined_primary_key_fields() {
3651
+		foreach ($this->indexes() as $index) {
3652
+			if ($index instanceof EE_Primary_Key_Index) {
3653 3653
 				return $index->fields();
3654 3654
 			}
3655 3655
 		}
@@ -3662,7 +3662,7 @@  discard block
 block discarded – undo
3662 3662
 	 * @param array $cols_n_values keys are field names, values are their values
3663 3663
 	 * @return string
3664 3664
 	 */
3665
-	public function get_index_primary_key_string($cols_n_values){
3665
+	public function get_index_primary_key_string($cols_n_values) {
3666 3666
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
3667 3667
 		return http_build_query($cols_n_values_for_primary_key_index);
3668 3668
 	}
@@ -3674,13 +3674,13 @@  discard block
 block discarded – undo
3674 3674
 	 * @param string $index_primary_key_string
3675 3675
 	 * @return null|array
3676 3676
 	 */
3677
-	function parse_index_primary_key_string( $index_primary_key_string) {
3677
+	function parse_index_primary_key_string($index_primary_key_string) {
3678 3678
 		$key_fields = $this->get_combined_primary_key_fields();
3679 3679
 		//check all of them are in the $id
3680 3680
 		$key_vals_in_combined_pk = array();
3681
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
3682
-		foreach( $key_fields as $key_field_name => $field_obj ) {
3683
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
3681
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
3682
+		foreach ($key_fields as $key_field_name => $field_obj) {
3683
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
3684 3684
 				return NULL;
3685 3685
 			}
3686 3686
 		}
@@ -3693,10 +3693,10 @@  discard block
 block discarded – undo
3693 3693
 	 * @param array $key_vals
3694 3694
 	 * @return boolean
3695 3695
 	 */
3696
-	function has_all_combined_primary_key_fields( $key_vals ) {
3697
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
3698
-		foreach( $keys_it_should_have as $key ){
3699
-			if( ! isset( $key_vals[ $key ] ) ){
3696
+	function has_all_combined_primary_key_fields($key_vals) {
3697
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
3698
+		foreach ($keys_it_should_have as $key) {
3699
+			if ( ! isset($key_vals[$key])) {
3700 3700
 				return false;
3701 3701
 			}
3702 3702
 		}
@@ -3712,23 +3712,23 @@  discard block
 block discarded – undo
3712 3712
 	 * @throws EE_Error
3713 3713
 	 * @return \EE_Base_Class[]
3714 3714
 	 */
3715
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
3715
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
3716 3716
 
3717
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
3717
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
3718 3718
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
3719
-		}elseif(is_array($model_object_or_attributes_array)){
3719
+		}elseif (is_array($model_object_or_attributes_array)) {
3720 3720
 			$attributes_array = $model_object_or_attributes_array;
3721
-		}else{
3722
-			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));
3721
+		} else {
3722
+			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));
3723 3723
 		}
3724 3724
 		//even copies obviously won't have the same ID, so remove the primary key
3725 3725
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
3726
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
3726
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
3727 3727
 			unset($attributes_array[$this->primary_key_name()]);
3728 3728
 		}
3729
-		if(isset($query_params[0])){
3730
-			$query_params[0] = array_merge($attributes_array,$query_params);
3731
-		}else{
3729
+		if (isset($query_params[0])) {
3730
+			$query_params[0] = array_merge($attributes_array, $query_params);
3731
+		} else {
3732 3732
 			$query_params[0] = $attributes_array;
3733 3733
 		}
3734 3734
 		return $this->get_all($query_params);
@@ -3742,16 +3742,16 @@  discard block
 block discarded – undo
3742 3742
 	 * @param array $query_params
3743 3743
 	 * @return EE_Base_Class
3744 3744
 	 */
3745
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
3746
-		if( ! is_array( $query_params ) ){
3747
-			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' );
3745
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
3746
+		if ( ! is_array($query_params)) {
3747
+			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');
3748 3748
 			$query_params = array();
3749 3749
 		}
3750 3750
 		$query_params['limit'] = 1;
3751
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
3752
-		if(is_array($copies)){
3751
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
3752
+		if (is_array($copies)) {
3753 3753
 			return array_shift($copies);
3754
-		}else{
3754
+		} else {
3755 3755
 			return null;
3756 3756
 		}
3757 3757
 	}
@@ -3765,10 +3765,10 @@  discard block
 block discarded – undo
3765 3765
 	 * @param int|string $id the value of the primary key to update
3766 3766
 	 * @return int number of rows updated
3767 3767
 	 */
3768
-	public function update_by_ID($fields_n_values,$id){
3768
+	public function update_by_ID($fields_n_values, $id) {
3769 3769
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
3770 3770
 			'default_where_conditions'=>'other_models_only',);
3771
-		return $this->update($fields_n_values,$query_params);
3771
+		return $this->update($fields_n_values, $query_params);
3772 3772
 	}
3773 3773
 
3774 3774
 
@@ -3779,12 +3779,12 @@  discard block
 block discarded – undo
3779 3779
 	 * @return string an operator which can be used in SQL
3780 3780
 	 * @throws EE_Error
3781 3781
 	 */
3782
-	private function _prepare_operator_for_sql($operator_supplied){
3782
+	private function _prepare_operator_for_sql($operator_supplied) {
3783 3783
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
3784
-		if($sql_operator){
3784
+		if ($sql_operator) {
3785 3785
 			return $sql_operator;
3786
-		}else{
3787
-			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))));
3786
+		} else {
3787
+			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))));
3788 3788
 		}
3789 3789
 	}
3790 3790
 
@@ -3794,10 +3794,10 @@  discard block
 block discarded – undo
3794 3794
 	 * @param array $query_params like get_all's
3795 3795
 	 * @return string[]
3796 3796
 	 */
3797
-	public function get_all_names($query_params = array()){
3797
+	public function get_all_names($query_params = array()) {
3798 3798
 		$objs = $this->get_all($query_params);
3799 3799
 		$names = array();
3800
-		foreach($objs as $obj){
3800
+		foreach ($objs as $obj) {
3801 3801
 			$names[$obj->ID()] = $obj->name();
3802 3802
 		}
3803 3803
 		return $names;
Please login to merge, or discard this patch.
Braces   +125 added lines, -115 removed lines patch added patch discarded remove patch
@@ -430,8 +430,9 @@  discard block
 block discarded – undo
430 430
 	 * @return array
431 431
 	 */
432 432
 	 public function status_array( $translated = FALSE ) {
433
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
434
-	 		return array();
433
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
434
+	 		 		return array();
435
+	 	}
435 436
 	 	$model_name = $this->get_this_model_name();
436 437
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
437 438
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -591,7 +592,7 @@  discard block
 block discarded – undo
591 592
 				$last_model_name = end( $models_to_follow_to_wp_users );
592 593
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
593 594
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
594
-			}else{
595
+			} else{
595 596
 				$model_with_fk_to_wp_users = $this;
596 597
 				$model_chain_to_wp_user = '';
597 598
 			}
@@ -627,11 +628,11 @@  discard block
 block discarded – undo
627 628
 	public function is_owned() {
628 629
 		if( $this->model_chain_to_wp_user() ){
629 630
 			return true;
630
-		}else{
631
+		} else{
631 632
 			try{
632 633
 				$this->get_foreign_key_to( 'WP_User' );
633 634
 				return true;
634
-			}catch( EE_Error $e ){
635
+			} catch( EE_Error $e ){
635 636
 				return false;
636 637
 			}
637 638
 		}
@@ -654,9 +655,9 @@  discard block
 block discarded – undo
654 655
 		//remember the custom selections, if any
655 656
 		if(is_array($columns_to_select)){
656 657
 			$this->_custom_selections = $columns_to_select;
657
-		}elseif(is_string($columns_to_select)){
658
+		} elseif(is_string($columns_to_select)){
658 659
 			$this->_custom_selections = array($this->_custom_selections);
659
-		}else{
660
+		} else{
660 661
 			$this->_custom_selections = array();
661 662
 		}
662 663
 
@@ -707,7 +708,7 @@  discard block
 block discarded – undo
707 708
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
708 709
 			}
709 710
 			$columns_to_select_string = implode(", ",$select_sql_array);
710
-		}else{
711
+		} else{
711 712
 			$columns_to_select_string = $columns_to_select;
712 713
 		}
713 714
 		return $columns_to_select_string;
@@ -735,10 +736,10 @@  discard block
 block discarded – undo
735 736
 	function get_one_by_ID($id){
736 737
 		if( $this->get_from_entity_map( $id ) ){
737 738
 			return $this->get_from_entity_map( $id );
738
-		}elseif( $this->has_primary_key_field ( ) ) {
739
+		} elseif( $this->has_primary_key_field ( ) ) {
739 740
 			$primary_key_name = $this->get_primary_key_field()->get_name();
740 741
 			return $this->get_one(array(array($primary_key_name => $id)));
741
-		}else{
742
+		} else{
742 743
 			//no primary key, so the $id must be from the get_index_primary_key_string()
743 744
 			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
744 745
 		}
@@ -760,7 +761,7 @@  discard block
 block discarded – undo
760 761
 		$items = $this->get_all($query_params);
761 762
 		if(empty($items)){
762 763
 			return null;
763
-		}else{
764
+		} else{
764 765
 			return array_shift($items);
765 766
 		}
766 767
 	}
@@ -1012,7 +1013,7 @@  discard block
 block discarded – undo
1012 1013
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1013 1014
 				if( $this->has_primary_key_field() ){
1014 1015
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1015
-				}else{
1016
+				} else{
1016 1017
 					//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)
1017 1018
 					$main_table_pk_value = null;
1018 1019
 				}
@@ -1051,7 +1052,7 @@  discard block
 block discarded – undo
1051 1052
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1052 1053
 			if( $this->has_primary_key_field() ){
1053 1054
 				$model_objs_affected_ids = $this->get_col( $query_params );
1054
-			}else{
1055
+			} else{
1055 1056
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1056 1057
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1057 1058
 				$model_objs_affected_ids = array();
@@ -1111,9 +1112,9 @@  discard block
 block discarded – undo
1111 1112
 
1112 1113
 		if( $field_to_select ){
1113 1114
 			$field = $this->field_settings_for( $field_to_select );
1114
-		}elseif( $this->has_primary_key_field ( ) ){
1115
+		} elseif( $this->has_primary_key_field ( ) ){
1115 1116
 			$field = $this->get_primary_key_field();
1116
-		}else{
1117
+		} else{
1117 1118
 			//no primary key, just grab the first column
1118 1119
 			$field = reset( $this->field_settings());
1119 1120
 		}
@@ -1204,7 +1205,7 @@  discard block
 block discarded – undo
1204 1205
 
1205 1206
 			//		/echo "delete sql:$SQL";
1206 1207
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1207
-		}else{
1208
+		} else{
1208 1209
 			$rows_deleted = 0;
1209 1210
 		}
1210 1211
 
@@ -1246,7 +1247,7 @@  discard block
 block discarded – undo
1246 1247
 		//first, if $ignore_this_model_obj was supplied, get its model
1247 1248
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1248 1249
 			$ignored_model = $ignore_this_model_obj->get_model();
1249
-		}else{
1250
+		} else{
1250 1251
 			$ignored_model = null;
1251 1252
 		}
1252 1253
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1259,7 +1260,7 @@  discard block
 block discarded – undo
1259 1260
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1260 1261
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1261 1262
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1262
-				}else{
1263
+				} else{
1263 1264
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1264 1265
 				}
1265 1266
 
@@ -1296,24 +1297,28 @@  discard block
 block discarded – undo
1296 1297
 				}
1297 1298
 
1298 1299
 				//primary table deletes
1299
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1300
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1300
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1301
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1302
+				}
1301 1303
 
1302 1304
 				//other tables
1303 1305
 				if ( !empty( $other_tables ) ) {
1304 1306
 					foreach ( $other_tables as $ot ) {
1305 1307
 
1306 1308
 						//first check if we've got the foreign key column here.
1307
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1308
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1309
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1310
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1311
+						}
1309 1312
 
1310 1313
 						//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
1311
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1312
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1314
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1315
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1316
+						}
1313 1317
 
1314 1318
 						//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!
1315
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1316
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1319
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1320
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1321
+						}
1317 1322
 					}
1318 1323
 				}
1319 1324
 			}
@@ -1326,7 +1331,7 @@  discard block
 block discarded – undo
1326 1331
 			}
1327 1332
 
1328 1333
 			return !empty($query) ? implode(' AND ', $query ) : '';
1329
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1334
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1330 1335
 			$ways_to_identify_a_row = array();
1331 1336
 			$fields = $this->get_combined_primary_key_fields();
1332 1337
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1338,7 +1343,7 @@  discard block
 block discarded – undo
1338 1343
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1339 1344
 			}
1340 1345
 			return implode(" OR ",$ways_to_identify_a_row);
1341
-		}else{
1346
+		} else{
1342 1347
 			//so there's no primary key and no combined key...
1343 1348
 			//sorry, can't help you
1344 1349
 			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)));
@@ -1360,10 +1365,10 @@  discard block
 block discarded – undo
1360 1365
 		if($field_to_count){
1361 1366
 			$field_obj = $this->field_settings_for($field_to_count);
1362 1367
 			$column_to_count = $field_obj->get_qualified_column();
1363
-		}elseif($this->has_primary_key_field ()){
1368
+		} elseif($this->has_primary_key_field ()){
1364 1369
 			$pk_field_obj = $this->get_primary_key_field();
1365 1370
 			$column_to_count = $pk_field_obj->get_qualified_column();
1366
-		}else{//there's no primary key
1371
+		} else{//there's no primary key
1367 1372
 			$column_to_count = '*';
1368 1373
 		}
1369 1374
 
@@ -1385,7 +1390,7 @@  discard block
 block discarded – undo
1385 1390
 		if($field_to_sum){
1386 1391
 			$field_obj = $this->field_settings_for($field_to_sum);
1387 1392
 
1388
-		}else{
1393
+		} else{
1389 1394
 			$field_obj = $this->get_primary_key_field();
1390 1395
 		}
1391 1396
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1394,7 +1399,7 @@  discard block
 block discarded – undo
1394 1399
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1395 1400
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1396 1401
 			return (int)$return_value;
1397
-		}else{//must be %f
1402
+		} else{//must be %f
1398 1403
 			return (float)$return_value;
1399 1404
 		}
1400 1405
 	}
@@ -1433,10 +1438,10 @@  discard block
 block discarded – undo
1433 1438
 			$wpdb->show_errors( $old_show_errors_value );
1434 1439
 			if( ! empty( $wpdb->last_error ) ){
1435 1440
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1436
-			}elseif( $result === false ){
1441
+			} elseif( $result === false ){
1437 1442
 				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 ) ) );
1438 1443
 			}
1439
-		}elseif( $result === false ) {
1444
+		} elseif( $result === false ) {
1440 1445
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1441 1446
 		}
1442 1447
 		return $result;
@@ -1650,7 +1655,7 @@  discard block
 block discarded – undo
1650 1655
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1651 1656
 		if( $results ){
1652 1657
 			return array_shift($results);
1653
-		}else{
1658
+		} else{
1654 1659
 			return null;
1655 1660
 		}
1656 1661
 
@@ -1721,7 +1726,7 @@  discard block
 block discarded – undo
1721 1726
 			 */
1722 1727
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
1723 1728
 			return $new_id;
1724
-		}else{
1729
+		} else{
1725 1730
 			return FALSE;
1726 1731
 		}
1727 1732
 	}
@@ -1762,9 +1767,9 @@  discard block
 block discarded – undo
1762 1767
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
1763 1768
 		if($obj_or_fields_array instanceof EE_Base_Class){
1764 1769
 			$fields_n_values = $obj_or_fields_array->model_field_array();
1765
-		}elseif( is_array($obj_or_fields_array)){
1770
+		} elseif( is_array($obj_or_fields_array)){
1766 1771
 			$fields_n_values = $obj_or_fields_array;
1767
-		}else{
1772
+		} else{
1768 1773
 			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));
1769 1774
 		}
1770 1775
 		$query_params = array();
@@ -1780,7 +1785,7 @@  discard block
 block discarded – undo
1780 1785
 		//if there is nothing to base this search on, then we shouldn't find anything
1781 1786
 		if( empty( $query_params ) ){
1782 1787
 			return array();
1783
-		}else{
1788
+		} else{
1784 1789
 			return $this->get_one($query_params);
1785 1790
 		}
1786 1791
 	}
@@ -1853,12 +1858,12 @@  discard block
 block discarded – undo
1853 1858
 		if($this->has_primary_key_field()){
1854 1859
 			if($this->get_primary_key_field()->is_auto_increment()){
1855 1860
 				return $wpdb->insert_id;
1856
-			}else{
1861
+			} else{
1857 1862
 				//it's not an auto-increment primary key, so
1858 1863
 				//it must have been supplied
1859 1864
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
1860 1865
 			}
1861
-		}else{
1866
+		} else{
1862 1867
 			//we can't return a  primary key because there is none. instead return
1863 1868
 			//a unique string indicating this model
1864 1869
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -1905,7 +1910,7 @@  discard block
 block discarded – undo
1905 1910
 					//leave the value alone
1906 1911
 			}
1907 1912
 			return $value;
1908
-		}else{
1913
+		} else{
1909 1914
 			return $value;
1910 1915
 		}
1911 1916
 	}
@@ -1998,7 +2003,7 @@  discard block
 block discarded – undo
1998 2003
 		if(array_key_exists('group_by', $query_params)){
1999 2004
 			if(is_array($query_params['group_by'])){
2000 2005
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2001
-			}elseif( ! empty ( $query_params['group_by'] )){
2006
+			} elseif( ! empty ( $query_params['group_by'] )){
2002 2007
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2003 2008
 			}
2004 2009
 		}
@@ -2006,10 +2011,11 @@  discard block
 block discarded – undo
2006 2011
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2007 2012
 		}
2008 2013
 		if(array_key_exists('order_by', $query_params)){
2009
-			if ( is_array( $query_params['order_by'] ) )
2010
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2011
-			elseif( ! empty( $query_params['order_by'] ))
2012
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2014
+			if ( is_array( $query_params['order_by'] ) ) {
2015
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2016
+			} elseif( ! empty( $query_params['order_by'] )) {
2017
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2018
+			}
2013 2019
 		}
2014 2020
 		if(array_key_exists('force_join', $query_params)){
2015 2021
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -2041,10 +2047,10 @@  discard block
 block discarded – undo
2041 2047
 					if (! is_array($possibly_array_of_params)){
2042 2048
 						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"),
2043 2049
 							$param,$possibly_array_of_params));
2044
-					}else{
2050
+					} else{
2045 2051
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2046 2052
 					}
2047
-				}elseif($query_param_type === 0 //ie WHERE
2053
+				} elseif($query_param_type === 0 //ie WHERE
2048 2054
 						&& is_array($possibly_array_of_params)
2049 2055
 						&& isset($possibly_array_of_params[2])
2050 2056
 						&& $possibly_array_of_params[2] == true){
@@ -2105,7 +2111,7 @@  discard block
 block discarded – undo
2105 2111
 		$query_object = $this->_extract_related_models_from_query($query_params);
2106 2112
 		if(array_key_exists(0,$query_params)){
2107 2113
 			$where_query_params = $query_params[0];
2108
-		}else{
2114
+		} else{
2109 2115
 			$where_query_params = array();
2110 2116
 		}
2111 2117
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
@@ -2116,7 +2122,7 @@  discard block
 block discarded – undo
2116 2122
 		}
2117 2123
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2118 2124
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2119
-		}else{
2125
+		} else{
2120 2126
 			$use_default_where_conditions = 'all';
2121 2127
 		}
2122 2128
 		$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 );
@@ -2139,7 +2145,7 @@  discard block
 block discarded – undo
2139 2145
 				}
2140 2146
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2141 2147
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2142
-			}elseif( ! empty ( $query_params['limit'] )){
2148
+			} elseif( ! empty ( $query_params['limit'] )){
2143 2149
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2144 2150
 			}
2145 2151
 		}
@@ -2161,11 +2167,11 @@  discard block
 block discarded – undo
2161 2167
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2162 2168
 				}
2163 2169
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2164
-			}elseif( ! empty ( $query_params['order_by'] )){
2170
+			} elseif( ! empty ( $query_params['order_by'] )){
2165 2171
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2166 2172
 				if(isset($query_params['order'])){
2167 2173
 					$order = $this->_extract_order($query_params['order']);
2168
-				}else{
2174
+				} else{
2169 2175
 					$order = 'DESC';
2170 2176
 				}
2171 2177
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2188,7 +2194,7 @@  discard block
 block discarded – undo
2188 2194
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2189 2195
 				}
2190 2196
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2191
-			}elseif( ! empty ( $query_params['group_by'] )){
2197
+			} elseif( ! empty ( $query_params['group_by'] )){
2192 2198
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2193 2199
 			}
2194 2200
 		}
@@ -2212,8 +2218,9 @@  discard block
 block discarded – undo
2212 2218
 			}
2213 2219
 		}
2214 2220
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2215
-		if ( empty( $main_model_join_sql ) )
2216
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2221
+		if ( empty( $main_model_join_sql ) ) {
2222
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2223
+		}
2217 2224
 		return $query_object;
2218 2225
 	}
2219 2226
 
@@ -2229,7 +2236,7 @@  discard block
 block discarded – undo
2229 2236
 	private function _extract_order($should_be_order_string){
2230 2237
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2231 2238
 			return $should_be_order_string;
2232
-		}else{
2239
+		} else{
2233 2240
 			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));
2234 2241
 		}
2235 2242
 	}
@@ -2255,7 +2262,7 @@  discard block
 block discarded – undo
2255 2262
 		}
2256 2263
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2257 2264
 			$universal_query_params = $this->_get_default_where_conditions();
2258
-		}else{
2265
+		} else{
2259 2266
 			$universal_query_params = array();
2260 2267
 		}
2261 2268
 
@@ -2295,14 +2302,14 @@  discard block
 block discarded – undo
2295 2302
 		foreach($default_where_conditions as $key => $val){
2296 2303
 			if( isset($provided_where_conditions[$key])){
2297 2304
 				$none_overridden = false;
2298
-			}else{
2305
+			} else{
2299 2306
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2300 2307
 			}
2301 2308
 		}
2302 2309
 		if( $none_overridden && $default_where_conditions){
2303 2310
 			if($model->has_primary_key_field()){
2304 2311
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2305
-			}else{
2312
+			} else{
2306 2313
 				//@todo NO PK, use other defaults
2307 2314
 			}
2308 2315
 		}
@@ -2318,8 +2325,9 @@  discard block
 block discarded – undo
2318 2325
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2319 2326
 	 */
2320 2327
 	private function _get_default_where_conditions($model_relation_path = null){
2321
-		if ( $this->_ignore_where_strategy )
2322
-			return array();
2328
+		if ( $this->_ignore_where_strategy ) {
2329
+					return array();
2330
+		}
2323 2331
 
2324 2332
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2325 2333
 	}
@@ -2393,7 +2401,7 @@  discard block
 block discarded – undo
2393 2401
 		if(array_key_exists($query_param,$this_model_fields)){
2394 2402
 			if($allow_fields){
2395 2403
 				return;
2396
-			}else{
2404
+			} else{
2397 2405
 				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"),
2398 2406
 						$query_param,get_class($this),$query_param_type,$original_query_param));
2399 2407
 			}
@@ -2402,7 +2410,7 @@  discard block
 block discarded – undo
2402 2410
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2403 2411
 			if($allow_logic_query_params){
2404 2412
 				return;
2405
-			}else{
2413
+			} else{
2406 2414
 				throw new EE_Error(
2407 2415
 					sprintf(
2408 2416
 						__( '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' ),
@@ -2432,12 +2440,12 @@  discard block
 block discarded – undo
2432 2440
 					//we should actually end in a field name, not a model like this!
2433 2441
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2434 2442
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2435
-				}else{
2443
+				} else{
2436 2444
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2437 2445
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2438 2446
 					return;
2439 2447
 				}
2440
-			}elseif($query_param == $valid_related_model_name){
2448
+			} elseif($query_param == $valid_related_model_name){
2441 2449
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2442 2450
 				return;
2443 2451
 			}
@@ -2497,7 +2505,7 @@  discard block
 block discarded – undo
2497 2505
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2498 2506
 		if($SQL){
2499 2507
 			return " WHERE ". $SQL;
2500
-		}else{
2508
+		} else{
2501 2509
 			return '';
2502 2510
 		}
2503 2511
 	}
@@ -2512,7 +2520,7 @@  discard block
 block discarded – undo
2512 2520
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2513 2521
 		if($SQL){
2514 2522
 			return " HAVING ". $SQL;
2515
-		}else{
2523
+		} else{
2516 2524
 			return '';
2517 2525
 		}
2518 2526
 
@@ -2535,7 +2543,7 @@  discard block
 block discarded – undo
2535 2543
 			$model_instance=call_user_func($model_name."::instance");
2536 2544
 			/* @var $model_instance EEM_Base */
2537 2545
 			return $model_instance->field_settings_for($field_name);
2538
-		}else{
2546
+		} else{
2539 2547
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2540 2548
 		}
2541 2549
 	}
@@ -2568,14 +2576,14 @@  discard block
 block discarded – undo
2568 2576
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2569 2577
 						break;
2570 2578
 				}
2571
-			}else{
2579
+			} else{
2572 2580
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2573 2581
 
2574 2582
 				//if it's not a normal field, maybe it's a custom selection?
2575 2583
 				if( ! $field_obj){
2576 2584
 					if(isset( $this->_custom_selections[$query_param][1])){
2577 2585
 						$field_obj = $this->_custom_selections[$query_param][1];
2578
-					}else{
2586
+					} else{
2579 2587
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2580 2588
 					}
2581 2589
 				}
@@ -2585,7 +2593,7 @@  discard block
 block discarded – undo
2585 2593
 		}
2586 2594
 		if($where_clauses){
2587 2595
 			$SQL = implode($glue,$where_clauses);
2588
-		}else{
2596
+		} else{
2589 2597
 			$SQL = '';
2590 2598
 		}
2591 2599
 		return $SQL;
@@ -2605,11 +2613,11 @@  discard block
 block discarded – undo
2605 2613
 		if( $field ){
2606 2614
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2607 2615
 			return $table_alias_prefix . $field->get_qualified_column();
2608
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2616
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
2609 2617
 			//maybe it's custom selection item?
2610 2618
 			//if so, just use it as the "column name"
2611 2619
 			return $query_param;
2612
-		}else{
2620
+		} else{
2613 2621
 			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)));
2614 2622
 		}
2615 2623
 	}
@@ -2626,7 +2634,7 @@  discard block
 block discarded – undo
2626 2634
 		$pos_of_star = strpos($condition_query_param_key, '*');
2627 2635
 		if($pos_of_star === FALSE){
2628 2636
 			return $condition_query_param_key;
2629
-		}else{
2637
+		} else{
2630 2638
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2631 2639
 			return $condition_query_param_sans_star;
2632 2640
 		}
@@ -2652,7 +2660,7 @@  discard block
 block discarded – undo
2652 2660
 				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)));
2653 2661
 			}
2654 2662
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2655
-		}else{
2663
+		} else{
2656 2664
 			$operator = '=';
2657 2665
 			$value = $op_and_value;
2658 2666
 		}
@@ -2660,7 +2668,7 @@  discard block
 block discarded – undo
2660 2668
 		//check to see if the value is actually another field
2661 2669
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2662 2670
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2663
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2671
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2664 2672
 			//in this case, the value should be an array, or at least a comma-separated list
2665 2673
 			//it will need to handle a little differently
2666 2674
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -2668,8 +2676,9 @@  discard block
 block discarded – undo
2668 2676
 			return $operator.SP.$cleaned_value;
2669 2677
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2670 2678
 			//the value should be an array with count of two.
2671
-			if ( count($value) !== 2 )
2672
-				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" ) );
2679
+			if ( count($value) !== 2 ) {
2680
+							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" ) );
2681
+			}
2673 2682
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2674 2683
 			return $operator.SP.$cleaned_value;
2675 2684
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -2677,17 +2686,17 @@  discard block
 block discarded – undo
2677 2686
 				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));
2678 2687
 			}
2679 2688
 			return $operator;
2680
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
2689
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
2681 2690
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
2682 2691
 			//remove other junk. So just treat it as a string.
2683 2692
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
2684
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2693
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2685 2694
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
2686
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2695
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2687 2696
 			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));
2688
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2697
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2689 2698
 			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));
2690
-		}else{
2699
+		} else{
2691 2700
 			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)));
2692 2701
 		}
2693 2702
 	}
@@ -2756,7 +2765,7 @@  discard block
 block discarded – undo
2756 2765
 		global $wpdb;
2757 2766
 		if($field_obj instanceof EE_Model_Field_Base){
2758 2767
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
2759
-		}else{//$field_obj should really just be a data type
2768
+		} else{//$field_obj should really just be a data type
2760 2769
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
2761 2770
 				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)));
2762 2771
 			}
@@ -2785,14 +2794,14 @@  discard block
 block discarded – undo
2785 2794
 		if($number_of_parts == 1){
2786 2795
 			$field_name = $last_query_param_part;
2787 2796
 			$model_obj = $this;
2788
-		}else{// $number_of_parts >= 2
2797
+		} else{// $number_of_parts >= 2
2789 2798
 			//the last part is the column name, and there are only 2parts. therefore...
2790 2799
 			$field_name = $last_query_param_part;
2791 2800
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
2792 2801
 		}
2793 2802
 		try{
2794 2803
 			return $model_obj->field_settings_for($field_name);
2795
-		}catch(EE_Error $e){
2804
+		} catch(EE_Error $e){
2796 2805
 			return null;
2797 2806
 		}
2798 2807
 	}
@@ -2811,7 +2820,7 @@  discard block
 block discarded – undo
2811 2820
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
2812 2821
 		if($field){
2813 2822
 			return $field->get_qualified_column();
2814
-		}else{
2823
+		} else{
2815 2824
 			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)));
2816 2825
 		}
2817 2826
 	}
@@ -2877,7 +2886,7 @@  discard block
 block discarded – undo
2877 2886
 					//the FROM statement, BUT the primary table isn't. So we want
2878 2887
 					//to add the inverse join sql
2879 2888
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
2880
-				}else{
2889
+				} else{
2881 2890
 					//just add a regular JOIN to this table from the primary table
2882 2891
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
2883 2892
 				}
@@ -2992,7 +3001,7 @@  discard block
 block discarded – undo
2992 3001
 		$fieldSettings = $this->field_settings(true);
2993 3002
 		if( isset($fieldSettings[$fieldName])){
2994 3003
 			return true;
2995
-		}else{
3004
+		} else{
2996 3005
 			return false;
2997 3006
 		}
2998 3007
 	}
@@ -3006,7 +3015,7 @@  discard block
 block discarded – undo
3006 3015
 		$relations = $this->relation_settings();
3007 3016
 		if(isset($relations[$relation_name])){
3008 3017
 			return true;
3009
-		}else{
3018
+		} else{
3010 3019
 			return false;
3011 3020
 		}
3012 3021
 	}
@@ -3057,7 +3066,7 @@  discard block
 block discarded – undo
3057 3066
 			try{
3058 3067
 				$this->get_primary_key_field();
3059 3068
 				$this->_has_primary_key_field = true;
3060
-			}catch(EE_Error $e){
3069
+			} catch(EE_Error $e){
3061 3070
 				$this->_has_primary_key_field = false;
3062 3071
 			}
3063 3072
 		}
@@ -3136,7 +3145,7 @@  discard block
 block discarded – undo
3136 3145
 				}
3137 3146
 			}
3138 3147
 			return $this->_cached_fields;
3139
-		}else{
3148
+		} else{
3140 3149
 			if( $this->_cached_fields_non_db_only === NULL ){
3141 3150
 				$this->_cached_fields_non_db_only = array();
3142 3151
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3268,7 +3277,7 @@  discard block
 block discarded – undo
3268 3277
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3269 3278
 				return NULL;
3270 3279
 			}
3271
-		}else if($this->unique_indexes()){
3280
+		} else if($this->unique_indexes()){
3272 3281
 			$first_column = reset($this_model_fields_n_values);
3273 3282
 			if(empty($first_column)){
3274 3283
 				return NULL;
@@ -3283,7 +3292,7 @@  discard block
 block discarded – undo
3283 3292
 				// add this new object to the entity map
3284 3293
 				$classInstance = $this->add_to_entity_map( $classInstance );
3285 3294
 			}
3286
-		}else{
3295
+		} else{
3287 3296
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3288 3297
 		}
3289 3298
 
@@ -3368,11 +3377,12 @@  discard block
 block discarded – undo
3368 3377
 						$this_model_fields_n_values[$field_name] = $field_obj->get_default_value();
3369 3378
 					}
3370 3379
 				}
3371
-			}else{
3380
+			} else{
3372 3381
 				//the table's rows existed. Use their values
3373 3382
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3374
-					if( ! $field_obj->is_db_only_field() )
3375
-					$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() );
3383
+					if( ! $field_obj->is_db_only_field() ) {
3384
+										$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() );
3385
+					}
3376 3386
 				}
3377 3387
 			}
3378 3388
 		}
@@ -3386,9 +3396,9 @@  discard block
 block discarded – undo
3386 3396
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
3387 3397
 			$value = $cols_n_values[ $qualified_column ];
3388 3398
 
3389
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3399
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
3390 3400
 			$value = $cols_n_values[ $regular_column ];
3391
-		}else{
3401
+		} else{
3392 3402
 			$value = NULL;
3393 3403
 		}
3394 3404
 
@@ -3421,7 +3431,7 @@  discard block
 block discarded – undo
3421 3431
 				}
3422 3432
 			}
3423 3433
 			return $obj_in_map;
3424
-		}else{
3434
+		} else{
3425 3435
 			return $this->get_one_by_ID( $id );
3426 3436
 		}
3427 3437
 	}
@@ -3456,7 +3466,7 @@  discard block
 block discarded – undo
3456 3466
 				}
3457 3467
 			}
3458 3468
 			return $obj_in_map;
3459
-		}else{
3469
+		} else{
3460 3470
 			$this->add_to_entity_map( $replacing_model_obj );
3461 3471
 			return $replacing_model_obj;
3462 3472
 		}
@@ -3486,7 +3496,7 @@  discard block
 block discarded – undo
3486 3496
 	public function item_name($quantity = 1){
3487 3497
 		if($quantity == 1){
3488 3498
 			return $this->singular_item;
3489
-		}else{
3499
+		} else{
3490 3500
 			return $this->plural_item;
3491 3501
 		}
3492 3502
 	}
@@ -3548,14 +3558,14 @@  discard block
 block discarded – undo
3548 3558
 		$primary_key_field = $this->get_primary_key_field();
3549 3559
 		if( $base_class_obj_or_id instanceof $className ){
3550 3560
 			$model_object = $base_class_obj_or_id;
3551
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3561
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3552 3562
 				is_int( $base_class_obj_or_id ) ||
3553 3563
 				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)
3554 3564
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3555
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3565
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3556 3566
 			//assume its a string representation of the object
3557 3567
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3558
-		}else{
3568
+		} else{
3559 3569
 			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)));
3560 3570
 		}
3561 3571
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -3579,13 +3589,13 @@  discard block
 block discarded – undo
3579 3589
 		if( $base_class_obj_or_id instanceof $className ){
3580 3590
 			/** @var $base_class_obj_or_id EE_Base_Class */
3581 3591
 			$id = $base_class_obj_or_id->ID();
3582
-		}elseif(is_int($base_class_obj_or_id)){
3592
+		} elseif(is_int($base_class_obj_or_id)){
3583 3593
 			//assume it's an ID
3584 3594
 			$id = $base_class_obj_or_id;
3585
-		}elseif(is_string($base_class_obj_or_id)){
3595
+		} elseif(is_string($base_class_obj_or_id)){
3586 3596
 			//assume its a string representation of the object
3587 3597
 			$id = $base_class_obj_or_id;
3588
-		}else{
3598
+		} else{
3589 3599
 			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)));
3590 3600
 		}
3591 3601
 		return $id;
@@ -3716,9 +3726,9 @@  discard block
 block discarded – undo
3716 3726
 
3717 3727
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
3718 3728
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
3719
-		}elseif(is_array($model_object_or_attributes_array)){
3729
+		} elseif(is_array($model_object_or_attributes_array)){
3720 3730
 			$attributes_array = $model_object_or_attributes_array;
3721
-		}else{
3731
+		} else{
3722 3732
 			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));
3723 3733
 		}
3724 3734
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -3728,7 +3738,7 @@  discard block
 block discarded – undo
3728 3738
 		}
3729 3739
 		if(isset($query_params[0])){
3730 3740
 			$query_params[0] = array_merge($attributes_array,$query_params);
3731
-		}else{
3741
+		} else{
3732 3742
 			$query_params[0] = $attributes_array;
3733 3743
 		}
3734 3744
 		return $this->get_all($query_params);
@@ -3751,7 +3761,7 @@  discard block
 block discarded – undo
3751 3761
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
3752 3762
 		if(is_array($copies)){
3753 3763
 			return array_shift($copies);
3754
-		}else{
3764
+		} else{
3755 3765
 			return null;
3756 3766
 		}
3757 3767
 	}
@@ -3783,7 +3793,7 @@  discard block
 block discarded – undo
3783 3793
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
3784 3794
 		if($sql_operator){
3785 3795
 			return $sql_operator;
3786
-		}else{
3796
+		} else{
3787 3797
 			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))));
3788 3798
 		}
3789 3799
 	}
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -7,6 +7,11 @@
 block discarded – undo
7 7
 
8 8
 	protected $_post_type;
9 9
 	protected $_meta_field;
10
+
11
+	/**
12
+	 * @param string $post_type
13
+	 * @param string $meta_field_to_chk
14
+	 */
10 15
 	function __construct($post_type, $meta_field_to_chk){
11 16
 		$this->_post_type = $post_type;
12 17
 		$this->_meta_field = $meta_field_to_chk;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 /*
4 4
  * Strategy specifically for adding where conditions specific to CPT models.
5 5
  */
6
-class EE_CPT_Where_Conditions extends EE_Default_Where_Conditions{
6
+class EE_CPT_Where_Conditions extends EE_Default_Where_Conditions {
7 7
 
8 8
 	protected $_post_type;
9 9
 	protected $_meta_field;
10
-	function __construct($post_type, $meta_field_to_chk){
10
+	function __construct($post_type, $meta_field_to_chk) {
11 11
 		$this->_post_type = $post_type;
12 12
 		$this->_meta_field = $meta_field_to_chk;
13 13
 	}
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 	 * @param string $column column name
18 18
 	 * @return EE_Model_Field_Base
19 19
 	 */
20
-	protected function _get_field_on_column($column){
20
+	protected function _get_field_on_column($column) {
21 21
 		$all_fields = $this->_model->field_settings(true);
22
-		foreach($all_fields as $field_name => $field_obj){
23
-			if($column == $field_obj->get_table_column()){
22
+		foreach ($all_fields as $field_name => $field_obj) {
23
+			if ($column == $field_obj->get_table_column()) {
24 24
 				return $field_obj;
25 25
 			}
26 26
 		}
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
31 31
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
32 32
 	 */
33
-	function get_default_where_conditions($model_relation_chain = null){
33
+	function get_default_where_conditions($model_relation_chain = null) {
34 34
 		//make sure there's a period at the end of $model_relation_chain
35
-		if($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain)-1] !='.'){
36
-			$model_relation_chain=$model_relation_chain.".";
35
+		if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') {
36
+			$model_relation_chain = $model_relation_chain.".";
37 37
 		}
38 38
 
39 39
 		//find post_type field
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 //		return $default_where_conditions;
61 61
 		return array(
62 62
 				$post_type_field_name => $this->_post_type,
63
-				$status_field_name => array('NOT IN',array('auto-draft','trash'))
63
+				$status_field_name => array('NOT IN', array('auto-draft', 'trash'))
64 64
 		);
65 65
 	}
66 66
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Line_Item.helper.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * Ensures that taxes have been applied to the order, if not applies them.
273 273
 	 * Returns the total amount of tax
274 274
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
275
-	 * @return float
275
+	 * @return boolean
276 276
 	 */
277 277
 	public static function ensure_taxes_applied( $total_line_item ){
278 278
 		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	/**
288 288
 	 * Deletes the line items as indicated by the line item code(s) provided
289 289
 	 * @param EE_Line_Item      $total_line_item of type EEM_Line_Item::type_total
290
-	 * @param array|bool|string $line_item_codes
290
+	 * @param boolean $line_item_codes
291 291
 	 * @return int number of items successfully removed
292 292
 	 */
293 293
 	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 /**
3 3
  *
4 4
  * EEH_Line_Item
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
35 35
 	 * @return boolean success
36 36
 	 */
37
-	public static function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
38
-		$items_subtotal = self::get_items_subtotal( $total_line_item );
37
+	public static function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
38
+		$items_subtotal = self::get_items_subtotal($total_line_item);
39 39
 		$line_item = EE_Line_Item::new_instance(array(
40 40
 			'LIN_name' => $name,
41 41
 			'LIN_desc' => $description,
42 42
 			'LIN_unit_price' => $unit_price,
43 43
 			'LIN_quantity' => $quantity,
44 44
 			'LIN_is_taxable' => $taxable,
45
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
46
-			'LIN_total' => floatval( $unit_price ) * intval( $quantity ),
45
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
46
+			'LIN_total' => floatval($unit_price) * intval($quantity),
47 47
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
48 48
 			'LIN_code' => $code,
49 49
 		));
50
-		return self::add_item($total_line_item, $line_item );
50
+		return self::add_item($total_line_item, $line_item);
51 51
 	}
52 52
 
53 53
 
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
 	 * @param int $qty
60 60
 	 * @return EE_Line_Item
61 61
 	 */
62
-	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
62
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
63 63
 		$datetimes = $ticket->datetimes();
64 64
 		$event_names = array();
65
-		foreach($datetimes as $datetime){
65
+		foreach ($datetimes as $datetime) {
66 66
 			$event = $datetime->event();
67 67
 			$event_names[$event->ID()] = $event->name();
68 68
 		}
69
-		$description_addition = " (For ".implode(", ",$event_names).")";
69
+		$description_addition = " (For ".implode(", ", $event_names).")";
70 70
 		$full_description = $ticket->description().$description_addition;
71
-		$items_subtotal = self::get_items_subtotal( $total_line_item );
71
+		$items_subtotal = self::get_items_subtotal($total_line_item);
72 72
 		// add $ticket to cart
73 73
 		$line_item = EE_Line_Item::new_instance(array(
74 74
 			'LIN_name'=>$ticket->name(),
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			'LIN_unit_price'=>$ticket->price(),
77 77
 			'LIN_quantity'=>$qty,
78 78
 			'LIN_is_taxable'=>$ticket->taxable(),
79
-			'LIN_order'=> $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
79
+			'LIN_order'=> $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
80 80
 			'LIN_total'=>$ticket->price() * $qty,
81 81
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
82 82
 			'OBJ_ID'=>$ticket->ID(),
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		));
85 85
 		//now add the sub-line items
86 86
 		$running_total_for_ticket = 0;
87
-		foreach($ticket->prices(array('order_by'=>array('PRC_order'=>'ASC'))) as $price){
87
+		foreach ($ticket->prices(array('order_by'=>array('PRC_order'=>'ASC'))) as $price) {
88 88
 			$sign = $price->is_discount() ? -1 : 1;
89 89
 			$price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty;
90 90
 
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
 				'OBJ_ID'=>$price->ID(),
100 100
 				'OBJ_type'=>'Price'
101 101
 			));
102
-			if($price->is_percent()){
102
+			if ($price->is_percent()) {
103 103
 				$sub_line_item->set_percent($sign * $price->amount());
104
-			}else{
104
+			} else {
105 105
 				$sub_line_item->set_unit_price($sign * $price->amount());
106 106
 			}
107 107
 			$running_total_for_ticket += $price_total;
108 108
 			$line_item->add_child_line_item($sub_line_item);
109 109
 		}
110 110
 
111
-		self::add_item( $total_line_item, $line_item );
111
+		self::add_item($total_line_item, $line_item);
112 112
 		return $line_item;
113 113
 	}
114 114
 
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param EE_Line_Item $item to be added
121 121
 	 * @return boolean
122 122
 	 */
123
-	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item ){
123
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
124 124
 		// add item to cart
125
-		$ticket_items = self::get_items_subtotal( $total_line_item );
126
-		if($ticket_items){
125
+		$ticket_items = self::get_items_subtotal($total_line_item);
126
+		if ($ticket_items) {
127 127
 			$success = $ticket_items->add_child_line_item($item);
128
-		}else{
128
+		} else {
129 129
 			return FALSE;
130 130
 		}
131 131
 		// recalculate cart totals based on new items
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
142 142
 	 *	@return \EE_Line_Item
143 143
 	 */
144
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
144
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
145 145
 		$tickets = $total_line_item->get_child_line_item('tickets');
146
-		return $tickets ? $tickets : self::create_default_items_subtotal( $total_line_item );
146
+		return $tickets ? $tickets : self::create_default_items_subtotal($total_line_item);
147 147
 	}
148 148
 
149 149
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
154 154
 	 * @return \EE_Line_Item
155 155
 	 */
156
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
156
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
157 157
 		$taxes = $total_line_item->get_child_line_item('taxes');
158
-		return $taxes ? $taxes : self::create_default_taxes_subtotal( $total_line_item );
158
+		return $taxes ? $taxes : self::create_default_taxes_subtotal($total_line_item);
159 159
 	}
160 160
 
161 161
 
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
 	 * @param EE_Transaction $transaction
168 168
 	 * @return \EE_Line_Item of type total
169 169
 	 */
170
-	public static function create_default_total_line_item( $transaction = NULL){
170
+	public static function create_default_total_line_item($transaction = NULL) {
171 171
 		$line_item = EE_Line_Item::new_instance(array(
172 172
 			'LIN_code'=>'total',
173 173
 			'LIN_name'=>  __('Grand Total', 'event_espresso'),
174 174
 			'LIN_type'=>  EEM_Line_Item::type_total,
175 175
 			'OBJ_type'=>'Transaction'
176 176
 		));
177
-		if( $transaction ){
178
-			$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
179
-			$line_item->set_TXN_ID( $transaction );
177
+		if ($transaction) {
178
+			$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
179
+			$line_item->set_TXN_ID($transaction);
180 180
 		}
181
-		self::create_default_items_subtotal( $line_item, $transaction );
182
-		self::create_default_taxes_subtotal( $line_item, $transaction );
181
+		self::create_default_items_subtotal($line_item, $transaction);
182
+		self::create_default_taxes_subtotal($line_item, $transaction);
183 183
 		return $line_item;
184 184
 	}
185 185
 
@@ -191,15 +191,15 @@  discard block
 block discarded – undo
191 191
 	 * @param EE_Transaction $transaction
192 192
 	 * @return EE_Line_Item
193 193
 	 */
194
-	protected static function create_default_items_subtotal(EE_Line_Item  $total_line_item, $transaction = NULL ){
194
+	protected static function create_default_items_subtotal(EE_Line_Item  $total_line_item, $transaction = NULL) {
195 195
 		$items_line_item = EE_Line_Item::new_instance(array(
196 196
 			'LIN_code'=>'tickets',
197 197
 			'LIN_name'=>  __('Tickets', 'event_espresso'),
198 198
 			'LIN_type'=>  EEM_Line_Item::type_sub_total
199 199
 		));
200
-		if( $transaction ){
201
-			$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
202
-			$total_line_item->set_TXN_ID( $transaction );
200
+		if ($transaction) {
201
+			$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
202
+			$total_line_item->set_TXN_ID($transaction);
203 203
 		}
204 204
 		$total_line_item->add_child_line_item($items_line_item);
205 205
 		return $items_line_item;
@@ -214,19 +214,19 @@  discard block
 block discarded – undo
214 214
 	 * @param EE_Transaction $transaction
215 215
 	 * @return EE_Line_Item
216 216
 	 */
217
-	protected static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
217
+	protected static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
218 218
 		$tax_line_item = EE_Line_Item::new_instance(array(
219 219
 			'LIN_code'=>'taxes',
220 220
 			'LIN_name'=> __('Taxes', 'event_espresso'),
221 221
 			'LIN_type'=>  EEM_Line_Item::type_tax_sub_total
222 222
 		));
223
-		if( $transaction ){
224
-			$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
225
-			$total_line_item->set_TXN_ID( $transaction );
223
+		if ($transaction) {
224
+			$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
225
+			$total_line_item->set_TXN_ID($transaction);
226 226
 		}
227 227
 		$total_line_item->add_child_line_item($tax_line_item);
228 228
 		//and lastly, add the actual taxes
229
-		self::apply_taxes( $total_line_item );
229
+		self::apply_taxes($total_line_item);
230 230
 		return $tax_line_item;
231 231
 	}
232 232
 
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	 * any old taxes are removed
239 239
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
240 240
 	 */
241
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
241
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
242 242
 		// get array of taxes via Price Model
243
-		$ordered_taxes = EE_Registry::instance()->load_model( 'Price' )->get_all_prices_that_are_taxes();
244
-		ksort( $ordered_taxes );
245
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
243
+		$ordered_taxes = EE_Registry::instance()->load_model('Price')->get_all_prices_that_are_taxes();
244
+		ksort($ordered_taxes);
245
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
246 246
 		//just to be safe, remove its old tax line items
247 247
 		$taxes_line_item->delete_children_line_items();
248 248
 		//loop thru taxes
249
-		foreach ( $ordered_taxes as $order => $taxes ) {
250
-			foreach ( $taxes as $tax ) {
251
-				if ( $tax instanceof EE_Price ) {
249
+		foreach ($ordered_taxes as $order => $taxes) {
250
+			foreach ($taxes as $tax) {
251
+				if ($tax instanceof EE_Price) {
252 252
 					$taxes_line_item->add_child_line_item(EE_Line_Item::new_instance(array(
253 253
 						'LIN_name'=>$tax->name(),
254 254
 						'LIN_desc'=>$tax->desc(),
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
275 275
 	 * @return float
276 276
 	 */
277
-	public static function ensure_taxes_applied( $total_line_item ){
278
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
279
-		if( ! $taxes_subtotal->children()){
280
-			self::apply_taxes( $total_line_item );
277
+	public static function ensure_taxes_applied($total_line_item) {
278
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
279
+		if ( ! $taxes_subtotal->children()) {
280
+			self::apply_taxes($total_line_item);
281 281
 		}
282 282
 		return $taxes_subtotal->total();
283 283
 	}
@@ -290,27 +290,27 @@  discard block
 block discarded – undo
290 290
 	 * @param array|bool|string $line_item_codes
291 291
 	 * @return int number of items successfully removed
292 292
 	 */
293
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
293
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
294 294
 
295
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
295
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
296 296
 
297 297
 		// check if only a single line_item_id was passed
298
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
298
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
299 299
 			// place single line_item_id in an array to appear as multiple line_item_ids
300
-			$line_item_codes = array ( $line_item_codes );
300
+			$line_item_codes = array($line_item_codes);
301 301
 		}
302 302
 
303
-		$items_line_item = self::get_items_subtotal( $total_line_item );
304
-		if( ! $items_line_item){
303
+		$items_line_item = self::get_items_subtotal($total_line_item);
304
+		if ( ! $items_line_item) {
305 305
 			return 0;
306 306
 		}
307 307
 		$removals = 0;
308 308
 		// cycle thru line_item_ids
309
-		foreach ( $line_item_codes as $line_item_id ) {
309
+		foreach ($line_item_codes as $line_item_id) {
310 310
 			$removals += $items_line_item->delete_child_line_item($line_item_id);
311 311
 		}
312 312
 
313
-		if ( $removals > 0 ) {
313
+		if ($removals > 0) {
314 314
 			$total_line_item->recalculate_taxes_and_tax_total();
315 315
 			return $removals;
316 316
 		} else {
@@ -327,23 +327,23 @@  discard block
 block discarded – undo
327 327
 	 * @param string $description
328 328
 	 * @return EE_Line_Item the new tax line item created
329 329
 	 */
330
-	public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL ){
330
+	public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL) {
331 331
 		//first: remove all tax descendants
332 332
 		//add this as a new tax descendant
333
-		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
333
+		$tax_subtotal = self::get_taxes_subtotal($total_line_item);
334 334
 		$tax_subtotal->delete_children_line_items();
335 335
 		$taxable_total = $total_line_item->taxable_total();
336 336
 		$new_tax = EE_Line_Item::new_instance(array(
337 337
 			'TXN_ID' => $total_line_item->TXN_ID(),
338 338
 			'LIN_name' => $name ? $name : __('Tax', 'event_espresso'),
339 339
 			'LIN_desc' => $description ? $description : '',
340
-			'LIN_percent' => $taxable_total ? ( $amount / $total_line_item->taxable_total()  * 100 ) : 0,
340
+			'LIN_percent' => $taxable_total ? ($amount / $total_line_item->taxable_total() * 100) : 0,
341 341
 			'LIN_total' => $amount,
342 342
 			'LIN_parent' => $tax_subtotal->ID(),
343 343
 			'LIN_type' => EEM_Line_Item::type_tax
344 344
 		));
345 345
 		$new_tax->save();
346
-		$tax_subtotal->set_total( $amount );
346
+		$tax_subtotal->set_total($amount);
347 347
 		$tax_subtotal->save();
348 348
 		$total_line_item->recalculate_total_including_taxes();
349 349
 		return $new_tax;
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 * @param int $indentation
356 356
 	 * @return void
357 357
 	 */
358
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
358
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
359 359
 		echo "\r\n";
360
-		for( $i = 0; $i < $indentation; $i++ ){
360
+		for ($i = 0; $i < $indentation; $i++) {
361 361
 			echo "-";
362 362
 		}
363
-		echo $line_item->name() . ": " . $line_item->type() . " $" . $line_item->total();
364
-		if( $line_item->is_taxable() ){
363
+		echo $line_item->name().": ".$line_item->type()." $".$line_item->total();
364
+		if ($line_item->is_taxable()) {
365 365
 			echo " taxable";
366 366
 		}
367
-		if( $line_item->children() ){
368
-			foreach($line_item->children() as $child){
367
+		if ($line_item->children()) {
368
+			foreach ($line_item->children() as $child) {
369 369
 				self::visualize($child, $indentation + 1);
370 370
 			}
371 371
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@
 block discarded – undo
61 61
 			$first_item = reset($arr);
62 62
 			if(is_array($first_item)){
63 63
 				return true;//yep, there's at least 2 levels to this array
64
-			}else{
64
+			} else{
65 65
 				return false;//nope, only 1 level
66 66
 			}
67
-		}else{
67
+		} else{
68 68
 			return false;//its not an array at all!
69 69
 		}
70 70
 	}
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Recipient_List_Shortcodes.lib.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -109,6 +109,9 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 
112
+	/**
113
+	 * @param EE_Registration $reg
114
+	 */
112 115
 	private function _get_tickets_from_event( EE_Event $event, $reg = NULL ) {
113 116
 		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs'] : array();
114 117
 
@@ -177,6 +180,9 @@  discard block
 block discarded – undo
177 180
 
178 181
 
179 182
 
183
+	/**
184
+	 * @param EE_Registration $reg
185
+	 */
180 186
 	private function _get_datetimes_from_event( EE_Event $event, $reg = NULL ) {
181 187
 		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] : array();
182 188
 
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 
44 44
 
45 45
 
46
-	protected function _parser( $shortcode ) {
47
-		switch ( $shortcode ) {
46
+	protected function _parser($shortcode) {
47
+		switch ($shortcode) {
48 48
 			case '[RECIPIENT_TICKET_LIST]' :
49 49
 				return $this->_get_recipient_ticket_list();
50 50
 				break;
@@ -64,58 +64,58 @@  discard block
 block discarded – undo
64 64
 	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
65 65
 	 * @return string
66 66
 	 */
67
-	private function _get_recipient_ticket_list( $primary = FALSE ) {
67
+	private function _get_recipient_ticket_list($primary = FALSE) {
68 68
 		$this->_validate_list_requirements();
69 69
 		$this->_set_shortcode_helper();
70 70
 
71
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee )
72
-			return $this->_get_recipient_ticket_list_parsed( $this->_data['data'], $primary );
71
+		if ($this->_data['data'] instanceof EE_Messages_Addressee)
72
+			return $this->_get_recipient_ticket_list_parsed($this->_data['data'], $primary);
73 73
 
74
-		else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee )
75
-			return $this->_get_recipient_ticket_list_parsed( $this->_extra_data['data'], $primary );
74
+		else if ($this->_extra_data['data'] instanceof EE_Messages_Addressee)
75
+			return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data'], $primary);
76 76
 
77 77
 		else
78 78
 			return '';
79 79
 	}
80 80
 
81 81
 
82
-	private function _get_recipient_ticket_list_parsed( EE_Messages_Addressee $data, $primary = FALSE ) {
82
+	private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data, $primary = FALSE) {
83 83
 		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
84
-			if ( ! $registration instanceof EE_Registration ) return '';
84
+			if ( ! $registration instanceof EE_Registration) return '';
85 85
 		//setup valid shortcodes depending on what the status of the $this->_data property is
86
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
87
-			$valid_shortcodes = array('ticket', 'event_list', 'attendee_list','datetime_list', 'registration_details', 'attendee');
86
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
87
+			$valid_shortcodes = array('ticket', 'event_list', 'attendee_list', 'datetime_list', 'registration_details', 'attendee');
88 88
 			$template = $this->_data['template'];
89 89
 			$tkts = array($data->registrations[$registration->ID()]['tkt_obj']);
90 90
 			$data = $this->_data;
91
-		} elseif ( $this->_data['data'] instanceof EE_Event ) {
91
+		} elseif ($this->_data['data'] instanceof EE_Event) {
92 92
 			$valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee');
93
-			$template = is_array($this->_data['template'] ) && isset($this->_data['template']['ticket_list']) ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
93
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list'];
94 94
 			//let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion.
95 95
 			$template = str_replace('[EVENT_LIST]', '', $template);
96 96
 			//data will be tickets for this event for this recipient.
97
-			$tkts = $this->_get_tickets_from_event( $this->_data['data'], $registration );
97
+			$tkts = $this->_get_tickets_from_event($this->_data['data'], $registration);
98 98
 			$data = $this->_extra_data;
99 99
 		} else {
100 100
 			return '';
101 101
 		}
102 102
 
103 103
 		$tkt_parsed = '';
104
-		foreach ( $tkts as $ticket ) {
105
-			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( $template, $ticket, $valid_shortcodes, $this->_extra_data );
104
+		foreach ($tkts as $ticket) {
105
+			$tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template($template, $ticket, $valid_shortcodes, $this->_extra_data);
106 106
 		}
107 107
 		return $tkt_parsed;
108 108
 	}
109 109
 
110 110
 
111
-	private function _get_tickets_from_event( EE_Event $event, $reg = NULL ) {
111
+	private function _get_tickets_from_event(EE_Event $event, $reg = NULL) {
112 112
 		$evt_tkts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs'] : array();
113 113
 
114
-		if ( $reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee ) {
114
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
115 115
 			$adj_tkts = array();
116 116
 			//return only tickets for the given attendee
117
-			foreach ( $evt_tkts as $tkt ) {
118
-				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'] ) && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID() )
117
+			foreach ($evt_tkts as $tkt) {
118
+				if (isset($this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']) && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID())
119 119
 					$adj_tkts[] = $tkt;
120 120
 			}
121 121
 			$evt_tkts = $adj_tkts;
@@ -132,58 +132,58 @@  discard block
 block discarded – undo
132 132
 	 * @param  boolean $primary whether we're getting the primary registrant ticket_list.
133 133
 	 * @return string
134 134
 	 */
135
-	private function _get_recipient_datetime_list( $primary = FALSE ) {
135
+	private function _get_recipient_datetime_list($primary = FALSE) {
136 136
 		$this->_validate_list_requirements();
137 137
 		$this->_set_shortcode_helper();
138 138
 
139
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee )
140
-			return $this->_get_recipient_datetime_list_parsed( $this->_data['data'], $primary );
139
+		if ($this->_data['data'] instanceof EE_Messages_Addressee)
140
+			return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
141 141
 
142
-		else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee )
143
-			return $this->_get_recipient_datetime_list_parsed( $this->_extra_data['data'], $primary );
142
+		else if ($this->_extra_data['data'] instanceof EE_Messages_Addressee)
143
+			return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data'], $primary);
144 144
 
145 145
 		else
146 146
 			return '';
147 147
 
148
-		return $this->_get_recipient_datetime_list_parsed( $this->_data['data'], $primary);
148
+		return $this->_get_recipient_datetime_list_parsed($this->_data['data'], $primary);
149 149
 	}
150 150
 
151 151
 
152
-	private function _get_recipient_datetime_list_parsed( EE_Messages_Addressee $data, $primary = FALSE ) {
152
+	private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data, $primary = FALSE) {
153 153
 		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
154
-		if ( ! $registration instanceof EE_Registration ) return '';
154
+		if ( ! $registration instanceof EE_Registration) return '';
155 155
 		//setup valid shortcodes depending on what the status of the $this->_data property is
156
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
156
+		if ($this->_data['data'] instanceof EE_Messages_Addressee) {
157 157
 			$valid_shortcodes = array('datetime', 'attendee');
158 158
 			$template = $this->_data['template'];
159 159
 			$dtts = $data->registrations[$registration->ID()]['dtt_objs'];
160 160
 			$data = $this->_data;
161
-		} elseif ( $this->_data['data'] instanceof EE_Event ) {
161
+		} elseif ($this->_data['data'] instanceof EE_Event) {
162 162
 			$valid_shortcodes = array('datetime', 'attendee');
163
-			$template = is_array($this->_data['template'] ) && isset($this->_data['template']['datetime_list']) ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
164
-			$dtts = $this->_get_datetimes_from_event( $this->_data['data'], $registration );
163
+			$template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list'];
164
+			$dtts = $this->_get_datetimes_from_event($this->_data['data'], $registration);
165 165
 			$data = $this->_extra_data;
166 166
 		} else {
167 167
 			return '';
168 168
 		}
169 169
 
170 170
 		$dtt_parsed = '';
171
-		foreach ( $dtts as $datetime ) {
172
-			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( $template, $datetime, $valid_shortcodes, $this->_extra_data );
171
+		foreach ($dtts as $datetime) {
172
+			$dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template($template, $datetime, $valid_shortcodes, $this->_extra_data);
173 173
 		}
174 174
 		return $dtt_parsed;
175 175
 	}
176 176
 
177 177
 
178 178
 
179
-	private function _get_datetimes_from_event( EE_Event $event, $reg = NULL ) {
179
+	private function _get_datetimes_from_event(EE_Event $event, $reg = NULL) {
180 180
 		$evt_dtts = isset($this->_extra_data['data']->events) ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] : array();
181 181
 
182
-		if ( $reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee ) {
182
+		if ($reg instanceof EE_Registration && $this->_extra_data['data'] instanceof EE_Messages_Addressee) {
183 183
 			$adj_dtts = array();
184 184
 			//return only dtts for the given attendee
185
-			foreach ( $evt_dtts as $dtt ) {
186
-				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()] ) )
185
+			foreach ($evt_dtts as $dtt) {
186
+				if (isset($this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()]))
187 187
 					$adj_dtts[] = $dtt;
188 188
 			}
189 189
 			$evt_dtts = $adj_dtts;
Please login to merge, or discard this patch.
Braces   +26 added lines, -22 removed lines patch added patch discarded remove patch
@@ -69,20 +69,21 @@  discard block
 block discarded – undo
69 69
 		$this->_validate_list_requirements();
70 70
 		$this->_set_shortcode_helper();
71 71
 
72
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee )
73
-			return $this->_get_recipient_ticket_list_parsed( $this->_data['data'], $primary );
74
-
75
-		else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee )
76
-			return $this->_get_recipient_ticket_list_parsed( $this->_extra_data['data'], $primary );
77
-
78
-		else
79
-			return '';
72
+		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
73
+					return $this->_get_recipient_ticket_list_parsed( $this->_data['data'], $primary );
74
+		} else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee ) {
75
+					return $this->_get_recipient_ticket_list_parsed( $this->_extra_data['data'], $primary );
76
+		} else {
77
+					return '';
78
+		}
80 79
 	}
81 80
 
82 81
 
83 82
 	private function _get_recipient_ticket_list_parsed( EE_Messages_Addressee $data, $primary = FALSE ) {
84 83
 		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
85
-			if ( ! $registration instanceof EE_Registration ) return '';
84
+			if ( ! $registration instanceof EE_Registration ) {
85
+				return '';
86
+			}
86 87
 		//setup valid shortcodes depending on what the status of the $this->_data property is
87 88
 		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
88 89
 			$valid_shortcodes = array('ticket', 'event_list', 'attendee_list','datetime_list', 'registration_details', 'attendee');
@@ -116,8 +117,9 @@  discard block
 block discarded – undo
116 117
 			$adj_tkts = array();
117 118
 			//return only tickets for the given attendee
118 119
 			foreach ( $evt_tkts as $tkt ) {
119
-				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'] ) && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID() )
120
-					$adj_tkts[] = $tkt;
120
+				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj'] ) && $this->_extra_data['data']->registrations[$reg->ID()]['tkt_obj']->ID() == $tkt->ID() ) {
121
+									$adj_tkts[] = $tkt;
122
+				}
121 123
 			}
122 124
 			$evt_tkts = $adj_tkts;
123 125
 		}
@@ -137,14 +139,13 @@  discard block
 block discarded – undo
137 139
 		$this->_validate_list_requirements();
138 140
 		$this->_set_shortcode_helper();
139 141
 
140
-		if ( $this->_data['data'] instanceof EE_Messages_Addressee )
141
-			return $this->_get_recipient_datetime_list_parsed( $this->_data['data'], $primary );
142
-
143
-		else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee )
144
-			return $this->_get_recipient_datetime_list_parsed( $this->_extra_data['data'], $primary );
145
-
146
-		else
147
-			return '';
142
+		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
143
+					return $this->_get_recipient_datetime_list_parsed( $this->_data['data'], $primary );
144
+		} else if ( $this->_extra_data['data'] instanceof EE_Messages_Addressee ) {
145
+					return $this->_get_recipient_datetime_list_parsed( $this->_extra_data['data'], $primary );
146
+		} else {
147
+					return '';
148
+		}
148 149
 
149 150
 		return $this->_get_recipient_datetime_list_parsed( $this->_data['data'], $primary);
150 151
 	}
@@ -152,7 +153,9 @@  discard block
 block discarded – undo
152 153
 
153 154
 	private function _get_recipient_datetime_list_parsed( EE_Messages_Addressee $data, $primary = FALSE ) {
154 155
 		$registration = $primary ? $data->primary_reg_obj : $data->reg_obj;
155
-		if ( ! $registration instanceof EE_Registration ) return '';
156
+		if ( ! $registration instanceof EE_Registration ) {
157
+			return '';
158
+		}
156 159
 		//setup valid shortcodes depending on what the status of the $this->_data property is
157 160
 		if ( $this->_data['data'] instanceof EE_Messages_Addressee ) {
158 161
 			$valid_shortcodes = array('datetime', 'attendee');
@@ -184,8 +187,9 @@  discard block
 block discarded – undo
184 187
 			$adj_dtts = array();
185 188
 			//return only dtts for the given attendee
186 189
 			foreach ( $evt_dtts as $dtt ) {
187
-				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()] ) )
188
-					$adj_dtts[] = $dtt;
190
+				if ( isset( $this->_extra_data['data']->registrations[$reg->ID()]['dtt_objs'][$dtt->ID()] ) ) {
191
+									$adj_dtts[] = $dtt;
192
+				}
189 193
 			}
190 194
 			$evt_dtts = $adj_dtts;
191 195
 		}
Please login to merge, or discard this patch.
general_settings/help_tabs/general_settings_templates.help_tab.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 </li>
34 34
 <li>
35 35
 <strong><?php _e('Display Descriptions', 'event_espresso'); ?></strong><br />
36
-<?php printf( __('Whether descriptions should be shown on the event list page.%sSelecting "none" will NOT display any of the text content you entered into the main text editor on the event admin page.%sSelecting "excerpt" will display the text you entered into the "Excerpt" textarea on the event admin page, OR, any text in the main text editor above the "' . htmlentities( '<!--more-->' ) . '" tag.%sSelecting "full description" will display ALL of the text content you entered into the main text editor on the event admin page.', 'event_espresso'), '<br/>', '<br/>', '<br/>' );?>
36
+<?php printf(__('Whether descriptions should be shown on the event list page.%sSelecting "none" will NOT display any of the text content you entered into the main text editor on the event admin page.%sSelecting "excerpt" will display the text you entered into the "Excerpt" textarea on the event admin page, OR, any text in the main text editor above the "'.htmlentities('<!--more-->').'" tag.%sSelecting "full description" will display ALL of the text content you entered into the main text editor on the event admin page.', 'event_espresso'), '<br/>', '<br/>', '<br/>'); ?>
37 37
 </li>
38 38
 <li>
39 39
 <strong><?php _e('Display Ticket Selector', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.