Completed
Branch BUG-7537 (396ea7)
by
unknown
310:09 queued 289:41
created
core/db_classes/EE_Ticket.class.php 3 patches
Doc Comments   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 	/**
199 199
 	 * Gets min
200
-	 * @return int
200
+	 * @return boolean
201 201
 	 */
202 202
 	function min() {
203 203
 		return $this->get( 'TKT_min' );
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * This returns the chronologically last datetime that this ticket is associated with
240 240
 	 * @param string 	$dt_frmt
241 241
 	 * @param string 	$conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
242
-	 * @return array
242
+	 * @return string
243 243
 	 */
244 244
 	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
245 245
 		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	/**
381 381
 	 * Gets all the ticket applicabilities (ie, relations between datetimes and tickets)
382 382
 	 * @param array $query_params see EEM_Base::get_all()
383
-	 * @return EE_Datetime_Ticket
383
+	 * @return EE_Base_Class[]
384 384
 	 */
385 385
 	public function datetime_tickets( $query_params = array() ) {
386 386
 		return $this->get_many_related( 'Datetime_Ticket', $query_params );
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 
403 403
 	/**
404 404
 	 * Gets ID
405
-	 * @return string
405
+	 * @return boolean
406 406
 	 */
407 407
 	function ID() {
408 408
 		return $this->get( 'TKT_ID' );
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 *
417 417
 	 * @since 4.5.0
418 418
 	 *
419
-	 * @return int
419
+	 * @return boolean
420 420
 	 */
421 421
 	public function wp_user() {
422 422
 		return $this->get('TKT_wp_user');
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 	/**
515 515
 	 * Sets name
516 516
 	 * @param string $name
517
-	 * @return boolean
517
+	 * @return boolean|null
518 518
 	 */
519 519
 	function set_name( $name ) {
520 520
 		$this->set( 'TKT_name', $name );
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
 	/**
526 526
 	 * Gets description
527
-	 * @return string
527
+	 * @return boolean
528 528
 	 */
529 529
 	function description() {
530 530
 		return $this->get( 'TKT_description' );
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	/**
536 536
 	 * Sets description
537 537
 	 * @param string $description
538
-	 * @return boolean
538
+	 * @return boolean|null
539 539
 	 */
540 540
 	function set_description( $description ) {
541 541
 		$this->set( 'TKT_description', $description );
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	/**
606 606
 	 * Sets min
607 607
 	 * @param int $min
608
-	 * @return boolean
608
+	 * @return boolean|null
609 609
 	 */
610 610
 	function set_min( $min ) {
611 611
 		$this->set( 'TKT_min', $min );
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 
616 616
 	/**
617 617
 	 * Gets max
618
-	 * @return int
618
+	 * @return boolean
619 619
 	 */
620 620
 	function max() {
621 621
 		return $this->get( 'TKT_max' );
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	/**
627 627
 	 * Sets max
628 628
 	 * @param int $max
629
-	 * @return boolean
629
+	 * @return boolean|null
630 630
 	 */
631 631
 	function set_max( $max ) {
632 632
 		$this->set( 'TKT_max', $max );
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	/**
638 638
 	 * Sets price
639 639
 	 * @param float $price
640
-	 * @return boolean
640
+	 * @return boolean|null
641 641
 	 */
642 642
 	function set_price( $price ) {
643 643
 		$this->set( 'TKT_price', $price );
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	/**
659 659
 	 * increments sold by amount passed by $qty
660 660
 	 * @param int $qty
661
-	 * @return boolean
661
+	 * @return boolean|null
662 662
 	 */
663 663
 	function increase_sold( $qty = 1 ) {
664 664
 		$sold = $this->sold() + $qty;
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	/**
672 672
 	 * Increases sold on related datetimes
673 673
 	 * @param int $qty
674
-	 * @return boolean
674
+	 * @return boolean|null
675 675
 	 */
676 676
 	protected function _increase_sold_for_datetimes( $qty = 1 ) {
677 677
 		$datetimes = $this->datetimes();
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	/**
691 691
 	 * Sets sold
692 692
 	 * @param int $sold
693
-	 * @return boolean
693
+	 * @return boolean|null
694 694
 	 */
695 695
 	function set_sold( $sold ) {
696 696
 		// sold can not go below zero
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	/**
704 704
 	 * decrements (subtracts) sold by amount passed by $qty
705 705
 	 * @param int $qty
706
-	 * @return boolean
706
+	 * @return boolean|null
707 707
 	 */
708 708
 	function decrease_sold( $qty = 1 ) {
709 709
 		$sold = $this->sold() - $qty;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 	* Decreases sold on related datetimes
718 718
 	*
719 719
 	* @param int $qty
720
-	* @return boolean
720
+	* @return boolean|null
721 721
 	*/
722 722
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
723 723
 		$datetimes = $this->datetimes();
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 	 * Sets qty - IMPORTANT!!! Does NOT allow QTY to be set higher than the lowest reg limit of any related datetimes
809 809
 	 *
810 810
 	 * @param int  $qty
811
-	 * @return bool
811
+	 * @return boolean|null
812 812
 	 * @throws \EE_Error
813 813
 	 */
814 814
 	function set_qty( $qty ) {
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 
826 826
 	/**
827 827
 	 * Gets uses
828
-	 * @return int
828
+	 * @return boolean
829 829
 	 */
830 830
 	function uses() {
831 831
 		return $this->get( 'TKT_uses' );
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 	/**
837 837
 	 * Sets uses
838 838
 	 * @param int $uses
839
-	 * @return boolean
839
+	 * @return boolean|null
840 840
 	 */
841 841
 	function set_uses( $uses ) {
842 842
 		$this->set( 'TKT_uses', $uses );
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 	/**
858 858
 	 * sets the TKT_required property
859 859
 	 * @param boolean $required
860
-	 * @return boolean
860
+	 * @return boolean|null
861 861
 	 */
862 862
 	public function set_required( $required ) {
863 863
 		$this->set( 'TKT_required', $required );
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 	/**
879 879
 	 * Sets taxable
880 880
 	 * @param boolean $taxable
881
-	 * @return boolean
881
+	 * @return boolean|null
882 882
 	 */
883 883
 	function set_taxable( $taxable ) {
884 884
 		$this->set( 'TKT_taxable', $taxable );
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	/**
900 900
 	 * Sets is_default
901 901
 	 * @param boolean $is_default
902
-	 * @return boolean
902
+	 * @return boolean|null
903 903
 	 */
904 904
 	function set_is_default( $is_default ) {
905 905
 		$this->set( 'TKT_is_default', $is_default );
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 
910 910
 	/**
911 911
 	 * Gets order
912
-	 * @return int
912
+	 * @return boolean
913 913
 	 */
914 914
 	function order() {
915 915
 		return $this->get( 'TKT_order' );
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 	/**
921 921
 	 * Sets order
922 922
 	 * @param int $order
923
-	 * @return boolean
923
+	 * @return boolean|null
924 924
 	 */
925 925
 	function set_order( $order ) {
926 926
 		$this->set( 'TKT_order', $order );
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 
931 931
 	/**
932 932
 	 * Gets row
933
-	 * @return int
933
+	 * @return boolean
934 934
 	 */
935 935
 	function row() {
936 936
 		return $this->get( 'TKT_row' );
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 	/**
942 942
 	 * Sets row
943 943
 	 * @param int $row
944
-	 * @return boolean
944
+	 * @return boolean|null
945 945
 	 */
946 946
 	function set_row( $row ) {
947 947
 		$this->set( 'TKT_row', $row );
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 	/**
963 963
 	 * Sets deleted
964 964
 	 * @param boolean $deleted
965
-	 * @return boolean
965
+	 * @return boolean|null
966 966
 	 */
967 967
 	function set_deleted( $deleted ) {
968 968
 		$this->set( 'TKT_deleted', $deleted );
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
 
973 973
 	/**
974 974
 	 * Gets parent
975
-	 * @return int
975
+	 * @return boolean
976 976
 	 */
977 977
 	function parent_ID() {
978 978
 		return $this->get( 'TKT_parent' );
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
 	/**
984 984
 	 * Sets parent
985 985
 	 * @param int $parent
986
-	 * @return boolean
986
+	 * @return boolean|null
987 987
 	 */
988 988
 	function set_parent_ID( $parent ) {
989 989
 		$this->set( 'TKT_parent', $parent );
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 
1008 1008
 	/**
1009 1009
 	 * Gets name
1010
-	 * @return string
1010
+	 * @return boolean
1011 1011
 	 */
1012 1012
 	function name() {
1013 1013
 		return $this->get( 'TKT_name' );
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 
1018 1018
 	/**
1019 1019
 	 * Gets price
1020
-	 * @return float
1020
+	 * @return boolean
1021 1021
 	 */
1022 1022
 	function price() {
1023 1023
 		return $this->get( 'TKT_price' );
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@  discard block
 block discarded – undo
2 2
 	exit( 'No direct script access allowed' );
3 3
 }
4 4
 /**
5
- * Event Espresso
6
- *
7
- * Event Registration and Management Plugin for WordPress
8
- *
9
- * @ package 		Event Espresso
10
- * @ author 		Event Espresso
11
- * @ copyright 	(c) 2008-2011 Event Espresso  All Rights Reserved.
12
- * @ license 		{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
- * @ link 				{@link http://www.eventespresso.com}
14
- * @ since 			4.0
15
- *
16
- */
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Management Plugin for WordPress
8
+	 *
9
+	 * @ package 		Event Espresso
10
+	 * @ author 		Event Espresso
11
+	 * @ copyright 	(c) 2008-2011 Event Espresso  All Rights Reserved.
12
+	 * @ license 		{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
13
+	 * @ link 				{@link http://www.eventespresso.com}
14
+	 * @ since 			4.0
15
+	 *
16
+	 */
17 17
 
18 18
 
19 19
 
@@ -714,11 +714,11 @@  discard block
 block discarded – undo
714 714
 
715 715
 
716 716
 	/**
717
-	* Decreases sold on related datetimes
718
-	*
719
-	* @param int $qty
720
-	* @return boolean
721
-	*/
717
+	 * Decreases sold on related datetimes
718
+	 *
719
+	 * @param int $qty
720
+	 * @return boolean
721
+	 */
722 722
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
723 723
 		$datetimes = $this->datetimes();
724 724
 		if ( is_array( $datetimes ) ) {
Please login to merge, or discard this patch.
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *                             		    date_format and the second value is the time format
67 67
 	 * @return EE_Ticket
68 68
 	 */
69
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
70
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
71
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
69
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
70
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
71
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
72 72
 	}
73 73
 
74 74
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 *                          		the website will be used.
80 80
 	 * @return EE_Ticket
81 81
 	 */
82
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
83
-		return new self( $props_n_values, TRUE, $timezone );
82
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
83
+		return new self($props_n_values, TRUE, $timezone);
84 84
 	}
85 85
 
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return bool
90 90
 	 */
91 91
 	public function parent() {
92
-		return $this->get( 'TKT_parent' );
92
+		return $this->get('TKT_parent');
93 93
 	}
94 94
 
95 95
 
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @param  int $DTT_ID the primary key for a particular datetime
100 100
 	 * @return boolean
101 101
 	 */
102
-	public function available( $DTT_ID = 0 ) {
102
+	public function available($DTT_ID = 0) {
103 103
 		// are we checking availability for a particular datetime ?
104
-		if ( $DTT_ID ) {
104
+		if ($DTT_ID) {
105 105
 			// get that datetime object
106
-			$datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
106
+			$datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
107 107
 			// if  ticket sales for this datetime have exceeded the reg limit...
108
-			if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) {
108
+			if ($datetime instanceof EE_Datetime && $datetime->sold_out()) {
109 109
 				return FALSE;
110 110
 			}
111 111
 		}
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
 	 * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const
121 121
 	 * @return mixed(int|string) status int if the display string isn't requested
122 122
 	 */
123
-	public function ticket_status( $display = FALSE ) {
124
-		if ( ! $this->is_remaining() ) {
125
-			return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out;
123
+	public function ticket_status($display = FALSE) {
124
+		if ( ! $this->is_remaining()) {
125
+			return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out;
126 126
 		}
127
-		if ( $this->get( 'TKT_deleted' ) ) {
128
-			return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived;
127
+		if ($this->get('TKT_deleted')) {
128
+			return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived;
129 129
 		}
130
-		if ( $this->is_expired() ) {
131
-			return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired;
130
+		if ($this->is_expired()) {
131
+			return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired;
132 132
 		}
133
-		if ( $this->is_pending() ) {
134
-			return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending;
133
+		if ($this->is_pending()) {
134
+			return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending;
135 135
 		}
136
-		if ( $this->is_on_sale() ) {
137
-			return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale;
136
+		if ($this->is_on_sale()) {
137
+			return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale;
138 138
 		}
139 139
 		return '';
140 140
 	}
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
149 149
 	 * @return boolean         true = tickets remaining, false not.
150 150
 	 */
151
-	public function is_remaining( $DTT_ID = 0 ) {
152
-		$num_remaining = $this->remaining( $DTT_ID );
153
-		if ( $num_remaining === 0 ) {
151
+	public function is_remaining($DTT_ID = 0) {
152
+		$num_remaining = $this->remaining($DTT_ID);
153
+		if ($num_remaining === 0) {
154 154
 			return FALSE;
155 155
 		}
156
-		if ( $num_remaining > 0 && $num_remaining < $this->min() ) {
156
+		if ($num_remaining > 0 && $num_remaining < $this->min()) {
157 157
 			return FALSE;
158 158
 		}
159 159
 		return TRUE;
@@ -167,25 +167,25 @@  discard block
 block discarded – undo
167 167
 	 *                     all related datetimes
168 168
 	 * @return int
169 169
 	 */
170
-	public function remaining( $DTT_ID = 0 ) {
170
+	public function remaining($DTT_ID = 0) {
171 171
 		// are we checking availability for a particular datetime ?
172
-		if ( $DTT_ID ) {
172
+		if ($DTT_ID) {
173 173
 			// get array with the one requested datetime
174
-			$datetimes = $this->get_many_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
174
+			$datetimes = $this->get_many_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
175 175
 		} else {
176 176
 			// we need to check availability of ALL datetimes
177
-			$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
177
+			$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
178 178
 		}
179 179
 		//		d( $datetimes );
180 180
 		// if datetime reg limit is not unlimited
181
-		if ( ! empty( $datetimes ) ) {
181
+		if ( ! empty($datetimes)) {
182 182
 			// although TKT_qty and $datetime->spaces_remaining() could both be EE_INF
183 183
 			// we only need to check for EE_INF explicitly if we want to optimize.
184 184
 			// because EE_INF - x = EE_INF; and min(x,EE_INF) = x;
185 185
 			$tickets_remaining = $this->qty() - $this->sold();
186
-			foreach ( $datetimes as $datetime ) {
187
-				if ( $datetime instanceof EE_Datetime ) {
188
-					$tickets_remaining = min( $tickets_remaining, $datetime->spaces_remaining() );
186
+			foreach ($datetimes as $datetime) {
187
+				if ($datetime instanceof EE_Datetime) {
188
+					$tickets_remaining = min($tickets_remaining, $datetime->spaces_remaining());
189 189
 				}
190 190
 			}
191 191
 			return $tickets_remaining;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return int
201 201
 	 */
202 202
 	function min() {
203
-		return $this->get( 'TKT_min' );
203
+		return $this->get('TKT_min');
204 204
 	}
205 205
 
206 206
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @return boolean
211 211
 	 */
212 212
 	public function is_expired() {
213
-		return ( $this->get_raw( 'TKT_end_date' ) < time() );
213
+		return ($this->get_raw('TKT_end_date') < time());
214 214
 	}
215 215
 
216 216
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function is_pending() {
223
-		return ( $this->get_raw( 'TKT_start_date' ) > time() );
223
+		return ($this->get_raw('TKT_start_date') > time());
224 224
 	}
225 225
 
226 226
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return boolean
231 231
 	 */
232 232
 	public function is_on_sale() {
233
-		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
233
+		return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time());
234 234
 	}
235 235
 
236 236
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 * @param string 	$conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
242 242
 	 * @return array
243 243
 	 */
244
-	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
245
-		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
246
-		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
244
+	public function date_range($dt_frmt = '', $conjunction = ' - ') {
245
+		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : '';
246
+		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : '';
247 247
 
248
-		return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
248
+		return $first_date && $last_date ? $first_date.$conjunction.$last_date : '';
249 249
 	}
250 250
 
251 251
 
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @return EE_Datetime
256 256
 	 */
257 257
 	public function first_datetime() {
258
-		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
259
-		return reset( $datetimes );
258
+		$datetimes = $this->datetimes(array('limit' => 1));
259
+		return reset($datetimes);
260 260
 	}
261 261
 
262 262
 
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 	 * @param array $query_params see EEM_Base::get_all()
268 268
 	 * @return EE_Datetime[]
269 269
 	 */
270
-	public function datetimes( $query_params = array() ) {
271
-		if ( ! isset( $query_params[ 'order_by' ] ) ) {
272
-			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
270
+	public function datetimes($query_params = array()) {
271
+		if ( ! isset($query_params['order_by'])) {
272
+			$query_params['order_by']['DTT_order'] = 'ASC';
273 273
 		}
274
-		return $this->get_many_related( 'Datetime', $query_params );
274
+		return $this->get_many_related('Datetime', $query_params);
275 275
 	}
276 276
 
277 277
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @return EE_Datetime
282 282
 	 */
283 283
 	public function last_datetime() {
284
-		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
285
-		return end( $datetimes );
284
+		$datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC')));
285
+		return end($datetimes);
286 286
 	}
287 287
 
288 288
 
@@ -296,22 +296,22 @@  discard block
 block discarded – undo
296 296
 	 * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
297 297
 	 * @return mixed (array|int)          how many tickets have sold
298 298
 	 */
299
-	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
299
+	public function tickets_sold($what = 'ticket', $dtt_id = NULL) {
300 300
 		$total = 0;
301 301
 		$tickets_sold = $this->_all_tickets_sold();
302
-		switch ( $what ) {
302
+		switch ($what) {
303 303
 			case 'ticket' :
304
-				return $tickets_sold[ 'ticket' ];
304
+				return $tickets_sold['ticket'];
305 305
 				break;
306 306
 			case 'datetime' :
307
-				if ( empty( $tickets_sold[ 'datetime' ] ) ) {
307
+				if (empty($tickets_sold['datetime'])) {
308 308
 					return $total;
309 309
 				}
310
-				if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) {
311
-					EE_Error::add_error( __( "You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
310
+				if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) {
311
+					EE_Error::add_error(__("You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
312 312
 					return $total;
313 313
 				}
314
-				return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ];
314
+				return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id];
315 315
 				break;
316 316
 			default:
317 317
 				return $total;
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 	 * @return EE_Ticket[]
326 326
 	 */
327 327
 	protected function _all_tickets_sold() {
328
-		$datetimes = $this->get_many_related( 'Datetime' );
328
+		$datetimes = $this->get_many_related('Datetime');
329 329
 		$tickets_sold = array();
330
-		if ( ! empty( $datetimes ) ) {
331
-			foreach ( $datetimes as $datetime ) {
332
-				$tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' );
330
+		if ( ! empty($datetimes)) {
331
+			foreach ($datetimes as $datetime) {
332
+				$tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold');
333 333
 			}
334 334
 		}
335 335
 		//Tickets sold
336
-		$tickets_sold[ 'ticket' ] = $this->sold();
336
+		$tickets_sold['ticket'] = $this->sold();
337 337
 		return $tickets_sold;
338 338
 	}
339 339
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 	 * @param  bool $return_array whether to return as an array indexed by price id or just the object.
347 347
 	 * @return EE_Price
348 348
 	 */
349
-	public function base_price( $return_array = FALSE ) {
350
-		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
351
-		return $return_array ? $this->get_many_related( 'Price', array( $_where ) ) : $this->get_first_related( 'Price', array( $_where ) );
349
+	public function base_price($return_array = FALSE) {
350
+		$_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price);
351
+		return $return_array ? $this->get_many_related('Price', array($_where)) : $this->get_first_related('Price', array($_where));
352 352
 	}
353 353
 
354 354
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @return EE_Price[]
361 361
 	 */
362 362
 	public function price_modifiers() {
363
-		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
364
-		return $this->prices( $query_params );
363
+		$query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax))));
364
+		return $this->prices($query_params);
365 365
 	}
366 366
 
367 367
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param array $query_params like EEM_Base::get_all
372 372
 	 * @return EE_Price[]
373 373
 	 */
374
-	public function prices( $query_params = array() ) {
375
-		return $this->get_many_related( 'Price', $query_params );
374
+	public function prices($query_params = array()) {
375
+		return $this->get_many_related('Price', $query_params);
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param array $query_params see EEM_Base::get_all()
383 383
 	 * @return EE_Datetime_Ticket
384 384
 	 */
385
-	public function datetime_tickets( $query_params = array() ) {
386
-		return $this->get_many_related( 'Datetime_Ticket', $query_params );
385
+	public function datetime_tickets($query_params = array()) {
386
+		return $this->get_many_related('Datetime_Ticket', $query_params);
387 387
 	}
388 388
 
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param boolean $show_deleted
395 395
 	 * @return EE_Datetime[]
396 396
 	 */
397
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
398
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
397
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) {
398
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted);
399 399
 	}
400 400
 
401 401
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return string
406 406
 	 */
407 407
 	function ID() {
408
-		return $this->get( 'TKT_ID' );
408
+		return $this->get('TKT_ID');
409 409
 	}
410 410
 
411 411
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @return EE_Ticket_Template
430 430
 	 */
431 431
 	public function template() {
432
-		return $this->get_first_related( 'Ticket_Template' );
432
+		return $this->get_first_related('Ticket_Template');
433 433
 	}
434 434
 
435 435
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @return bool
449 449
 	 */
450 450
 	public function ticket_price() {
451
-		return $this->get( 'TKT_price' );
451
+		return $this->get('TKT_price');
452 452
 	}
453 453
 
454 454
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 * @return mixed
458 458
 	 */
459 459
 	public function pretty_price() {
460
-		return $this->get_pretty( 'TKT_price' );
460
+		return $this->get_pretty('TKT_price');
461 461
 	}
462 462
 
463 463
 
@@ -476,17 +476,17 @@  discard block
 block discarded – undo
476 476
 	 * @param bool $no_cache
477 477
 	 * @return float
478 478
 	 */
479
-	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
480
-		if ( ! isset( $this->_ticket_total_with_taxes ) || $no_cache ) {
479
+	public function get_ticket_total_with_taxes($no_cache = FALSE) {
480
+		if ( ! isset($this->_ticket_total_with_taxes) || $no_cache) {
481 481
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
482 482
 		}
483
-		return (float)$this->_ticket_total_with_taxes;
483
+		return (float) $this->_ticket_total_with_taxes;
484 484
 	}
485 485
 
486 486
 
487 487
 
488 488
 	public function ensure_TKT_Price_correct() {
489
-		$this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) );
489
+		$this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this));
490 490
 		$this->save();
491 491
 	}
492 492
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	 * @return float
497 497
 	 */
498 498
 	public function get_ticket_subtotal() {
499
-		return EE_Taxes::get_subtotal_for_admin( $this );
499
+		return EE_Taxes::get_subtotal_for_admin($this);
500 500
 	}
501 501
 
502 502
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 * @return float
507 507
 	 */
508 508
 	public function get_ticket_taxes_total_for_admin() {
509
-		return EE_Taxes::get_total_taxes_for_admin( $this );
509
+		return EE_Taxes::get_total_taxes_for_admin($this);
510 510
 	}
511 511
 
512 512
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 * @param string $name
517 517
 	 * @return boolean
518 518
 	 */
519
-	function set_name( $name ) {
520
-		$this->set( 'TKT_name', $name );
519
+	function set_name($name) {
520
+		$this->set('TKT_name', $name);
521 521
 	}
522 522
 
523 523
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 * @return string
528 528
 	 */
529 529
 	function description() {
530
-		return $this->get( 'TKT_description' );
530
+		return $this->get('TKT_description');
531 531
 	}
532 532
 
533 533
 
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @param string $description
538 538
 	 * @return boolean
539 539
 	 */
540
-	function set_description( $description ) {
541
-		$this->set( 'TKT_description', $description );
540
+	function set_description($description) {
541
+		$this->set('TKT_description', $description);
542 542
 	}
543 543
 
544 544
 
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @param string $tm_frmt
550 550
 	 * @return string
551 551
 	 */
552
-	function start_date( $dt_frmt = '', $tm_frmt = '' ) {
553
-		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
552
+	function start_date($dt_frmt = '', $tm_frmt = '') {
553
+		return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt);
554 554
 	}
555 555
 
556 556
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 	 * @param string $start_date
561 561
 	 * @return void
562 562
 	 */
563
-	function set_start_date( $start_date ) {
564
-		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
563
+	function set_start_date($start_date) {
564
+		$this->_set_date_time('B', $start_date, 'TKT_start_date');
565 565
 	}
566 566
 
567 567
 
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param string $tm_frmt
573 573
 	 * @return string
574 574
 	 */
575
-	function end_date( $dt_frmt = '', $tm_frmt = '' ) {
576
-		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
575
+	function end_date($dt_frmt = '', $tm_frmt = '') {
576
+		return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt);
577 577
 	}
578 578
 
579 579
 
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @param string $end_date
584 584
 	 * @return void
585 585
 	 */
586
-	function set_end_date( $end_date ) {
587
-		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
586
+	function set_end_date($end_date) {
587
+		$this->_set_date_time('B', $end_date, 'TKT_end_date');
588 588
 	}
589 589
 
590 590
 
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
598 598
 	 */
599
-	function set_end_time( $time ) {
600
-		$this->_set_time_for( $time, 'TKT_end_date' );
599
+	function set_end_time($time) {
600
+		$this->_set_time_for($time, 'TKT_end_date');
601 601
 	}
602 602
 
603 603
 
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @param int $min
608 608
 	 * @return boolean
609 609
 	 */
610
-	function set_min( $min ) {
611
-		$this->set( 'TKT_min', $min );
610
+	function set_min($min) {
611
+		$this->set('TKT_min', $min);
612 612
 	}
613 613
 
614 614
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	 * @return int
619 619
 	 */
620 620
 	function max() {
621
-		return $this->get( 'TKT_max' );
621
+		return $this->get('TKT_max');
622 622
 	}
623 623
 
624 624
 
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 	 * @param int $max
629 629
 	 * @return boolean
630 630
 	 */
631
-	function set_max( $max ) {
632
-		$this->set( 'TKT_max', $max );
631
+	function set_max($max) {
632
+		$this->set('TKT_max', $max);
633 633
 	}
634 634
 
635 635
 
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 * @param float $price
640 640
 	 * @return boolean
641 641
 	 */
642
-	function set_price( $price ) {
643
-		$this->set( 'TKT_price', $price );
642
+	function set_price($price) {
643
+		$this->set('TKT_price', $price);
644 644
 	}
645 645
 
646 646
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 * @return int
651 651
 	 */
652 652
 	function sold() {
653
-		return $this->get_raw( 'TKT_sold' );
653
+		return $this->get_raw('TKT_sold');
654 654
 	}
655 655
 
656 656
 
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 	 * @param int $qty
661 661
 	 * @return boolean
662 662
 	 */
663
-	function increase_sold( $qty = 1 ) {
663
+	function increase_sold($qty = 1) {
664 664
 		$sold = $this->sold() + $qty;
665
-		$this->_increase_sold_for_datetimes( $qty );
666
-		return $this->set_sold( $sold );
665
+		$this->_increase_sold_for_datetimes($qty);
666
+		return $this->set_sold($sold);
667 667
 	}
668 668
 
669 669
 
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
 	 * @param int $qty
674 674
 	 * @return boolean
675 675
 	 */
676
-	protected function _increase_sold_for_datetimes( $qty = 1 ) {
676
+	protected function _increase_sold_for_datetimes($qty = 1) {
677 677
 		$datetimes = $this->datetimes();
678
-		if ( is_array( $datetimes ) ) {
679
-			foreach ( $datetimes as $datetime ) {
680
-				if ( $datetime instanceof EE_Datetime ) {
681
-					$datetime->increase_sold( $qty );
678
+		if (is_array($datetimes)) {
679
+			foreach ($datetimes as $datetime) {
680
+				if ($datetime instanceof EE_Datetime) {
681
+					$datetime->increase_sold($qty);
682 682
 					$datetime->save();
683 683
 				}
684 684
 			}
@@ -692,10 +692,10 @@  discard block
 block discarded – undo
692 692
 	 * @param int $sold
693 693
 	 * @return boolean
694 694
 	 */
695
-	function set_sold( $sold ) {
695
+	function set_sold($sold) {
696 696
 		// sold can not go below zero
697
-		$sold = max( 0, $sold );
698
-		$this->set( 'TKT_sold', $sold );
697
+		$sold = max(0, $sold);
698
+		$this->set('TKT_sold', $sold);
699 699
 	}
700 700
 
701 701
 
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 	 * @param int $qty
706 706
 	 * @return boolean
707 707
 	 */
708
-	function decrease_sold( $qty = 1 ) {
708
+	function decrease_sold($qty = 1) {
709 709
 		$sold = $this->sold() - $qty;
710
-		$this->_decrease_sold_for_datetimes( $qty );
711
-		return $this->set_sold( $sold );
710
+		$this->_decrease_sold_for_datetimes($qty);
711
+		return $this->set_sold($sold);
712 712
 	}
713 713
 
714 714
 
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 	* @param int $qty
720 720
 	* @return boolean
721 721
 	*/
722
-	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
722
+	protected function _decrease_sold_for_datetimes($qty = 1) {
723 723
 		$datetimes = $this->datetimes();
724
-		if ( is_array( $datetimes ) ) {
725
-			foreach ( $datetimes as $datetime ) {
726
-				if ( $datetime instanceof EE_Datetime ) {
727
-					$datetime->decrease_sold( $qty );
724
+		if (is_array($datetimes)) {
725
+			foreach ($datetimes as $datetime) {
726
+				if ($datetime instanceof EE_Datetime) {
727
+					$datetime->decrease_sold($qty);
728 728
 					$datetime->save();
729 729
 				}
730 730
 			}
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 	 *
746 746
 	 * @return int
747 747
 	 */
748
-	function qty( $context = '' ) {
749
-		switch ( $context ) {
748
+	function qty($context = '') {
749
+		switch ($context) {
750 750
 			case 'reg_limit' :
751 751
 				return $this->real_quantity_on_ticket();
752 752
 			case 'saleable' :
753
-				return $this->real_quantity_on_ticket( 'saleable' );
753
+				return $this->real_quantity_on_ticket('saleable');
754 754
 			default:
755
-				return $this->get_raw( 'TKT_qty' );
755
+				return $this->get_raw('TKT_qty');
756 756
 		}
757 757
 	}
758 758
 
@@ -769,38 +769,38 @@  discard block
 block discarded – undo
769 769
 	 *
770 770
 	 * @return int
771 771
 	 */
772
-	function real_quantity_on_ticket( $context = 'reg_limit' ) {
772
+	function real_quantity_on_ticket($context = 'reg_limit') {
773 773
 		// start with the original db value for ticket quantity
774
-		$raw = $this->get_raw( 'TKT_qty' );
774
+		$raw = $this->get_raw('TKT_qty');
775 775
 		// return immediately if it's zero
776
-		if ( $raw === 0 ) {
776
+		if ($raw === 0) {
777 777
 			return $raw;
778 778
 		}
779 779
 		// ensure qty doesn't exceed raw value for THIS ticket
780
-		$qty = min( EE_INF, $raw );
780
+		$qty = min(EE_INF, $raw);
781 781
 		// NOW that we know the  maximum number of tickets available for the ticket
782 782
 		// we need to calculate the maximum number of tickets available for the datetime
783 783
 		// without really factoring this ticket into the calculations
784 784
 		$datetimes = $this->datetimes();
785
-		foreach ( $datetimes as $datetime ) {
786
-			if ( $datetime instanceof EE_Datetime ) {
785
+		foreach ($datetimes as $datetime) {
786
+			if ($datetime instanceof EE_Datetime) {
787 787
 				// initialize with no restrictions for each datetime
788 788
 				// but adjust datetime qty based on datetime reg limit
789
-				$datetime_qty = min( EE_INF, $datetime->reg_limit() );
789
+				$datetime_qty = min(EE_INF, $datetime->reg_limit());
790 790
 				// if we want the actual saleable amount, then we need to consider OTHER ticket sales
791 791
 				// for this datetime, that do NOT include sales for this ticket (so we add THIS ticket's sales back in)
792
-				if ( $context == 'saleable' ) {
793
-					$datetime_qty = max( $datetime_qty - $datetime->sold() + $this->sold(), 0 );
792
+				if ($context == 'saleable') {
793
+					$datetime_qty = max($datetime_qty - $datetime->sold() + $this->sold(), 0);
794 794
 					$datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0;
795 795
 				}
796
-				$qty = min( $datetime_qty, $qty );
796
+				$qty = min($datetime_qty, $qty);
797 797
 			}
798 798
 
799 799
 		}
800 800
 		// we need to factor in the details for this specific ticket
801
-		if ( $qty > 0 && $context == 'saleable' ) {
801
+		if ($qty > 0 && $context == 'saleable') {
802 802
 			// and subtract the sales for THIS ticket
803
-			$qty = max( $qty - $this->sold(), 0 );
803
+			$qty = max($qty - $this->sold(), 0);
804 804
 			//echo '&nbsp; $qty: ' . $qty . "<br />";
805 805
 		}
806 806
 		//echo '$qty: ' . $qty . "<br />";
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
 	 * @return bool
817 817
 	 * @throws \EE_Error
818 818
 	 */
819
-	function set_qty( $qty ) {
819
+	function set_qty($qty) {
820 820
 		$datetimes = $this->datetimes();
821
-		foreach ( $datetimes as $datetime ) {
822
-			if ( $datetime instanceof EE_Datetime ) {
823
-				$qty = min( $qty, $datetime->reg_limit() );
821
+		foreach ($datetimes as $datetime) {
822
+			if ($datetime instanceof EE_Datetime) {
823
+				$qty = min($qty, $datetime->reg_limit());
824 824
 			}
825 825
 		}
826
-		$this->set( 'TKT_qty', $qty );
826
+		$this->set('TKT_qty', $qty);
827 827
 	}
828 828
 
829 829
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	 * @return int
834 834
 	 */
835 835
 	function uses() {
836
-		return $this->get( 'TKT_uses' );
836
+		return $this->get('TKT_uses');
837 837
 	}
838 838
 
839 839
 
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @param int $uses
844 844
 	 * @return boolean
845 845
 	 */
846
-	function set_uses( $uses ) {
847
-		$this->set( 'TKT_uses', $uses );
846
+	function set_uses($uses) {
847
+		$this->set('TKT_uses', $uses);
848 848
 	}
849 849
 
850 850
 
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 	 * @return boolean
855 855
 	 */
856 856
 	public function required() {
857
-		return $this->get( 'TKT_required' );
857
+		return $this->get('TKT_required');
858 858
 	}
859 859
 
860 860
 
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 	 * @param boolean $required
865 865
 	 * @return boolean
866 866
 	 */
867
-	public function set_required( $required ) {
868
-		$this->set( 'TKT_required', $required );
867
+	public function set_required($required) {
868
+		$this->set('TKT_required', $required);
869 869
 	}
870 870
 
871 871
 
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	 * @return boolean
876 876
 	 */
877 877
 	function taxable() {
878
-		return $this->get( 'TKT_taxable' );
878
+		return $this->get('TKT_taxable');
879 879
 	}
880 880
 
881 881
 
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 	 * @param boolean $taxable
886 886
 	 * @return boolean
887 887
 	 */
888
-	function set_taxable( $taxable ) {
889
-		$this->set( 'TKT_taxable', $taxable );
888
+	function set_taxable($taxable) {
889
+		$this->set('TKT_taxable', $taxable);
890 890
 	}
891 891
 
892 892
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 * @return boolean
897 897
 	 */
898 898
 	function is_default() {
899
-		return $this->get( 'TKT_is_default' );
899
+		return $this->get('TKT_is_default');
900 900
 	}
901 901
 
902 902
 
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 	 * @param boolean $is_default
907 907
 	 * @return boolean
908 908
 	 */
909
-	function set_is_default( $is_default ) {
910
-		$this->set( 'TKT_is_default', $is_default );
909
+	function set_is_default($is_default) {
910
+		$this->set('TKT_is_default', $is_default);
911 911
 	}
912 912
 
913 913
 
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 	 * @return int
918 918
 	 */
919 919
 	function order() {
920
-		return $this->get( 'TKT_order' );
920
+		return $this->get('TKT_order');
921 921
 	}
922 922
 
923 923
 
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @param int $order
928 928
 	 * @return boolean
929 929
 	 */
930
-	function set_order( $order ) {
931
-		$this->set( 'TKT_order', $order );
930
+	function set_order($order) {
931
+		$this->set('TKT_order', $order);
932 932
 	}
933 933
 
934 934
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	 * @return int
939 939
 	 */
940 940
 	function row() {
941
-		return $this->get( 'TKT_row' );
941
+		return $this->get('TKT_row');
942 942
 	}
943 943
 
944 944
 
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 	 * @param int $row
949 949
 	 * @return boolean
950 950
 	 */
951
-	function set_row( $row ) {
952
-		$this->set( 'TKT_row', $row );
951
+	function set_row($row) {
952
+		$this->set('TKT_row', $row);
953 953
 	}
954 954
 
955 955
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	 * @return boolean
960 960
 	 */
961 961
 	function deleted() {
962
-		return $this->get( 'TKT_deleted' );
962
+		return $this->get('TKT_deleted');
963 963
 	}
964 964
 
965 965
 
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 	 * @param boolean $deleted
970 970
 	 * @return boolean
971 971
 	 */
972
-	function set_deleted( $deleted ) {
973
-		$this->set( 'TKT_deleted', $deleted );
972
+	function set_deleted($deleted) {
973
+		$this->set('TKT_deleted', $deleted);
974 974
 	}
975 975
 
976 976
 
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 	 * @return int
981 981
 	 */
982 982
 	function parent_ID() {
983
-		return $this->get( 'TKT_parent' );
983
+		return $this->get('TKT_parent');
984 984
 	}
985 985
 
986 986
 
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 	 * @param int $parent
991 991
 	 * @return boolean
992 992
 	 */
993
-	function set_parent_ID( $parent ) {
994
-		$this->set( 'TKT_parent', $parent );
993
+	function set_parent_ID($parent) {
994
+		$this->set('TKT_parent', $parent);
995 995
 	}
996 996
 
997 997
 
@@ -1002,10 +1002,10 @@  discard block
 block discarded – undo
1002 1002
 	 */
1003 1003
 	function name_and_info() {
1004 1004
 		$times = array();
1005
-		foreach ( $this->datetimes() as $datetime ) {
1005
+		foreach ($this->datetimes() as $datetime) {
1006 1006
 			$times[] = $datetime->start_date_and_time();
1007 1007
 		}
1008
-		return $this->name() . " @ " . implode( ", ", $times ) . " for " . $this->price();
1008
+		return $this->name()." @ ".implode(", ", $times)." for ".$this->price();
1009 1009
 	}
1010 1010
 
1011 1011
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 * @return string
1016 1016
 	 */
1017 1017
 	function name() {
1018
-		return $this->get( 'TKT_name' );
1018
+		return $this->get('TKT_name');
1019 1019
 	}
1020 1020
 
1021 1021
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 * @return float
1026 1026
 	 */
1027 1027
 	function price() {
1028
-		return $this->get( 'TKT_price' );
1028
+		return $this->get('TKT_price');
1029 1029
 	}
1030 1030
 
1031 1031
 
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	 * @param array $query_params like EEM_Base::get_all's
1036 1036
 	 * @return EE_Registration[]
1037 1037
 	 */
1038
-	public function registrations( $query_params = array() ) {
1039
-		return $this->get_many_related( 'Registration', $query_params );
1038
+	public function registrations($query_params = array()) {
1039
+		return $this->get_many_related('Registration', $query_params);
1040 1040
 	}
1041 1041
 
1042 1042
 
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @return int
1048 1048
 	 */
1049 1049
 	public function update_tickets_sold() {
1050
-		$count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) );
1051
-		$this->set_sold( $count_regs_for_this_ticket );
1050
+		$count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0)));
1051
+		$this->set_sold($count_regs_for_this_ticket);
1052 1052
 		$this->save();
1053 1053
 		return $count_regs_for_this_ticket;
1054 1054
 	}
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @param array $query_params like EEM_Base::get_all's
1061 1061
 	 * @return int
1062 1062
 	 */
1063
-	public function count_registrations( $query_params = array() ) {
1063
+	public function count_registrations($query_params = array()) {
1064 1064
 		return $this->count_related('Registration', $query_params);
1065 1065
 	}
1066 1066
 
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	public function get_related_event() {
1086 1086
 		//get one datetime to use for getting the event
1087 1087
 		$datetime = $this->first_datetime();
1088
-		if ( $datetime instanceof EE_Datetime ) {
1088
+		if ($datetime instanceof EE_Datetime) {
1089 1089
 			return $datetime->event();
1090 1090
 		}
1091 1091
 		return null;
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 2 patches
Doc Comments   +18 added lines, -15 removed lines patch added patch discarded remove patch
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	 * Returns the name of the field's name that points to the WP_User table
742 742
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
743 743
 	 * foreign key to the WP_User table)
744
-	 * @return string|boolean string on success, boolean false when there is no
744
+	 * @return string|false string on success, boolean false when there is no
745 745
 	 * foreign key to the WP_User table
746 746
 	 */
747 747
 	function wp_user_field_name() {
@@ -837,6 +837,7 @@  discard block
 block discarded – undo
837 837
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
838 838
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
839 839
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
840
+	 * @param string $columns_to_select
840 841
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
841 842
 	 */
842 843
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1139,7 +1140,7 @@  discard block
 block discarded – undo
1139 1140
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1140 1141
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1141 1142
 	 *
1142
-	 * @return array formats in an array with the date format first, and the time format last.
1143
+	 * @return string[] formats in an array with the date format first, and the time format last.
1143 1144
 	 */
1144 1145
 	public function get_formats_for( $field_name, $pretty = false ) {
1145 1146
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1174,7 +1175,7 @@  discard block
 block discarded – undo
1174 1175
 	 *
1175 1176
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1176 1177
 	 *
1177
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1178
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1178 1179
 	 *                    	     exception is triggered.
1179 1180
 	 */
1180 1181
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1474,7 +1475,7 @@  discard block
 block discarded – undo
1474 1475
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1475 1476
 	 * Wrapper for EEM_Base::delete()
1476 1477
 	 * @param mixed $id
1477
-	 * @return boolean whether the row got deleted or not
1478
+	 * @return integer whether the row got deleted or not
1478 1479
 	 */
1479 1480
 	public function delete_by_ID( $id ){
1480 1481
 		return $this->delete( array(
@@ -1834,7 +1835,7 @@  discard block
 block discarded – undo
1834 1835
 	/**
1835 1836
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1836 1837
 	 * EEM_Base::$_db_verification_level
1837
-	 * @param $wpdb_method
1838
+	 * @param string $wpdb_method
1838 1839
 	 * @param $arguments_to_provide
1839 1840
 	 * @return string
1840 1841
 	 */
@@ -1902,7 +1903,6 @@  discard block
 block discarded – undo
1902 1903
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1903 1904
 	 * 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
1904 1905
 	 *
1905
-	 * @param EE_Base_Class/int $thisModelObject
1906 1906
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1907 1907
 	 * @param string $relationName, key in EEM_Base::_relations
1908 1908
 	 * 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')
@@ -1924,8 +1924,8 @@  discard block
 block discarded – undo
1924 1924
 	 *
1925 1925
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
1926 1926
 	 *
1927
-	 * @param EE_Base_Class/int $id_or_obj
1928
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1927
+	 * @param EE_CPT_Base $id_or_obj
1928
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1929 1929
 	 * @param string $relationName key in EEM_Base::_relations
1930 1930
 	 * @return boolean of success
1931 1931
 	 * @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.
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 	/**
2002 2002
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
2003 2003
 	 * unless otherwise specified in the $query_params
2004
-	 * @param int/EE_Base_Class $id_or_obj
2004
+	 * @param EE_Event $id_or_obj
2005 2005
 	 * @param string $model_name like 'Event', or 'Registration'
2006 2006
 	 * @param array $query_params like EEM_Base::get_all's
2007 2007
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 	/**
2391 2391
 	 * Finds all the fields that correspond to the given table
2392 2392
 	 * @param string $table_alias, array key in EEM_Base::_tables
2393
-	 * @return EE_Model_Field_Base[]
2393
+	 * @return EE_Model_Field_Base
2394 2394
 	 */
2395 2395
 	function _get_fields_for_table($table_alias){
2396 2396
 		return $this->_fields[$table_alias];
@@ -3454,8 +3454,8 @@  discard block
 block discarded – undo
3454 3454
 	/**
3455 3455
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3456 3456
 	 * Eg, on EE_Answer that would be ANS_ID field object
3457
-	 * @param $field_obj
3458
-	 * @return EE_Model_Field_Base
3457
+	 * @param EE_Model_Field_Base $field_obj
3458
+	 * @return boolean
3459 3459
 	 */
3460 3460
 	public function is_primary_key_field( $field_obj ){
3461 3461
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3549,7 +3549,7 @@  discard block
 block discarded – undo
3549 3549
 	 * Gets the actual table for the table alias
3550 3550
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3551 3551
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3552
-	 * @return EE_Table_Base
3552
+	 * @return string
3553 3553
 	 */
3554 3554
 	function get_table_for_alias($table_alias){
3555 3555
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3649,7 +3649,7 @@  discard block
 block discarded – undo
3649 3649
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3650 3650
 	 * 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!).
3651 3651
 	 *
3652
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3652
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3653 3653
 	 */
3654 3654
 	public function create_default_object() {
3655 3655
 
@@ -3804,6 +3804,9 @@  discard block
 block discarded – undo
3804 3804
 		return $this_model_fields_n_values;
3805 3805
 	}
3806 3806
 
3807
+	/**
3808
+	 * @param string $cols_n_values
3809
+	 */
3807 3810
 	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3808 3811
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3809 3812
 		//does the field on the model relate to this column retrieved from the db?
@@ -4039,7 +4042,7 @@  discard block
 block discarded – undo
4039 4042
 	}
4040 4043
 	/**
4041 4044
 	 * Read comments for assume_values_already_prepared_by_model_object()
4042
-	 * @return int
4045
+	 * @return boolean
4043 4046
 	 */
4044 4047
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4045 4048
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Spacing   +945 added lines, -945 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * Flag indicating whether this model has a primary key or not
229 229
 	 * @var boolean
230 230
 	 */
231
-	protected $_has_primary_key_field=null;
231
+	protected $_has_primary_key_field = null;
232 232
 
233 233
 	/**
234 234
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
284 284
 	 * @var array
285 285
 	 */
286
-	protected $_between_style_operators = array( 'BETWEEN' );
286
+	protected $_between_style_operators = array('BETWEEN');
287 287
 
288 288
 	/**
289 289
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
290 290
 	 * @var array
291 291
 	 */
292
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
292
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
293 293
 
294 294
 	/**
295 295
 	 * Allowed values for $query_params['order'] for ordering in queries
296 296
 	 * @var array
297 297
 	 */
298
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
298
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
299 299
 
300 300
 	/**
301 301
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
310 310
 	 * @var array
311 311
 	 */
312
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
312
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
313 313
 
314 314
 	/**
315 315
 	 * All the data types that can be used in $wpdb->prepare statements.
316 316
 	 * @var array
317 317
 	 */
318
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
318
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
319 319
 
320 320
 	/**
321 321
 	 * 	EE_Registry Object
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 	/**
349 349
 	 * constant used to show EEM_Base has not yet verified the db on this http request
350 350
 	 */
351
-	const db_verified_none 		= 0;
351
+	const db_verified_none = 0;
352 352
 	/**
353 353
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
354 354
 	 * but not the addons' dbs
355 355
 	 */
356
-	const db_verified_core 		= 1;
356
+	const db_verified_core = 1;
357 357
 	/**
358 358
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
359 359
 	 * the EE core db too)
360 360
 	 */
361
-	const db_verified_addons 	= 2;
361
+	const db_verified_addons = 2;
362 362
 
363 363
 	/**
364 364
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 	 * @param null $timezone
396 396
 	 * @throws \EE_Error
397 397
 	 */
398
-	protected function __construct( $timezone = NULL ){
398
+	protected function __construct($timezone = NULL) {
399 399
 		// check that the model has not been loaded too soon
400
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
401
-			throw new EE_Error (
400
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
401
+			throw new EE_Error(
402 402
 				sprintf(
403
-					__( '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' ),
404
-					get_class( $this )
403
+					__('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'),
404
+					get_class($this)
405 405
 				)
406 406
 			);
407 407
 		}
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 		 * just use EE_Register_Model_Extension
412 412
 		 * @var EE_Table_Base[] $_tables
413 413
 		 */
414
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
415
-		foreach($this->_tables as $table_alias => $table_obj){
414
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
415
+		foreach ($this->_tables as $table_alias => $table_obj) {
416 416
 			/** @var $table_obj EE_Table_Base */
417 417
 			$table_obj->_construct_finalize_with_alias($table_alias);
418
-			if( $table_obj instanceof EE_Secondary_Table ){
418
+			if ($table_obj instanceof EE_Secondary_Table) {
419 419
 				/** @var $table_obj EE_Secondary_Table */
420 420
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
421 421
 			}
@@ -425,48 +425,48 @@  discard block
 block discarded – undo
425 425
 		 * EE_Register_Model_Extension
426 426
 		 * @param EE_Model_Field_Base[] $_fields
427 427
 		 */
428
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
429
-		foreach($this->_fields as $table_alias => $fields_for_table){
430
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
431
-				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)));
428
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
429
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
430
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
431
+				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)));
432 432
 			}
433
-			foreach($fields_for_table as $field_name => $field_obj){
433
+			foreach ($fields_for_table as $field_name => $field_obj) {
434 434
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
435 435
 				//primary key field base has a slightly different _construct_finalize
436 436
 				/** @var $field_obj EE_Model_Field_Base */
437
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
437
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
438 438
 			}
439 439
 		}
440 440
 
441 441
 		// everything is related to Extra_Meta
442
-		if( get_class($this) != 'EEM_Extra_Meta'){
442
+		if (get_class($this) != 'EEM_Extra_Meta') {
443 443
 			//make extra meta related to everything, but don't block deleting things just
444 444
 			//because they have related extra meta info. For now just orphan those extra meta
445 445
 			//in the future we should automatically delete them
446
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
446
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
447 447
 		}
448 448
 		//and change logs
449
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
450
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
449
+		if (get_class($this) != 'EEM_Change_Log') {
450
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
451 451
 		}
452 452
 		/**
453 453
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
454 454
 		 * EE_Register_Model_Extension
455 455
 		 * @param EE_Model_Relation_Base[] $_model_relations
456 456
 		 */
457
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
458
-		foreach($this->_model_relations as $model_name => $relation_obj){
457
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
458
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
459 459
 			/** @var $relation_obj EE_Model_Relation_Base */
460 460
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
461 461
 		}
462
-		foreach($this->_indexes as $index_name => $index_obj){
462
+		foreach ($this->_indexes as $index_name => $index_obj) {
463 463
 			/** @var $index_obj EE_Index */
464 464
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
465 465
 		}
466 466
 
467 467
 		$this->set_timezone($timezone);
468 468
 		//finalize default where condition strategy, or set default
469
-		if( ! $this->_default_where_conditions_strategy){
469
+		if ( ! $this->_default_where_conditions_strategy) {
470 470
 			//nothing was set during child constructor, so set default
471 471
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
472 472
 		}
@@ -474,15 +474,15 @@  discard block
 block discarded – undo
474 474
 
475 475
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
476 476
 		//to indicate to NOT set it, set it to the logical default
477
-		if( $this->_caps_slug === null ) {
478
-			EE_Registry::instance()->load_helper( 'Inflector' );
479
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
477
+		if ($this->_caps_slug === null) {
478
+			EE_Registry::instance()->load_helper('Inflector');
479
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
480 480
 		}
481 481
 		//initialize the standard cap restriction generators if none were specified by the child constructor
482
-		if( $this->_cap_restriction_generators !== false ){
483
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
484
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
485
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
482
+		if ($this->_cap_restriction_generators !== false) {
483
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
484
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
485
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
486 486
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
487 487
 						new EE_Restriction_Generator_Protected(),
488 488
 						$cap_context,
@@ -492,23 +492,23 @@  discard block
 block discarded – undo
492 492
 			}
493 493
 		}
494 494
 		//if there are cap restriction generators, use them to make the default cap restrictions
495
-		if( $this->_cap_restriction_generators !== false ){
496
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
497
-				if( ! $generator_object ){
495
+		if ($this->_cap_restriction_generators !== false) {
496
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
497
+				if ( ! $generator_object) {
498 498
 					continue;
499 499
 				}
500
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
500
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
501 501
 					throw new EE_Error(
502 502
 						sprintf(
503
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
503
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
504 504
 							$context,
505 505
 							$this->get_this_model_name()
506 506
 						)
507 507
 					);
508 508
 				}
509
-				$action = $this->cap_action_for_context( $context );
510
-				if( ! $generator_object->construction_finalized() ){
511
-					$generator_object->_construct_finalize( $this, $action );
509
+				$action = $this->cap_action_for_context($context);
510
+				if ( ! $generator_object->construction_finalized()) {
511
+					$generator_object->_construct_finalize($this, $action);
512 512
 				}
513 513
 
514 514
 			}
@@ -522,11 +522,11 @@  discard block
 block discarded – undo
522 522
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
523 523
 	 * @return EE_Default_Where_Conditions[]
524 524
 	 */
525
-	protected function _generate_cap_restrictions( $context ){
526
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
527
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
528
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
529
-		}else{
525
+	protected function _generate_cap_restrictions($context) {
526
+		if (isset($this->_cap_restriction_generators[$context]) &&
527
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
528
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
529
+		} else {
530 530
 			return array();
531 531
 		}
532 532
 }
@@ -539,16 +539,16 @@  discard block
 block discarded – undo
539 539
 	 *		@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)
540 540
 	 *		@return static (as in the concrete child class)
541 541
 	 */
542
-	public static function instance( $timezone = NULL ){
542
+	public static function instance($timezone = NULL) {
543 543
 
544 544
 		// check if instance of Espresso_model already exists
545 545
 		if ( ! static::$_instance instanceof static) {
546 546
 			// instantiate Espresso_model
547
-			static::$_instance = new static( $timezone );
547
+			static::$_instance = new static($timezone);
548 548
 		}
549 549
 
550 550
 		//we might have a timezone set, let set_timezone decide what to do with it
551
-		static::$_instance->set_timezone( $timezone );
551
+		static::$_instance->set_timezone($timezone);
552 552
 
553 553
 		// Espresso_model object
554 554
 		return static::$_instance;
@@ -561,11 +561,11 @@  discard block
 block discarded – undo
561 561
 	 * @param null | string $timezone
562 562
 	 * @return static
563 563
 	 */
564
-	public static function reset(  $timezone = NULL ){
565
-		if ( ! is_null( static::$_instance ) ) {
564
+	public static function reset($timezone = NULL) {
565
+		if ( ! is_null(static::$_instance)) {
566 566
 			static::$_instance = null;
567 567
 
568
-			return self::instance( $timezone );
568
+			return self::instance($timezone);
569 569
 		}
570 570
 		return null;
571 571
 	}
@@ -576,15 +576,15 @@  discard block
 block discarded – undo
576 576
 	 * @param  boolean $translated return localized strings or JUST the array.
577 577
 	 * @return array
578 578
 	 */
579
-	 public function status_array( $translated = FALSE ) {
580
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
579
+	 public function status_array($translated = FALSE) {
580
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
581 581
 	 		return array();
582 582
 	 	$model_name = $this->get_this_model_name();
583
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
584
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
583
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
584
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
585 585
 	 	$status_array = array();
586
-	 	foreach ( $stati as $status ) {
587
-            $status_array[ $status->ID() ] = $status->get('STS_code');
586
+	 	foreach ($stati as $status) {
587
+            $status_array[$status->ID()] = $status->get('STS_code');
588 588
         }
589 589
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
590 590
     }
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	 *			'order_by'=>array('ANS_value'=>'ASC')
768 768
 	 *		));
769 769
 	 */
770
-	function get_all($query_params = array()){
770
+	function get_all($query_params = array()) {
771 771
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
772 772
 	}
773 773
 
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
 	 * @param array $query_params @see EEM_Base::get_all()
778 778
 	 * @return array like EEM_Base::get_all
779 779
 	 */
780
-	function alter_query_params_to_only_include_mine( $query_params = array() ) {
780
+	function alter_query_params_to_only_include_mine($query_params = array()) {
781 781
 		$wp_user_field_name = $this->wp_user_field_name();
782
-		if( $wp_user_field_name ){
783
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
782
+		if ($wp_user_field_name) {
783
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
784 784
 		}
785 785
 		return $query_params;
786 786
 	}
@@ -793,19 +793,19 @@  discard block
 block discarded – undo
793 793
 	 * foreign key to the WP_User table
794 794
 	 */
795 795
 	function wp_user_field_name() {
796
-		try{
797
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
798
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
799
-				$last_model_name = end( $models_to_follow_to_wp_users );
800
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
801
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
802
-			}else{
796
+		try {
797
+			if ( ! empty($this->_model_chain_to_wp_user)) {
798
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
799
+				$last_model_name = end($models_to_follow_to_wp_users);
800
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
801
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
802
+			} else {
803 803
 				$model_with_fk_to_wp_users = $this;
804 804
 				$model_chain_to_wp_user = '';
805 805
 			}
806
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
807
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
808
-		}catch( EE_Error $e ) {
806
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
807
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
808
+		} catch (EE_Error $e) {
809 809
 			return false;
810 810
 		}
811 811
 	}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 	 * (or transietly-related model)
820 820
 	 * @return string
821 821
 	 */
822
-	public function model_chain_to_wp_user(){
822
+	public function model_chain_to_wp_user() {
823 823
 		return $this->_model_chain_to_wp_user;
824 824
 	}
825 825
 
@@ -831,13 +831,13 @@  discard block
 block discarded – undo
831 831
 	 * @return boolean
832 832
 	 */
833 833
 	public function is_owned() {
834
-		if( $this->model_chain_to_wp_user() ){
834
+		if ($this->model_chain_to_wp_user()) {
835 835
 			return true;
836
-		}else{
837
-			try{
838
-				$this->get_foreign_key_to( 'WP_User' );
836
+		} else {
837
+			try {
838
+				$this->get_foreign_key_to('WP_User');
839 839
 				return true;
840
-			}catch( EE_Error $e ){
840
+			} catch (EE_Error $e) {
841 841
 				return false;
842 842
 			}
843 843
 		}
@@ -856,21 +856,21 @@  discard block
 block discarded – undo
856 856
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
857 857
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
858 858
 	 */
859
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
859
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
860 860
 		//remember the custom selections, if any
861
-		if(is_array($columns_to_select)){
861
+		if (is_array($columns_to_select)) {
862 862
 			$this->_custom_selections = $columns_to_select;
863
-		}elseif(is_string($columns_to_select)){
863
+		}elseif (is_string($columns_to_select)) {
864 864
 			$this->_custom_selections = array($this->_custom_selections);
865
-		}else{
865
+		} else {
866 866
 			$this->_custom_selections = array();
867 867
 		}
868 868
 
869 869
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
870 870
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
871
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
871
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
872 872
 //		echo "sql:$SQL";
873
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
873
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
874 874
 		return $results;
875 875
 	}
876 876
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
888 888
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
889 889
 	 */
890
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
890
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
891 891
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
892 892
 	}
893 893
 
@@ -899,21 +899,21 @@  discard block
 block discarded – undo
899 899
 	 * @throws EE_Error
900 900
 	 * @return string
901 901
 	 */
902
-	private function _construct_select_from_input($columns_to_select){
903
-		if(is_array($columns_to_select)){
902
+	private function _construct_select_from_input($columns_to_select) {
903
+		if (is_array($columns_to_select)) {
904 904
 			$select_sql_array = array();
905 905
 
906
-			foreach($columns_to_select as $alias => $selection_and_datatype){
907
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
908
-					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));
906
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
907
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
908
+					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));
909 909
 				}
910
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
911
-					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)));
910
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
911
+					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)));
912 912
 				}
913 913
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
914 914
 			}
915
-			$columns_to_select_string = implode(", ",$select_sql_array);
916
-		}else{
915
+			$columns_to_select_string = implode(", ", $select_sql_array);
916
+		} else {
917 917
 			$columns_to_select_string = $columns_to_select;
918 918
 		}
919 919
 		return $columns_to_select_string;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
927 927
 	 * @return string
928 928
 	 */
929
-	function primary_key_name(){
929
+	function primary_key_name() {
930 930
 		return $this->get_primary_key_field()->get_name();
931 931
 	}
932 932
 
@@ -938,15 +938,15 @@  discard block
 block discarded – undo
938 938
 	 * @param mixed $id int or string, depending on the type of the model's primary key
939 939
 	 * @return EE_Base_Class
940 940
 	 */
941
-	function get_one_by_ID($id){
942
-		if( $this->get_from_entity_map( $id ) ){
943
-			return $this->get_from_entity_map( $id );
944
-		}elseif( $this->has_primary_key_field ( ) ) {
941
+	function get_one_by_ID($id) {
942
+		if ($this->get_from_entity_map($id)) {
943
+			return $this->get_from_entity_map($id);
944
+		}elseif ($this->has_primary_key_field( )) {
945 945
 			$primary_key_name = $this->get_primary_key_field()->get_name();
946 946
 			return $this->get_one(array(array($primary_key_name => $id)));
947
-		}else{
947
+		} else {
948 948
 			//no primary key, so the $id must be from the get_index_primary_key_string()
949
-			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
949
+			return $this->get_one(array($this->parse_index_primary_key_string($id)));
950 950
 		}
951 951
 	}
952 952
 
@@ -957,16 +957,16 @@  discard block
 block discarded – undo
957 957
 	 * @param array $query_params like EEM_Base's $query_params variable.
958 958
 	 * @return EE_Base_Class | NULL
959 959
 	 */
960
-	function get_one($query_params = array()){
961
-		if( ! is_array( $query_params ) ){
962
-			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' );
960
+	function get_one($query_params = array()) {
961
+		if ( ! is_array($query_params)) {
962
+			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');
963 963
 			$query_params = array();
964 964
 		}
965 965
 		$query_params['limit'] = 1;
966 966
 		$items = $this->get_all($query_params);
967
-		if(empty($items)){
967
+		if (empty($items)) {
968 968
 			return null;
969
-		}else{
969
+		} else {
970 970
 			return array_shift($items);
971 971
 		}
972 972
 	}
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 	 *
991 991
 	 * @return EE_Base_Class[]|array
992 992
 	 */
993
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
994
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
993
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
994
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
995 995
 	}
996 996
 
997 997
 
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 	 *
1015 1015
 	 * @return EE_Base_Class[]|array
1016 1016
 	 */
1017
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1018
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1017
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1018
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1019 1019
 	}
1020 1020
 
1021 1021
 
@@ -1037,9 +1037,9 @@  discard block
 block discarded – undo
1037 1037
 	 *
1038 1038
 	 * @return EE_Base_Class|null|array()
1039 1039
 	 */
1040
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1041
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1042
-		return empty( $results ) ? null : reset( $results );
1040
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1041
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1042
+		return empty($results) ? null : reset($results);
1043 1043
 	}
1044 1044
 
1045 1045
 
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
 	 *
1062 1062
 	 * @return EE_Base_Class|null|array()
1063 1063
 	 */
1064
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1065
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1066
-		return empty( $results ) ? null : reset( $results );
1064
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1065
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1066
+		return empty($results) ? null : reset($results);
1067 1067
 	}
1068 1068
 
1069 1069
 
@@ -1089,40 +1089,40 @@  discard block
 block discarded – undo
1089 1089
 	 * @return EE_Base_Class[]|array
1090 1090
 	 * @throws EE_Error
1091 1091
 	 */
1092
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1092
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1093 1093
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1094
-		if ( empty( $field_to_order_by ) ) {
1095
-			if ( $this->has_primary_key_field() ) {
1094
+		if (empty($field_to_order_by)) {
1095
+			if ($this->has_primary_key_field()) {
1096 1096
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1097 1097
 			} else {
1098 1098
 
1099
-				if ( WP_DEBUG ) {
1100
-					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' ) );
1099
+				if (WP_DEBUG) {
1100
+					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'));
1101 1101
 				}
1102
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1102
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1103 1103
 				return array();
1104 1104
 			}
1105 1105
 		}
1106 1106
 
1107
-		if( ! is_array( $query_params ) ){
1108
-			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' );
1107
+		if ( ! is_array($query_params)) {
1108
+			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');
1109 1109
 			$query_params = array();
1110 1110
 		}
1111 1111
 
1112 1112
 		//let's add the where query param for consecutive look up.
1113
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1113
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1114 1114
 		$query_params['limit'] = $limit;
1115 1115
 
1116 1116
 		//set direction
1117
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1118
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1117
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1118
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1119 1119
 
1120 1120
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1121
-		if ( empty( $columns_to_select ) ) {
1122
-			return $this->get_all( $query_params );
1121
+		if (empty($columns_to_select)) {
1122
+			return $this->get_all($query_params);
1123 1123
 		} else {
1124 1124
 			//getting just the fields
1125
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1125
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1126 1126
 		}
1127 1127
 	}
1128 1128
 
@@ -1133,18 +1133,18 @@  discard block
 block discarded – undo
1133 1133
 	 * This sets the _timezone property after model object has been instantiated.
1134 1134
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1135 1135
 	 */
1136
-	public function set_timezone( $timezone ) {
1137
-		if ( $timezone !== null ) {
1136
+	public function set_timezone($timezone) {
1137
+		if ($timezone !== null) {
1138 1138
 			$this->_timezone = $timezone;
1139 1139
 		}
1140 1140
 		//note we need to loop through relations and set the timezone on those objects as well.
1141
-		foreach ( $this->_model_relations as $relation ) {
1142
-			$relation->set_timezone( $timezone );
1141
+		foreach ($this->_model_relations as $relation) {
1142
+			$relation->set_timezone($timezone);
1143 1143
 		}
1144 1144
 		//and finally we do the same for any datetime fields
1145
-		foreach ( $this->_fields as $field ) {
1146
-			if ( $field instanceof EE_Datetime_Field ) {
1147
-				$field->set_timezone( $timezone );
1145
+		foreach ($this->_fields as $field) {
1146
+			if ($field instanceof EE_Datetime_Field) {
1147
+				$field->set_timezone($timezone);
1148 1148
 			}
1149 1149
 		}
1150 1150
 	}
@@ -1159,9 +1159,9 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
 	public function get_timezone() {
1161 1161
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1162
-		if ( empty( $this->_timezone ) ) {
1163
-			foreach( $this->_fields as $field ) {
1164
-				if ( $field instanceof EE_Datetime_Field ) {
1162
+		if (empty($this->_timezone)) {
1163
+			foreach ($this->_fields as $field) {
1164
+				if ($field instanceof EE_Datetime_Field) {
1165 1165
 					$this->set_timezone($field->get_timezone());
1166 1166
 					break;
1167 1167
 				}
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
 		}
1170 1170
 
1171 1171
 		//if timezone STILL empty then return the default timezone for the site.
1172
-		if ( empty( $this->_timezone ) ) {
1173
-			EE_Registry::instance()->load_helper( 'DTT_Helper' );
1174
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1172
+		if (empty($this->_timezone)) {
1173
+			EE_Registry::instance()->load_helper('DTT_Helper');
1174
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1175 1175
 		}
1176 1176
 		return $this->_timezone;
1177 1177
 	}
@@ -1189,19 +1189,19 @@  discard block
 block discarded – undo
1189 1189
 	 *
1190 1190
 	 * @return array formats in an array with the date format first, and the time format last.
1191 1191
 	 */
1192
-	public function get_formats_for( $field_name, $pretty = false ) {
1193
-		$field_settings = $this->field_settings_for( $field_name );
1192
+	public function get_formats_for($field_name, $pretty = false) {
1193
+		$field_settings = $this->field_settings_for($field_name);
1194 1194
 
1195 1195
 		//if not a valid EE_Datetime_Field then throw error
1196
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1197
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1196
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1197
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1198 1198
 		}
1199 1199
 
1200 1200
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1201 1201
 		//the field.
1202 1202
 		$this->_timezone = $field_settings->get_timezone();
1203 1203
 
1204
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1204
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1205 1205
 	}
1206 1206
 
1207 1207
 
@@ -1225,25 +1225,25 @@  discard block
 block discarded – undo
1225 1225
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1226 1226
 	 *                    	     exception is triggered.
1227 1227
 	 */
1228
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1229
-		$formats = $this->get_formats_for( $field_name );
1228
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1229
+		$formats = $this->get_formats_for($field_name);
1230 1230
 
1231
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1231
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1232 1232
 
1233
-		if ( $timestamp ) {
1234
-			return $DateTime->format( 'U' );
1233
+		if ($timestamp) {
1234
+			return $DateTime->format('U');
1235 1235
 		}
1236 1236
 
1237 1237
 		//not returning timestamp, so return formatted string in timezone.
1238
-		switch( $what ) {
1238
+		switch ($what) {
1239 1239
 			case 'time' :
1240
-				return $DateTime->format( $formats[1] );
1240
+				return $DateTime->format($formats[1]);
1241 1241
 				break;
1242 1242
 			case 'date' :
1243
-				return $DateTime->format( $formats[0] );
1243
+				return $DateTime->format($formats[0]);
1244 1244
 				break;
1245 1245
 			default :
1246
-				return $DateTime->format( implode( ' ', $formats ) );
1246
+				return $DateTime->format(implode(' ', $formats));
1247 1247
 				break;
1248 1248
 		}
1249 1249
 	}
@@ -1267,18 +1267,18 @@  discard block
 block discarded – undo
1267 1267
 	 *                           		'U', this is ignored.
1268 1268
 	 * @return DateTime
1269 1269
 	 */
1270
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1270
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1271 1271
 
1272 1272
 		//just using this to ensure the timezone is set correctly internally
1273
-		$this->get_formats_for( $field_name );
1273
+		$this->get_formats_for($field_name);
1274 1274
 
1275 1275
 		//load EEH_DTT_Helper
1276
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1277
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1276
+		EE_Registry::instance()->load_helper('DTT_Helper');
1277
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1278 1278
 
1279
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1279
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1280 1280
 
1281
-		return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) );
1281
+		return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone));
1282 1282
 	}
1283 1283
 
1284 1284
 
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1289 1289
 	 * @return EE_Table_Base[]
1290 1290
 	 */
1291
-	function get_tables(){
1291
+	function get_tables() {
1292 1292
 		return $this->_tables;
1293 1293
 	}
1294 1294
 
@@ -1322,9 +1322,9 @@  discard block
 block discarded – undo
1322 1322
 	 * be aware that model objects being used could get out-of-sync with the database
1323 1323
 	 * @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)
1324 1324
 	 */
1325
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1326
-		if( ! is_array( $query_params ) ){
1327
-			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' );
1325
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1326
+		if ( ! is_array($query_params)) {
1327
+			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');
1328 1328
 			$query_params = array();
1329 1329
 		}
1330 1330
 		/**
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
 		 * @param array $fields_n_values the updated fields and their new values
1335 1335
 		 * @param array $query_params @see EEM_Base::get_all()
1336 1336
 		 */
1337
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1337
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1338 1338
 		/**
1339 1339
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1340 1340
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1342,10 +1342,10 @@  discard block
 block discarded – undo
1342 1342
 		 * @param EEM_Base $model the model being queried
1343 1343
 		 * @param array $query_params see EEM_Base::get_all()
1344 1344
 		 */
1345
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1345
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1346 1346
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1347 1347
 		//to do that, for each table, verify that it's PK isn't null.
1348
-		$tables= $this->get_tables();
1348
+		$tables = $this->get_tables();
1349 1349
 
1350 1350
 		//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
1351 1351
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1355,29 +1355,29 @@  discard block
 block discarded – undo
1355 1355
 			//we want to make sure the default_where strategy is ignored
1356 1356
 			$this->_ignore_where_strategy = TRUE;
1357 1357
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1358
-			foreach( $wpdb_select_results as $wpdb_result ){
1358
+			foreach ($wpdb_select_results as $wpdb_result) {
1359 1359
 				// type cast stdClass as array
1360
-				$wpdb_result = (array)$wpdb_result;
1360
+				$wpdb_result = (array) $wpdb_result;
1361 1361
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1362
-				if( $this->has_primary_key_field() ){
1363
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1364
-				}else{
1362
+				if ($this->has_primary_key_field()) {
1363
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1364
+				} else {
1365 1365
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1366 1366
 					$main_table_pk_value = null;
1367 1367
 				}
1368 1368
 				//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
1369 1369
 				//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
1370
-				if(count($tables) > 1){
1370
+				if (count($tables) > 1) {
1371 1371
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1372 1372
 					//in that table, and so we'll want to insert one
1373
-					foreach($tables as $table_obj){
1373
+					foreach ($tables as $table_obj) {
1374 1374
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1375 1375
 						//if there is no private key for this table on the results, it means there's no entry
1376 1376
 						//in this table, right? so insert a row in the current table, using any fields available
1377
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1377
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1378 1378
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1379 1379
 							//if we died here, report the error
1380
-							if( ! $success ) {
1380
+							if ( ! $success) {
1381 1381
 								return false;
1382 1382
 							}
1383 1383
 						}
@@ -1397,44 +1397,44 @@  discard block
 block discarded – undo
1397 1397
 		//if this wasn't called from a model object (to update itself)
1398 1398
 		//then we want to make sure we keep all the existing
1399 1399
 		//model objects in sync with the db
1400
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1401
-			if( $this->has_primary_key_field() ){
1402
-				$model_objs_affected_ids = $this->get_col( $query_params );
1403
-			}else{
1400
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1401
+			if ($this->has_primary_key_field()) {
1402
+				$model_objs_affected_ids = $this->get_col($query_params);
1403
+			} else {
1404 1404
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1405
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1405
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1406 1406
 				$model_objs_affected_ids = array();
1407
-				foreach( $models_affected_key_columns as $row ){
1408
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1409
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1407
+				foreach ($models_affected_key_columns as $row) {
1408
+					$combined_index_key = $this->get_index_primary_key_string($row);
1409
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1410 1410
 				}
1411 1411
 
1412 1412
 			}
1413 1413
 
1414
-			if( ! $model_objs_affected_ids ){
1414
+			if ( ! $model_objs_affected_ids) {
1415 1415
 				//wait wait wait- if nothing was affected let's stop here
1416 1416
 				return 0;
1417 1417
 			}
1418
-			foreach( $model_objs_affected_ids as $id ){
1419
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1420
-				if( $model_obj_in_entity_map ){
1421
-					foreach( $fields_n_values as $field => $new_value ){
1422
-						$model_obj_in_entity_map->set( $field, $new_value );
1418
+			foreach ($model_objs_affected_ids as $id) {
1419
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1420
+				if ($model_obj_in_entity_map) {
1421
+					foreach ($fields_n_values as $field => $new_value) {
1422
+						$model_obj_in_entity_map->set($field, $new_value);
1423 1423
 					}
1424 1424
 				}
1425 1425
 			}
1426 1426
 			//if there is a primary key on this model, we can now do a slight optimization
1427
-			if( $this->has_primary_key_field() ){
1427
+			if ($this->has_primary_key_field()) {
1428 1428
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1429 1429
 				$query_params = array(
1430
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1431
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1430
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1431
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1432 1432
 			}
1433 1433
 		}
1434 1434
 
1435
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1436
-		$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.
1437
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1435
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1436
+		$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.
1437
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1438 1438
 		/**
1439 1439
 		 * Action called after a model update call has been made.
1440 1440
 		 *
@@ -1443,8 +1443,8 @@  discard block
 block discarded – undo
1443 1443
 		 * @param array $query_params @see EEM_Base::get_all()
1444 1444
 		 * @param int $rows_affected
1445 1445
 		 */
1446
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1447
-		return $rows_affected;//how many supposedly got updated
1446
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1447
+		return $rows_affected; //how many supposedly got updated
1448 1448
 	}
1449 1449
 
1450 1450
 	/**
@@ -1456,22 +1456,22 @@  discard block
 block discarded – undo
1456 1456
 	 * @param string $field_to_select
1457 1457
 	 * @return array just like $wpdb->get_col()
1458 1458
 	 */
1459
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1459
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1460 1460
 
1461
-		if( $field_to_select ){
1462
-			$field = $this->field_settings_for( $field_to_select );
1463
-		}elseif( $this->has_primary_key_field ( ) ){
1461
+		if ($field_to_select) {
1462
+			$field = $this->field_settings_for($field_to_select);
1463
+		}elseif ($this->has_primary_key_field( )) {
1464 1464
 			$field = $this->get_primary_key_field();
1465
-		}else{
1465
+		} else {
1466 1466
 			//no primary key, just grab the first column
1467
-			$field = reset( $this->field_settings());
1467
+			$field = reset($this->field_settings());
1468 1468
 		}
1469 1469
 
1470 1470
 
1471 1471
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1472 1472
 		$select_expressions = $field->get_qualified_column();
1473
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1474
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1473
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1474
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1475 1475
 		return $results;
1476 1476
 	}
1477 1477
 
@@ -1481,12 +1481,12 @@  discard block
 block discarded – undo
1481 1481
 	 * @param string $field_to_select @see EEM_Base::get_col()
1482 1482
 	 * @return string
1483 1483
 	 */
1484
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1485
-		$query_params[ 'limit' ] = 1;
1486
-		$col = $this->get_col( $query_params, $field_to_select );
1487
-		if( ! empty( $col ) ) {
1488
-			return reset( $col );
1489
-		}else{
1484
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1485
+		$query_params['limit'] = 1;
1486
+		$col = $this->get_col($query_params, $field_to_select);
1487
+		if ( ! empty($col)) {
1488
+			return reset($col);
1489
+		} else {
1490 1490
 			return NULL;
1491 1491
 		}
1492 1492
 	}
@@ -1500,19 +1500,19 @@  discard block
 block discarded – undo
1500 1500
 	 * @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
1501 1501
 	 * @return string of SQL
1502 1502
 	 */
1503
-	function _construct_update_sql($fields_n_values){
1503
+	function _construct_update_sql($fields_n_values) {
1504 1504
 		/** @type WPDB $wpdb */
1505 1505
 		global $wpdb;
1506 1506
 		$cols_n_values = array();
1507
-		foreach($fields_n_values as $field_name => $value){
1507
+		foreach ($fields_n_values as $field_name => $value) {
1508 1508
 			$field_obj = $this->field_settings_for($field_name);
1509 1509
 			//if the value is NULL, we want to assign the value to that.
1510 1510
 			//wpdb->prepare doesn't really handle that properly
1511
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1512
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1511
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1512
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1513 1513
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1514 1514
 		}
1515
-		return implode(",",$cols_n_values);
1515
+		return implode(",", $cols_n_values);
1516 1516
 
1517 1517
 	}
1518 1518
 
@@ -1527,11 +1527,11 @@  discard block
 block discarded – undo
1527 1527
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1528 1528
 	 * @return boolean whether the row got deleted or not
1529 1529
 	 */
1530
-	public function delete_by_ID( $id, $allow_blocking = true ){
1531
-		return $this->delete( array(
1532
-			array( $this->get_primary_key_field()->get_name() => $id ),
1530
+	public function delete_by_ID($id, $allow_blocking = true) {
1531
+		return $this->delete(array(
1532
+			array($this->get_primary_key_field()->get_name() => $id),
1533 1533
 			'limit' 	=> 1
1534
-		), $allow_blocking );
1534
+		), $allow_blocking);
1535 1535
 	}
1536 1536
 
1537 1537
 
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1547 1547
 	 * @return int how many rows got deleted
1548 1548
 	 */
1549
-	function delete($query_params,$allow_blocking = true){
1549
+	function delete($query_params, $allow_blocking = true) {
1550 1550
 		/**
1551 1551
 		 * Action called just before performing a real deletion query. You can use the
1552 1552
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1555,34 +1555,34 @@  discard block
 block discarded – undo
1555 1555
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1556 1556
 		 * to block (prevent) this deletion
1557 1557
 		 */
1558
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1558
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1559 1559
 		//some MySQL databases may be running safe mode, which may restrict
1560 1560
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1561 1561
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1562 1562
 		//to delete them
1563 1563
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1564
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1565
-		if($deletion_where){
1564
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1565
+		if ($deletion_where) {
1566 1566
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1567 1567
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1568 1568
 			$table_aliases = array();
1569
-			foreach(array_keys($this->_tables) as $table_alias){
1569
+			foreach (array_keys($this->_tables) as $table_alias) {
1570 1570
 				$table_aliases[] = $table_alias;
1571 1571
 			}
1572
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1572
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1573 1573
 
1574 1574
 			//		/echo "delete sql:$SQL";
1575
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1576
-		}else{
1575
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1576
+		} else {
1577 1577
 			$rows_deleted = 0;
1578 1578
 		}
1579 1579
 
1580 1580
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1581
-		if( $this->has_primary_key_field() ){
1582
-			foreach($items_for_deletion as $item_for_deletion_row ){
1583
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1584
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1585
-					unset( $this->_entity_map[ $pk_value ] );
1581
+		if ($this->has_primary_key_field()) {
1582
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1583
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1584
+				if (isset($this->_entity_map[$pk_value])) {
1585
+					unset($this->_entity_map[$pk_value]);
1586 1586
 				}
1587 1587
 			}
1588 1588
 		}
@@ -1594,8 +1594,8 @@  discard block
 block discarded – undo
1594 1594
 		 * @param array $query_params @see EEM_Base::get_all()
1595 1595
 		 * @param int $rows_deleted
1596 1596
 		 */
1597
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1598
-		return $rows_deleted;//how many supposedly got deleted
1597
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1598
+		return $rows_deleted; //how many supposedly got deleted
1599 1599
 	}
1600 1600
 
1601 1601
 
@@ -1611,28 +1611,28 @@  discard block
 block discarded – undo
1611 1611
 	 * blocking its deletion before removing the relation between A and B
1612 1612
 	 * @return boolean
1613 1613
 	 */
1614
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1614
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1615 1615
 		//first, if $ignore_this_model_obj was supplied, get its model
1616
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1616
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1617 1617
 			$ignored_model = $ignore_this_model_obj->get_model();
1618
-		}else{
1618
+		} else {
1619 1619
 			$ignored_model = null;
1620 1620
 		}
1621 1621
 		//now check all the relations of $this_model_obj_or_id and see if there
1622 1622
 		//are any related model objects blocking it?
1623 1623
 		$is_blocked = false;
1624
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1625
-			if( $relation_obj->block_delete_if_related_models_exist()){
1624
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1625
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1626 1626
 				//if $ignore_this_model_obj was supplied, then for the query
1627 1627
 				//on that model needs to be told to ignore $ignore_this_model_obj
1628
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1629
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1630
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1631
-				}else{
1628
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1629
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1630
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1631
+				} else {
1632 1632
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1633 1633
 				}
1634 1634
 
1635
-				if($related_model_objects){
1635
+				if ($related_model_objects) {
1636 1636
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1637 1637
 					$is_blocked = true;
1638 1638
 				}
@@ -1652,65 +1652,65 @@  discard block
 block discarded – undo
1652 1652
 	 * @throws EE_Error
1653 1653
 	 * @return string    everything that comes after the WHERE statement.
1654 1654
 	 */
1655
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1656
-		if($this->has_primary_key_field()){
1655
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1656
+		if ($this->has_primary_key_field()) {
1657 1657
 			$primary_table = $this->_get_main_table();
1658 1658
 			$other_tables = $this->_get_other_tables();
1659 1659
 			$deletes = $query = array();
1660
-			foreach ( $objects_for_deletion as $delete_object ) {
1660
+			foreach ($objects_for_deletion as $delete_object) {
1661 1661
 				//before we mark this object for deletion,
1662 1662
 				//make sure there's no related objects blocking its deletion (if we're checking)
1663
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1663
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1664 1664
 					continue;
1665 1665
 				}
1666 1666
 
1667 1667
 				//primary table deletes
1668
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1668
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1669 1669
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1670 1670
 
1671 1671
 				//other tables
1672
-				if ( !empty( $other_tables ) ) {
1673
-					foreach ( $other_tables as $ot ) {
1672
+				if ( ! empty($other_tables)) {
1673
+					foreach ($other_tables as $ot) {
1674 1674
 
1675 1675
 						//first check if we've got the foreign key column here.
1676
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1676
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1677 1677
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1678 1678
 
1679 1679
 						//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
1680
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1680
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1681 1681
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1682 1682
 
1683 1683
 						//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!
1684
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1684
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1685 1685
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1686 1686
 					}
1687 1687
 				}
1688 1688
 			}
1689 1689
 
1690 1690
 			//we should have deletes now, so let's just go through and setup the where statement
1691
-			foreach ( $deletes as $column => $values ) {
1691
+			foreach ($deletes as $column => $values) {
1692 1692
 				//make sure we have unique $values;
1693 1693
 				$values = array_unique($values);
1694
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1694
+				$query[] = $column.' IN('.implode(",", $values).')';
1695 1695
 			}
1696 1696
 
1697
-			return !empty($query) ? implode(' AND ', $query ) : '';
1698
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1697
+			return ! empty($query) ? implode(' AND ', $query) : '';
1698
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1699 1699
 			$ways_to_identify_a_row = array();
1700 1700
 			$fields = $this->get_combined_primary_key_fields();
1701 1701
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1702
-			foreach($objects_for_deletion as  $delete_object){
1702
+			foreach ($objects_for_deletion as  $delete_object) {
1703 1703
 				$values_for_each_cpk_for_a_row = array();
1704
-				foreach($fields as $cpk_field){
1704
+				foreach ($fields as $cpk_field) {
1705 1705
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1706 1706
 				}
1707
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1707
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1708 1708
 			}
1709
-			return implode(" OR ",$ways_to_identify_a_row);
1710
-		}else{
1709
+			return implode(" OR ", $ways_to_identify_a_row);
1710
+		} else {
1711 1711
 			//so there's no primary key and no combined key...
1712 1712
 			//sorry, can't help you
1713
-			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)));
1713
+			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)));
1714 1714
 		}
1715 1715
 	}
1716 1716
 
@@ -1724,21 +1724,21 @@  discard block
 block discarded – undo
1724 1724
 	 * @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;
1725 1725
 	 * @return int
1726 1726
 	 */
1727
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1727
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1728 1728
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1729
-		if($field_to_count){
1729
+		if ($field_to_count) {
1730 1730
 			$field_obj = $this->field_settings_for($field_to_count);
1731 1731
 			$column_to_count = $field_obj->get_qualified_column();
1732
-		}elseif($this->has_primary_key_field ()){
1732
+		}elseif ($this->has_primary_key_field()) {
1733 1733
 			$pk_field_obj = $this->get_primary_key_field();
1734 1734
 			$column_to_count = $pk_field_obj->get_qualified_column();
1735
-		}else{//there's no primary key
1735
+		} else {//there's no primary key
1736 1736
 			$column_to_count = '*';
1737 1737
 		}
1738 1738
 
1739
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1740
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1741
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1739
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1740
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1741
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1742 1742
 	}
1743 1743
 
1744 1744
 	/**
@@ -1748,23 +1748,23 @@  discard block
 block discarded – undo
1748 1748
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1749 1749
 	 * @return float
1750 1750
 	 */
1751
-	function sum($query_params, $field_to_sum = NULL){
1751
+	function sum($query_params, $field_to_sum = NULL) {
1752 1752
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1753 1753
 
1754
-		if($field_to_sum){
1754
+		if ($field_to_sum) {
1755 1755
 			$field_obj = $this->field_settings_for($field_to_sum);
1756 1756
 
1757
-		}else{
1757
+		} else {
1758 1758
 			$field_obj = $this->get_primary_key_field();
1759 1759
 		}
1760 1760
 		$column_to_count = $field_obj->get_qualified_column();
1761 1761
 
1762
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1763
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1764
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1765
-			return (float)$return_value;
1766
-		}else{//must be %f
1767
-			return (float)$return_value;
1762
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1763
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1764
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1765
+			return (float) $return_value;
1766
+		} else {//must be %f
1767
+			return (float) $return_value;
1768 1768
 		}
1769 1769
 	}
1770 1770
 
@@ -1779,33 +1779,33 @@  discard block
 block discarded – undo
1779 1779
 	 * @global wpdb $wpdb
1780 1780
 	 * @return mixed
1781 1781
 	 */
1782
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1782
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1783 1783
 		//if we're in maintenance mode level 2, DON'T run any queries
1784 1784
 		//because level 2 indicates the database needs updating and
1785 1785
 		//is probably out of sync with the code
1786
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1786
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1787 1787
 			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")));
1788 1788
 		}
1789 1789
 		/** @type WPDB $wpdb */
1790 1790
 		global $wpdb;
1791
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1792
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1791
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1792
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1793 1793
 		}
1794
-		if( WP_DEBUG ){
1794
+		if (WP_DEBUG) {
1795 1795
 			$old_show_errors_value = $wpdb->show_errors;
1796
-			$wpdb->show_errors( FALSE );
1797
-		}
1798
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1799
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1800
-		if( WP_DEBUG ){
1801
-			$wpdb->show_errors( $old_show_errors_value );
1802
-			if( ! empty( $wpdb->last_error ) ){
1803
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1804
-			}elseif( $result === false ){
1805
-				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 ) ) );
1796
+			$wpdb->show_errors(FALSE);
1797
+		}
1798
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1799
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1800
+		if (WP_DEBUG) {
1801
+			$wpdb->show_errors($old_show_errors_value);
1802
+			if ( ! empty($wpdb->last_error)) {
1803
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1804
+			}elseif ($result === false) {
1805
+				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)));
1806 1806
 			}
1807
-		}elseif( $result === false ) {
1808
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1807
+		}elseif ($result === false) {
1808
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1809 1809
 		}
1810 1810
 		return $result;
1811 1811
 	}
@@ -1821,23 +1821,23 @@  discard block
 block discarded – undo
1821 1821
 	 * @param array $arguments_to_provide
1822 1822
 	 * @return mixed
1823 1823
 	 */
1824
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1824
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1825 1825
 		/** @type WPDB $wpdb */
1826 1826
 		global $wpdb;
1827 1827
 		$wpdb->last_error = null;
1828
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1828
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1829 1829
 		// was there an error running the query?
1830
-		if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) {
1831
-			switch ( EEM_Base::$_db_verification_level ) {
1830
+		if (($result === false || ! empty($wpdb->last_error))) {
1831
+			switch (EEM_Base::$_db_verification_level) {
1832 1832
 
1833 1833
 				case EEM_Base::db_verified_none :
1834 1834
 					// let's double-check core's DB
1835
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1835
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1836 1836
 					break;
1837 1837
 
1838 1838
 				case EEM_Base::db_verified_core :
1839 1839
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1840
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1840
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1841 1841
 					break;
1842 1842
 
1843 1843
 				case EEM_Base::db_verified_addons :
@@ -1845,11 +1845,11 @@  discard block
 block discarded – undo
1845 1845
 					return $result;
1846 1846
 					break;
1847 1847
 			}
1848
-			if ( ! empty( $error_message ) ) {
1849
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1850
-				trigger_error( $error_message );
1848
+			if ( ! empty($error_message)) {
1849
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1850
+				trigger_error($error_message);
1851 1851
 			}
1852
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1852
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1853 1853
 
1854 1854
 		}
1855 1855
 
@@ -1865,18 +1865,18 @@  discard block
 block discarded – undo
1865 1865
 	 * @param array $arguments_to_provide
1866 1866
 	 * @return string
1867 1867
 	 */
1868
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1868
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1869 1869
 		/** @type WPDB $wpdb */
1870 1870
 		global $wpdb;
1871 1871
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1872 1872
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1873 1873
 		$error_message = sprintf(
1874
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1874
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1875 1875
 			$wpdb->last_error,
1876 1876
 			$wpdb_method,
1877
-			json_encode( $arguments_to_provide )
1877
+			json_encode($arguments_to_provide)
1878 1878
 		);
1879
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1879
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1880 1880
 		return $error_message;
1881 1881
 	}
1882 1882
 
@@ -1889,16 +1889,16 @@  discard block
 block discarded – undo
1889 1889
 	 * @param $arguments_to_provide
1890 1890
 	 * @return string
1891 1891
 	 */
1892
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1892
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1893 1893
 		/** @type WPDB $wpdb */
1894 1894
 		global $wpdb;
1895 1895
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1896 1896
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1897 1897
 		$error_message = sprintf(
1898
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1898
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1899 1899
 			$wpdb->last_error,
1900 1900
 			$wpdb_method,
1901
-			json_encode( $arguments_to_provide )
1901
+			json_encode($arguments_to_provide)
1902 1902
 		);
1903 1903
 		EE_System::instance()->initialize_addons();
1904 1904
 		return $error_message;
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1914 1914
 	 * @return string
1915 1915
 	 */
1916
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1916
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1917 1917
 		return " FROM ".$model_query_info->get_full_join_sql().
1918 1918
 				$model_query_info->get_where_sql().
1919 1919
 				$model_query_info->get_group_by_sql().
@@ -1926,7 +1926,7 @@  discard block
 block discarded – undo
1926 1926
 	 * Set to easily debug the next X queries ran from this model.
1927 1927
 	 * @param int $count
1928 1928
 	 */
1929
-	function show_next_x_db_queries($count = 1){
1929
+	function show_next_x_db_queries($count = 1) {
1930 1930
 		$this->_show_next_x_db_queries = $count;
1931 1931
 	}
1932 1932
 
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
 	/**
1936 1936
 	 * @param $sql_query
1937 1937
 	 */
1938
-	function show_db_query_if_previously_requested($sql_query){
1939
-		if($this->_show_next_x_db_queries > 0){
1938
+	function show_db_query_if_previously_requested($sql_query) {
1939
+		if ($this->_show_next_x_db_queries > 0) {
1940 1940
 			echo $sql_query;
1941 1941
 			$this->_show_next_x_db_queries--;
1942 1942
 		}
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 	 * @param array   $extra_join_model_fields_n_values 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.
1961 1961
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
1962 1962
 	 */
1963
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
1963
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
1964 1964
 		$relation_obj = $this->related_settings_for($relationName);
1965 1965
 		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
1966 1966
 	}
@@ -1981,9 +1981,9 @@  discard block
 block discarded – undo
1981 1981
 	 * @return boolean of success
1982 1982
 	 * @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.
1983 1983
 	 */
1984
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
1984
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1985 1985
 		$relation_obj = $this->related_settings_for($relationName);
1986
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
1986
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1987 1987
 	}
1988 1988
 
1989 1989
 
@@ -1996,9 +1996,9 @@  discard block
 block discarded – undo
1996 1996
 	 * @param EE_Base_Class[] objects to which relations were removed
1997 1997
 	 * @return \EE_Base_Class[]
1998 1998
 	 */
1999
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
1999
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2000 2000
 		$relation_obj = $this->related_settings_for($relationName);
2001
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2001
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2002 2002
 	}
2003 2003
 
2004 2004
 
@@ -2011,10 +2011,10 @@  discard block
 block discarded – undo
2011 2011
 	 * @param array $query_params like EEM_Base::get_all
2012 2012
 	 * @return EE_Base_Class[]
2013 2013
 	 */
2014
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
2014
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
2015 2015
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2016 2016
 		$relation_settings = $this->related_settings_for($model_name);
2017
-		return $relation_settings->get_all_related($model_obj,$query_params);
2017
+		return $relation_settings->get_all_related($model_obj, $query_params);
2018 2018
 	}
2019 2019
 
2020 2020
 	/**
@@ -2027,10 +2027,10 @@  discard block
 block discarded – undo
2027 2027
 	 * @param array $query_params
2028 2028
 	 * @return int how many deleted
2029 2029
 	 */
2030
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2030
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2031 2031
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2032 2032
 		$relation_settings = $this->related_settings_for($model_name);
2033
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2033
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2034 2034
 	}
2035 2035
 
2036 2036
 	/**
@@ -2043,10 +2043,10 @@  discard block
 block discarded – undo
2043 2043
 	 * @param array $query_params
2044 2044
 	 * @return int how many deleted
2045 2045
 	 */
2046
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2046
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2047 2047
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2048 2048
 		$relation_settings = $this->related_settings_for($model_name);
2049
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2049
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2050 2050
 	}
2051 2051
 
2052 2052
 	/**
@@ -2059,17 +2059,17 @@  discard block
 block discarded – undo
2059 2059
 	 * @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;
2060 2060
 	 * @return int
2061 2061
 	 */
2062
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2062
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2063 2063
 		$related_model = $this->get_related_model_obj($model_name);
2064 2064
 		//we're just going to use the query params on the related model's normal get_all query,
2065 2065
 		//except add a condition to say to match the current mod
2066
-		if( ! isset($query_params['default_where_conditions'])){
2067
-			$query_params['default_where_conditions']='none';
2066
+		if ( ! isset($query_params['default_where_conditions'])) {
2067
+			$query_params['default_where_conditions'] = 'none';
2068 2068
 		}
2069 2069
 		$this_model_name = $this->get_this_model_name();
2070 2070
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2071
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2072
-		return $related_model->count($query_params,$field_to_count,$distinct);
2071
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2072
+		return $related_model->count($query_params, $field_to_count, $distinct);
2073 2073
 	}
2074 2074
 
2075 2075
 
@@ -2083,21 +2083,21 @@  discard block
 block discarded – undo
2083 2083
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2084 2084
 	 * @return float
2085 2085
 	 */
2086
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2086
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2087 2087
 		$related_model = $this->get_related_model_obj($model_name);
2088
-		if( ! is_array( $query_params ) ){
2089
-			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' );
2088
+		if ( ! is_array($query_params)) {
2089
+			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');
2090 2090
 			$query_params = array();
2091 2091
 		}
2092 2092
 		//we're just going to use the query params on the related model's normal get_all query,
2093 2093
 		//except add a condition to say to match the current mod
2094
-		if( ! isset($query_params['default_where_conditions'])){
2095
-			$query_params['default_where_conditions']='none';
2094
+		if ( ! isset($query_params['default_where_conditions'])) {
2095
+			$query_params['default_where_conditions'] = 'none';
2096 2096
 		}
2097 2097
 		$this_model_name = $this->get_this_model_name();
2098 2098
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2099
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2100
-		return $related_model->sum($query_params,$field_to_sum);
2099
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2100
+		return $related_model->sum($query_params, $field_to_sum);
2101 2101
 	}
2102 2102
 
2103 2103
 
@@ -2109,12 +2109,12 @@  discard block
 block discarded – undo
2109 2109
 	 * @param array $query_params like EEM_Base::get_all's
2110 2110
 	 * @return EE_Base_Class
2111 2111
 	 */
2112
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2113
-		$query_params['limit']=1;
2114
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2115
-		if( $results ){
2112
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2113
+		$query_params['limit'] = 1;
2114
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2115
+		if ($results) {
2116 2116
 			return array_shift($results);
2117
-		}else{
2117
+		} else {
2118 2118
 			return null;
2119 2119
 		}
2120 2120
 
@@ -2124,8 +2124,8 @@  discard block
 block discarded – undo
2124 2124
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2125 2125
 	 * @return string
2126 2126
 	 */
2127
-	function get_this_model_name(){
2128
-		return str_replace("EEM_","",get_class($this));
2127
+	function get_this_model_name() {
2128
+		return str_replace("EEM_", "", get_class($this));
2129 2129
 	}
2130 2130
 
2131 2131
 	/**
@@ -2133,14 +2133,14 @@  discard block
 block discarded – undo
2133 2133
 	 * @return EE_Any_Foreign_Model_Name_Field
2134 2134
 	 * @throws EE_Error
2135 2135
 	 */
2136
-	public function get_field_containing_related_model_name(){
2137
-		foreach($this->field_settings(true) as $field){
2138
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2136
+	public function get_field_containing_related_model_name() {
2137
+		foreach ($this->field_settings(true) as $field) {
2138
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2139 2139
 				$field_with_model_name = $field;
2140 2140
 			}
2141 2141
 		}
2142
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2143
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2142
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2143
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2144 2144
 		}
2145 2145
 		return $field_with_model_name;
2146 2146
 	}
@@ -2161,19 +2161,19 @@  discard block
 block discarded – undo
2161 2161
 	 * @return int new primary key on main table that got inserted
2162 2162
 	 * @throws EE_Error
2163 2163
 	 */
2164
-	function insert($field_n_values){
2164
+	function insert($field_n_values) {
2165 2165
 		/**
2166 2166
 		 * Filters the fields and their values before inserting an item using the models
2167 2167
 		 * @param array $fields_n_values keys are the fields and values are their new values
2168 2168
 		 * @param EEM_Base $model the model used
2169 2169
 		 */
2170
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2171
-		if($this->_satisfies_unique_indexes($field_n_values)){
2170
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2171
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2172 2172
 			$main_table = $this->_get_main_table();
2173 2173
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2174
-			if( $new_id !== false ) {
2175
-				foreach($this->_get_other_tables() as $other_table){
2176
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2174
+			if ($new_id !== false) {
2175
+				foreach ($this->_get_other_tables() as $other_table) {
2176
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2177 2177
 				}
2178 2178
 			}
2179 2179
 			/**
@@ -2183,9 +2183,9 @@  discard block
 block discarded – undo
2183 2183
 			 * @param array $fields_n_values fields and their values
2184 2184
 			 * @param int|string the ID of the newly-inserted model object
2185 2185
 			 */
2186
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2186
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2187 2187
 			return $new_id;
2188
-		}else{
2188
+		} else {
2189 2189
 			return FALSE;
2190 2190
 		}
2191 2191
 	}
@@ -2198,11 +2198,11 @@  discard block
 block discarded – undo
2198 2198
 	 * @param string $action
2199 2199
 	 * @return boolean
2200 2200
 	 */
2201
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2202
-		foreach($this->unique_indexes() as $index_name => $index){
2201
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2202
+		foreach ($this->unique_indexes() as $index_name => $index) {
2203 2203
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2204
-			if($this->exists(array($uniqueness_where_params))){
2205
-				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__ );
2204
+			if ($this->exists(array($uniqueness_where_params))) {
2205
+				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__);
2206 2206
 				return false;
2207 2207
 			}
2208 2208
 		}
@@ -2223,28 +2223,28 @@  discard block
 block discarded – undo
2223 2223
 	 * @throws EE_Error
2224 2224
 	 * @return EE_Base_Class
2225 2225
 	 */
2226
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2227
-		if($obj_or_fields_array instanceof EE_Base_Class){
2226
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2227
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2228 2228
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2229
-		}elseif( is_array($obj_or_fields_array)){
2229
+		}elseif (is_array($obj_or_fields_array)) {
2230 2230
 			$fields_n_values = $obj_or_fields_array;
2231
-		}else{
2232
-			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));
2231
+		} else {
2232
+			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));
2233 2233
 		}
2234
-		$query_params = array( 'default_where_conditions' => 'minimum' );
2235
-		if( $this->has_primary_key_field() &&
2236
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2237
-				isset($fields_n_values[$this->primary_key_name()])){
2234
+		$query_params = array('default_where_conditions' => 'minimum');
2235
+		if ($this->has_primary_key_field() &&
2236
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2237
+				isset($fields_n_values[$this->primary_key_name()])) {
2238 2238
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2239 2239
 		}
2240
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2240
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2241 2241
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2242 2242
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2243 2243
 		}
2244 2244
 		//if there is nothing to base this search on, then we shouldn't find anything
2245
-		if( ! isset( $query_params[0] ) || ( isset( $query_params[0] ) && empty( $query_params[0] ) ) ) {
2245
+		if ( ! isset($query_params[0]) || (isset($query_params[0]) && empty($query_params[0]))) {
2246 2246
 			return array();
2247
-		}else{
2247
+		} else {
2248 2248
 			return $this->get_one($query_params);
2249 2249
 		}
2250 2250
 	}
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 	 * @param array $query_params
2255 2255
 	 * @return boolean
2256 2256
 	 */
2257
-	function exists($query_params){
2257
+	function exists($query_params) {
2258 2258
 		$query_params['limit'] = 1;
2259 2259
 		return $this->count($query_params) > 0;
2260 2260
 	}
@@ -2264,7 +2264,7 @@  discard block
 block discarded – undo
2264 2264
 	 * @param int|string $id
2265 2265
 	 * @return boolean
2266 2266
 	 */
2267
-	function exists_by_ID($id){
2267
+	function exists_by_ID($id) {
2268 2268
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2269 2269
 	}
2270 2270
 
@@ -2284,45 +2284,45 @@  discard block
 block discarded – undo
2284 2284
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2285 2285
 	 * @return int ID of new row inserted, or FALSE on failure
2286 2286
 	 */
2287
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2287
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2288 2288
 		global $wpdb;
2289 2289
 		$insertion_col_n_values = array();
2290 2290
 		$format_for_insertion = array();
2291 2291
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2292
-		foreach($fields_on_table as $field_name => $field_obj){
2292
+		foreach ($fields_on_table as $field_name => $field_obj) {
2293 2293
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2294
-			if($field_obj->is_auto_increment()){
2294
+			if ($field_obj->is_auto_increment()) {
2295 2295
 				continue;
2296 2296
 			}
2297 2297
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2298 2298
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2299
-			if( $prepared_value !== NULL ){
2300
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2299
+			if ($prepared_value !== NULL) {
2300
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2301 2301
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2302 2302
 			}
2303 2303
 		}
2304 2304
 
2305
-		if($table instanceof EE_Secondary_Table && $new_id){
2305
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2306 2306
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2307 2307
 			//so add the fk to the main table as a column
2308 2308
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2309
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2309
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2310 2310
 		}
2311 2311
 		//insert the new entry
2312
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2313
-		if( $result === false ) {
2312
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2313
+		if ($result === false) {
2314 2314
 			return false;
2315 2315
 		}
2316 2316
 		//ok, now what do we return for the ID of the newly-inserted thing?
2317
-		if($this->has_primary_key_field()){
2318
-			if($this->get_primary_key_field()->is_auto_increment()){
2317
+		if ($this->has_primary_key_field()) {
2318
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2319 2319
 				return $wpdb->insert_id;
2320
-			}else{
2320
+			} else {
2321 2321
 				//it's not an auto-increment primary key, so
2322 2322
 				//it must have been supplied
2323 2323
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2324 2324
 			}
2325
-		}else{
2325
+		} else {
2326 2326
 			//we can't return a  primary key because there is none. instead return
2327 2327
 			//a unique string indicating this model
2328 2328
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2337,15 +2337,15 @@  discard block
 block discarded – undo
2337 2337
 	 * @param array $fields_n_values
2338 2338
 	 * @return mixed string|int|float depending on what the table column will be expecting
2339 2339
 	 */
2340
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2340
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2341 2341
 		//if this field doesn't allow nullable, don't allow it
2342
-		if( ! $field_obj->is_nullable() && (
2343
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2344
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2345
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2342
+		if ( ! $field_obj->is_nullable() && (
2343
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2344
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2345
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2346 2346
 		}
2347
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2348
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2347
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2348
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2349 2349
 	}
2350 2350
 
2351 2351
 
@@ -2357,9 +2357,9 @@  discard block
 block discarded – undo
2357 2357
 	 * @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
2358 2358
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2359 2359
 	 */
2360
-	private function _prepare_value_for_use_in_db($value, $field){
2361
-		if($field && $field instanceof EE_Model_Field_Base){
2362
-			switch( $this->_values_already_prepared_by_model_object ){
2360
+	private function _prepare_value_for_use_in_db($value, $field) {
2361
+		if ($field && $field instanceof EE_Model_Field_Base) {
2362
+			switch ($this->_values_already_prepared_by_model_object) {
2363 2363
 				/** @noinspection PhpMissingBreakStatementInspection */
2364 2364
 				case self::not_prepared_by_model_object:
2365 2365
 					$value = $field->prepare_for_set($value);
@@ -2370,7 +2370,7 @@  discard block
 block discarded – undo
2370 2370
 					//leave the value alone
2371 2371
 			}
2372 2372
 			return $value;
2373
-		}else{
2373
+		} else {
2374 2374
 			return $value;
2375 2375
 		}
2376 2376
 	}
@@ -2380,13 +2380,13 @@  discard block
 block discarded – undo
2380 2380
 	 * @return EE_Primary_Table
2381 2381
 	 * @throws EE_Error
2382 2382
 	 */
2383
-	protected function _get_main_table(){
2384
-		foreach($this->_tables as $table){
2385
-			if($table instanceof EE_Primary_Table){
2383
+	protected function _get_main_table() {
2384
+		foreach ($this->_tables as $table) {
2385
+			if ($table instanceof EE_Primary_Table) {
2386 2386
 				return $table;
2387 2387
 			}
2388 2388
 		}
2389
-		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)));
2389
+		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)));
2390 2390
 	}
2391 2391
 
2392 2392
 	/**
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
 	 */
2406 2406
 	public function second_table() {
2407 2407
 		// grab second table from tables array
2408
-		$second_table = end( $this->_tables );
2408
+		$second_table = end($this->_tables);
2409 2409
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2410 2410
 	}
2411 2411
 
@@ -2418,8 +2418,8 @@  discard block
 block discarded – undo
2418 2418
 	 * @param string $table_alias
2419 2419
 	 * @return EE_Primary_Table | EE_Secondary_Table
2420 2420
 	 */
2421
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2422
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2421
+	public function get_table_obj_by_alias($table_alias = '') {
2422
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2423 2423
 	}
2424 2424
 
2425 2425
 
@@ -2428,10 +2428,10 @@  discard block
 block discarded – undo
2428 2428
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2429 2429
 	 * @return EE_Secondary_Table[]
2430 2430
 	 */
2431
-	protected function _get_other_tables(){
2432
-		$other_tables =array();
2433
-		foreach($this->_tables as $table_alias => $table){
2434
-			if($table instanceof EE_Secondary_Table){
2431
+	protected function _get_other_tables() {
2432
+		$other_tables = array();
2433
+		foreach ($this->_tables as $table_alias => $table) {
2434
+			if ($table instanceof EE_Secondary_Table) {
2435 2435
 				$other_tables[$table_alias] = $table;
2436 2436
 			}
2437 2437
 		}
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
 	 * @param string $table_alias, array key in EEM_Base::_tables
2444 2444
 	 * @return EE_Model_Field_Base[]
2445 2445
 	 */
2446
-	function _get_fields_for_table($table_alias){
2446
+	function _get_fields_for_table($table_alias) {
2447 2447
 		return $this->_fields[$table_alias];
2448 2448
 	}
2449 2449
 
@@ -2455,29 +2455,29 @@  discard block
 block discarded – undo
2455 2455
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2456 2456
 	 * @return EE_Model_Query_Info_Carrier
2457 2457
 	 */
2458
-	function _extract_related_models_from_query($query_params){
2458
+	function _extract_related_models_from_query($query_params) {
2459 2459
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2460
-		if(array_key_exists(0,$query_params)){
2461
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2462
-		}
2463
-		if(array_key_exists('group_by', $query_params)){
2464
-			if(is_array($query_params['group_by'])){
2465
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2466
-			}elseif( ! empty ( $query_params['group_by'] )){
2467
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2460
+		if (array_key_exists(0, $query_params)) {
2461
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2462
+		}
2463
+		if (array_key_exists('group_by', $query_params)) {
2464
+			if (is_array($query_params['group_by'])) {
2465
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2466
+			}elseif ( ! empty ($query_params['group_by'])) {
2467
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2468 2468
 			}
2469 2469
 		}
2470
-		if(array_key_exists('having',$query_params)){
2471
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2470
+		if (array_key_exists('having', $query_params)) {
2471
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2472 2472
 		}
2473
-		if(array_key_exists('order_by', $query_params)){
2474
-			if ( is_array( $query_params['order_by'] ) )
2475
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2476
-			elseif( ! empty( $query_params['order_by'] ))
2477
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2473
+		if (array_key_exists('order_by', $query_params)) {
2474
+			if (is_array($query_params['order_by']))
2475
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2476
+			elseif ( ! empty($query_params['order_by']))
2477
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2478 2478
 		}
2479
-		if(array_key_exists('force_join', $query_params)){
2480
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2479
+		if (array_key_exists('force_join', $query_params)) {
2480
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2481 2481
 		}
2482 2482
 		return $query_info_carrier;
2483 2483
 	}
@@ -2490,34 +2490,34 @@  discard block
 block discarded – undo
2490 2490
 	 * @throws EE_Error
2491 2491
 	 * @return \EE_Model_Query_Info_Carrier
2492 2492
 	 */
2493
-	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){
2494
-		if (!empty($sub_query_params)){
2493
+	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) {
2494
+		if ( ! empty($sub_query_params)) {
2495 2495
 			$sub_query_params = (array) $sub_query_params;
2496
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2496
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2497 2497
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2498
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2498
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2499 2499
 
2500 2500
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2501 2501
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2502 2502
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2503 2503
 				//of array('Registration.TXN_ID'=>23)
2504 2504
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2505
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2506
-					if (! is_array($possibly_array_of_params)){
2505
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2506
+					if ( ! is_array($possibly_array_of_params)) {
2507 2507
 						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"),
2508
-							$param,$possibly_array_of_params));
2509
-					}else{
2510
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2508
+							$param, $possibly_array_of_params));
2509
+					} else {
2510
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2511 2511
 					}
2512
-				}elseif($query_param_type === 0 //ie WHERE
2512
+				}elseif ($query_param_type === 0 //ie WHERE
2513 2513
 						&& is_array($possibly_array_of_params)
2514 2514
 						&& isset($possibly_array_of_params[2])
2515
-						&& $possibly_array_of_params[2] == true){
2515
+						&& $possibly_array_of_params[2] == true) {
2516 2516
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2517 2517
 					//indicating that $possible_array_of_params[1] is actually a field name,
2518 2518
 					//from which we should extract query parameters!
2519
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2520
-						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)));
2519
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2520
+						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)));
2521 2521
 					}
2522 2522
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2523 2523
 				}
@@ -2536,14 +2536,14 @@  discard block
 block discarded – undo
2536 2536
 	 * @throws EE_Error
2537 2537
 	 * @return \EE_Model_Query_Info_Carrier
2538 2538
 	 */
2539
-	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){
2540
-		if (!empty($sub_query_params)){
2541
-			if(!is_array($sub_query_params)){
2542
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2539
+	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) {
2540
+		if ( ! empty($sub_query_params)) {
2541
+			if ( ! is_array($sub_query_params)) {
2542
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2543 2543
 			}
2544
-			foreach($sub_query_params as $param){
2544
+			foreach ($sub_query_params as $param) {
2545 2545
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2546
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2546
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2547 2547
 			}
2548 2548
 		}
2549 2549
 		return $model_query_info_carrier;
@@ -2562,81 +2562,81 @@  discard block
 block discarded – undo
2562 2562
 	 * @throws EE_Error
2563 2563
 	 * @return EE_Model_Query_Info_Carrier
2564 2564
 	 */
2565
-	function _create_model_query_info_carrier($query_params){
2566
-		if( ! is_array( $query_params ) ){
2567
-			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' );
2565
+	function _create_model_query_info_carrier($query_params) {
2566
+		if ( ! is_array($query_params)) {
2567
+			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');
2568 2568
 			$query_params = array();
2569 2569
 		}
2570
-		if( isset( $query_params[0] ) ) {
2570
+		if (isset($query_params[0])) {
2571 2571
 			$where_query_params = $query_params[0];
2572
-		}else{
2572
+		} else {
2573 2573
 			$where_query_params = array();
2574 2574
 		}
2575 2575
 		//first check if we should alter the query to account for caps or not
2576 2576
 		//because the caps might require us to do extra joins
2577
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2578
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2577
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2578
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2579 2579
 		}
2580 2580
 		$query_object = $this->_extract_related_models_from_query($query_params);
2581 2581
 
2582 2582
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2583
-		foreach($where_query_params as $key => $value){
2584
-			if(is_int($key)){
2585
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2583
+		foreach ($where_query_params as $key => $value) {
2584
+			if (is_int($key)) {
2585
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2586 2586
 			}
2587 2587
 		}
2588
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2588
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2589 2589
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2590
-		}else{
2590
+		} else {
2591 2591
 			$use_default_where_conditions = 'all';
2592 2592
 		}
2593
-		$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 );
2594
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2593
+		$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);
2594
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2595 2595
 
2596 2596
 
2597 2597
 		//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:
2598 2598
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2599
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2600
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2599
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2600
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2601 2601
 		}
2602 2602
 
2603 2603
 
2604 2604
 		//set limit
2605
-		if(array_key_exists('limit',$query_params)){
2606
-			if(is_array($query_params['limit'])){
2607
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2608
-					$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']));
2605
+		if (array_key_exists('limit', $query_params)) {
2606
+			if (is_array($query_params['limit'])) {
2607
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2608
+					$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']));
2609 2609
 					throw new EE_Error($e."|".$e);
2610 2610
 				}
2611 2611
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2612 2612
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2613
-			}elseif( ! empty ( $query_params['limit'] )){
2613
+			}elseif ( ! empty ($query_params['limit'])) {
2614 2614
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2615 2615
 			}
2616 2616
 		}
2617 2617
 		//set order by
2618
-		if(array_key_exists('order_by',$query_params)){
2619
-			if(is_array($query_params['order_by'])){
2618
+		if (array_key_exists('order_by', $query_params)) {
2619
+			if (is_array($query_params['order_by'])) {
2620 2620
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2621 2621
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2622 2622
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2623
-				if(array_key_exists('order', $query_params)){
2623
+				if (array_key_exists('order', $query_params)) {
2624 2624
 					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"),
2625
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2625
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2626 2626
 				}
2627
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2627
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2628 2628
 				//assume it's an array of fields to order by
2629 2629
 				$order_array = array();
2630
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2630
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2631 2631
 					$order = $this->_extract_order($order);
2632 2632
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2633 2633
 				}
2634
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2635
-			}elseif( ! empty ( $query_params['order_by'] )){
2636
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2637
-				if(isset($query_params['order'])){
2634
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2635
+			}elseif ( ! empty ($query_params['order_by'])) {
2636
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2637
+				if (isset($query_params['order'])) {
2638 2638
 					$order = $this->_extract_order($query_params['order']);
2639
-				}else{
2639
+				} else {
2640 2640
 					$order = 'DESC';
2641 2641
 				}
2642 2642
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2644,46 +2644,46 @@  discard block
 block discarded – undo
2644 2644
 		}
2645 2645
 
2646 2646
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2647
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2647
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2648 2648
 			$pk_field = $this->get_primary_key_field();
2649 2649
 			$order = $this->_extract_order($query_params['order']);
2650 2650
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2651 2651
 		}
2652 2652
 
2653 2653
 		//set group by
2654
-		if(array_key_exists('group_by',$query_params)){
2655
-			if(is_array($query_params['group_by'])){
2654
+		if (array_key_exists('group_by', $query_params)) {
2655
+			if (is_array($query_params['group_by'])) {
2656 2656
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2657 2657
 				$group_by_array = array();
2658
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2658
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2659 2659
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2660 2660
 				}
2661
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2662
-			}elseif( ! empty ( $query_params['group_by'] )){
2661
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2662
+			}elseif ( ! empty ($query_params['group_by'])) {
2663 2663
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2664 2664
 			}
2665 2665
 		}
2666 2666
 		//set having
2667
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2668
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2667
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2668
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2669 2669
 		}
2670 2670
 
2671 2671
 		//now, just verify they didn't pass anything wack
2672
-		foreach($query_params as $query_key => $query_value){
2673
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2672
+		foreach ($query_params as $query_key => $query_value) {
2673
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2674 2674
 				throw new EE_Error(
2675 2675
 					sprintf(
2676
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2676
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2677 2677
 						$query_key,
2678 2678
 						get_class($this),
2679 2679
 //						print_r( $this->_allowed_query_params, TRUE )
2680
-						implode( ',', $this->_allowed_query_params )
2680
+						implode(',', $this->_allowed_query_params)
2681 2681
 					)
2682 2682
 				);
2683 2683
 			}
2684 2684
 		}
2685 2685
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2686
-		if ( empty( $main_model_join_sql ) )
2686
+		if (empty($main_model_join_sql))
2687 2687
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2688 2688
 		return $query_object;
2689 2689
 	}
@@ -2694,17 +2694,17 @@  discard block
 block discarded – undo
2694 2694
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2695 2695
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2696 2696
 	 */
2697
-	public function caps_where_conditions( $context = self::caps_read ) {
2698
-		EEM_Base::verify_is_valid_cap_context( $context );
2697
+	public function caps_where_conditions($context = self::caps_read) {
2698
+		EEM_Base::verify_is_valid_cap_context($context);
2699 2699
 		$cap_where_conditions = array();
2700
-		$cap_restrictions = $this->caps_missing( $context );
2700
+		$cap_restrictions = $this->caps_missing($context);
2701 2701
 		/**
2702 2702
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2703 2703
 		 */
2704
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2705
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2704
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2705
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2706 2706
 		}
2707
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2707
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2708 2708
 	}
2709 2709
 
2710 2710
 	/**
@@ -2714,11 +2714,11 @@  discard block
 block discarded – undo
2714 2714
 	 * @return string either ASC, asc, DESC or desc
2715 2715
 	 * @throws EE_Error
2716 2716
 	 */
2717
-	private function _extract_order($should_be_order_string){
2718
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2717
+	private function _extract_order($should_be_order_string) {
2718
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2719 2719
 			return $should_be_order_string;
2720
-		}else{
2721
-			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));
2720
+		} else {
2721
+			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));
2722 2722
 		}
2723 2723
 	}
2724 2724
 
@@ -2736,25 +2736,25 @@  discard block
 block discarded – undo
2736 2736
 	 * @throws EE_Error
2737 2737
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2738 2738
 	 */
2739
-	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()){
2740
-		$allowed_used_default_where_conditions_values = array('all', 'minimum', 'this_model_only', 'other_models_only','none');
2741
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2742
-			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)));
2739
+	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()) {
2740
+		$allowed_used_default_where_conditions_values = array('all', 'minimum', 'this_model_only', 'other_models_only', 'none');
2741
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2742
+			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)));
2743 2743
 		}
2744
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2744
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2745 2745
 			$universal_query_params = $this->_get_default_where_conditions();
2746
-		}elseif( $use_default_where_conditions == 'minimum' ) {
2746
+		}elseif ($use_default_where_conditions == 'minimum') {
2747 2747
 			$universal_query_params = $this->_get_minimum_where_conditions();
2748
-		}else{
2748
+		} else {
2749 2749
 			$universal_query_params = array();
2750 2750
 		}
2751 2751
 
2752
-		if(in_array($use_default_where_conditions,array('all', 'minimum',  'other_models_only'))){
2753
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2752
+		if (in_array($use_default_where_conditions, array('all', 'minimum', 'other_models_only'))) {
2753
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2754 2754
 				$related_model = $this->get_related_model_obj($model_name);
2755
-				if( $use_default_where_conditions == 'minimum' ) {
2755
+				if ($use_default_where_conditions == 'minimum') {
2756 2756
 					$related_model_universal_where_params = $related_model->_get_minimum_where_conditions($model_relation_path);
2757
-				}else{
2757
+				} else {
2758 2758
 					$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2759 2759
 				}
2760 2760
 
@@ -2781,22 +2781,22 @@  discard block
 block discarded – undo
2781 2781
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2782 2782
 	 * @return array like EEM_Base::get_all's $query_params[0]
2783 2783
 	 */
2784
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2784
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2785 2785
 		$null_friendly_where_conditions = array();
2786 2786
 		$none_overridden = true;
2787 2787
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2788 2788
 
2789
-		foreach($default_where_conditions as $key => $val){
2790
-			if( isset($provided_where_conditions[$key])){
2789
+		foreach ($default_where_conditions as $key => $val) {
2790
+			if (isset($provided_where_conditions[$key])) {
2791 2791
 				$none_overridden = false;
2792
-			}else{
2792
+			} else {
2793 2793
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2794 2794
 			}
2795 2795
 		}
2796
-		if( $none_overridden && $default_where_conditions){
2797
-			if($model->has_primary_key_field()){
2796
+		if ($none_overridden && $default_where_conditions) {
2797
+			if ($model->has_primary_key_field()) {
2798 2798
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2799
-			}else{
2799
+			} else {
2800 2800
 				//@todo NO PK, use other defaults
2801 2801
 			}
2802 2802
 		}
@@ -2811,8 +2811,8 @@  discard block
 block discarded – undo
2811 2811
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2812 2812
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2813 2813
 	 */
2814
-	protected function _get_default_where_conditions($model_relation_path = null){
2815
-		if ( $this->_ignore_where_strategy )
2814
+	protected function _get_default_where_conditions($model_relation_path = null) {
2815
+		if ($this->_ignore_where_strategy)
2816 2816
 			return array();
2817 2817
 
2818 2818
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2826,8 +2826,8 @@  discard block
 block discarded – undo
2826 2826
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2827 2827
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2828 2828
 	 */
2829
-	private function _get_minimum_where_conditions($model_relation_path = null){
2830
-		if ( $this->_ignore_where_strategy )
2829
+	private function _get_minimum_where_conditions($model_relation_path = null) {
2830
+		if ($this->_ignore_where_strategy)
2831 2831
 			return array();
2832 2832
 
2833 2833
 		return $this->_default_where_conditions_strategy->get_minimum_where_conditions($model_relation_path);
@@ -2838,13 +2838,13 @@  discard block
 block discarded – undo
2838 2838
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2839 2839
 	 * @return string
2840 2840
 	 */
2841
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2841
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2842 2842
 		$selects = $this->_get_columns_to_select_for_this_model();
2843
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2843
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2844 2844
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2845 2845
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2846 2846
 		}
2847
-		return implode(", ",$selects);
2847
+		return implode(", ", $selects);
2848 2848
 	}
2849 2849
 
2850 2850
 	/**
@@ -2853,19 +2853,19 @@  discard block
 block discarded – undo
2853 2853
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2854 2854
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2855 2855
 	 */
2856
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2856
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2857 2857
 		$fields = $this->field_settings();
2858 2858
 		$selects = array();
2859 2859
 		$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());
2860
-		foreach($fields as $field_obj){
2861
-			$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()."'";
2860
+		foreach ($fields as $field_obj) {
2861
+			$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()."'";
2862 2862
 		}
2863 2863
 		//make sure we are also getting the PKs of each table
2864 2864
 		$tables = $this->get_tables();
2865
-		if(count($tables) > 1){
2866
-			foreach($tables as $table_obj){
2867
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2868
-				if( ! in_array($qualified_pk_column,$selects)){
2865
+		if (count($tables) > 1) {
2866
+			foreach ($tables as $table_obj) {
2867
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2868
+				if ( ! in_array($qualified_pk_column, $selects)) {
2869 2869
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2870 2870
 				}
2871 2871
 			}
@@ -2889,66 +2889,66 @@  discard block
 block discarded – undo
2889 2889
 	 * @throws EE_Error
2890 2890
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2891 2891
 	 */
2892
-	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 ){
2893
-		if($original_query_param == NULL){
2892
+	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) {
2893
+		if ($original_query_param == NULL) {
2894 2894
 			$original_query_param = $query_param;
2895 2895
 		}
2896 2896
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2897 2897
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2898
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2899
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2898
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2899
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2900 2900
 		//check to see if we have a field on this model
2901 2901
 		$this_model_fields = $this->field_settings(true);
2902
-		if(array_key_exists($query_param,$this_model_fields)){
2903
-			if($allow_fields){
2902
+		if (array_key_exists($query_param, $this_model_fields)) {
2903
+			if ($allow_fields) {
2904 2904
 				return;
2905
-			}else{
2905
+			} else {
2906 2906
 				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"),
2907
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2907
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2908 2908
 			}
2909 2909
 		}
2910 2910
 		//check if this is a special logic query param
2911
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2912
-			if($allow_logic_query_params){
2911
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2912
+			if ($allow_logic_query_params) {
2913 2913
 				return;
2914
-			}else{
2914
+			} else {
2915 2915
 				throw new EE_Error(
2916 2916
 					sprintf(
2917
-						__( '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' ),
2918
-						implode( '", "', $this->_logic_query_param_keys ),
2919
-						$query_param ,
2920
-						get_class( $this ),
2917
+						__('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'),
2918
+						implode('", "', $this->_logic_query_param_keys),
2919
+						$query_param,
2920
+						get_class($this),
2921 2921
 						'<br />',
2922
-						"\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
2922
+						"\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
2923 2923
 					)
2924 2924
 				);
2925 2925
 			}
2926 2926
 		}
2927 2927
 
2928 2928
 		//check if it's a custom selection
2929
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2929
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2930 2930
 			return;
2931 2931
 		}
2932 2932
 
2933 2933
 		//check if has a model name at the beginning
2934 2934
 		//and
2935 2935
 		//check if it's a field on a related model
2936
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2937
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2938
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2936
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2937
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2938
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2939 2939
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2940
-				if($query_param == ''){
2940
+				if ($query_param == '') {
2941 2941
 					//nothing left to $query_param
2942 2942
 					//we should actually end in a field name, not a model like this!
2943 2943
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2944
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2945
-				}else{
2944
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2945
+				} else {
2946 2946
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2947 2947
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2948 2948
 					return;
2949 2949
 				}
2950
-			}elseif($query_param == $valid_related_model_name){
2951
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2950
+			}elseif ($query_param == $valid_related_model_name) {
2951
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2952 2952
 				return;
2953 2953
 			}
2954 2954
 		}
@@ -2958,7 +2958,7 @@  discard block
 block discarded – undo
2958 2958
 		//and we previously confirmed it wasn't a logic query param or field on the current model
2959 2959
 		//it's wack, that's what it is
2960 2960
 		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"),
2961
-				$query_param,get_class($this),$query_param_type,$original_query_param));
2961
+				$query_param, get_class($this), $query_param_type, $original_query_param));
2962 2962
 
2963 2963
 	}
2964 2964
 
@@ -2975,26 +2975,26 @@  discard block
 block discarded – undo
2975 2975
 	 * 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)
2976 2976
 	 * @return void
2977 2977
 	 */
2978
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
2978
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
2979 2979
 		$relation_obj = $this->related_settings_for($model_name);
2980 2980
 
2981 2981
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
2982 2982
 		//check if the relation is HABTM, because then we're essentially doing two joins
2983 2983
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
2984
-		if($relation_obj instanceof EE_HABTM_Relation){
2984
+		if ($relation_obj instanceof EE_HABTM_Relation) {
2985 2985
 			$join_model_obj = $relation_obj->get_join_model();
2986 2986
 			//replace the model specified with the join model for this relation chain, whi
2987 2987
 			$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);
2988 2988
 			$new_query_info = new EE_Model_Query_Info_Carrier(
2989 2989
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
2990 2990
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
2991
-			$passed_in_query_info->merge( $new_query_info  );
2991
+			$passed_in_query_info->merge($new_query_info);
2992 2992
 		}
2993 2993
 		//now just join to the other table pointed to by the relation object, and add its data types
2994 2994
 		$new_query_info = new EE_Model_Query_Info_Carrier(
2995 2995
 				array($model_relation_chain=>$model_name),
2996 2996
 				$relation_obj->get_join_statement($model_relation_chain));
2997
-		$passed_in_query_info->merge( $new_query_info  );
2997
+		$passed_in_query_info->merge($new_query_info);
2998 2998
 	}
2999 2999
 
3000 3000
 
@@ -3003,11 +3003,11 @@  discard block
 block discarded – undo
3003 3003
 	 * @param array $where_params like EEM_Base::get_all
3004 3004
 	 * @return string of SQL
3005 3005
 	 */
3006
-	private function _construct_where_clause($where_params){
3006
+	private function _construct_where_clause($where_params) {
3007 3007
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3008
-		if($SQL){
3009
-			return " WHERE ". $SQL;
3010
-		}else{
3008
+		if ($SQL) {
3009
+			return " WHERE ".$SQL;
3010
+		} else {
3011 3011
 			return '';
3012 3012
 		}
3013 3013
 	}
@@ -3018,11 +3018,11 @@  discard block
 block discarded – undo
3018 3018
 	 * @param array $having_params
3019 3019
 	 * @return string
3020 3020
 	 */
3021
-	private function _construct_having_clause($having_params){
3021
+	private function _construct_having_clause($having_params) {
3022 3022
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3023
-		if($SQL){
3024
-			return " HAVING ". $SQL;
3025
-		}else{
3023
+		if ($SQL) {
3024
+			return " HAVING ".$SQL;
3025
+		} else {
3026 3026
 			return '';
3027 3027
 		}
3028 3028
 
@@ -3036,17 +3036,17 @@  discard block
 block discarded – undo
3036 3036
 	 * @return EE_Model_Field_Base
3037 3037
 	 * @throws EE_Error
3038 3038
 	 */
3039
-	protected function _get_field_on_model($field_name,$model_name){
3039
+	protected function _get_field_on_model($field_name, $model_name) {
3040 3040
 		$model_class = 'EEM_'.$model_name;
3041 3041
 		$model_filepath = $model_class.".model.php";
3042
-		EE_Registry::instance()->load_helper( 'File' );
3043
-		if ( is_readable($model_filepath)){
3042
+		EE_Registry::instance()->load_helper('File');
3043
+		if (is_readable($model_filepath)) {
3044 3044
 			require_once($model_filepath);
3045
-			$model_instance=call_user_func($model_name."::instance");
3045
+			$model_instance = call_user_func($model_name."::instance");
3046 3046
 			/* @var $model_instance EEM_Base */
3047 3047
 			return $model_instance->field_settings_for($field_name);
3048
-		}else{
3049
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3048
+		} else {
3049
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3050 3050
 		}
3051 3051
 	}
3052 3052
 
@@ -3059,43 +3059,43 @@  discard block
 block discarded – undo
3059 3059
 	 * @throws EE_Error
3060 3060
 	 * @return string of SQL
3061 3061
 	 */
3062
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3063
-		$where_clauses=array();
3064
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3065
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3066
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3067
-				switch($query_param){
3062
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3063
+		$where_clauses = array();
3064
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3065
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3066
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3067
+				switch ($query_param) {
3068 3068
 					case 'not':
3069 3069
 					case 'NOT':
3070
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3070
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3071 3071
 						break;
3072 3072
 					case 'and':
3073 3073
 					case 'AND':
3074
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3074
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3075 3075
 						break;
3076 3076
 					case 'or':
3077 3077
 					case 'OR':
3078
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3078
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3079 3079
 						break;
3080 3080
 				}
3081
-			}else{
3081
+			} else {
3082 3082
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3083 3083
 
3084 3084
 				//if it's not a normal field, maybe it's a custom selection?
3085
-				if( ! $field_obj){
3086
-					if(isset( $this->_custom_selections[$query_param][1])){
3085
+				if ( ! $field_obj) {
3086
+					if (isset($this->_custom_selections[$query_param][1])) {
3087 3087
 						$field_obj = $this->_custom_selections[$query_param][1];
3088
-					}else{
3089
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3088
+					} else {
3089
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3090 3090
 					}
3091 3091
 				}
3092 3092
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3093
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3093
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3094 3094
 			}
3095 3095
 		}
3096
-		if($where_clauses){
3097
-			$SQL = implode($glue,$where_clauses);
3098
-		}else{
3096
+		if ($where_clauses) {
3097
+			$SQL = implode($glue, $where_clauses);
3098
+		} else {
3099 3099
 			$SQL = '';
3100 3100
 		}
3101 3101
 		return $SQL;
@@ -3109,18 +3109,18 @@  discard block
 block discarded – undo
3109 3109
 	 * @throws EE_Error
3110 3110
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3111 3111
 	 */
3112
-	private function _deduce_column_name_from_query_param($query_param){
3112
+	private function _deduce_column_name_from_query_param($query_param) {
3113 3113
 		$field = $this->_deduce_field_from_query_param($query_param);
3114 3114
 
3115
-		if( $field ){
3116
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3117
-			return $table_alias_prefix . $field->get_qualified_column();
3118
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3115
+		if ($field) {
3116
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3117
+			return $table_alias_prefix.$field->get_qualified_column();
3118
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3119 3119
 			//maybe it's custom selection item?
3120 3120
 			//if so, just use it as the "column name"
3121 3121
 			return $query_param;
3122
-		}else{
3123
-			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)));
3122
+		} else {
3123
+			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)));
3124 3124
 		}
3125 3125
 	}
3126 3126
 
@@ -3132,11 +3132,11 @@  discard block
 block discarded – undo
3132 3132
 	 * @param string $condition_query_param_key
3133 3133
 	 * @return string
3134 3134
 	 */
3135
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3135
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3136 3136
 		$pos_of_star = strpos($condition_query_param_key, '*');
3137
-		if($pos_of_star === FALSE){
3137
+		if ($pos_of_star === FALSE) {
3138 3138
 			return $condition_query_param_key;
3139
-		}else{
3139
+		} else {
3140 3140
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3141 3141
 			return $condition_query_param_sans_star;
3142 3142
 		}
@@ -3151,54 +3151,54 @@  discard block
 block discarded – undo
3151 3151
 	 * @throws EE_Error
3152 3152
 	 * @return string
3153 3153
 	 */
3154
-	private function _construct_op_and_value($op_and_value, $field_obj){
3155
-		if(is_array( $op_and_value )){
3154
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3155
+		if (is_array($op_and_value)) {
3156 3156
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3157
-			if( ! $operator){
3157
+			if ( ! $operator) {
3158 3158
 				$php_array_like_string = array();
3159
-				foreach($op_and_value as $key => $value){
3159
+				foreach ($op_and_value as $key => $value) {
3160 3160
 					$php_array_like_string[] = "$key=>$value";
3161 3161
 				}
3162
-				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)));
3162
+				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)));
3163 3163
 			}
3164 3164
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3165
-		}else{
3165
+		} else {
3166 3166
 			$operator = '=';
3167 3167
 			$value = $op_and_value;
3168 3168
 		}
3169 3169
 
3170 3170
 		//check to see if the value is actually another field
3171
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3171
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3172 3172
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3173
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3173
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3174 3174
 			//in this case, the value should be an array, or at least a comma-separated list
3175 3175
 			//it will need to handle a little differently
3176 3176
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3177 3177
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3178 3178
 			return $operator.SP.$cleaned_value;
3179
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3179
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3180 3180
 			//the value should be an array with count of two.
3181
-			if ( count($value) !== 2 )
3182
-				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" ) );
3183
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3181
+			if (count($value) !== 2)
3182
+				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"));
3183
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3184 3184
 			return $operator.SP.$cleaned_value;
3185
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
3186
-			if($value != NULL){
3187
-				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));
3185
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3186
+			if ($value != NULL) {
3187
+				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));
3188 3188
 			}
3189 3189
 			return $operator;
3190
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3190
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
3191 3191
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3192 3192
 			//remove other junk. So just treat it as a string.
3193 3193
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3194
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3195
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3196
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3197
-			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));
3198
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3199
-			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));
3200
-		}else{
3201
-			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)));
3194
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3195
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3196
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3197
+			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));
3198
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3199
+			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));
3200
+		} else {
3201
+			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)));
3202 3202
 		}
3203 3203
 	}
3204 3204
 
@@ -3210,12 +3210,12 @@  discard block
 block discarded – undo
3210 3210
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
3211 3211
 	 * @return string
3212 3212
 	 */
3213
-	function _construct_between_value( $values, $field_obj ) {
3213
+	function _construct_between_value($values, $field_obj) {
3214 3214
 		$cleaned_values = array();
3215
-		foreach ( $values as $value ) {
3216
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3215
+		foreach ($values as $value) {
3216
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3217 3217
 		}
3218
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3218
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3219 3219
 	}
3220 3220
 
3221 3221
 
@@ -3231,26 +3231,26 @@  discard block
 block discarded – undo
3231 3231
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
3232 3232
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3233 3233
 	 */
3234
-	function _construct_in_value($values,  $field_obj){
3234
+	function _construct_in_value($values, $field_obj) {
3235 3235
 		//check if the value is a CSV list
3236
-		if(is_string($values)){
3236
+		if (is_string($values)) {
3237 3237
 			//in which case, turn it into an array
3238
-			$values = explode(",",$values);
3238
+			$values = explode(",", $values);
3239 3239
 		}
3240 3240
 		$cleaned_values = array();
3241
-		foreach($values as $value){
3242
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3241
+		foreach ($values as $value) {
3242
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3243 3243
 		}
3244 3244
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3245 3245
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3246 3246
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3247
-		if(empty($cleaned_values)){
3247
+		if (empty($cleaned_values)) {
3248 3248
 			$all_fields = $this->field_settings();
3249 3249
 			$a_field = array_shift($all_fields);
3250 3250
 			$main_table = $this->_get_main_table();
3251 3251
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3252 3252
 		}
3253
-		return "(".implode(",",$cleaned_values).")";
3253
+		return "(".implode(",", $cleaned_values).")";
3254 3254
 	}
3255 3255
 
3256 3256
 
@@ -3262,16 +3262,16 @@  discard block
 block discarded – undo
3262 3262
 	 * @throws EE_Error
3263 3263
 	 * @return false|null|string
3264 3264
 	 */
3265
-	private function _wpdb_prepare_using_field($value,$field_obj){
3265
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3266 3266
 		/** @type WPDB $wpdb */
3267 3267
 		global $wpdb;
3268
-		if($field_obj instanceof EE_Model_Field_Base){
3269
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3270
-		}else{//$field_obj should really just be a data type
3271
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3272
-				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)));
3268
+		if ($field_obj instanceof EE_Model_Field_Base) {
3269
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3270
+		} else {//$field_obj should really just be a data type
3271
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3272
+				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)));
3273 3273
 			}
3274
-			return $wpdb->prepare($field_obj,$value);
3274
+			return $wpdb->prepare($field_obj, $value);
3275 3275
 		}
3276 3276
 	}
3277 3277
 
@@ -3283,27 +3283,27 @@  discard block
 block discarded – undo
3283 3283
 	 * @throws EE_Error
3284 3284
 	 * @return EE_Model_Field_Base
3285 3285
 	 */
3286
-	protected function _deduce_field_from_query_param($query_param_name){
3286
+	protected function _deduce_field_from_query_param($query_param_name) {
3287 3287
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3288 3288
 		//which will help us find the database table and column
3289 3289
 
3290
-		$query_param_parts = explode(".",$query_param_name);
3291
-		if(empty($query_param_parts)){
3292
-			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));
3290
+		$query_param_parts = explode(".", $query_param_name);
3291
+		if (empty($query_param_parts)) {
3292
+			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));
3293 3293
 		}
3294 3294
 		$number_of_parts = count($query_param_parts);
3295
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3296
-		if($number_of_parts == 1){
3295
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3296
+		if ($number_of_parts == 1) {
3297 3297
 			$field_name = $last_query_param_part;
3298 3298
 			$model_obj = $this;
3299
-		}else{// $number_of_parts >= 2
3299
+		} else {// $number_of_parts >= 2
3300 3300
 			//the last part is the column name, and there are only 2parts. therefore...
3301 3301
 			$field_name = $last_query_param_part;
3302
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3302
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3303 3303
 		}
3304
-		try{
3304
+		try {
3305 3305
 			return $model_obj->field_settings_for($field_name);
3306
-		}catch(EE_Error $e){
3306
+		} catch (EE_Error $e) {
3307 3307
 			return null;
3308 3308
 		}
3309 3309
 	}
@@ -3317,13 +3317,13 @@  discard block
 block discarded – undo
3317 3317
 	 * @throws EE_Error
3318 3318
 	 * @return string
3319 3319
 	 */
3320
-	function _get_qualified_column_for_field($field_name){
3320
+	function _get_qualified_column_for_field($field_name) {
3321 3321
 		$all_fields = $this->field_settings();
3322 3322
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3323
-		if($field){
3323
+		if ($field) {
3324 3324
 			return $field->get_qualified_column();
3325
-		}else{
3326
-			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)));
3325
+		} else {
3326
+			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)));
3327 3327
 		}
3328 3328
 	}
3329 3329
 
@@ -3337,14 +3337,14 @@  discard block
 block discarded – undo
3337 3337
 	 * @param  mixed|string $limit The limit for this select
3338 3338
 	 * @return string 				The final select join element for the query.
3339 3339
 	 */
3340
-	function _construct_limit_join_select( $table_alias, $limit ) {
3340
+	function _construct_limit_join_select($table_alias, $limit) {
3341 3341
 		$SQL = '';
3342 3342
 
3343
-		foreach ( $this->_tables as $table_obj ) {
3344
-			if ( $table_obj instanceof EE_Primary_Table ) {
3345
-				$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;
3346
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3347
-				$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;
3343
+		foreach ($this->_tables as $table_obj) {
3344
+			if ($table_obj instanceof EE_Primary_Table) {
3345
+				$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;
3346
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3347
+				$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;
3348 3348
 			}
3349 3349
 		}
3350 3350
 		return $SQL;
@@ -3357,7 +3357,7 @@  discard block
 block discarded – undo
3357 3357
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3358 3358
 	 * @return string SQL
3359 3359
 	 */
3360
-	function _construct_internal_join(){
3360
+	function _construct_internal_join() {
3361 3361
 		$SQL = $this->_get_main_table()->get_table_sql();
3362 3362
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3363 3363
 		return $SQL;
@@ -3378,17 +3378,17 @@  discard block
 block discarded – undo
3378 3378
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3379 3379
 	 * @return string
3380 3380
 	 */
3381
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3381
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3382 3382
 		$SQL = '';
3383 3383
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3384
-		foreach($this->_tables as $table_obj){
3385
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3386
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3384
+		foreach ($this->_tables as $table_obj) {
3385
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3386
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3387 3387
 					//so we're joining to this table, meaning the table is already in
3388 3388
 					//the FROM statement, BUT the primary table isn't. So we want
3389 3389
 					//to add the inverse join sql
3390 3390
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3391
-				}else{
3391
+				} else {
3392 3392
 					//just add a regular JOIN to this table from the primary table
3393 3393
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3394 3394
 				}
@@ -3402,9 +3402,9 @@  discard block
 block discarded – undo
3402 3402
 	 * 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)
3403 3403
 	 * @return array
3404 3404
 	 */
3405
-	function _get_data_types(){
3405
+	function _get_data_types() {
3406 3406
 		$data_types = array();
3407
-		foreach(array_values($this->field_settings()) as $field_obj){
3407
+		foreach (array_values($this->field_settings()) as $field_obj) {
3408 3408
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3409 3409
 			/** @var $field_obj EE_Model_Field_Base */
3410 3410
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3420,11 +3420,11 @@  discard block
 block discarded – undo
3420 3420
 	 * @throws EE_Error
3421 3421
 	 * @return EEM_Base
3422 3422
 	 */
3423
-	function get_related_model_obj($model_name){
3423
+	function get_related_model_obj($model_name) {
3424 3424
 
3425 3425
 		$model_classname = "EEM_".$model_name;
3426
-		if(!class_exists($model_classname)){
3427
-			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));
3426
+		if ( ! class_exists($model_classname)) {
3427
+			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));
3428 3428
 		}
3429 3429
 		$model_obj = call_user_func($model_classname."::instance");
3430 3430
 		return $model_obj;
@@ -3435,7 +3435,7 @@  discard block
 block discarded – undo
3435 3435
 	 * Returns the array of EE_ModelRelations for this model.
3436 3436
 	 * @return EE_Model_Relation_Base[]
3437 3437
 	 */
3438
-	public function relation_settings(){
3438
+	public function relation_settings() {
3439 3439
 		return $this->_model_relations;
3440 3440
 	}
3441 3441
 
@@ -3445,10 +3445,10 @@  discard block
 block discarded – undo
3445 3445
 	 * (Eg, without an event, datetimes have little purpose.)
3446 3446
 	 * @return EE_Belongs_To_Relation[]
3447 3447
 	 */
3448
-	public function belongs_to_relations(){
3448
+	public function belongs_to_relations() {
3449 3449
 		$belongs_to_relations = array();
3450
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3451
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3450
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3451
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3452 3452
 				$belongs_to_relations[$model_name] = $relation_obj;
3453 3453
 			}
3454 3454
 		}
@@ -3463,15 +3463,15 @@  discard block
 block discarded – undo
3463 3463
 	 * @throws EE_Error
3464 3464
 	 * @return EE_Model_Relation_Base
3465 3465
 	 */
3466
-	public function related_settings_for($relation_name){
3467
-		$relatedModels=$this->relation_settings();
3468
-		if(!array_key_exists($relation_name,$relatedModels)){
3466
+	public function related_settings_for($relation_name) {
3467
+		$relatedModels = $this->relation_settings();
3468
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3469 3469
 			throw new EE_Error(
3470 3470
 				sprintf(
3471
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3471
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3472 3472
 					$relation_name,
3473 3473
 					$this->_get_class_name(),
3474
-					implode( ', ', array_keys( $relatedModels ))
3474
+					implode(', ', array_keys($relatedModels))
3475 3475
 				)
3476 3476
 			);
3477 3477
 		}
@@ -3486,10 +3486,10 @@  discard block
 block discarded – undo
3486 3486
 	 * @throws EE_Error
3487 3487
 	 * @return EE_Model_Field_Base
3488 3488
 	 */
3489
-	public function field_settings_for($fieldName){
3490
-		$fieldSettings=$this->field_settings(true);
3491
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3492
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3489
+	public function field_settings_for($fieldName) {
3490
+		$fieldSettings = $this->field_settings(true);
3491
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3492
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3493 3493
 		}
3494 3494
 		return $fieldSettings[$fieldName];
3495 3495
 	}
@@ -3499,11 +3499,11 @@  discard block
 block discarded – undo
3499 3499
 	 * @param string $fieldName a key in the model's _field_settings array
3500 3500
 	 * @return boolean
3501 3501
 	 */
3502
-	public function has_field($fieldName){
3502
+	public function has_field($fieldName) {
3503 3503
 		$fieldSettings = $this->field_settings(true);
3504
-		if( isset($fieldSettings[$fieldName])){
3504
+		if (isset($fieldSettings[$fieldName])) {
3505 3505
 			return true;
3506
-		}else{
3506
+		} else {
3507 3507
 			return false;
3508 3508
 		}
3509 3509
 	}
@@ -3513,11 +3513,11 @@  discard block
 block discarded – undo
3513 3513
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3514 3514
 	 * @return boolean
3515 3515
 	 */
3516
-	public function has_relation($relation_name){
3516
+	public function has_relation($relation_name) {
3517 3517
 		$relations = $this->relation_settings();
3518
-		if(isset($relations[$relation_name])){
3518
+		if (isset($relations[$relation_name])) {
3519 3519
 			return true;
3520
-		}else{
3520
+		} else {
3521 3521
 			return false;
3522 3522
 		}
3523 3523
 	}
@@ -3529,7 +3529,7 @@  discard block
 block discarded – undo
3529 3529
 	 * @param $field_obj
3530 3530
 	 * @return EE_Model_Field_Base
3531 3531
 	 */
3532
-	public function is_primary_key_field( $field_obj ){
3532
+	public function is_primary_key_field($field_obj) {
3533 3533
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3534 3534
 	}
3535 3535
 
@@ -3541,16 +3541,16 @@  discard block
 block discarded – undo
3541 3541
 	 * @return EE_Model_Field_Base
3542 3542
 	 * @throws EE_Error
3543 3543
 	 */
3544
-	public function get_primary_key_field(){
3545
-		if( $this->_primary_key_field === NULL ){
3546
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3547
-				if( $this->is_primary_key_field( $field_obj )){
3544
+	public function get_primary_key_field() {
3545
+		if ($this->_primary_key_field === NULL) {
3546
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3547
+				if ($this->is_primary_key_field($field_obj)) {
3548 3548
 					$this->_primary_key_field = $field_obj;
3549 3549
 					break;
3550 3550
 				}
3551 3551
 			}
3552
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3553
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3552
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3553
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3554 3554
 			}
3555 3555
 		}
3556 3556
 		return $this->_primary_key_field;
@@ -3563,12 +3563,12 @@  discard block
 block discarded – undo
3563 3563
 	 * Internally does some caching.
3564 3564
 	 * @return boolean
3565 3565
 	 */
3566
-	public function has_primary_key_field(){
3567
-		if($this->_has_primary_key_field === null){
3568
-			try{
3566
+	public function has_primary_key_field() {
3567
+		if ($this->_has_primary_key_field === null) {
3568
+			try {
3569 3569
 				$this->get_primary_key_field();
3570 3570
 				$this->_has_primary_key_field = true;
3571
-			}catch(EE_Error $e){
3571
+			} catch (EE_Error $e) {
3572 3572
 				$this->_has_primary_key_field = false;
3573 3573
 			}
3574 3574
 		}
@@ -3582,9 +3582,9 @@  discard block
 block discarded – undo
3582 3582
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3583 3583
 	 * @return EE_Model_Field_Base or null if none is found
3584 3584
 	 */
3585
-	public function get_a_field_of_type($field_class_name){
3586
-		foreach($this->field_settings() as $field){
3587
-			if( $field instanceof $field_class_name ){
3585
+	public function get_a_field_of_type($field_class_name) {
3586
+		foreach ($this->field_settings() as $field) {
3587
+			if ($field instanceof $field_class_name) {
3588 3588
 				return $field;
3589 3589
 			}
3590 3590
 		}
@@ -3598,21 +3598,21 @@  discard block
 block discarded – undo
3598 3598
 	 * @return EE_Foreign_Key_Field_Base
3599 3599
 	 * @throws EE_Error
3600 3600
 	 */
3601
-	public function get_foreign_key_to($model_name){
3602
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3603
-			foreach($this->field_settings() as $field){
3601
+	public function get_foreign_key_to($model_name) {
3602
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3603
+			foreach ($this->field_settings() as $field) {
3604 3604
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3605
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3606
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3607
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3605
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3606
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3607
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3608 3608
 					}
3609 3609
 				}
3610 3610
 			}
3611
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3612
-				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)));
3611
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3612
+				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)));
3613 3613
 			}
3614 3614
 		}
3615
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3615
+		return $this->_cache_foreign_key_to_fields[$model_name];
3616 3616
 	}
3617 3617
 
3618 3618
 
@@ -3623,7 +3623,7 @@  discard block
 block discarded – undo
3623 3623
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3624 3624
 	 * @return EE_Table_Base
3625 3625
 	 */
3626
-	function get_table_for_alias($table_alias){
3626
+	function get_table_for_alias($table_alias) {
3627 3627
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3628 3628
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3629 3629
 	}
@@ -3636,25 +3636,25 @@  discard block
 block discarded – undo
3636 3636
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3637 3637
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3638 3638
 	 */
3639
-	public function field_settings($include_db_only_fields = false){
3640
-		if( $include_db_only_fields ){
3641
-			if( $this->_cached_fields === NULL ){
3639
+	public function field_settings($include_db_only_fields = false) {
3640
+		if ($include_db_only_fields) {
3641
+			if ($this->_cached_fields === NULL) {
3642 3642
 				$this->_cached_fields = array();
3643
-				foreach($this->_fields as $fields_corresponding_to_table){
3644
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3645
-						$this->_cached_fields[$field_name]=$field_obj;
3643
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3644
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3645
+						$this->_cached_fields[$field_name] = $field_obj;
3646 3646
 					}
3647 3647
 				}
3648 3648
 			}
3649 3649
 			return $this->_cached_fields;
3650
-		}else{
3651
-			if( $this->_cached_fields_non_db_only === NULL ){
3650
+		} else {
3651
+			if ($this->_cached_fields_non_db_only === NULL) {
3652 3652
 				$this->_cached_fields_non_db_only = array();
3653
-				foreach($this->_fields as $fields_corresponding_to_table){
3654
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3653
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3654
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3655 3655
 						/** @var $field_obj EE_Model_Field_Base */
3656
-						if( ! $field_obj->is_db_only_field() ){
3657
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3656
+						if ( ! $field_obj->is_db_only_field()) {
3657
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3658 3658
 						}
3659 3659
 					}
3660 3660
 				}
@@ -3673,40 +3673,40 @@  discard block
 block discarded – undo
3673 3673
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3674 3674
 	 * @throws \EE_Error
3675 3675
 	 */
3676
-	protected function _create_objects( $rows = array() ) {
3677
-		$array_of_objects=array();
3678
-		if(empty($rows)){
3676
+	protected function _create_objects($rows = array()) {
3677
+		$array_of_objects = array();
3678
+		if (empty($rows)) {
3679 3679
 			return array();
3680 3680
 		}
3681 3681
 		$count_if_model_has_no_primary_key = 0;
3682
-		foreach ( $rows as $row ) {
3683
-			if(empty($row)){//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3682
+		foreach ($rows as $row) {
3683
+			if (empty($row)) {//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3684 3684
 				return array();
3685 3685
 			}
3686
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3687
-			if( ! $classInstance ) {
3688
-				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 ) ) );
3686
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3687
+			if ( ! $classInstance) {
3688
+				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)));
3689 3689
 			}
3690 3690
 			//set the timezone on the instantiated objects
3691
-			$classInstance->set_timezone( $this->_timezone );
3691
+			$classInstance->set_timezone($this->_timezone);
3692 3692
 			//make sure if there is any timezone setting present that we set the timezone for the object
3693
-			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++]=$classInstance;
3693
+			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++] = $classInstance;
3694 3694
 			//also, for all the relations of type BelongsTo, see if we can cache
3695 3695
 			//those related models
3696 3696
 			//(we could do this for other relations too, but if there are conditions
3697 3697
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3698 3698
 			//so it requires a little more thought than just caching them immediately...)
3699
-			foreach($this->_model_relations as $modelName => $relation_obj){
3700
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3699
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3700
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3701 3701
 					//check if this model's INFO is present. If so, cache it on the model
3702 3702
 					$other_model = $relation_obj->get_other_model();
3703 3703
 
3704 3704
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3705 3705
 
3706 3706
 					//if we managed to make a model object from the results, cache it on the main model object
3707
-					if( $other_model_obj_maybe ){
3707
+					if ($other_model_obj_maybe) {
3708 3708
 						//set timezone on these other model objects if they are present
3709
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3709
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3710 3710
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3711 3711
 					}
3712 3712
 				}
@@ -3727,12 +3727,12 @@  discard block
 block discarded – undo
3727 3727
 
3728 3728
 		$this_model_fields_and_values = array();
3729 3729
 		//setup the row using default values;
3730
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3730
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3731 3731
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3732 3732
 		}
3733 3733
 
3734 3734
 		$className = $this->_get_class_name();
3735
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3735
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3736 3736
 
3737 3737
 		return $classInstance;
3738 3738
 	}
@@ -3745,45 +3745,45 @@  discard block
 block discarded – undo
3745 3745
 	 * or an stdClass where each property is the name of a column,
3746 3746
 	 * @return EE_Base_Class
3747 3747
 	 */
3748
-	public function instantiate_class_from_array_or_object($cols_n_values){
3749
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3750
-			$cols_n_values = get_object_vars( $cols_n_values );
3748
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3749
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3750
+			$cols_n_values = get_object_vars($cols_n_values);
3751 3751
 		}
3752 3752
 		$primary_key = NULL;
3753 3753
 		//make sure the array only has keys that are fields/columns on this model
3754
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3755
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3756
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3754
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3755
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3756
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3757 3757
 		}
3758
-		$className=$this->_get_class_name();
3758
+		$className = $this->_get_class_name();
3759 3759
 
3760 3760
 		//check we actually found results that we can use to build our model object
3761 3761
 		//if not, return null
3762
-		if( $this->has_primary_key_field()){
3763
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3762
+		if ($this->has_primary_key_field()) {
3763
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3764 3764
 				return NULL;
3765 3765
 			}
3766
-		}else if($this->unique_indexes()){
3766
+		} else if ($this->unique_indexes()) {
3767 3767
 			$first_column = reset($this_model_fields_n_values);
3768
-			if(empty($first_column)){
3768
+			if (empty($first_column)) {
3769 3769
 				return NULL;
3770 3770
 			}
3771 3771
 		}
3772 3772
 
3773 3773
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3774
-		if ( $primary_key){
3775
-			$classInstance = $this->get_from_entity_map( $primary_key );
3776
-			if( ! $classInstance) {
3777
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3774
+		if ($primary_key) {
3775
+			$classInstance = $this->get_from_entity_map($primary_key);
3776
+			if ( ! $classInstance) {
3777
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3778 3778
 				// add this new object to the entity map
3779
-				$classInstance = $this->add_to_entity_map( $classInstance );
3779
+				$classInstance = $this->add_to_entity_map($classInstance);
3780 3780
 			}
3781
-		}else{
3782
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3781
+		} else {
3782
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3783 3783
 		}
3784 3784
 
3785 3785
 			//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.
3786
-		$this->set_timezone( $classInstance->get_timezone() );
3786
+		$this->set_timezone($classInstance->get_timezone());
3787 3787
 		return $classInstance;
3788 3788
 	}
3789 3789
 	/**
@@ -3791,8 +3791,8 @@  discard block
 block discarded – undo
3791 3791
 	 * @param int|string $id the ID of the model object
3792 3792
 	 * @return EE_Base_Class
3793 3793
 	 */
3794
-	public function get_from_entity_map( $id ){
3795
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3794
+	public function get_from_entity_map($id) {
3795
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3796 3796
 	}
3797 3797
 
3798 3798
 
@@ -3811,21 +3811,21 @@  discard block
 block discarded – undo
3811 3811
 	 * @throws EE_Error
3812 3812
 	 * @return \EE_Base_Class
3813 3813
 	 */
3814
-	public function add_to_entity_map( EE_Base_Class $object) {
3814
+	public function add_to_entity_map(EE_Base_Class $object) {
3815 3815
 		$className = $this->_get_class_name();
3816
-		if( ! $object instanceof $className ){
3817
-			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 ) );
3816
+		if ( ! $object instanceof $className) {
3817
+			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));
3818 3818
 		}
3819 3819
 		/** @var $object EE_Base_Class */
3820
-		if ( ! $object->ID() ){
3821
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3820
+		if ( ! $object->ID()) {
3821
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3822 3822
 		}
3823 3823
 		// double check it's not already there
3824
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3825
-		if ( $classInstance ) {
3824
+		$classInstance = $this->get_from_entity_map($object->ID());
3825
+		if ($classInstance) {
3826 3826
 			return $classInstance;
3827 3827
 		} else {
3828
-			$this->_entity_map[ $object->ID() ] = $object;
3828
+			$this->_entity_map[$object->ID()] = $object;
3829 3829
 			return $object;
3830 3830
 		}
3831 3831
 	}
@@ -3838,8 +3838,8 @@  discard block
 block discarded – undo
3838 3838
 	 * @param array $cols_n_values
3839 3839
 	 * @return array
3840 3840
 	 */
3841
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3842
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3841
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3842
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3843 3843
 	}
3844 3844
 
3845 3845
 
@@ -3852,40 +3852,40 @@  discard block
 block discarded – undo
3852 3852
 	 * @param string $cols_n_values
3853 3853
 	 * @return array
3854 3854
 	 */
3855
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3855
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3856 3856
 		$this_model_fields_n_values = array();
3857
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3858
-			$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() );
3857
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3858
+			$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());
3859 3859
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3860
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3861
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3862
-					if( ! $field_obj->is_db_only_field() ){
3860
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3861
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3862
+					if ( ! $field_obj->is_db_only_field()) {
3863 3863
 						//prepare field as if its coming from db
3864
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
3865
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3864
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
3865
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
3866 3866
 					}
3867 3867
 				}
3868
-			}else{
3868
+			} else {
3869 3869
 				//the table's rows existed. Use their values
3870
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3871
-					if( ! $field_obj->is_db_only_field() )
3872
-					$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() );
3870
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3871
+					if ( ! $field_obj->is_db_only_field())
3872
+					$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());
3873 3873
 				}
3874 3874
 			}
3875 3875
 		}
3876 3876
 		return $this_model_fields_n_values;
3877 3877
 	}
3878 3878
 
3879
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3879
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3880 3880
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3881 3881
 		//does the field on the model relate to this column retrieved from the db?
3882 3882
 		//or is it a db-only field? (not relating to the model)
3883
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3884
-			$value = $cols_n_values[ $qualified_column ];
3883
+		if (isset($cols_n_values[$qualified_column])) {
3884
+			$value = $cols_n_values[$qualified_column];
3885 3885
 
3886
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3887
-			$value = $cols_n_values[ $regular_column ];
3888
-		}else{
3886
+		}elseif (isset($cols_n_values[$regular_column])) {
3887
+			$value = $cols_n_values[$regular_column];
3888
+		} else {
3889 3889
 			$value = NULL;
3890 3890
 		}
3891 3891
 
@@ -3903,23 +3903,23 @@  discard block
 block discarded – undo
3903 3903
 	 * @param int|string $id
3904 3904
 	 * @return EE_Base_Class
3905 3905
 	 */
3906
-	public function refresh_entity_map_from_db( $id ){
3907
-		$obj_in_map = $this->get_from_entity_map( $id );
3908
-		if( $obj_in_map ){
3909
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3910
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3911
-				$one_row = reset( $wpdb_results );
3912
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3913
-					$obj_in_map->set_from_db( $field_name, $db_value );
3906
+	public function refresh_entity_map_from_db($id) {
3907
+		$obj_in_map = $this->get_from_entity_map($id);
3908
+		if ($obj_in_map) {
3909
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3910
+			if ($wpdb_results && is_array($wpdb_results)) {
3911
+				$one_row = reset($wpdb_results);
3912
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3913
+					$obj_in_map->set_from_db($field_name, $db_value);
3914 3914
 				}
3915 3915
 				//clear the cache of related model objects
3916
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3917
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3916
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3917
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3918 3918
 				}
3919 3919
 			}
3920 3920
 			return $obj_in_map;
3921
-		}else{
3922
-			return $this->get_one_by_ID( $id );
3921
+		} else {
3922
+			return $this->get_one_by_ID($id);
3923 3923
 		}
3924 3924
 	}
3925 3925
 
@@ -3937,24 +3937,24 @@  discard block
 block discarded – undo
3937 3937
 	 * @param EE_Base_Class $replacing_model_obj
3938 3938
 	 * @return \EE_Base_Class
3939 3939
 	 */
3940
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
3941
-		$obj_in_map = $this->get_from_entity_map( $id );
3942
-		if( $obj_in_map ){
3943
-			if( $replacing_model_obj instanceof EE_Base_Class ){
3944
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
3945
-					$obj_in_map->set( $field_name, $value );
3940
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
3941
+		$obj_in_map = $this->get_from_entity_map($id);
3942
+		if ($obj_in_map) {
3943
+			if ($replacing_model_obj instanceof EE_Base_Class) {
3944
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
3945
+					$obj_in_map->set($field_name, $value);
3946 3946
 				}
3947 3947
 				//make the model object in the entity map's cache match the $replacing_model_obj
3948
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3949
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3950
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
3951
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
3948
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3949
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3950
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
3951
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
3952 3952
 					}
3953 3953
 				}
3954 3954
 			}
3955 3955
 			return $obj_in_map;
3956
-		}else{
3957
-			$this->add_to_entity_map( $replacing_model_obj );
3956
+		} else {
3957
+			$this->add_to_entity_map($replacing_model_obj);
3958 3958
 			return $replacing_model_obj;
3959 3959
 		}
3960 3960
 	}
@@ -3967,7 +3967,7 @@  discard block
 block discarded – undo
3967 3967
 	 * require_once($this->_getClassName().".class.php");
3968 3968
 	 * @return string
3969 3969
 	 */
3970
-	private function _get_class_name(){
3970
+	private function _get_class_name() {
3971 3971
 		return "EE_".$this->get_this_model_name();
3972 3972
 	}
3973 3973
 
@@ -3980,10 +3980,10 @@  discard block
 block discarded – undo
3980 3980
 	 * @param int $quantity
3981 3981
 	 * @return string
3982 3982
 	 */
3983
-	public function item_name($quantity = 1){
3984
-		if($quantity == 1){
3983
+	public function item_name($quantity = 1) {
3984
+		if ($quantity == 1) {
3985 3985
 			return $this->singular_item;
3986
-		}else{
3986
+		} else {
3987 3987
 			return $this->plural_item;
3988 3988
 		}
3989 3989
 	}
@@ -4012,13 +4012,13 @@  discard block
 block discarded – undo
4012 4012
 	 * @throws EE_Error
4013 4013
 	 * @return mixed whatever the plugin which calls add_filter decides
4014 4014
 	 */
4015
-	public function __call($methodName,$args){
4016
-		$className=get_class($this);
4017
-		$tagName="FHEE__{$className}__{$methodName}";
4018
-		if(!has_filter($tagName)){
4015
+	public function __call($methodName, $args) {
4016
+		$className = get_class($this);
4017
+		$tagName = "FHEE__{$className}__{$methodName}";
4018
+		if ( ! has_filter($tagName)) {
4019 4019
 			throw new EE_Error(
4020 4020
 				sprintf(
4021
-					__( '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' ),
4021
+					__('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'),
4022 4022
 					$methodName,
4023 4023
 					$className,
4024 4024
 					$tagName,
@@ -4027,7 +4027,7 @@  discard block
 block discarded – undo
4027 4027
 			);
4028 4028
 		}
4029 4029
 
4030
-		return apply_filters($tagName,null,$this,$args);
4030
+		return apply_filters($tagName, null, $this, $args);
4031 4031
 	}
4032 4032
 
4033 4033
 
@@ -4040,22 +4040,22 @@  discard block
 block discarded – undo
4040 4040
 	 * @throws EE_Error
4041 4041
 	 * @return EE_Base_Class
4042 4042
 	 */
4043
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4043
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4044 4044
 		$className = $this->_get_class_name();
4045 4045
 		$primary_key_field = $this->get_primary_key_field();
4046
-		if( $base_class_obj_or_id instanceof $className ){
4046
+		if ($base_class_obj_or_id instanceof $className) {
4047 4047
 			$model_object = $base_class_obj_or_id;
4048
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4049
-				is_int( $base_class_obj_or_id ) ||
4050
-				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)
4048
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
4049
+				is_int($base_class_obj_or_id) ||
4050
+				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)
4051 4051
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4052
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4052
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
4053 4053
 			//assume its a string representation of the object
4054 4054
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4055
-		}else{
4056
-			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)));
4055
+		} else {
4056
+			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)));
4057 4057
 		}
4058
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
4058
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
4059 4059
 			$model_object->save();
4060 4060
 		}
4061 4061
 		return $model_object;
@@ -4071,19 +4071,19 @@  discard block
 block discarded – undo
4071 4071
 	 * @return int|string depending on the type of this model object's ID
4072 4072
 	 * @throws EE_Error
4073 4073
 	 */
4074
-	public function ensure_is_ID($base_class_obj_or_id){
4074
+	public function ensure_is_ID($base_class_obj_or_id) {
4075 4075
 		$className = $this->_get_class_name();
4076
-		if( $base_class_obj_or_id instanceof $className ){
4076
+		if ($base_class_obj_or_id instanceof $className) {
4077 4077
 			/** @var $base_class_obj_or_id EE_Base_Class */
4078 4078
 			$id = $base_class_obj_or_id->ID();
4079
-		}elseif(is_int($base_class_obj_or_id)){
4079
+		}elseif (is_int($base_class_obj_or_id)) {
4080 4080
 			//assume it's an ID
4081 4081
 			$id = $base_class_obj_or_id;
4082
-		}elseif(is_string($base_class_obj_or_id)){
4082
+		}elseif (is_string($base_class_obj_or_id)) {
4083 4083
 			//assume its a string representation of the object
4084 4084
 			$id = $base_class_obj_or_id;
4085
-		}else{
4086
-			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)));
4085
+		} else {
4086
+			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)));
4087 4087
 		}
4088 4088
 		return $id;
4089 4089
 	}
@@ -4106,14 +4106,14 @@  discard block
 block discarded – undo
4106 4106
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4107 4107
 	 * @return void
4108 4108
 	 */
4109
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4109
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4110 4110
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4111 4111
 	}
4112 4112
 	/**
4113 4113
 	 * Read comments for assume_values_already_prepared_by_model_object()
4114 4114
 	 * @return int
4115 4115
 	 */
4116
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4116
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4117 4117
 		return $this->_values_already_prepared_by_model_object;
4118 4118
 	}
4119 4119
 
@@ -4121,17 +4121,17 @@  discard block
 block discarded – undo
4121 4121
 	 * Gets all the indexes on this model
4122 4122
 	 * @return EE_Index[]
4123 4123
 	 */
4124
-	public function indexes(){
4124
+	public function indexes() {
4125 4125
 		return $this->_indexes;
4126 4126
 	}
4127 4127
 	/**
4128 4128
 	 * Gets all the Unique Indexes on this model
4129 4129
 	 * @return EE_Unique_Index[]
4130 4130
 	 */
4131
-	public function unique_indexes(){
4131
+	public function unique_indexes() {
4132 4132
 		$unique_indexes = array();
4133
-		foreach($this->_indexes as $name => $index){
4134
-			if($index instanceof EE_Unique_Index){
4133
+		foreach ($this->_indexes as $name => $index) {
4134
+			if ($index instanceof EE_Unique_Index) {
4135 4135
 				$unique_indexes [$name] = $index;
4136 4136
 			}
4137 4137
 		}
@@ -4144,9 +4144,9 @@  discard block
 block discarded – undo
4144 4144
 	 * on a primary index
4145 4145
 	 * @return EE_Model_Field_Base[]
4146 4146
 	 */
4147
-	public function get_combined_primary_key_fields(){
4148
-		foreach($this->indexes() as $index){
4149
-			if($index instanceof EE_Primary_Key_Index){
4147
+	public function get_combined_primary_key_fields() {
4148
+		foreach ($this->indexes() as $index) {
4149
+			if ($index instanceof EE_Primary_Key_Index) {
4150 4150
 				return $index->fields();
4151 4151
 			}
4152 4152
 		}
@@ -4159,7 +4159,7 @@  discard block
 block discarded – undo
4159 4159
 	 * @param array $cols_n_values keys are field names, values are their values
4160 4160
 	 * @return string
4161 4161
 	 */
4162
-	public function get_index_primary_key_string($cols_n_values){
4162
+	public function get_index_primary_key_string($cols_n_values) {
4163 4163
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4164 4164
 		return http_build_query($cols_n_values_for_primary_key_index);
4165 4165
 	}
@@ -4171,13 +4171,13 @@  discard block
 block discarded – undo
4171 4171
 	 * @param string $index_primary_key_string
4172 4172
 	 * @return null|array
4173 4173
 	 */
4174
-	function parse_index_primary_key_string( $index_primary_key_string) {
4174
+	function parse_index_primary_key_string($index_primary_key_string) {
4175 4175
 		$key_fields = $this->get_combined_primary_key_fields();
4176 4176
 		//check all of them are in the $id
4177 4177
 		$key_vals_in_combined_pk = array();
4178
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4179
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4180
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4178
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4179
+		foreach ($key_fields as $key_field_name => $field_obj) {
4180
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4181 4181
 				return NULL;
4182 4182
 			}
4183 4183
 		}
@@ -4190,10 +4190,10 @@  discard block
 block discarded – undo
4190 4190
 	 * @param array $key_vals
4191 4191
 	 * @return boolean
4192 4192
 	 */
4193
-	function has_all_combined_primary_key_fields( $key_vals ) {
4194
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4195
-		foreach( $keys_it_should_have as $key ){
4196
-			if( ! isset( $key_vals[ $key ] ) ){
4193
+	function has_all_combined_primary_key_fields($key_vals) {
4194
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4195
+		foreach ($keys_it_should_have as $key) {
4196
+			if ( ! isset($key_vals[$key])) {
4197 4197
 				return false;
4198 4198
 			}
4199 4199
 		}
@@ -4209,23 +4209,23 @@  discard block
 block discarded – undo
4209 4209
 	 * @throws EE_Error
4210 4210
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4211 4211
 	 */
4212
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4212
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4213 4213
 
4214
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4214
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4215 4215
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4216
-		}elseif(is_array($model_object_or_attributes_array)){
4216
+		}elseif (is_array($model_object_or_attributes_array)) {
4217 4217
 			$attributes_array = $model_object_or_attributes_array;
4218
-		}else{
4219
-			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));
4218
+		} else {
4219
+			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));
4220 4220
 		}
4221 4221
 		//even copies obviously won't have the same ID, so remove the primary key
4222 4222
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4223
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4223
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4224 4224
 			unset($attributes_array[$this->primary_key_name()]);
4225 4225
 		}
4226
-		if(isset($query_params[0])){
4227
-			$query_params[0] = array_merge($attributes_array,$query_params);
4228
-		}else{
4226
+		if (isset($query_params[0])) {
4227
+			$query_params[0] = array_merge($attributes_array, $query_params);
4228
+		} else {
4229 4229
 			$query_params[0] = $attributes_array;
4230 4230
 		}
4231 4231
 		return $this->get_all($query_params);
@@ -4239,16 +4239,16 @@  discard block
 block discarded – undo
4239 4239
 	 * @param array $query_params
4240 4240
 	 * @return EE_Base_Class
4241 4241
 	 */
4242
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4243
-		if( ! is_array( $query_params ) ){
4244
-			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' );
4242
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4243
+		if ( ! is_array($query_params)) {
4244
+			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');
4245 4245
 			$query_params = array();
4246 4246
 		}
4247 4247
 		$query_params['limit'] = 1;
4248
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4249
-		if(is_array($copies)){
4248
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4249
+		if (is_array($copies)) {
4250 4250
 			return array_shift($copies);
4251
-		}else{
4251
+		} else {
4252 4252
 			return null;
4253 4253
 		}
4254 4254
 	}
@@ -4262,10 +4262,10 @@  discard block
 block discarded – undo
4262 4262
 	 * @param int|string $id the value of the primary key to update
4263 4263
 	 * @return int number of rows updated
4264 4264
 	 */
4265
-	public function update_by_ID($fields_n_values,$id){
4265
+	public function update_by_ID($fields_n_values, $id) {
4266 4266
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4267 4267
 			'default_where_conditions'=>'other_models_only',);
4268
-		return $this->update($fields_n_values,$query_params);
4268
+		return $this->update($fields_n_values, $query_params);
4269 4269
 	}
4270 4270
 
4271 4271
 
@@ -4276,12 +4276,12 @@  discard block
 block discarded – undo
4276 4276
 	 * @return string an operator which can be used in SQL
4277 4277
 	 * @throws EE_Error
4278 4278
 	 */
4279
-	private function _prepare_operator_for_sql($operator_supplied){
4279
+	private function _prepare_operator_for_sql($operator_supplied) {
4280 4280
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4281
-		if($sql_operator){
4281
+		if ($sql_operator) {
4282 4282
 			return $sql_operator;
4283
-		}else{
4284
-			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))));
4283
+		} else {
4284
+			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))));
4285 4285
 		}
4286 4286
 	}
4287 4287
 
@@ -4291,10 +4291,10 @@  discard block
 block discarded – undo
4291 4291
 	 * @param array $query_params like get_all's
4292 4292
 	 * @return string[]
4293 4293
 	 */
4294
-	public function get_all_names($query_params = array()){
4294
+	public function get_all_names($query_params = array()) {
4295 4295
 		$objs = $this->get_all($query_params);
4296 4296
 		$names = array();
4297
-		foreach($objs as $obj){
4297
+		foreach ($objs as $obj) {
4298 4298
 			$names[$obj->ID()] = $obj->name();
4299 4299
 		}
4300 4300
 		return $names;
@@ -4309,22 +4309,22 @@  discard block
 block discarded – undo
4309 4309
 	 * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
4310 4310
 	 * @return array
4311 4311
 	 */
4312
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4313
-		if( ! $this->has_primary_key_field() ) {
4314
-			if( WP_DEBUG ) {
4315
-				EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4312
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4313
+		if ( ! $this->has_primary_key_field()) {
4314
+			if (WP_DEBUG) {
4315
+				EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4316 4316
 				return array();
4317 4317
 			}
4318 4318
 		}
4319 4319
 		$IDs = array();
4320
-		foreach( $model_objects as $model_object ) {
4320
+		foreach ($model_objects as $model_object) {
4321 4321
 			$id = $model_object->ID();
4322
-			if( ! $id ) {
4323
-				if( $filter_out_empty_ids ) {
4322
+			if ( ! $id) {
4323
+				if ($filter_out_empty_ids) {
4324 4324
 					continue;
4325 4325
 				}
4326
-				if( WP_DEBUG ) {
4327
-					EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4326
+				if (WP_DEBUG) {
4327
+					EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4328 4328
 				}
4329 4329
 			}
4330 4330
 			$IDs[] = $id;
@@ -4337,8 +4337,8 @@  discard block
 block discarded – undo
4337 4337
 	 * are no capabilities that relate to this model returns false
4338 4338
 	 * @return string|false
4339 4339
 	 */
4340
-	public function cap_slug(){
4341
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4340
+	public function cap_slug() {
4341
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4342 4342
 	}
4343 4343
 
4344 4344
 	/**
@@ -4350,27 +4350,27 @@  discard block
 block discarded – undo
4350 4350
 	 * @param string $context
4351 4351
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4352 4352
 	 */
4353
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4354
-		EEM_Base::verify_is_valid_cap_context( $context );
4353
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4354
+		EEM_Base::verify_is_valid_cap_context($context);
4355 4355
 		//check if we ought to run the restriction generator first
4356
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4357
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4358
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4359
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4356
+		if (isset($this->_cap_restriction_generators[$context]) &&
4357
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4358
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4359
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4360 4360
 		}
4361 4361
 		//and make sure we've finalized the construction of each restriction
4362
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4363
-			$where_conditions_obj->_finalize_construct( $this );
4362
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4363
+			$where_conditions_obj->_finalize_construct($this);
4364 4364
 		}
4365 4365
 
4366
-		return $this->_cap_restrictions[ $context ];
4366
+		return $this->_cap_restrictions[$context];
4367 4367
 	}
4368 4368
 
4369 4369
 	/**
4370 4370
 	 * Indicating whether or not this model thinks its a wp core model
4371 4371
 	 * @return boolean
4372 4372
 	 */
4373
-	public function is_wp_core_model(){
4373
+	public function is_wp_core_model() {
4374 4374
 		return $this->_wp_core_model;
4375 4375
 	}
4376 4376
 
@@ -4380,12 +4380,12 @@  discard block
 block discarded – undo
4380 4380
 	 * @param string $context one of EEM_Base::caps_ constants
4381 4381
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4382 4382
 	 */
4383
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4383
+	public function caps_missing($context = EEM_Base::caps_read) {
4384 4384
 		$missing_caps = array();
4385
-		$cap_restrictions = $this->cap_restrictions( $context );
4386
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4387
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4388
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4385
+		$cap_restrictions = $this->cap_restrictions($context);
4386
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4387
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4388
+				$missing_caps[$cap] = $restriction_if_no_cap;
4389 4389
 			}
4390 4390
 		}
4391 4391
 		return $missing_caps;
@@ -4397,7 +4397,7 @@  discard block
 block discarded – undo
4397 4397
 	 * one of 'read', 'edit', or 'delete'
4398 4398
 	 */
4399 4399
 	public function cap_contexts_to_cap_action_map() {
4400
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4400
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4401 4401
 	}
4402 4402
 
4403 4403
 
@@ -4408,19 +4408,19 @@  discard block
 block discarded – undo
4408 4408
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4409 4409
 	 * @throws \EE_Error
4410 4410
 	 */
4411
-	public function cap_action_for_context( $context ) {
4411
+	public function cap_action_for_context($context) {
4412 4412
 		$mapping = $this->cap_contexts_to_cap_action_map();
4413
-		if( isset( $mapping[ $context ] ) ) {
4414
-			return $mapping[ $context ];
4413
+		if (isset($mapping[$context])) {
4414
+			return $mapping[$context];
4415 4415
 		}
4416
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4416
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4417 4417
 			return $action;
4418 4418
 		}
4419 4419
 		throw new EE_Error(
4420 4420
 			sprintf(
4421
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4421
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4422 4422
 				$context,
4423
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4423
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4424 4424
 			)
4425 4425
 		);
4426 4426
 
@@ -4431,7 +4431,7 @@  discard block
 block discarded – undo
4431 4431
 	 * @return array
4432 4432
 	 */
4433 4433
 	static public function valid_cap_contexts() {
4434
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4434
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4435 4435
 			self::caps_read,
4436 4436
 			self::caps_read_admin,
4437 4437
 			self::caps_edit,
@@ -4447,17 +4447,17 @@  discard block
 block discarded – undo
4447 4447
 	 * @return bool
4448 4448
 	 * @throws \EE_Error
4449 4449
 	 */
4450
-	static public function verify_is_valid_cap_context( $context ) {
4450
+	static public function verify_is_valid_cap_context($context) {
4451 4451
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4452
-		if( in_array( $context, $valid_cap_contexts ) ) {
4452
+		if (in_array($context, $valid_cap_contexts)) {
4453 4453
 			return true;
4454
-		}else{
4454
+		} else {
4455 4455
 			throw new EE_Error(
4456 4456
 				sprintf(
4457
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4457
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4458 4458
 					$context,
4459
-					'EEM_Base' ,
4460
-					implode(',', $valid_cap_contexts )
4459
+					'EEM_Base',
4460
+					implode(',', $valid_cap_contexts)
4461 4461
 				)
4462 4462
 			);
4463 4463
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@
 block discarded – undo
219 219
 	 * Gets an array for converting between QST_system and QST_IDs for system questions. Eg, if you want to know
220 220
 	 * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
221 221
 	 * @param $QST_system
222
-	 * @return int of QST_ID for the question that corresponds to that QST_system
222
+	 * @return string of QST_ID for the question that corresponds to that QST_system
223 223
 	 */
224 224
 	public function get_Question_ID_from_system_string( $QST_system ){
225 225
 		 return $this->get_var( array( array( 'QST_system' => $QST_system ) ) );
Please login to merge, or discard this patch.
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -160,58 +160,58 @@
 block discarded – undo
160 160
 		return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) );
161 161
 	}
162 162
 
163
-        /**
164
-         * Returns an array of all the QST_system values that can be allowed in the system question group
165
-         * identified by $system_question_group_id
166
-         * @param string $system_question_group_id QSG_system
167
-         * @return array of system question names (QST_system)
168
-         */
169
-        public function allowed_system_questions_in_system_question_group( $system_question_group_id ) {
170
-            $question_system_ids = array();
171
-            switch( $system_question_group_id ) {
172
-                case EEM_Question_Group::system_personal:
173
-                    $question_system_ids = array(
174
-                        EEM_Attendee::system_question_fname,
175
-                        EEM_Attendee::system_question_lname,
176
-                        EEM_Attendee::system_question_email,
177
-                        EEM_Attendee::system_question_phone
178
-                    );
179
-                    break;
180
-                case EEM_Question_Group::system_address:
181
-                    $question_system_ids = array(
163
+		/**
164
+		 * Returns an array of all the QST_system values that can be allowed in the system question group
165
+		 * identified by $system_question_group_id
166
+		 * @param string $system_question_group_id QSG_system
167
+		 * @return array of system question names (QST_system)
168
+		 */
169
+		public function allowed_system_questions_in_system_question_group( $system_question_group_id ) {
170
+			$question_system_ids = array();
171
+			switch( $system_question_group_id ) {
172
+				case EEM_Question_Group::system_personal:
173
+					$question_system_ids = array(
174
+						EEM_Attendee::system_question_fname,
175
+						EEM_Attendee::system_question_lname,
176
+						EEM_Attendee::system_question_email,
177
+						EEM_Attendee::system_question_phone
178
+					);
179
+					break;
180
+				case EEM_Question_Group::system_address:
181
+					$question_system_ids = array(
182 182
 						EEM_Attendee::system_question_address,
183
-                        EEM_Attendee::system_question_address2,
184
-                        EEM_Attendee::system_question_city,
185
-                        EEM_Attendee::system_question_state,
186
-                        EEM_Attendee::system_question_country,
187
-                        EEM_Attendee::system_question_zip,
188
-                        EEM_Attendee::system_question_phone
189
-                    );
190
-                    break;
191
-            }
192
-            return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id );
193
-        }
194
-
195
-        /**
196
-         * Returns an array of all the QST_system values that are required in the system question group
197
-         * identified by $system_question_group_id
198
-         * @param string $system_question_group_id QSG_system
199
-         * @return array of system question names (QST_system)
200
-         */
201
-        public function required_system_questions_in_system_question_group( $system_question_group_id ) {
202
-            $question_system_ids = null;
203
-            switch( $system_question_group_id ) {
204
-                case EEM_Question_Group::system_personal:
205
-                    $question_system_ids =  array(
183
+						EEM_Attendee::system_question_address2,
184
+						EEM_Attendee::system_question_city,
185
+						EEM_Attendee::system_question_state,
186
+						EEM_Attendee::system_question_country,
187
+						EEM_Attendee::system_question_zip,
188
+						EEM_Attendee::system_question_phone
189
+					);
190
+					break;
191
+			}
192
+			return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id );
193
+		}
194
+
195
+		/**
196
+		 * Returns an array of all the QST_system values that are required in the system question group
197
+		 * identified by $system_question_group_id
198
+		 * @param string $system_question_group_id QSG_system
199
+		 * @return array of system question names (QST_system)
200
+		 */
201
+		public function required_system_questions_in_system_question_group( $system_question_group_id ) {
202
+			$question_system_ids = null;
203
+			switch( $system_question_group_id ) {
204
+				case EEM_Question_Group::system_personal:
205
+					$question_system_ids =  array(
206 206
 						EEM_Attendee::system_question_fname,
207 207
 						EEM_Attendee::system_question_email,
208 208
 					);
209
-                    break;
210
-                default:
211
-                    $question_system_ids = array();
212
-            }
213
-            return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id );
214
-        }
209
+					break;
210
+				default:
211
+					$question_system_ids = array();
212
+			}
213
+			return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id );
214
+		}
215 215
 
216 216
 
217 217
 
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once( EE_CLASSES . 'EE_Question.class.php');
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once(EE_CLASSES.'EE_Question.class.php');
26 26
 
27 27
 class EEM_Question extends EEM_Soft_Delete_Base {
28 28
 
@@ -69,21 +69,21 @@  discard block
 block discarded – undo
69 69
 	// private instance of the Attendee object
70 70
 	protected static $_instance = NULL;
71 71
 
72
-	protected function __construct( $timezone = NULL ) {
73
-		$this->singular_item = __('Question','event_espresso');
74
-		$this->plural_item = __('Questions','event_espresso');
75
-		$this->_allowed_question_types=apply_filters(
72
+	protected function __construct($timezone = NULL) {
73
+		$this->singular_item = __('Question', 'event_espresso');
74
+		$this->plural_item = __('Questions', 'event_espresso');
75
+		$this->_allowed_question_types = apply_filters(
76 76
 			'FHEE__EEM_Question__construct__allowed_question_types',
77 77
 			array(
78
-				EEM_Question::QST_type_text =>__('Text','event_espresso'),
79
-				EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'),
80
-				EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'),
81
-				EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'),
82
-				EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'),
83
-				EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'),
84
-				EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'),
85
-				EEM_Question::QST_type_date =>__('Date Picker','event_espresso'),
86
-				EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ),
78
+				EEM_Question::QST_type_text =>__('Text', 'event_espresso'),
79
+				EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'),
80
+				EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'),
81
+				EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'),
82
+				EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'),
83
+				EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'),
84
+				EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'),
85
+				EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'),
86
+				EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'),
87 87
 			)
88 88
 		);
89 89
 		$this->_question_type_categories = apply_filters(
@@ -102,21 +102,21 @@  discard block
 block discarded – undo
102 102
 		);
103 103
 
104 104
 		$this->_tables = array(
105
-			'Question'=>new EE_Primary_Table('esp_question','QST_ID')
105
+			'Question'=>new EE_Primary_Table('esp_question', 'QST_ID')
106 106
 		);
107 107
 		$this->_fields = array(
108 108
 			'Question'=>array(
109
-				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')),
110
-				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''),
111
-				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''),
112
-				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ),
113
-				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types),
114
-				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false),
115
-				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''),
116
-				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0),
117
-				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false),
118
-				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ),
119
-				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false)
109
+				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
110
+				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
111
+				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
112
+				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL),
113
+				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
114
+				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
115
+				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
116
+				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
117
+				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
118
+				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
119
+				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
120 120
 			)
121 121
 		);
122 122
 		$this->_model_relations = array(
@@ -128,15 +128,15 @@  discard block
 block discarded – undo
128 128
 			'Question_Group_Question'=>new EE_Has_Many_Relation()
129 129
 		);
130 130
 		$this->_indexes = array(
131
-			'admin_label' => new EE_Unique_Index( array( 'QST_admin_label') )
131
+			'admin_label' => new EE_Unique_Index(array('QST_admin_label'))
132 132
 		);
133 133
 
134 134
 		//this model is generally available for reading
135
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
136
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system');
137
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system');
138
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system');
139
-		parent::__construct( $timezone );
135
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
136
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system');
137
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system');
138
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system');
139
+		parent::__construct($timezone);
140 140
 	}
141 141
 
142 142
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * but they can be extended
145 145
 	 * @return string[]
146 146
 	 */
147
-	public function allowed_question_types(){
147
+	public function allowed_question_types() {
148 148
 		return $this->_allowed_question_types;
149 149
 	}
150 150
 	/**
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
 	 * @param string $question_type one of EEM_Question::allowed_question_types(
153 153
 	 * @return string[] like EEM_Question::allowed_question_types()
154 154
 	 */
155
-	public function question_types_in_same_category( $question_type ) {
156
-		$question_types = array( $question_type );
157
-		foreach( $this->_question_type_categories as $category => $question_types_in_category ) {
158
-			if( in_array( $question_type, $question_types_in_category ) ) {
155
+	public function question_types_in_same_category($question_type) {
156
+		$question_types = array($question_type);
157
+		foreach ($this->_question_type_categories as $category => $question_types_in_category) {
158
+			if (in_array($question_type, $question_types_in_category)) {
159 159
 				$question_types = $question_types_in_category;
160 160
 				break;
161 161
 			}
162 162
 		}
163 163
 
164
-		return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) );
164
+		return array_intersect_key($this->allowed_question_types(), array_flip($question_types));
165 165
 	}
166 166
 
167 167
         /**
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
          * @param string $system_question_group_id QSG_system
171 171
          * @return array of system question names (QST_system)
172 172
          */
173
-        public function allowed_system_questions_in_system_question_group( $system_question_group_id ) {
173
+        public function allowed_system_questions_in_system_question_group($system_question_group_id) {
174 174
             $question_system_ids = array();
175
-            switch( $system_question_group_id ) {
175
+            switch ($system_question_group_id) {
176 176
                 case EEM_Question_Group::system_personal:
177 177
                     $question_system_ids = array(
178 178
                         EEM_Attendee::system_question_fname,
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                     );
194 194
                     break;
195 195
             }
196
-            return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id );
196
+            return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id);
197 197
         }
198 198
 
199 199
         /**
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
          * @param string $system_question_group_id QSG_system
203 203
          * @return array of system question names (QST_system)
204 204
          */
205
-        public function required_system_questions_in_system_question_group( $system_question_group_id ) {
205
+        public function required_system_questions_in_system_question_group($system_question_group_id) {
206 206
             $question_system_ids = null;
207
-            switch( $system_question_group_id ) {
207
+            switch ($system_question_group_id) {
208 208
                 case EEM_Question_Group::system_personal:
209
-                    $question_system_ids =  array(
209
+                    $question_system_ids = array(
210 210
 						EEM_Attendee::system_question_fname,
211 211
 						EEM_Attendee::system_question_email,
212 212
 					);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
                 default:
215 215
                     $question_system_ids = array();
216 216
             }
217
-            return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id );
217
+            return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id);
218 218
         }
219 219
 
220 220
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param string $QST_system
226 226
 	 * @return int of QST_ID for the question that corresponds to that QST_system
227 227
 	 */
228
-	public function get_Question_ID_from_system_string( $QST_system ){
229
-		 return $this->get_var( array( array( 'QST_system' => $QST_system ) ) );
228
+	public function get_Question_ID_from_system_string($QST_system) {
229
+		 return $this->get_var(array(array('QST_system' => $QST_system)));
230 230
 	}
231 231
 
232 232
 
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function get_latest_question_order() {
240 240
 		$columns_to_select = array(
241
-			'max_order' => array("MAX(QST_order)","%d")
241
+			'max_order' => array("MAX(QST_order)", "%d")
242 242
 		);
243
-		$max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select );
243
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
244 244
 		return $max[0]['max_order'];
245 245
 	}
246 246
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 2 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @access    public
40 40
 	 * @param    int $EVT_ID
41
-	 * @return    object
41
+	 * @return    null|boolean
42 42
 	 */
43 43
 	public static function get_event( $EVT_ID = 0 ) {
44 44
 		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 *  @access 	public
118 118
 	 * @param    int $EVT_ID
119
-	 *  @return 	string
119
+	 *  @return 	boolean
120 120
 	 */
121 121
 	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122 122
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *    event_active_status
137 137
 	 *
138 138
 	 * @access    public
139
-	 * @param null $num_words
139
+	 * @param integer $num_words
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @access    public
324 324
 	 * @param int $EVT_ID
325
-	 * @return    string
325
+	 * @return    string|null
326 326
 	 */
327 327
 	public static function get_primary_date_obj( $EVT_ID = 0 ) {
328 328
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @access    public
349 349
 	 * @param int $EVT_ID
350
-	 * @return    string
350
+	 * @return    string|null
351 351
 	 */
352 352
 	public static function get_last_date_obj( $EVT_ID = 0 ) {
353 353
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @access    public
374 374
 	 * @param int $EVT_ID
375
-	 * @return    string
375
+	 * @return    string|null
376 376
 	 */
377 377
 	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
378 378
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @access    public
424 424
 	 * @param int $EVT_ID
425
-	 * @param null $include_expired
425
+	 * @param false|null $include_expired
426 426
 	 * @param bool $include_deleted
427 427
 	 * @param null $limit
428 428
 	 * @return EE_Datetime[]
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param    int $EVT_ID
41 41
 	 * @return    object
42 42
 	 */
43
-	public static function get_event( $EVT_ID = 0 ) {
44
-		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
43
+	public static function get_event($EVT_ID = 0) {
44
+		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
45 45
 		// do we already have the Event  you are looking for?
46
-		if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) {
46
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
47 47
 			return EEH_Event_View::$_event;
48 48
 		}
49 49
 		EEH_Event_View::$_event = NULL;
50 50
 		// international newspaper?
51 51
 		global $post;
52 52
 		// if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
53
-		 if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) {
53
+		 if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
54 54
 //			d( $post );
55 55
 			// grab the event we're looking for
56
-			if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) {
56
+			if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) {
57 57
 				EEH_Event_View::$_event = $post->EE_Event;
58 58
 //				d( EEH_Event_View::$_event );
59 59
 			}
60 60
 			// now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
61
-			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) {
61
+			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
62 62
 				// sigh... pull it from the db
63
-				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
63
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
64 64
 //				d( EEH_Event_View::$_event );
65 65
 			}
66 66
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @param    int $EVT_ID
77 77
 	 * @return    boolean
78 78
 	 */
79
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
80
-		$event = EEH_Event_View::get_event( $EVT_ID );
79
+	public static function display_ticket_selector($EVT_ID = 0) {
80
+		$event = EEH_Event_View::get_event($EVT_ID);
81 81
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
82 82
 	}
83 83
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param    int $EVT_ID
91 91
 	 * @return    string
92 92
 	 */
93
-	public static function event_status( $EVT_ID = 0 ) {
94
-		$event = EEH_Event_View::get_event( $EVT_ID );
95
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
93
+	public static function event_status($EVT_ID = 0) {
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
96 96
 	}
97 97
 
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param    int $EVT_ID
105 105
 	 *  @return 	string
106 106
 	 */
107
-	public static function event_active_status( $EVT_ID = 0 ) {
108
-		$event = EEH_Event_View::get_event( $EVT_ID );
107
+	public static function event_active_status($EVT_ID = 0) {
108
+		$event = EEH_Event_View::get_event($EVT_ID);
109 109
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
110 110
 	}
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param    int $EVT_ID
119 119
 	 *  @return 	string
120 120
 	 */
121
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122
-		$event = EEH_Event_View::get_event( $EVT_ID );
121
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
122
+		$event = EEH_Event_View::get_event($EVT_ID);
123 123
 		$has_content_or_excerpt = FALSE;
124
-		if ( $event instanceof EE_Event ) {
125
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
124
+		if ($event instanceof EE_Event) {
125
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
126 126
 		}
127
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
127
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
128 128
 			$has_content_or_excerpt = FALSE;
129 129
 		}
130 130
 		return $has_content_or_excerpt;
@@ -140,45 +140,45 @@  discard block
 block discarded – undo
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
143
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
143
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
144 144
 		global $post;
145 145
 
146 146
 		ob_start();
147
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
147
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
148 148
 
149 149
 			// admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option
150 150
 			the_content();
151 151
 
152
-		} else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) {
152
+		} else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
153 153
 
154 154
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
155 155
 			// AND an excerpt actually exists
156 156
 			the_excerpt();
157 157
 
158
-		} else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) {
158
+		} else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
159 159
 
160 160
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
161 161
 			// but NO excerpt actually exists, so we need to create one
162
-			if ( ! empty( $num_words )) {
163
-				if ( empty( $more )) {
164
-					$more_link_text = __( '(more&hellip;)' );
165
-					$more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>';
166
-					$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
162
+			if ( ! empty($num_words)) {
163
+				if (empty($more)) {
164
+					$more_link_text = __('(more&hellip;)');
165
+					$more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>';
166
+					$more = apply_filters('the_content_more_link', $more, $more_link_text);
167 167
 				}
168
-				$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
168
+				$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
169 169
 
170
-				$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
170
+				$content = wp_trim_words($content, $num_words, ' ').$more;
171 171
 			} else {
172
-				$content =  get_the_content();
172
+				$content = get_the_content();
173 173
 			}
174 174
 			global $allowedtags;
175
-			$content = wp_kses( $content, $allowedtags );
176
-			$content = strip_shortcodes( $content );
177
-			echo apply_filters( 'the_content', $content );
175
+			$content = wp_kses($content, $allowedtags);
176
+			$content = strip_shortcodes($content);
177
+			echo apply_filters('the_content', $content);
178 178
 
179 179
 		} else {
180 180
 			// admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option
181
-			echo apply_filters( 'the_content', '' );
181
+			echo apply_filters('the_content', '');
182 182
 		}
183 183
 		return ob_get_clean();
184 184
 	}
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param    int $EVT_ID
193 193
 	 *  @return 	EE_Ticket[]
194 194
 	 */
195
-	public static function event_tickets_available( $EVT_ID = 0 ) {
196
-		$event = EEH_Event_View::get_event( $EVT_ID );
195
+	public static function event_tickets_available($EVT_ID = 0) {
196
+		$event = EEH_Event_View::get_event($EVT_ID);
197 197
 		$tickets_available_for_purchase = array();
198
-		if( $event instanceof EE_Event ) {
199
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
200
-			foreach( $datetimes as $datetime ) {
201
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
198
+		if ($event instanceof EE_Event) {
199
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
200
+			foreach ($datetimes as $datetime) {
201
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
202 202
 			}
203 203
 		}
204 204
 		return $tickets_available_for_purchase;
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 	 * @param 	  bool   $hide_uncategorized
215 215
 	 * @return    string
216 216
 	 */
217
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
217
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
218 218
 		$category_links = array();
219
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
-		if ( $event instanceof EE_Event ) {
221
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
222
-			if ( $event_categories ) {
219
+		$event = EEH_Event_View::get_event($EVT_ID);
220
+		if ($event instanceof EE_Event) {
221
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
222
+			if ($event_categories) {
223 223
 				// loop thru terms and create links
224
-				foreach ( $event_categories as $term ) {
225
-					$url = get_term_link( $term, 'espresso_venue_categories' );
226
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
227
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>';
224
+				foreach ($event_categories as $term) {
225
+					$url = get_term_link($term, 'espresso_venue_categories');
226
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
227
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>';
228 228
 					}
229 229
 				}
230 230
 			}
231 231
 		}
232
-		return implode( ', ', $category_links );
232
+		return implode(', ', $category_links);
233 233
 	}
234 234
 
235 235
 
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 	 * @param int    $EVT_ID
244 244
 	 * @return    string
245 245
 	 */
246
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
247
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
248
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
249
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
246
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
247
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
248
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
249
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
250 250
 	}
251 251
 
252 252
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	 * @param int    $EVT_ID
261 261
 	 * @return    string
262 262
 	 */
263
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
264
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
265
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
266
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
263
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
264
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
265
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
266
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
267 267
 	}
268 268
 
269 269
 
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
 	 * @param int    $EVT_ID
278 278
 	 * @return    string
279 279
 	 */
280
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
281
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
282
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
283
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
280
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
281
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
282
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
283
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
284 284
 	}
285 285
 
286 286
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @param int    $EVT_ID
295 295
 	 * @return    string
296 296
 	 */
297
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
298
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
299
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
300
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
297
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
298
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
299
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
300
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
301 301
 	}
302 302
 
303 303
 
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * @param int $EVT_ID
310 310
 	 * @return    string
311 311
 	 */
312
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
313
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
314
-		if ( $datetime instanceof EE_Datetime ) {
312
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
313
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
314
+		if ($datetime instanceof EE_Datetime) {
315 315
 	?>
316 316
 		<div class="event-date-calendar-page-dv">
317
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
318
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
317
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
318
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
319 319
 		</div>
320 320
 	<?php
321 321
 		}
@@ -330,17 +330,17 @@  discard block
 block discarded – undo
330 330
 	 * @param int $EVT_ID
331 331
 	 * @return    string
332 332
 	 */
333
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
334
-		$event = EEH_Event_View::get_event( $EVT_ID );
335
-		if ( $event instanceof EE_Event ) {
333
+	public static function get_primary_date_obj($EVT_ID = 0) {
334
+		$event = EEH_Event_View::get_event($EVT_ID);
335
+		if ($event instanceof EE_Event) {
336 336
 			$datetimes = $event->get_many_related(
337 337
 				'Datetime',
338 338
 				array(
339 339
 					'limit' => 1,
340
-					'order_by' => array( 'DTT_order' => 'ASC' )
340
+					'order_by' => array('DTT_order' => 'ASC')
341 341
 				)
342 342
 			);
343
-			return reset( $datetimes );
343
+			return reset($datetimes);
344 344
 		} else {
345 345
 			 return FALSE;
346 346
 		}
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 * @param int $EVT_ID
356 356
 	 * @return    string
357 357
 	 */
358
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
359
-		$event = EEH_Event_View::get_event( $EVT_ID );
360
-		if ( $event instanceof EE_Event ) {
358
+	public static function get_last_date_obj($EVT_ID = 0) {
359
+		$event = EEH_Event_View::get_event($EVT_ID);
360
+		if ($event instanceof EE_Event) {
361 361
 			$datetimes = $event->get_many_related(
362 362
 				'Datetime',
363 363
 				array(
364 364
 					'limit' => 1,
365
-					'order_by' => array( 'DTT_order' => 'DESC' )
365
+					'order_by' => array('DTT_order' => 'DESC')
366 366
 				)
367 367
 			);
368
-			return end( $datetimes );
368
+			return end($datetimes);
369 369
 		} else {
370 370
 			return FALSE;
371 371
 		}
@@ -380,17 +380,17 @@  discard block
 block discarded – undo
380 380
 	 * @param int $EVT_ID
381 381
 	 * @return    string
382 382
 	 */
383
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
384
-		$event = EEH_Event_View::get_event( $EVT_ID );
385
-		if ( $event instanceof EE_Event ) {
383
+	public static function get_earliest_date_obj($EVT_ID = 0) {
384
+		$event = EEH_Event_View::get_event($EVT_ID);
385
+		if ($event instanceof EE_Event) {
386 386
 			$datetimes = $event->get_many_related(
387 387
 				'Datetime',
388 388
 				array(
389 389
 					'limit' => 1,
390
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
390
+					'order_by' => array('DTT_EVT_start' => 'ASC')
391 391
 				)
392 392
 			);
393
-			return reset( $datetimes );
393
+			return reset($datetimes);
394 394
 		} else {
395 395
 			 return FALSE;
396 396
 		}
@@ -405,17 +405,17 @@  discard block
 block discarded – undo
405 405
 	 * @param int $EVT_ID
406 406
 	 * @return    string
407 407
 	 */
408
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
409
-		$event = EEH_Event_View::get_event( $EVT_ID );
410
-		if ( $event instanceof EE_Event ) {
408
+	public static function get_latest_date_obj($EVT_ID = 0) {
409
+		$event = EEH_Event_View::get_event($EVT_ID);
410
+		if ($event instanceof EE_Event) {
411 411
 			$datetimes = $event->get_many_related(
412 412
 				'Datetime',
413 413
 				array(
414 414
 					'limit' => 1,
415
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
415
+					'order_by' => array('DTT_EVT_start' => 'DESC')
416 416
 				)
417 417
 			);
418
-			return end( $datetimes );
418
+			return end($datetimes);
419 419
 		} else {
420 420
 			return FALSE;
421 421
 		}
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
 	 * @param null $limit
434 434
 	 * @return EE_Datetime[]
435 435
 	 */
436
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
437
-		$event = EEH_Event_View::get_event( $EVT_ID );
438
-		if($include_expired === null){
439
-			if($event instanceof EE_Event && $event->is_expired()){
436
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
437
+		$event = EEH_Event_View::get_event($EVT_ID);
438
+		if ($include_expired === null) {
439
+			if ($event instanceof EE_Event && $event->is_expired()) {
440 440
 				$include_expired = true;
441
-			}else{
441
+			} else {
442 442
 				$include_expired = false;
443 443
 			}
444 444
 		}
445 445
 
446
-		if ( $event instanceof EE_Event ) {
446
+		if ($event instanceof EE_Event) {
447 447
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
448 448
 		} else {
449 449
 			 return array();
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 	 * @param int $EVT_ID
460 460
 	 * @return    string
461 461
 	 */
462
-	public static function event_link_url( $EVT_ID = 0 ) {
463
-		$event = EEH_Event_View::get_event( $EVT_ID );
464
-		if ( $event instanceof EE_Event ) {
465
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
466
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
462
+	public static function event_link_url($EVT_ID = 0) {
463
+		$event = EEH_Event_View::get_event($EVT_ID);
464
+		if ($event instanceof EE_Event) {
465
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
466
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
467 467
 		}
468 468
 		return NULL;
469 469
 	}
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * @param int $EVT_ID
478 478
 	 * @return    string
479 479
 	 */
480
-	public static function event_phone( $EVT_ID = 0 ) {
481
-		$event = EEH_Event_View::get_event( $EVT_ID );
482
-		if ( $event instanceof EE_Event ) {
483
-			EE_Registry::instance()->load_helper( 'Formatter' );
484
-			return EEH_Schema::telephone( $event->phone() );
480
+	public static function event_phone($EVT_ID = 0) {
481
+		$event = EEH_Event_View::get_event($EVT_ID);
482
+		if ($event instanceof EE_Event) {
483
+			EE_Registry::instance()->load_helper('Formatter');
484
+			return EEH_Schema::telephone($event->phone());
485 485
 		}
486 486
 		return NULL;
487 487
 	}
@@ -498,23 +498,23 @@  discard block
 block discarded – undo
498 498
 	 * @param string $after
499 499
 	 * @return    string
500 500
 	 */
501
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
502
-		$event = EEH_Event_View::get_event( $EVT_ID );
503
-		if ( $event instanceof EE_Event ) {
501
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
502
+		$event = EEH_Event_View::get_event($EVT_ID);
503
+		if ($event instanceof EE_Event) {
504 504
 			// can the user edit this post ?
505
-			if ( current_user_can( 'edit_post', $event->ID() )) {
505
+			if (current_user_can('edit_post', $event->ID())) {
506 506
 				// set link text
507
-				$link = ! empty( $link ) ? $link : __('edit this event');
507
+				$link = ! empty($link) ? $link : __('edit this event');
508 508
 				// generate nonce
509
-				$nonce = wp_create_nonce( 'edit_nonce' );
509
+				$nonce = wp_create_nonce('edit_nonce');
510 510
 				// generate url to event editor for this event
511
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
511
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
512 512
 				// get edit CPT text
513
-				$post_type_obj = get_post_type_object( 'espresso_events' );
513
+				$post_type_obj = get_post_type_object('espresso_events');
514 514
 				// build final link html
515
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
515
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
516 516
 				// put it all together
517
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
517
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
518 518
 			}
519 519
 		}
520 520
 		return '';
Please login to merge, or discard this patch.
core/helpers/EEH_Formatter.helper.php 2 patches
Doc Comments   +14 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,6 +88,7 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * [ee_tep_not_null description]
90 90
 	 * @param  string | array $value [description]
91
+	 * @param string $value
91 92
 	 * @return bool       [description]
92 93
 	 */
93 94
 	static public function ee_tep_not_null($value) {
@@ -152,6 +153,15 @@  discard block
 block discarded – undo
152 153
  */
153 154
 class EE_Address_Formatter {
154 155
 
156
+	/**
157
+	 * @param string $address
158
+	 * @param string $address2
159
+	 * @param string $city
160
+	 * @param string $state
161
+	 * @param string $zip
162
+	 * @param string $country
163
+	 * @param string $sub
164
+	 */
155 165
 	protected function parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, $sub ) {
156 166
 		// swap address part placeholders for the real text
157 167
 		$formatted_address = str_replace(
@@ -629,6 +639,8 @@  discard block
 block discarded – undo
629 639
 	 * @param EE_State | string $state
630 640
 	 * @param string $zip
631 641
 	 * @param EE_Country | string $country
642
+	 * @param integer $state
643
+	 * @param string $country
632 644
 	 * @return EE_Generic_Address
633 645
 	 */
634 646
 	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
@@ -716,7 +728,7 @@  discard block
 block discarded – undo
716 728
 
717 729
 
718 730
 	/**
719
-	 * @return \EE_State
731
+	 * @return string
720 732
 	 */
721 733
 	public function state_obj() {
722 734
 		return $this->_state_obj;
@@ -765,7 +777,7 @@  discard block
 block discarded – undo
765 777
 
766 778
 
767 779
 	/**
768
-	 * @return \EE_Country
780
+	 * @return string
769 781
 	 */
770 782
 	public function country_obj() {
771 783
 		return $this->_country_obj;
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param  string $content content to format
40 40
 	 * @return string          formatted content
41 41
 	 */
42
-	static public function admin_format_content($content='') {
42
+	static public function admin_format_content($content = '') {
43 43
 		return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
44 44
 	}
45 45
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @return string
80 80
 	 */
81 81
 	static public	function ee_tep_parse_input_field_data($data, $parse) {
82
-		return strtr( trim($data), $parse);
82
+		return strtr(trim($data), $parse);
83 83
 	}
84 84
 
85 85
 
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 * @return string
119 119
 	 * @deprecated v4.6.21
120 120
 	 */
121
-	static public function event_date_display( $date, $format = '' ) {
121
+	static public function event_date_display($date, $format = '') {
122 122
 		EE_Error::doing_it_wrong(
123 123
 			__METHOD__,
124
-			__( 'This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso' ),
124
+			__('This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.', 'event_espresso'),
125 125
 			'4.6.21'
126 126
 		);
127 127
 
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
  */
153 153
 class EE_Address_Formatter {
154 154
 
155
-	protected function parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, $sub ) {
155
+	protected function parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, $sub) {
156 156
 		// swap address part placeholders for the real text
157 157
 		$formatted_address = str_replace(
158 158
 			// find
159
-			array( '{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}' ),
159
+			array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'),
160 160
 			// replace
161
-			array( $address, $address2, $city, $state, $zip, $country ),
161
+			array($address, $address2, $city, $state, $zip, $country),
162 162
 			// string
163 163
 			$formatted_address
164 164
 		);
165 165
 		// remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks
166
-		return preg_replace( '/%+/', $sub, trim( $formatted_address, '%' ) );
166
+		return preg_replace('/%+/', $sub, trim($formatted_address, '%'));
167 167
 	}
168 168
 
169 169
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param string $CNT_ISO
200 200
 	 * @return string
201 201
 	 */
202
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
202
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
203 203
 
204 204
 		$address_formats = apply_filters(
205 205
 			'FHEE__EE_MultiLine_Address_Formatter__address_formats',
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 			)
212 212
 		);
213 213
 		// if the incoming country has a set format, use that, else use the default
214
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] : $address_formats[ 'ZZ' ];
215
-		return $this->parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, '<br />' );
214
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] : $address_formats['ZZ'];
215
+		return $this->parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, '<br />');
216 216
 	}
217 217
 }
218 218
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @param string $CNT_ISO
246 246
 	 * @return string
247 247
 	 */
248
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
248
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
249 249
 		$address_formats = apply_filters(
250 250
 			'FHEE__EE_Inline_Address_Formatter__address_formats',
251 251
 			array(
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 			)
257 257
 		);
258 258
 		// if the incoming country has a set format, use that, else use the default
259
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ] : $address_formats[ 'ZZZ' ];
260
-		return $this->parse_formatted_address( $address, $address2, $city, $state, $zip, $country, $formatted_address, ', ' );
259
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO] : $address_formats['ZZZ'];
260
+		return $this->parse_formatted_address($address, $address2, $city, $state, $zip, $country, $formatted_address, ', ');
261 261
 
262 262
 	}
263 263
 }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @param string $CNT_ISO
293 293
 	 * @return string
294 294
 	 */
295
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
295
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
296 296
 		return NULL;
297 297
 	}
298 298
 }
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
 	 * @param bool    $add_wrapper
329 329
 	 * @return string
330 330
 	 */
331
-	public static function format ( $obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true ) {
331
+	public static function format($obj_with_address = null, $type = 'multiline', $use_schema = true, $add_wrapper = true) {
332 332
 		// check that incoming object implements the EEI_Address interface
333
-		if ( ! $obj_with_address instanceof EEI_Address ) {
334
-			$msg = __( 'The address could not be formatted.', 'event_espresso' );
335
-			$dev_msg = __( 'The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso' );
336
-			EE_Error::add_error( $msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
333
+		if ( ! $obj_with_address instanceof EEI_Address) {
334
+			$msg = __('The address could not be formatted.', 'event_espresso');
335
+			$dev_msg = __('The EE_Address_Formatter requires passed objects to implement the EEI_Address interface.', 'event_espresso');
336
+			EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
337 337
 			return null;
338 338
 		}
339 339
 		// obtain an address formatter
340
-		$formatter = EEH_Address::_get_formatter( $type );
340
+		$formatter = EEH_Address::_get_formatter($type);
341 341
 		// apply schema.org formatting ?
342 342
 		$use_schema = ! is_admin() ? $use_schema : false;
343
-		$formatted_address = $use_schema ? EEH_Address::_schema_formatting( $formatter, $obj_with_address ) : EEH_Address::_regular_formatting( $formatter, $obj_with_address, $add_wrapper ) ;
344
-		$formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">' . $formatted_address . '</div>' : $formatted_address;
343
+		$formatted_address = $use_schema ? EEH_Address::_schema_formatting($formatter, $obj_with_address) : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
344
+		$formatted_address = $add_wrapper && ! $use_schema ? '<div class="espresso-address-dv">'.$formatted_address.'</div>' : $formatted_address;
345 345
 		// return the formatted address
346 346
 		return $formatted_address;
347 347
 	}
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	* 	@param string $type how the address is formatted. for example: 'multiline' or 'inline'
356 356
 	* 	@return EEI_Address_Formatter
357 357
 	*/
358
-	private static function _get_formatter( $type ) {
359
-		switch( $type ) {
358
+	private static function _get_formatter($type) {
359
+		switch ($type) {
360 360
 
361 361
 			case 'multiline' :
362 362
 				return new EE_MultiLine_Address_Formatter();
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 	 * @param bool $add_wrapper
383 383
 	 * @return string
384 384
 	 */
385
-	private static function _regular_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE ){
385
+	private static function _regular_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address, $add_wrapper = TRUE) {
386 386
 		$formatted_address = $add_wrapper ? '<div>' : '';
387 387
 		$formatted_address .= $formatter->format(
388 388
 			$obj_with_address->address(),
@@ -409,15 +409,15 @@  discard block
 block discarded – undo
409 409
 	* 	@param object EEI_Address $obj_with_address
410 410
 	* 	@return string
411 411
 	*/
412
-	private static function _schema_formatting( EEI_Address_Formatter $formatter, EEI_Address $obj_with_address ){
412
+	private static function _schema_formatting(EEI_Address_Formatter $formatter, EEI_Address $obj_with_address) {
413 413
 		$formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
414 414
 		$formatted_address .= $formatter->format(
415
-			EEH_Schema::streetAddress( $obj_with_address ),
416
-			EEH_Schema::postOfficeBoxNumber( $obj_with_address ),
417
-			EEH_Schema::addressLocality( $obj_with_address ),
418
-			EEH_Schema::addressRegion( $obj_with_address ),
419
-			EEH_Schema::postalCode( $obj_with_address ),
420
-			EEH_Schema::addressCountry( $obj_with_address ),
415
+			EEH_Schema::streetAddress($obj_with_address),
416
+			EEH_Schema::postOfficeBoxNumber($obj_with_address),
417
+			EEH_Schema::addressLocality($obj_with_address),
418
+			EEH_Schema::addressRegion($obj_with_address),
419
+			EEH_Schema::postalCode($obj_with_address),
420
+			EEH_Schema::addressCountry($obj_with_address),
421 421
 			$obj_with_address->country_ID()
422 422
 		);
423 423
 		$formatted_address .= '</div>';
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 	* 	@param string $location
461 461
 	* 	@return string
462 462
 	*/
463
-	public static function location ( $location = NULL ) {
464
-		return ! empty( $location ) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">' . $location . '</div>' : '';
463
+	public static function location($location = NULL) {
464
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'.$location.'</div>' : '';
465 465
 	}
466 466
 
467 467
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	* 	@param string $name
473 473
 	* 	@return string
474 474
 	*/
475
-	public static function name ( $name = NULL ) {
476
-		return ! empty( $name ) ? '<span itemprop="name">' . $name . '</span>' : '';
475
+	public static function name($name = NULL) {
476
+		return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
477 477
 	}
478 478
 
479 479
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	* 	@param EEI_Address $obj_with_address
485 485
 	* 	@return string
486 486
 	*/
487
-	public static function streetAddress ( EEI_Address $obj_with_address = NULL ) {
488
-		return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
487
+	public static function streetAddress(EEI_Address $obj_with_address = NULL) {
488
+		return $obj_with_address->address() !== NULL && $obj_with_address->address() !== '' ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
489 489
 	}
490 490
 
491 491
 	/**
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 	* 	@param EEI_Address $obj_with_address
497 497
 	* 	@return string
498 498
 	*/
499
-	public static function postOfficeBoxNumber ( EEI_Address $obj_with_address = NULL ) {
499
+	public static function postOfficeBoxNumber(EEI_Address $obj_with_address = NULL) {
500 500
 		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
501
-		if ( preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2() )) {
502
-			return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
501
+		if (preg_match("/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i", $obj_with_address->address2())) {
502
+			return $obj_with_address->address2() !== NULL && $obj_with_address->address2() !== '' ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
503 503
 		} else {
504 504
 			return $obj_with_address->address2();
505 505
 		}
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	* 	@param EEI_Address $obj_with_address
514 514
 	* 	@return string
515 515
 	*/
516
-	public static function addressLocality ( EEI_Address $obj_with_address = NULL ) {
517
-		return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
516
+	public static function addressLocality(EEI_Address $obj_with_address = NULL) {
517
+		return $obj_with_address->city() !== NULL && $obj_with_address->city() !== '' ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
518 518
 	}
519 519
 
520 520
 	/**
@@ -525,10 +525,10 @@  discard block
 block discarded – undo
525 525
 	* 	@param EEI_Address $obj_with_address
526 526
 	* 	@return string
527 527
 	*/
528
-	public static function addressRegion ( EEI_Address $obj_with_address = NULL ) {
528
+	public static function addressRegion(EEI_Address $obj_with_address = NULL) {
529 529
 		$state = $obj_with_address->state_name();
530
-		if ( ! empty( $state ) ) {
531
-			return '<span itemprop="addressRegion">' . $state . '</span>';
530
+		if ( ! empty($state)) {
531
+			return '<span itemprop="addressRegion">'.$state.'</span>';
532 532
 		} else {
533 533
 			return '';
534 534
 		}
@@ -542,10 +542,10 @@  discard block
 block discarded – undo
542 542
 	* 	@param EEI_Address $obj_with_address
543 543
 	* 	@return string
544 544
 	*/
545
-	public static function addressCountry ( EEI_Address $obj_with_address = NULL ) {
545
+	public static function addressCountry(EEI_Address $obj_with_address = NULL) {
546 546
 		$country = $obj_with_address->country_name();
547
-		if ( ! empty( $country ) ) {
548
-			return '<span itemprop="addressCountry">' . $country . '</span>';
547
+		if ( ! empty($country)) {
548
+			return '<span itemprop="addressCountry">'.$country.'</span>';
549 549
 		} else {
550 550
 			return '';
551 551
 		}
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	* 	@param EEI_Address $obj_with_address
560 560
 	* 	@return string
561 561
 	*/
562
-	public static function postalCode ( EEI_Address $obj_with_address = NULL ) {
563
-		return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== ''  ? '<span itemprop="postalCode">' . $obj_with_address->zip() . '</span>' : '';
562
+	public static function postalCode(EEI_Address $obj_with_address = NULL) {
563
+		return $obj_with_address->zip() !== NULL && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'.$obj_with_address->zip().'</span>' : '';
564 564
 	}
565 565
 
566 566
 	/**
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 	* 	@param string $phone_nmbr
572 572
 	* 	@return string
573 573
 	*/
574
-	public static function telephone ( $phone_nmbr = NULL ) {
575
-		return $phone_nmbr !== NULL && $phone_nmbr !== ''  ? '<span itemprop="telephone">' . $phone_nmbr . '</span>' : '';
574
+	public static function telephone($phone_nmbr = NULL) {
575
+		return $phone_nmbr !== NULL && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>' : '';
576 576
 	}
577 577
 
578 578
 	/**
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 	* 	@param array $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
586 586
 	* 	@return string (link)
587 587
 	*/
588
-	public static function url ( $url = NULL, $text = NULL, $attributes = array() ) {
588
+	public static function url($url = NULL, $text = NULL, $attributes = array()) {
589 589
 		$atts = '';
590
-		foreach ( $attributes as $attribute => $value ) {
591
-			$atts .= ' ' . $attribute . '="' . $value . '"';
590
+		foreach ($attributes as $attribute => $value) {
591
+			$atts .= ' '.$attribute.'="'.$value.'"';
592 592
 		}
593 593
 		$text = $text !== NULL && $text !== '' ? $text : $url;
594
-		return $url !== NULL && $url !== '' ? '<a itemprop="url" href="' . $url . '"' . $atts . '>' . $text . '</a>' : '';
594
+		return $url !== NULL && $url !== '' ? '<a itemprop="url" href="'.$url.'"'.$atts.'>'.$text.'</a>' : '';
595 595
 	}
596 596
 
597 597
 
@@ -631,18 +631,18 @@  discard block
 block discarded – undo
631 631
 	 * @param EE_Country | string $country
632 632
 	 * @return EE_Generic_Address
633 633
 	 */
634
-	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
634
+	public function __construct($address, $address2, $city, $state, $zip, $country) {
635 635
 		$this->_address = $address;
636 636
 		$this->_address2 = $address2;
637 637
 		$this->_city = $city;
638
-		if ( $state instanceof EE_State ) {
638
+		if ($state instanceof EE_State) {
639 639
 			$this->_state_obj = $state;
640 640
 		} else {
641 641
 			$this->_state_ID = $state;
642 642
 			$this->_state_obj = $this->_get_state_obj();
643 643
 		}
644 644
 		$this->_zip = $zip;
645
-		if ( $country instanceof EE_Country ) {
645
+		if ($country instanceof EE_Country) {
646 646
 			$this->_country_obj = $country;
647 647
 		} else {
648 648
 			$this->_country_ID = $country;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 	 * @return \EE_State
684 684
 	 */
685 685
 	private function _get_state_obj() {
686
-		return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID );
686
+		return $this->_state_obj instanceof EE_State ? $this->_state_obj : EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
687 687
 	}
688 688
 
689 689
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	 * @return string
702 702
 	 */
703 703
 	public function state_abbrev() {
704
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __( 'Unknown', 'event_espresso' );
704
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : __('Unknown', 'event_espresso');
705 705
 	}
706 706
 
707 707
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @return string
711 711
 	 */
712 712
 	public function state_name() {
713
-		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() :  __( 'Unknown', 'event_espresso' );
713
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : __('Unknown', 'event_espresso');
714 714
 	}
715 715
 
716 716
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 	 * @return string
729 729
 	 */
730 730
 	public function state() {
731
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
731
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
732 732
 			return $this->state_obj()->abbrev();
733 733
 		} else {
734 734
 			return $this->state_name();
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	 * @return EE_Country
742 742
 	 */
743 743
 	private function _get_country_obj() {
744
-		return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID );
744
+		return $this->_country_obj instanceof EE_Country ? $this->_country_obj : EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
745 745
 	}
746 746
 
747 747
 
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 * @return string
760 760
 	 */
761 761
 	public function country_name() {
762
-		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() :  __( 'Unknown', 'event_espresso' );
762
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : __('Unknown', 'event_espresso');
763 763
 	}
764 764
 
765 765
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 * @return string
778 778
 	 */
779 779
 	public function country() {
780
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
780
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
781 781
 			return $this->country_ID();
782 782
 		} else {
783 783
 			return $this->country_name();
Please login to merge, or discard this patch.
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@
 block discarded – undo
12 12
 
13 13
 	protected $_max_length;
14 14
 
15
+	/**
16
+	 * @param integer $max_length
17
+	 */
15 18
 	public function __construct( $validation_error_message = NULL, $max_length = INF ) {
16 19
 		$this->_max_length = $max_length;
17 20
 		parent::__construct( $validation_error_message );
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@
 block discarded – undo
8 8
  * @subpackage	Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php.
9 9
  * @author				Mike Nelson
10 10
  */
11
-class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base{
11
+class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base {
12 12
 
13 13
 	protected $_max_length;
14 14
 
15
-	public function __construct( $validation_error_message = NULL, $max_length = EE_INF ) {
15
+	public function __construct($validation_error_message = NULL, $max_length = EE_INF) {
16 16
 		$this->_max_length = $max_length;
17
-		parent::__construct( $validation_error_message );
17
+		parent::__construct($validation_error_message);
18 18
 	}
19 19
 
20 20
 	/**
21 21
 	 * @param $normalized_value
22 22
 	 */
23 23
 	public function validate($normalized_value) {
24
-		if( $this->_max_length !== EE_INF &&
24
+		if ($this->_max_length !== EE_INF &&
25 25
 				$normalized_value &&
26
-				is_string( $normalized_value ) &&
27
-				 strlen( $normalized_value ) > $this->_max_length){
28
-			throw new EE_Validation_Error( $this->get_validation_error_message(), 'maxlength' );
26
+				is_string($normalized_value) &&
27
+				 strlen($normalized_value) > $this->_max_length) {
28
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
29 29
 		}
30 30
 	}
31 31
 
32 32
 	/**
33 33
 	 * @return array
34 34
 	 */
35
-	function get_jquery_validation_rule_array(){
36
-		return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
35
+	function get_jquery_validation_rule_array() {
36
+		return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message()));
37 37
 	}
38 38
 }
39 39
 
Please login to merge, or discard this patch.
core/Psr4Autoloader.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * Loads the class file for a given class name.
112 112
 	 *
113 113
 	 * @param string $class The fully-qualified class name.
114
-	 * @return mixed The mapped file name on success, or boolean false on
114
+	 * @return string|false The mapped file name on success, or boolean false on
115 115
 	 * failure.
116 116
 	 */
117 117
 	public function loadClass( $class ) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param string $prefix The namespace prefix.
146 146
 	 * @param string $relative_class The relative class name.
147
-	 * @return mixed Boolean false if no mapped file can be loaded, or the
147
+	 * @return false|string Boolean false if no mapped file can be loaded, or the
148 148
 	 * name of the mapped file that was loaded.
149 149
 	 */
150 150
 	protected function loadMappedFile( $prefix, $relative_class ) {
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @return void
73 73
 	 */
74 74
 	public function register() {
75
-		spl_autoload_register( array( $this, 'loadClass' ) );
75
+		spl_autoload_register(array($this, 'loadClass'));
76 76
 	}
77 77
 
78 78
 
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 	 * than last.
89 89
 	 * @return void
90 90
 	 */
91
-	public function addNamespace( $prefix, $base_dir, $prepend = false ) {
91
+	public function addNamespace($prefix, $base_dir, $prepend = false) {
92 92
 		// normalize namespace prefix
93
-		$prefix = trim( $prefix, '\\' ) . '\\';
93
+		$prefix = trim($prefix, '\\').'\\';
94 94
 		// normalize the base directory with a trailing separator
95
-		$base_dir = rtrim( $base_dir, DIRECTORY_SEPARATOR ) . '/';
95
+		$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR).'/';
96 96
 		// initialize the namespace prefix array
97
-		if ( isset( $this->prefixes[ $prefix ] ) === false ) {
98
-			$this->prefixes[ $prefix ] = array();
97
+		if (isset($this->prefixes[$prefix]) === false) {
98
+			$this->prefixes[$prefix] = array();
99 99
 		}
100 100
 		// retain the base directory for the namespace prefix
101
-		if ( $prepend ) {
102
-			array_unshift( $this->prefixes[ $prefix ], $base_dir );
101
+		if ($prepend) {
102
+			array_unshift($this->prefixes[$prefix], $base_dir);
103 103
 		} else {
104
-			array_push( $this->prefixes[ $prefix ], $base_dir );
104
+			array_push($this->prefixes[$prefix], $base_dir);
105 105
 		}
106 106
 	}
107 107
 
@@ -114,24 +114,24 @@  discard block
 block discarded – undo
114 114
 	 * @return mixed The mapped file name on success, or boolean false on
115 115
 	 * failure.
116 116
 	 */
117
-	public function loadClass( $class ) {
117
+	public function loadClass($class) {
118 118
 		// the current namespace prefix
119 119
 		$prefix = $class;
120 120
 		// work backwards through the namespace names of the fully-qualified
121 121
 		// class name to find a mapped file name
122
-		while ( false !== $pos = strrpos( $prefix, '\\' ) ) {
122
+		while (false !== $pos = strrpos($prefix, '\\')) {
123 123
 			// retain the trailing namespace separator in the prefix
124
-			$prefix = substr( $class, 0, $pos + 1 );
124
+			$prefix = substr($class, 0, $pos + 1);
125 125
 			// the rest is the relative class name
126
-			$relative_class = substr( $class, $pos + 1 );
126
+			$relative_class = substr($class, $pos + 1);
127 127
 			// try to load a mapped file for the prefix and relative class
128
-			$mapped_file = $this->loadMappedFile( $prefix, $relative_class );
129
-			if ( $mapped_file ) {
128
+			$mapped_file = $this->loadMappedFile($prefix, $relative_class);
129
+			if ($mapped_file) {
130 130
 				return $mapped_file;
131 131
 			}
132 132
 			// remove the trailing namespace separator for the next iteration
133 133
 			// of strrpos()
134
-			$prefix = rtrim( $prefix, '\\' );
134
+			$prefix = rtrim($prefix, '\\');
135 135
 		}
136 136
 		// never found a mapped file
137 137
 		return false;
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 	 * @return mixed Boolean false if no mapped file can be loaded, or the
148 148
 	 * name of the mapped file that was loaded.
149 149
 	 */
150
-	protected function loadMappedFile( $prefix, $relative_class ) {
150
+	protected function loadMappedFile($prefix, $relative_class) {
151 151
 		// are there any base directories for this namespace prefix?
152
-		if ( isset( $this->prefixes[ $prefix ] ) === false ) {
152
+		if (isset($this->prefixes[$prefix]) === false) {
153 153
 			return false;
154 154
 		}
155 155
 		// look through base directories for this namespace prefix
156
-		foreach ( $this->prefixes[ $prefix ] as $base_dir ) {
156
+		foreach ($this->prefixes[$prefix] as $base_dir) {
157 157
 			// replace the namespace prefix with the base directory,
158 158
 			// replace namespace separators with directory separators
159 159
 			// in the relative class name, append with .php
160 160
 			$file = $base_dir
161
-				. str_replace( '\\', '/', $relative_class )
161
+				. str_replace('\\', '/', $relative_class)
162 162
 				. '.php';
163 163
 			// if the mapped file exists, require it
164
-			if ( $this->requireFile( $file ) ) {
164
+			if ($this->requireFile($file)) {
165 165
 				// yes, we're done
166 166
 				return $file;
167 167
 			}
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	 * @param string $file The file to require.
179 179
 	 * @return bool True if the file exists, false if not.
180 180
 	 */
181
-	protected function requireFile( $file ) {
182
-		if ( file_exists( $file ) ) {
181
+	protected function requireFile($file) {
182
+		if (file_exists($file)) {
183 183
 			require $file;
184 184
 			return true;
185 185
 		}
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_List_Table.class.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 
34 34
 	private $_dtt;
35 35
 
36
-	public function __construct( $admin_page ) {
36
+	public function __construct($admin_page) {
37 37
 		parent::__construct($admin_page);
38
-		require_once( EE_HELPERS . 'EEH_DTT_Helper.helper.php' );
38
+		require_once(EE_HELPERS.'EEH_DTT_Helper.helper.php');
39 39
 	}
40 40
 
41 41
 	protected function _setup_data() {
42 42
 		$this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page);
43
- 		$this->_all_data_count = $this->_admin_page->get_events(0,0, TRUE);
43
+ 		$this->_all_data_count = $this->_admin_page->get_events(0, 0, TRUE);
44 44
 	}
45 45
 
46 46
 	protected function _set_properties() {
@@ -67,17 +67,17 @@  discard block
 block discarded – undo
67 67
 
68 68
 
69 69
 		$this->_sortable_columns = array(
70
-			'id' => array( 'EVT_ID' => true ),
71
-			'name' => array( 'EVT_name' => false ),
72
-			'author' => array( 'EVT_wp_user' => false ),
73
-			'venue' => array( 'Venue.VNU_name' => false ),
70
+			'id' => array('EVT_ID' => true),
71
+			'name' => array('EVT_name' => false),
72
+			'author' => array('EVT_wp_user' => false),
73
+			'venue' => array('Venue.VNU_name' => false),
74 74
 			'start_date_time' => array('Datetime.DTT_EVT_start' => false),
75 75
 			'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false),
76 76
 			);
77 77
 
78 78
 		$this->_primary_column = 'id';
79 79
 
80
-		$this->_hidden_columns = array( 'author' );
80
+		$this->_hidden_columns = array('author');
81 81
 	}
82 82
 
83 83
 
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
 	protected function _add_view_counts() {
93 93
 		$this->_views['all']['count'] = $this->_admin_page->total_events();
94 94
 		$this->_views['draft']['count'] = $this->_admin_page->total_events_draft();
95
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
95
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
96 96
 			$this->_views['trash']['count'] = $this->_admin_page->total_trashed_events();
97 97
 		}
98 98
 	}
99 99
 
100 100
 
101 101
 
102
-	protected function _get_row_class( $item ) {
103
-		$class = parent::_get_row_class( $item );
102
+	protected function _get_row_class($item) {
103
+		$class = parent::_get_row_class($item);
104 104
 		//add status class
105
-		$class .= ' ee-status-strip event-status-' . $item->get_active_status();
106
-		if ( $this->_has_checkbox_column ) {
105
+		$class .= ' ee-status-strip event-status-'.$item->get_active_status();
106
+		if ($this->_has_checkbox_column) {
107 107
 			$class .= ' has-checkbox-column';
108 108
 		}
109 109
 		return $class;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 
112 112
 
113 113
 
114
-	public function column_status( EE_Event $item ) {
115
-		return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>';
114
+	public function column_status(EE_Event $item) {
115
+		return '<span class="ee-status-strip ee-status-strip-td event-status-'.$item->get_active_status().'"></span>';
116 116
 	}/**/
117 117
 
118 118
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 	public function column_id($item) {
134 134
 		$content = $item->ID();
135
-		$content .= '  <span class="show-on-mobile-view-only">' . $item->name() . '</span>';
135
+		$content .= '  <span class="show-on-mobile-view-only">'.$item->name().'</span>';
136 136
 		return $content;
137 137
 	}
138 138
 
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 				'action' => 'edit',
144 144
 				'post' => $item->ID()
145 145
 			);
146
-		$edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL );
147
-		$actions = $this->_column_name_action_setup( $item );
146
+		$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
147
+		$actions = $this->_column_name_action_setup($item);
148 148
 		$status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : '';
149
-		$content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status;
150
-		$content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->get_active_status(), false, 'sentence' ) . '</span>';
149
+		$content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>'.$status;
150
+		$content .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->get_active_status(), false, 'sentence').'</span>';
151 151
 		$content .= $this->row_actions($actions);
152 152
 		return $content;
153 153
 
@@ -164,72 +164,72 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @return array array of actions
166 166
 	 */
167
-	protected function _column_name_action_setup( EE_Event $item ) {
167
+	protected function _column_name_action_setup(EE_Event $item) {
168 168
 		//todo: remove when attendees is active
169
-		if ( !defined('REG_ADMIN_URL') )
169
+		if ( ! defined('REG_ADMIN_URL'))
170 170
 			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
171 171
 
172 172
 		$actions = array();
173 173
 
174
-		if ( EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID() ) ) {
174
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
175 175
 			$edit_query_args = array(
176 176
 					'action' => 'edit',
177 177
 					'post' => $item->ID()
178 178
 				);
179
-			$edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL );
180
-			$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>';
179
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
180
+			$actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
181 181
 
182 182
 		}
183 183
 
184
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) {
184
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) {
185 185
 			$attendees_query_args = array(
186 186
 					'action' => 'default',
187 187
 					'event_id' => $item->ID()
188 188
 				);
189
-			$attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL );
190
-			$actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>';
189
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
190
+			$actions['attendees'] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrations', 'event_espresso').'">'.__('Registrations', 'event_espresso').'</a>';
191 191
 		}
192 192
 
193
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) {
193
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) {
194 194
 			$trash_event_query_args = array(
195 195
 					'action' => 'trash_event',
196 196
 					'EVT_ID' => $item->ID()
197 197
 				);
198
-			$trash_event_link = EE_Admin_Page::add_query_args_and_nonce( $trash_event_query_args, EVENTS_ADMIN_URL );
198
+			$trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, EVENTS_ADMIN_URL);
199 199
 		}
200 200
 
201
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) {
201
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) {
202 202
 			$restore_event_query_args = array(
203 203
 					'action' => 'restore_event',
204 204
 					'EVT_ID' => $item->ID()
205 205
 				);
206
-			$restore_event_link = EE_Admin_Page::add_query_args_and_nonce( $restore_event_query_args, EVENTS_ADMIN_URL );
206
+			$restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, EVENTS_ADMIN_URL);
207 207
 		}
208 208
 
209
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) {
209
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) {
210 210
 			$delete_event_query_args = array(
211 211
 					'action' => 'delete_event',
212 212
 					'EVT_ID' => $item->ID()
213 213
 				);
214
-			$delete_event_link = EE_Admin_Page::add_query_args_and_nonce( $delete_event_query_args, EVENTS_ADMIN_URL );
214
+			$delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, EVENTS_ADMIN_URL);
215 215
 		}
216 216
 
217 217
 		$view_link = get_permalink($item->ID());
218 218
 
219
-		$actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>';
219
+		$actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'">'.__('View', 'event_espresso').'</a>';
220 220
 
221
-		switch ( $item->get( 'status' ) ) {
221
+		switch ($item->get('status')) {
222 222
 			case 'trash' :
223
-					if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) {
224
-						$actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>';
223
+					if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) {
224
+						$actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" title="'.esc_attr__('Restore from Trash', 'event_espresso').'">'.__('Restore from Trash', 'event_espresso').'</a>';
225 225
 					}
226
-					if ( $item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) {
227
-						$actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>';
226
+					if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) {
227
+						$actions['delete'] = '<a href="'.$delete_event_link.'" title="'.esc_attr__('Delete Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
228 228
 					}
229 229
 				break;
230 230
 			default :
231
-					if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) {
232
-						$actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>';
231
+					if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) {
232
+						$actions['move to trash'] = '<a href="'.$trash_event_link.'" title="'.esc_attr__('Trash Event', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>';
233 233
 					}
234 234
 		}
235 235
 		return $actions;
@@ -238,34 +238,34 @@  discard block
 block discarded – undo
238 238
 
239 239
 
240 240
 
241
-	public function column_author( EE_Event $item ) {
241
+	public function column_author(EE_Event $item) {
242 242
 		//user author info
243
-		$event_author = get_userdata( $item->wp_user() );
244
-		$gravatar = get_avatar( $item->wp_user(), '15' );
243
+		$event_author = get_userdata($item->wp_user());
244
+		$gravatar = get_avatar($item->wp_user(), '15');
245 245
 		//filter link
246 246
 		$query_args = array(
247 247
 			'action' => 'default',
248 248
 			'EVT_wp_user' => $item->wp_user()
249 249
 			);
250
-		$filter_url = EE_Admin_Page::add_query_args_and_nonce( $query_args, EVENTS_ADMIN_URL );
251
-		return $gravatar . '  <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' . $event_author->display_name . '</a>';
250
+		$filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL);
251
+		return $gravatar.'  <a href="'.$filter_url.'" title="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">'.$event_author->display_name.'</a>';
252 252
 	}
253 253
 
254 254
 
255 255
 
256 256
 
257 257
 	public function column_venue($item) {
258
-		$venue = $item->get_first_related( 'Venue' );
259
-		return !empty( $venue ) ? $venue->name() : '';
258
+		$venue = $item->get_first_related('Venue');
259
+		return ! empty($venue) ? $venue->name() : '';
260 260
 	}
261 261
 
262 262
 
263 263
 
264 264
 
265 265
 	public function column_start_date_time($item) {
266
-		echo !empty( $this->_dtt ) ?  $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso');
266
+		echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso');
267 267
 		//display in user's timezone?
268
-		echo !empty( $this->_dtt ) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ' ) : '';
268
+		echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ') : '';
269 269
 
270 270
 	}
271 271
 
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 
275 275
 	public function column_reg_begins($item) {
276 276
 		$reg_start = $item->get_ticket_with_earliest_start_time();
277
-		echo !empty( $reg_start ) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso');
277
+		echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso');
278 278
 		//display in user's timezone?
279
-		echo !empty( $reg_start ) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ' ) : '';/**/
279
+		echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ') : ''; /**/
280 280
 	}
281 281
 
282 282
 
@@ -294,51 +294,51 @@  discard block
 block discarded – undo
294 294
 				'action' => 'default',
295 295
 				'event_id' => $item->ID()
296 296
 			);
297
-		$attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL );
298
-		$registered_attendees = EEM_Registration::instance()->get_event_registration_count( $item->ID() );
299
-		return  EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees;
297
+		$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
298
+		$registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID());
299
+		return  EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' : $registered_attendees;
300 300
 	}
301 301
 
302 302
 
303 303
 
304 304
 	public function column_tkts_sold($item) {
305
-		return EEM_Ticket::instance()->sum(array( array('Datetime.EVT_ID' => $item->ID() )), 'TKT_sold' );
305
+		return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold');
306 306
 	}
307 307
 
308 308
 
309 309
 
310 310
 	public function column_actions($item) {
311 311
 		//todo: remove when attendees is active
312
-		if ( !defined('REG_ADMIN_URL') )
312
+		if ( ! defined('REG_ADMIN_URL'))
313 313
 			define('REG_ADMIN_URL', EVENTS_ADMIN_URL);
314 314
 		$actionlinks = array();
315 315
 
316 316
 		$view_link = get_permalink($item->ID());
317 317
 
318
-		$actionlinks[] = '<a href="' .  $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">';
318
+		$actionlinks[] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">';
319 319
 		$actionlinks[] = '<div class="dashicons dashicons-search"></div></a>';
320 320
 
321
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $item->ID() ) ) {
321
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) {
322 322
 			$edit_query_args = array(
323 323
 					'action' => 'edit',
324 324
 					'post' => $item->ID()
325 325
 				);
326
-			$edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL );
327
-			$actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
326
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL);
327
+			$actionlinks[] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'"><div class="ee-icon ee-icon-calendar-edit"></div></a>';
328 328
 		}
329 329
 
330
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) {
330
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) {
331 331
 			$attendees_query_args = array(
332 332
 				'action' => 'default',
333 333
 				'event_id' => $item->ID()
334 334
 			);
335
-			$attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL );
336
-			$actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>';
335
+			$attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL);
336
+			$actionlinks[] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrants', 'event_espresso').'"><div class="dashicons dashicons-groups"></div></a>';
337 337
 		}
338 338
 
339
-		$actionlinks = apply_filters( 'FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item );
339
+		$actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item);
340 340
 
341
-		return $this->_action_string( implode( "\n\t", $actionlinks ), $item, 'div' );
341
+		return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div');
342 342
 	}
343 343
 
344 344
 
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 3 patches
Braces   +20 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if (!defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -1199,7 +1200,9 @@  discard block
 block discarded – undo
1199 1200
 
1200 1201
 
1201 1202
 		//if no postid then get out cause we need it for stuff in here
1202
-		if ( empty( $postid ) ) return;
1203
+		if ( empty( $postid ) ) {
1204
+			return;
1205
+		}
1203 1206
 
1204 1207
 
1205 1208
 		//handle datetime saves
@@ -1440,10 +1443,11 @@  discard block
 block discarded – undo
1440 1443
 			//get the earliest datetime (if present);
1441 1444
 			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1442 1445
 
1443
-			if ( !empty( $earliest_dtt ) )
1444
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1445
-			else
1446
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1446
+			if ( !empty( $earliest_dtt ) ) {
1447
+							$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1448
+			} else {
1449
+							$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1450
+			}
1447 1451
 		}
1448 1452
 
1449 1453
 		$template_args = array_merge( $template_args, $price_args );
@@ -1674,8 +1678,9 @@  discard block
 block discarded – undo
1674 1678
 		}
1675 1679
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1676 1680
 
1677
-		if ( $redirect_after )
1678
-			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1681
+		if ( $redirect_after ) {
1682
+					$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1683
+		}
1679 1684
 	}
1680 1685
 
1681 1686
 	/**
@@ -1800,8 +1805,9 @@  discard block
 block discarded – undo
1800 1805
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1801 1806
 		}
1802 1807
 
1803
-		if ( $redirect_after )
1804
-			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1808
+		if ( $redirect_after ) {
1809
+					$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1810
+		}
1805 1811
 	}
1806 1812
 
1807 1813
 	/**
@@ -2033,8 +2039,10 @@  discard block
 block discarded – undo
2033 2039
 	 * @return void
2034 2040
 	 */
2035 2041
 	private function _set_category_object() {
2036
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2037
-			return; //already have the category object so get out.
2042
+		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) {
2043
+					return;
2044
+		}
2045
+		//already have the category object so get out.
2038 2046
 
2039 2047
 		//set default category object
2040 2048
 		$this->_set_empty_category_object();
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1345,7 +1345,7 @@
 block discarded – undo
1345 1345
 	 * This just returns whatever is set as the _event object property
1346 1346
 	 *
1347 1347
 	 * //todo this will become obsolete once the models are in place
1348
-	 * @return object
1348
+	 * @return EE_CPT_Base
1349 1349
 	 */
1350 1350
 	public function get_event_object() {
1351 1351
 		return $this->_cpt_model_obj;
Please login to merge, or discard this patch.
Spacing   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			'espresso_events' => 'edit'
68 68
 			);
69 69
 
70
-		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) );
70
+		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit'));
71 71
 	}
72 72
 
73 73
 	protected function _ajax_hooks() {
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 				'edit' => __('Update Event', 'event_espresso'),
94 94
 				'add_category' => __('Save New Category', 'event_espresso'),
95 95
 				'edit_category' => __('Update Category', 'event_espresso'),
96
-				'template_settings' => __( 'Update Settings', 'event_espresso' )
96
+				'template_settings' => __('Update Settings', 'event_espresso')
97 97
 				)
98 98
 		);
99 99
 	}
100 100
 
101 101
 	protected function _set_page_routes() {
102 102
 		//load formatter helper
103
-		EE_Registry::instance()->load_helper( 'Formatter' );
103
+		EE_Registry::instance()->load_helper('Formatter');
104 104
 		//load field generator helper
105
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
105
+		EE_Registry::instance()->load_helper('Form_Fields');
106 106
 
107 107
 		//is there a evt_id in the request?
108
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
109
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
108
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
109
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
110 110
 
111 111
 
112 112
 		$this->_page_routes = array(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				'help_tour' => array(
321 321
 					'Event_Editor_Help_Tour'
322 322
 					),
323
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
323
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
324 324
 				'require_nonce' => FALSE
325 325
 			),
326 326
 			'edit' => array(
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 				'help_tour' => array(
377 377
 					'Event_Edit_Help_Tour'
378 378
 				),
379
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
379
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
380 380
 				'require_nonce' => FALSE
381 381
 			),
382 382
 			'default_event_settings' => array(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 						'filename' => 'events_default_settings_status'
399 399
 					)
400 400
 				),
401
-				'help_tour' => array( 'Event_Default_Settings_Help_Tour'),
401
+				'help_tour' => array('Event_Default_Settings_Help_Tour'),
402 402
 				'require_nonce' => FALSE
403 403
 			),
404 404
 			//template settings
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 						'filename' => 'general_settings_templates'
415 415
 					)
416 416
 				),
417
-				'help_tour' => array( 'Templates_Help_Tour' ),
417
+				'help_tour' => array('Templates_Help_Tour'),
418 418
 				'require_nonce' => FALSE
419 419
 			),
420 420
 			//event category stuff
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					'label' => __('Edit Category', 'event_espresso'),
439 439
 					'order' => 15,
440 440
 					'persistent' => FALSE,
441
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
441
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
442 442
 					),
443 443
 				'help_tabs' => array(
444 444
 					'edit_category_help_tab' => array(
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 
509 509
 	public function load_scripts_styles() {
510 510
 
511
-		wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
511
+		wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
513 513
 		wp_enqueue_style('events-admin-css');
514 514
 		wp_enqueue_style('ee-cat-admin');
515 515
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
516 516
 		//registers for all views
517 517
 		//scripts
518
-		wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
518
+		wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
519 519
 	}
520 520
 
521 521
 	/**
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function load_scripts_styles_edit() {
534 534
 		//styles
535 535
 		wp_enqueue_style('espresso-ui-theme');
536
-		wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
536
+		wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
537 537
 		wp_enqueue_style('event-editor-css');
538 538
 
539 539
 		//scripts
540
-		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION );
540
+		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION);
541 541
 		wp_enqueue_script('event-datetime-metabox');
542 542
 
543 543
 	}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
 	public function admin_init() {
575
-		EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' );
575
+		EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso');
576 576
 	}
577 577
 
578 578
 
@@ -593,35 +593,35 @@  discard block
 block discarded – undo
593 593
 	 */
594 594
 	public function verify_event_edit($event = NULL) {
595 595
 		// no event?
596
-		if ( empty( $event )) {
596
+		if (empty($event)) {
597 597
 			// set event
598 598
 			$event = $this->_cpt_model_obj;
599 599
 		}
600 600
 		// STILL no event?
601
-		if ( empty ( $event )) {
601
+		if (empty ($event)) {
602 602
 			return;
603 603
 		}
604 604
 		// first check if event is active.
605
-		if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) {
605
+		if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) {
606 606
 			return;
607 607
 		}
608 608
 		$orig_status = $event->status();
609 609
 		//made it here so it IS active... next check that any of the tickets are sold.
610
-		if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
611
-			if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out  ) {
612
-				EE_Error::add_attention( sprintf(
613
-					__( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso' ),
614
-					EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' )
610
+		if ($event->is_sold_out() || $event->is_sold_out(TRUE)) {
611
+			if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) {
612
+				EE_Error::add_attention(sprintf(
613
+					__('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso'),
614
+					EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence')
615 615
 				));
616 616
 			}
617 617
 			return;
618 618
 		}
619 619
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
620
-		if ( ! $event->tickets_on_sale() ) {
620
+		if ( ! $event->tickets_on_sale()) {
621 621
 			return;
622 622
 		}
623 623
 		//made it here so show warning
624
-		EE_Error::add_attention( $this->_edit_event_warning() );
624
+		EE_Error::add_attention($this->_edit_event_warning());
625 625
 	}
626 626
 
627 627
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			),
662 662
 		);
663 663
 
664
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
664
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
665 665
 			$this->_views['trash'] = array(
666 666
 				'slug' => 'trash',
667 667
 				'label' => __('Trash', 'event_espresso'),
@@ -691,39 +691,39 @@  discard block
 block discarded – undo
691 691
 				'desc' => __('View Registrations for Event', 'event_espresso')
692 692
 			)
693 693
 		);
694
-		$items  = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
694
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
695 695
 		$statuses = array(
696 696
 			'sold_out_status' => array(
697
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
698
-				'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' )
697
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
698
+				'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence')
699 699
 			),
700 700
 			'active_status' => array(
701
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
702
-				'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' )
701
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
702
+				'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence')
703 703
 			),
704 704
 			'upcoming_status' => array(
705
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
706
-				'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' )
705
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
706
+				'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence')
707 707
 			),
708 708
 			'postponed_status' => array(
709
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
710
-				'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' )
709
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
710
+				'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence')
711 711
 			),
712 712
 			'cancelled_status' => array(
713
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
714
-				'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' )
713
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
714
+				'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence')
715 715
 			),
716 716
 			'expired_status' => array(
717
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
718
-				'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' )
717
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
718
+				'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence')
719 719
 			),
720 720
 			'inactive_status' => array(
721
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
722
-				'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' )
721
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
722
+				'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence')
723 723
 			)
724 724
 		);
725
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
726
-		return array_merge( $items, $statuses );
725
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
726
+		return array_merge($items, $statuses);
727 727
 	}
728 728
 
729 729
 
@@ -735,8 +735,8 @@  discard block
 block discarded – undo
735 735
 	 * @return EEM_Event
736 736
 	 */
737 737
 	private function _event_model() {
738
-		if ( ! $this->_event_model instanceof EEM_Event ) {
739
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
738
+		if ( ! $this->_event_model instanceof EEM_Event) {
739
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
740 740
 		}
741 741
 		return $this->_event_model;
742 742
 	}
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 	 * @param  string $new_slug  what the slug is
756 756
 	 * @return string            The new html string for the permalink area
757 757
 	 */
758
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
758
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
759 759
 		//make sure this is only when editing
760
-		if ( !empty( $id ) ) {
761
-			$post = get_post( $id );
762
-			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> ';
763
-			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">';
760
+		if ( ! empty($id)) {
761
+			$post = get_post($id);
762
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> ';
763
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">';
764 764
 		}
765 765
 		return $return;
766 766
 	}
@@ -776,8 +776,8 @@  discard block
 block discarded – undo
776 776
 	 * @return string html for generated table
777 777
 	 */
778 778
 	protected function _events_overview_list_table() {
779
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
780
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) .
779
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
780
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button').
781 781
 		$this->_display_legend($this->_event_legend_items());
782 782
 		$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
783 783
 		$this->display_admin_list_table_page_with_no_sidebar();
@@ -795,51 +795,51 @@  discard block
 block discarded – undo
795 795
 
796 796
 
797 797
 
798
-	protected function _insert_update_cpt_item( $post_id, $post ) {
798
+	protected function _insert_update_cpt_item($post_id, $post) {
799 799
 
800
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
800
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
801 801
 			//getout we're not processing an event save.
802 802
 			return;
803 803
 		}
804 804
 
805 805
 		$event_values = array(
806
-			'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0,
807
-			'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
806
+			'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,
807
+			'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
808 808
 			'EVT_additional_limit' => min(
809
-					apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
810
-					!empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ),
811
-			'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
812
-			'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0,
813
-			'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
814
-			'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL,
815
-			'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL,
816
-			'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL
809
+					apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
810
+					! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ),
811
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
812
+			'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,
813
+			'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
814
+			'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL,
815
+			'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL,
816
+			'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL
817 817
 			);
818 818
 
819 819
 		//update event
820
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
820
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
821 821
 
822 822
 
823 823
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
824
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
825
-		$event = $this->_event_model()->get_one( array($get_one_where) );
824
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
825
+		$event = $this->_event_model()->get_one(array($get_one_where));
826 826
 
827 827
 
828 828
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
829
-		$event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) );
829
+		$event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')));
830 830
 
831 831
 		$att_success = TRUE;
832 832
 
833
-		foreach ( $event_update_callbacks as $e_callback ) {
834
-			$_succ = call_user_func_array( $e_callback, array( $event,  $this->_req_data ) );
835
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
833
+		foreach ($event_update_callbacks as $e_callback) {
834
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
835
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
836 836
 		}
837 837
 
838 838
 		//any errors?
839
-		if ( $success && FALSE === $att_success ) {
840
-			EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
841
-		} else if ( $success === FALSE ) {
842
-			EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
839
+		if ($success && FALSE === $att_success) {
840
+			EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
841
+		} else if ($success === FALSE) {
842
+			EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
843 843
 		}
844 844
 	}
845 845
 
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 	/**
850 850
 	 * @see parent::restore_item()
851 851
 	 */
852
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
852
+	protected function _restore_cpt_item($post_id, $revision_id) {
853 853
 		//copy existing event meta to new post
854 854
 		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
855
-		if ( $post_evt instanceof EE_Event ) {
855
+		if ($post_evt instanceof EE_Event) {
856 856
 			//meta revision restore
857
-			$post_evt->restore_revision( $revision_id );
857
+			$post_evt->restore_revision($revision_id);
858 858
 			//related objs restore
859
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
859
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
860 860
 		}
861 861
 	}
862 862
 
@@ -869,52 +869,52 @@  discard block
 block discarded – undo
869 869
 	 * @param  array  $data   The request data from the form
870 870
 	 * @return bool           Success or fail.
871 871
 	 */
872
-	protected function _default_venue_update( $evtobj, $data ) {
873
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
872
+	protected function _default_venue_update($evtobj, $data) {
873
+		require_once(EE_MODELS.'EEM_Venue.model.php');
874 874
 		$venue_model = EE_Registry::instance()->load_model('Venue');
875 875
 		$rows_affected = NULL;
876
-		$venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL;
876
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL;
877 877
 
878 878
 		// very important.  If we don't have a venue name...
879 879
 		// then we'll get out because not necessary to create empty venue
880
-		if ( empty( $data['venue_title'] ) ) {
880
+		if (empty($data['venue_title'])) {
881 881
 			return false;
882 882
 		}
883 883
 
884 884
 		$venue_array = array(
885 885
 				'VNU_wp_user' => $evtobj->get('EVT_wp_user'),
886
-				'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL,
887
-				'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL,
888
-				'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL,
889
-				'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL,
890
-				'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL,
891
-				'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL,
892
-				'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL,
893
-				'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL,
894
-				'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL,
895
-				'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL,
896
-				'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL,
897
-				'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL,
898
-				'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL,
899
-				'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
900
-				'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL,
901
-				'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
886
+				'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL,
887
+				'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL,
888
+				'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL,
889
+				'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL,
890
+				'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL,
891
+				'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL,
892
+				'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL,
893
+				'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL,
894
+				'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL,
895
+				'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL,
896
+				'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL,
897
+				'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL,
898
+				'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL,
899
+				'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
900
+				'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL,
901
+				'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
902 902
 				'status' => 'publish'
903 903
 			);
904 904
 
905 905
 
906 906
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
907
-		if ( !empty( $venue_id ) ) {
908
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
909
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
907
+		if ( ! empty($venue_id)) {
908
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
909
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
910 910
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
911
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
911
+			$evtobj->_add_relation_to($venue_id, 'Venue');
912 912
 			return $rows_affected > 0 ? TRUE : FALSE;
913 913
 		} else {
914 914
 			//we insert the venue
915
-			$venue_id = $venue_model->insert( $venue_array );
916
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
917
-			return !empty( $venue_id ) ? TRUE : FALSE;
915
+			$venue_id = $venue_model->insert($venue_array);
916
+			$evtobj->_add_relation_to($venue_id, 'Venue');
917
+			return ! empty($venue_id) ? TRUE : FALSE;
918 918
 		}
919 919
 		//when we have the ancestor come in it's already been handled by the revision save.
920 920
 	}
@@ -928,55 +928,55 @@  discard block
 block discarded – undo
928 928
 	 * @param  array    $data   The request data from the form
929 929
 	 * @return bool             success or fail
930 930
 	 */
931
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
931
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
932 932
 		$success = true;
933 933
 		$saved_dtt = null;
934 934
 		$saved_tickets = array();
935
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
935
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
936 936
 
937
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
937
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
938 938
 			//trim all values to ensure any excess whitespace is removed.
939
-			$dtt =  array_map( 'trim', $dtt );
940
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
939
+			$dtt = array_map('trim', $dtt);
940
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
941 941
 			$datetime_values = array(
942
-				'DTT_ID' 		=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
942
+				'DTT_ID' 		=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
943 943
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
944 944
 				'DTT_EVT_end' 	=> $dtt['DTT_EVT_end'],
945
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
945
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
946 946
 				'DTT_order' 	=> $row,
947 947
 			);
948 948
 
949 949
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
950 950
 
951
-			if ( !empty( $dtt['DTT_ID'] ) ) {
952
-				$DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] );
953
-				$DTM->set_date_format( $incoming_date_formats[0] );
954
-				$DTM->set_time_format( $incoming_date_formats[1] );
955
-				foreach ( $datetime_values as $field => $value ) {
956
-					$DTM->set( $field, $value );
951
+			if ( ! empty($dtt['DTT_ID'])) {
952
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']);
953
+				$DTM->set_date_format($incoming_date_formats[0]);
954
+				$DTM->set_time_format($incoming_date_formats[1]);
955
+				foreach ($datetime_values as $field => $value) {
956
+					$DTM->set($field, $value);
957 957
 				}
958 958
 
959 959
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
960 960
 				$saved_dtts[$DTM->ID()] = $DTM;
961 961
 			} else {
962
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE );
963
-				$DTM->set_date_format( $incoming_date_formats[0] );
964
-				$DTM->set_time_format( $incoming_date_formats[1] );
965
-				$DTM->set_timezone( $evtobj->get_timezone() );
966
-				foreach ( $datetime_values as $field => $value ) {
967
-					$DTM->set( $field, $value );
962
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE);
963
+				$DTM->set_date_format($incoming_date_formats[0]);
964
+				$DTM->set_time_format($incoming_date_formats[1]);
965
+				$DTM->set_timezone($evtobj->get_timezone());
966
+				foreach ($datetime_values as $field => $value) {
967
+					$DTM->set($field, $value);
968 968
 				}
969 969
 			}
970 970
 			$DTM->save();
971 971
 
972
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
972
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
973 973
 
974 974
 			//load DTT helper
975 975
 			EE_Registry::instance()->load_helper('DTT_Helper');
976 976
 
977 977
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
978
-			if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) {
979
-				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') );
978
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
979
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
980 980
 				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
981 981
 				$DTT->save();
982 982
 			}
@@ -984,45 +984,45 @@  discard block
 block discarded – undo
984 984
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
985 985
 			$saved_dtt = $DTT;
986 986
 
987
-			$success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
987
+			$success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
988 988
 		}
989 989
 
990 990
 		//no dtts get deleted so we don't do any of that logic here.
991 991
 		//update tickets next
992
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
993
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
994
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
992
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
993
+		foreach ($data['edit_tickets'] as $row => $tkt) {
994
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
995 995
 			$update_prices = false;
996
-			$ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
996
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
997 997
 
998 998
 			// trim inputs to ensure any excess whitespace is removed.
999
-			$tkt = array_map( 'trim', $tkt );
999
+			$tkt = array_map('trim', $tkt);
1000 1000
 
1001
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1001
+			if (empty($tkt['TKT_start_date'])) {
1002 1002
 				//let's use now in the set timezone.
1003
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1004
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1003
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1004
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1005 1005
 			}
1006 1006
 
1007
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1007
+			if (empty($tkt['TKT_end_date'])) {
1008 1008
 				//use the start date of the first datetime
1009 1009
 				$dtt = $evtobj->first_datetime();
1010
-				$tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] );
1010
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]);
1011 1011
 			}
1012 1012
 
1013 1013
 			$TKT_values = array(
1014
-				'TKT_ID' 			=> !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
1015
-				'TTM_ID' 			=> !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1016
-				'TKT_name' 			=> !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1017
-				'TKT_description' 	=> !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1014
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
1015
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1016
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1017
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1018 1018
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
1019 1019
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
1020
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'],
1021
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ],
1022
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1023
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1020
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1021
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1022
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1023
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1024 1024
 				'TKT_row' 			=> $row,
1025
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1025
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1026 1026
 				'TKT_price' 		=> $ticket_price
1027 1027
 			);
1028 1028
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 
1031 1031
 
1032 1032
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1033
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1033
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1034 1034
 				$TKT_values['TKT_ID'] = 0;
1035 1035
 				$TKT_values['TKT_is_default'] = 0;
1036 1036
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1041,58 +1041,58 @@  discard block
 block discarded – undo
1041 1041
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1042 1042
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1043 1043
 
1044
-			if ( !empty( $tkt['TKT_ID'] ) ) {
1045
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] );
1046
-				if ( $TKT instanceof EE_Ticket ) {
1047
-					$ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false;
1044
+			if ( ! empty($tkt['TKT_ID'])) {
1045
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']);
1046
+				if ($TKT instanceof EE_Ticket) {
1047
+					$ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false;
1048 1048
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1049
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false;
1050
-					$TKT->set_date_format( $incoming_date_formats[ 0 ] );
1051
-					$TKT->set_time_format( $incoming_date_formats[ 1 ] );
1049
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false;
1050
+					$TKT->set_date_format($incoming_date_formats[0]);
1051
+					$TKT->set_time_format($incoming_date_formats[1]);
1052 1052
 					//set new values
1053
-					foreach ( $TKT_values as $field => $value ) {
1054
-						if ( $field == 'TKT_qty' ) {
1055
-							$TKT->set_qty( $value );
1053
+					foreach ($TKT_values as $field => $value) {
1054
+						if ($field == 'TKT_qty') {
1055
+							$TKT->set_qty($value);
1056 1056
 						} else {
1057
-							$TKT->set( $field, $value );
1057
+							$TKT->set($field, $value);
1058 1058
 						}
1059 1059
 					}
1060 1060
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1061
-					if ( $create_new_TKT ) {
1061
+					if ($create_new_TKT) {
1062 1062
 						//archive the old ticket first
1063
-						$TKT->set( 'TKT_deleted', 1 );
1063
+						$TKT->set('TKT_deleted', 1);
1064 1064
 						$TKT->save();
1065 1065
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1066
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1066
+						$saved_tickets[$TKT->ID()] = $TKT;
1067 1067
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1068 1068
 						$TKT = clone $TKT;
1069
-						$TKT->set( 'TKT_ID', 0 );
1070
-						$TKT->set( 'TKT_deleted', 0 );
1071
-						$TKT->set( 'TKT_price', $ticket_price );
1072
-						$TKT->set( 'TKT_sold', 0 );
1069
+						$TKT->set('TKT_ID', 0);
1070
+						$TKT->set('TKT_deleted', 0);
1071
+						$TKT->set('TKT_price', $ticket_price);
1072
+						$TKT->set('TKT_sold', 0);
1073 1073
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1074 1074
 						$update_prices = true;
1075 1075
 					}
1076 1076
 					//make sure price is set if it hasn't been already
1077
-					$TKT->set( 'TKT_price', $ticket_price );
1077
+					$TKT->set('TKT_price', $ticket_price);
1078 1078
 				}
1079 1079
 
1080 1080
 			} else {
1081 1081
 				//no TKT_id so a new TKT
1082 1082
 				$TKT_values['TKT_price'] = $ticket_price;
1083
-				$TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE );
1084
-				if ( $TKT instanceof EE_Ticket ) {
1083
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE);
1084
+				if ($TKT instanceof EE_Ticket) {
1085 1085
 					//need to reset values to properly account for the date formats
1086
-					$TKT->set_date_format( $incoming_date_formats[0] );
1087
-					$TKT->set_time_format( $incoming_date_formats[1] );
1088
-					$TKT->set_timezone( $evtobj->get_timezone() );
1086
+					$TKT->set_date_format($incoming_date_formats[0]);
1087
+					$TKT->set_time_format($incoming_date_formats[1]);
1088
+					$TKT->set_timezone($evtobj->get_timezone());
1089 1089
 
1090 1090
 					//set new values
1091
-					foreach ( $TKT_values as $field => $value ) {
1092
-						if ( $field == 'TKT_qty' ) {
1093
-							$TKT->set_qty( $value );
1091
+					foreach ($TKT_values as $field => $value) {
1092
+						if ($field == 'TKT_qty') {
1093
+							$TKT->set_qty($value);
1094 1094
 						} else {
1095
-							$TKT->set( $field, $value );
1095
+							$TKT->set($field, $value);
1096 1096
 						}
1097 1097
 					}
1098 1098
 
@@ -1100,32 +1100,32 @@  discard block
 block discarded – undo
1100 1100
 				}
1101 1101
 			}
1102 1102
 			// cap ticket qty by datetime reg limits
1103
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1103
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1104 1104
 			//update ticket.
1105 1105
 			$TKT->save();
1106 1106
 
1107 1107
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1108
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
1109
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
1108
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1109
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1110 1110
 				EE_Registry::instance()->load_helper('DTT_Helper');
1111 1111
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1112 1112
 				$TKT->save();
1113 1113
 			}
1114 1114
 
1115 1115
 			//initially let's add the ticket to the dtt
1116
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1116
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1117 1117
 
1118 1118
 			$saved_tickets[$TKT->ID()] = $TKT;
1119 1119
 
1120 1120
 			//add prices to ticket
1121
-			$this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices );
1121
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1122 1122
 		}
1123 1123
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1124
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1125
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1124
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1125
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1126 1126
 
1127
-		foreach ( $tickets_removed as $id ) {
1128
-			$id = absint( $id );
1127
+		foreach ($tickets_removed as $id) {
1128
+			$id = absint($id);
1129 1129
 
1130 1130
 			//get the ticket for this id
1131 1131
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1134 1134
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
1135 1135
 
1136
-			foreach( $dtts as $dtt ) {
1136
+			foreach ($dtts as $dtt) {
1137 1137
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1138 1138
 			}
1139 1139
 
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1145 1145
 			$tkt_to_remove->delete_permanently();
1146 1146
 		}
1147
-		return array( $saved_dtt, $saved_tickets );
1147
+		return array($saved_dtt, $saved_tickets);
1148 1148
 	}
1149 1149
 
1150 1150
 
@@ -1159,31 +1159,31 @@  discard block
 block discarded – undo
1159 1159
 	 * @param bool 		$new_prices Whether attach existing incoming prices or create new ones.
1160 1160
 	 * @return  void
1161 1161
 	 */
1162
-	private function  _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) {
1163
-		foreach ( $prices as $row => $prc ) {
1162
+	private function  _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) {
1163
+		foreach ($prices as $row => $prc) {
1164 1164
 			$PRC_values = array(
1165
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
1166
-				'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL,
1167
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1168
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1169
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1165
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
1166
+				'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL,
1167
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1168
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1169
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1170 1170
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1171 1171
 				'PRC_order' => $row
1172 1172
 			);
1173 1173
 
1174
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1174
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1175 1175
 				$PRC_values['PRC_ID'] = 0;
1176
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
1176
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
1177 1177
 			} else {
1178
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1178
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1179 1179
 				//update this price with new values
1180
-				foreach ( $PRC_values as $field => $newprc ) {
1181
-					$PRC->set( $field, $newprc );
1180
+				foreach ($PRC_values as $field => $newprc) {
1181
+					$PRC->set($field, $newprc);
1182 1182
 				}
1183 1183
 				$PRC->save();
1184 1184
 			}
1185 1185
 
1186
-			$ticket->_add_relation_to( $PRC, 'Price' );
1186
+			$ticket->_add_relation_to($PRC, 'Price');
1187 1187
 		}
1188 1188
 	}
1189 1189
 
@@ -1206,33 +1206,33 @@  discard block
 block discarded – undo
1206 1206
 
1207 1207
 		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1208 1208
 
1209
-		$postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL;
1209
+		$postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL;
1210 1210
 
1211 1211
 
1212 1212
 		//if no postid then get out cause we need it for stuff in here
1213
-		if ( empty( $postid ) ) return;
1213
+		if (empty($postid)) return;
1214 1214
 
1215 1215
 
1216 1216
 		//handle datetime saves
1217 1217
 		$items = array();
1218 1218
 
1219
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $postid );
1220
-		$event = $this->_event_model()->get_one( array($get_one_where) );
1219
+		$get_one_where = array($this->_event_model()->primary_key_name() => $postid);
1220
+		$event = $this->_event_model()->get_one(array($get_one_where));
1221 1221
 
1222 1222
 		//now let's get the attached datetimes from the most recent autosave
1223 1223
 		$dtts = $event->get_many_related('Datetime');
1224 1224
 
1225 1225
 		$dtt_ids = array();
1226
-		foreach( $dtts as $dtt ) {
1226
+		foreach ($dtts as $dtt) {
1227 1227
 			$dtt_ids[] = $dtt->ID();
1228 1228
 			$order = $dtt->order();
1229 1229
 			$this->_template_args['data']['items']['ID-'.$order] = $dtt->ID();
1230 1230
 		}
1231
-		$this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids );
1231
+		$this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids);
1232 1232
 
1233 1233
 		//handle DECAF venues
1234 1234
 		//we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event.
1235
-		if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) {
1235
+		if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) {
1236 1236
 			$venue = $event->get_first_related('Venue');
1237 1237
 			$this->_template_args['data']['items']['venue-id'] = $venue->ID();
1238 1238
 		}
@@ -1243,23 +1243,23 @@  discard block
 block discarded – undo
1243 1243
 
1244 1244
 		$ticket_ids = array();
1245 1245
 		$price_ids = array();
1246
-		foreach ( $tickets as $ticket ) {
1246
+		foreach ($tickets as $ticket) {
1247 1247
 			$ticket_ids[] = $price->ID();
1248 1248
 			$ticket_order = $price->get('TKT_order');
1249
-			$this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID();
1250
-			$this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID();
1249
+			$this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID();
1250
+			$this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID();
1251 1251
 
1252 1252
 			//now we have to make sure the prices are updated appropriately
1253 1253
 			$prices = $ticket->get_many_related('Prices');
1254 1254
 
1255
-			foreach ( $prices as $price ) {
1255
+			foreach ($prices as $price) {
1256 1256
 				$price_ids[] = $price->ID();
1257 1257
 				$price_order = $price->get('PRC_order');
1258
-				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID();
1259
-				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID();
1260
-				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default');
1258
+				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID();
1259
+				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID();
1260
+				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default');
1261 1261
 			}
1262
-			$this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids);
1262
+			$this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids);
1263 1263
 		}
1264 1264
 		$this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids);
1265 1265
 	}
@@ -1277,12 +1277,12 @@  discard block
 block discarded – undo
1277 1277
 	private function _generate_publish_box_extra_content() {
1278 1278
 
1279 1279
 		//load formatter helper
1280
-  		EE_Registry::instance()->load_helper( 'Formatter' );
1280
+  		EE_Registry::instance()->load_helper('Formatter');
1281 1281
 
1282 1282
   		//args for getting related registrations
1283
-  		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1284
-  		$not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) );
1285
-  		$pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) );
1283
+  		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1284
+  		$not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved));
1285
+  		$pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment));
1286 1286
 
1287 1287
 
1288 1288
 		// publish box
@@ -1311,9 +1311,9 @@  discard block
 block discarded – undo
1311 1311
 				),
1312 1312
 				REG_ADMIN_URL
1313 1313
 			),
1314
-			'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ),
1315
-			'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ),
1316
-			'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ),
1314
+			'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args),
1315
+			'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args),
1316
+			'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args),
1317 1317
 			'misc_pub_section_class' => apply_filters(
1318 1318
 				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1319 1319
 				'misc-pub-section'
@@ -1332,9 +1332,9 @@  discard block
 block discarded – undo
1332 1332
 			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1333 1333
 			$this->_cpt_model_obj
1334 1334
 		);
1335
-		$publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean();
1335
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1336 1336
 		// load template
1337
-		EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args );
1337
+		EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args);
1338 1338
 	}
1339 1339
 
1340 1340
 
@@ -1366,16 +1366,16 @@  discard block
 block discarded – undo
1366 1366
 		$this->verify_cpt_object();
1367 1367
 		add_meta_box(
1368 1368
 			'espresso_event_editor_tickets',
1369
-			__( 'Event Datetime & Ticket', 'event_espresso' ),
1370
-			array( $this, 'ticket_metabox' ),
1369
+			__('Event Datetime & Ticket', 'event_espresso'),
1370
+			array($this, 'ticket_metabox'),
1371 1371
 			$this->page_slug,
1372 1372
 			'normal',
1373 1373
 			'high'
1374 1374
 		);
1375 1375
 		add_meta_box(
1376 1376
 			'espresso_event_editor_event_options',
1377
-			__( 'Event Registration Options', 'event_espresso' ),
1378
-			array( $this, 'registration_options_meta_box' ),
1377
+			__('Event Registration Options', 'event_espresso'),
1378
+			array($this, 'registration_options_meta_box'),
1379 1379
 			$this->page_slug,
1380 1380
 			'side',
1381 1381
 			'default'
@@ -1405,38 +1405,38 @@  discard block
 block discarded – undo
1405 1405
 			'disabled' => ''
1406 1406
 			);
1407 1407
 
1408
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL;
1408
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL;
1409 1409
 
1410
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1410
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1411 1411
 
1412 1412
 		/**
1413 1413
 		 * 1. Start with retrieving Datetimes
1414 1414
 		 * 2. Fore each datetime get related tickets
1415 1415
 		 * 3. For each ticket get related prices
1416 1416
 		 */
1417
-		$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id );
1418
-		EE_Registry::instance()->load_helper('DTT_Helper' );
1417
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1418
+		EE_Registry::instance()->load_helper('DTT_Helper');
1419 1419
 		/** @type EE_Datetime $first_datetime */
1420
-		$first_datetime = array_slice( $times, 0, 1 );
1420
+		$first_datetime = array_slice($times, 0, 1);
1421 1421
 		//do we get related tickets?
1422
-		if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) {
1423
-			foreach ( $times as $time ) {
1424
-				if ( $time instanceof EE_Datetime ) {
1422
+		if ($first_datetime[0]->get('DTT_ID') !== 0) {
1423
+			foreach ($times as $time) {
1424
+				if ($time instanceof EE_Datetime) {
1425 1425
 					$existing_datetime_ids[] = $time->get('DTT_ID');
1426 1426
 					$template_args['time'] = $time;
1427 1427
 					$related_tickets = $time->tickets(
1428 1428
 						array(
1429
-							array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1429
+							array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1430 1430
 							'default_where_conditions' => 'none'
1431 1431
 						)
1432 1432
 					);
1433 1433
 
1434
-					if ( !empty($related_tickets) ) {
1434
+					if ( ! empty($related_tickets)) {
1435 1435
 						$template_args['total_ticket_rows'] = count($related_tickets);
1436 1436
 						$row = 0;
1437
-						foreach ( $related_tickets as $ticket ) {
1437
+						foreach ($related_tickets as $ticket) {
1438 1438
 							$existing_ticket_ids[] = $ticket->get('TKT_ID');
1439
-							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row );
1439
+							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row);
1440 1440
 
1441 1441
 							$row++;
1442 1442
 						}
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
 						$template_args['total_ticket_rows'] = 1;
1445 1445
 						/** @type EE_Ticket $ticket */
1446 1446
 						$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1447
-						$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1447
+						$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1448 1448
 					}
1449 1449
 				}
1450 1450
 			}
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 			$template_args['time'] = $times[0];
1453 1453
 			/** @type EE_Ticket $ticket */
1454 1454
 			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1455
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1455
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1456 1456
 			// NOTE: we're just sending the first default row
1457 1457
 			// (decaf can't manage default tickets so this should be sufficient);
1458 1458
 		}
@@ -1461,8 +1461,8 @@  discard block
 block discarded – undo
1461 1461
 		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1462 1462
 		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1463 1463
 		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1464
-		$template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE );
1465
-		$template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' );
1464
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE);
1465
+		$template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php');
1466 1466
 		EEH_Template::display_template($template, $template_args);
1467 1467
 	}
1468 1468
 
@@ -1477,21 +1477,21 @@  discard block
 block discarded – undo
1477 1477
 	 * @param int        $row
1478 1478
 	 * @return string generated html for the ticket row.
1479 1479
 	 */
1480
-	private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) {
1480
+	private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) {
1481 1481
 		$template_args = array(
1482
-			'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),
1483
-			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '',
1482
+			'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(),
1483
+			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '',
1484 1484
 			'ticketrow' => $skeleton ? 'TICKETNUM' : $row,
1485 1485
 			'TKT_ID' => $ticket->get('TKT_ID'),
1486 1486
 			'TKT_name' => $ticket->get('TKT_name'),
1487 1487
 			'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1488 1488
 			'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1489 1489
 			'TKT_is_default' => $ticket->get('TKT_is_default'),
1490
-			'TKT_qty' => $ticket->get_pretty('TKT_qty','input'),
1490
+			'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'),
1491 1491
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1492 1492
 			'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'),
1493
-			'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1494
-			'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled'
1493
+			'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1494
+			'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled'
1495 1495
 			);
1496 1496
 
1497 1497
 		$price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object();
@@ -1507,23 +1507,23 @@  discard block
 block discarded – undo
1507 1507
 
1508 1508
 		//make sure we have default start and end dates if skeleton
1509 1509
 		//handle rows that should NOT be empty
1510
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1510
+		if (empty($template_args['TKT_start_date'])) {
1511 1511
 			//if empty then the start date will be now.
1512 1512
 			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1513 1513
 		}
1514 1514
 
1515
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1515
+		if (empty($template_args['TKT_end_date'])) {
1516 1516
 			//get the earliest datetime (if present);
1517
-			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1517
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1518 1518
 
1519
-			if ( !empty( $earliest_dtt ) )
1519
+			if ( ! empty($earliest_dtt))
1520 1520
 				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1521 1521
 			else
1522
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1522
+				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")));
1523 1523
 		}
1524 1524
 
1525
-		$template_args = array_merge( $template_args, $price_args );
1526
-		$template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket);
1525
+		$template_args = array_merge($template_args, $price_args);
1526
+		$template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket);
1527 1527
 		return EEH_Template::display_template($template, $template_args, TRUE);
1528 1528
 	}
1529 1529
 
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
1553 1553
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
1554 1554
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
1555
-		$template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values );
1556
-		$templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php';
1555
+		$template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values);
1556
+		$templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php';
1557 1557
 		EEH_Template::display_template($templatepath, $template_args);
1558 1558
 	}
1559 1559
 
@@ -1581,21 +1581,21 @@  discard block
 block discarded – undo
1581 1581
 		$EEME = $this->_event_model();
1582 1582
 
1583 1583
 		$offset = ($current_page - 1) * $per_page;
1584
-		$limit = $count ? NULL : $offset . ',' . $per_page;
1584
+		$limit = $count ? NULL : $offset.','.$per_page;
1585 1585
 		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1586 1586
 		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1587 1587
 
1588 1588
 		if (isset($this->_req_data['month_range'])) {
1589 1589
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1590
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1591
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1590
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1591
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1592 1592
 		}
1593 1593
 
1594 1594
 		$where = array();
1595 1595
 
1596
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
1596
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
1597 1597
 		//determine what post_status our condition will have for the query.
1598
-		switch ( $status ) {
1598
+		switch ($status) {
1599 1599
 			case 'month' :
1600 1600
 			case 'today' :
1601 1601
 			case NULL :
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 				break;
1604 1604
 
1605 1605
 			case 'draft' :
1606
-				$where['status'] = array( 'IN', array('draft', 'auto-draft') );
1606
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1607 1607
 				break;
1608 1608
 
1609 1609
 			default :
@@ -1611,43 +1611,43 @@  discard block
 block discarded – undo
1611 1611
 		}
1612 1612
 
1613 1613
 		//categories?
1614
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1614
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1615 1615
 
1616
-		if ( !empty ( $category ) ) {
1616
+		if ( ! empty ($category)) {
1617 1617
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1618 1618
 			$where['Term_Taxonomy.term_id'] = $category;
1619 1619
 		}
1620 1620
 
1621 1621
 		//date where conditions
1622
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1622
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1623 1623
 		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1624
-			$DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) );
1625
-			$start = $DateTime->format( implode( ' ', $start_formats  ) );
1626
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) );
1627
-			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) );
1624
+			$DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone()));
1625
+			$start = $DateTime->format(implode(' ', $start_formats));
1626
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1627
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1628 1628
 		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1629
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1630
-			$start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) );
1631
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1632
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1633
-		} else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) {
1634
-			$now = date( 'Y-m-01' );
1635
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1636
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1637
-			$end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1638
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1629
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1630
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1631
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1632
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1633
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1634
+			$now = date('Y-m-01');
1635
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1636
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1637
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1638
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1639 1639
 		}
1640 1640
 
1641 1641
 
1642
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1643
-			$where['EVT_wp_user'] =  get_current_user_id();
1642
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1643
+			$where['EVT_wp_user'] = get_current_user_id();
1644 1644
 		} else {
1645
-			if ( ! isset( $where['status'] ) ) {
1646
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1645
+			if ( ! isset($where['status'])) {
1646
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1647 1647
 					$where['OR'] = array(
1648
-						'status*restrict_private' => array( '!=', 'private' ),
1648
+						'status*restrict_private' => array('!=', 'private'),
1649 1649
 						'AND' => array(
1650
-							'status*inclusive' => array( '=', 'private' ),
1650
+							'status*inclusive' => array('=', 'private'),
1651 1651
 							'EVT_wp_user' => get_current_user_id()
1652 1652
 						)
1653 1653
 					);
@@ -1655,16 +1655,16 @@  discard block
 block discarded – undo
1655 1655
 			}
1656 1656
 		}
1657 1657
 
1658
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1659
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1658
+		if (isset($this->_req_data['EVT_wp_user'])) {
1659
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1660 1660
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1661 1661
 			}
1662 1662
 		}
1663 1663
 
1664 1664
 
1665 1665
 		//search query handling
1666
-		if ( isset( $this->_req_data['s'] ) ) {
1667
-			$search_string = '%' . $this->_req_data['s'] . '%';
1666
+		if (isset($this->_req_data['s'])) {
1667
+			$search_string = '%'.$this->_req_data['s'].'%';
1668 1668
 			$where['OR'] = array(
1669 1669
 				'EVT_name' => array('LIKE', $search_string),
1670 1670
 				'EVT_desc' => array('LIKE', $search_string),
@@ -1673,32 +1673,32 @@  discard block
 block discarded – undo
1673 1673
 		}
1674 1674
 
1675 1675
 
1676
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1677
-		$query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data );
1676
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1677
+		$query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data);
1678 1678
 
1679 1679
 
1680 1680
 		//let's first check if we have special requests coming in.
1681
-		if ( isset( $this->_req_data['active_status'] ) ) {
1682
-			switch ( $this->_req_data['active_status'] ) {
1681
+		if (isset($this->_req_data['active_status'])) {
1682
+			switch ($this->_req_data['active_status']) {
1683 1683
 				case 'upcoming' :
1684
-					return $EEME->get_upcoming_events( $query_params, $count );
1684
+					return $EEME->get_upcoming_events($query_params, $count);
1685 1685
 					break;
1686 1686
 
1687 1687
 				case 'expired' :
1688
-					return $EEME->get_expired_events( $query_params, $count );
1688
+					return $EEME->get_expired_events($query_params, $count);
1689 1689
 					break;
1690 1690
 
1691 1691
 				case 'active' :
1692
-					return $EEME->get_active_events( $query_params, $count );
1692
+					return $EEME->get_active_events($query_params, $count);
1693 1693
 					break;
1694 1694
 
1695 1695
 				case 'inactive' :
1696
-					return $EEME->get_inactive_events( $query_params, $count );
1696
+					return $EEME->get_inactive_events($query_params, $count);
1697 1697
 					break;
1698 1698
 			}
1699 1699
 		}
1700 1700
 
1701
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1701
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1702 1702
 
1703 1703
 		return $events;
1704 1704
 	}
@@ -1707,23 +1707,23 @@  discard block
 block discarded – undo
1707 1707
 
1708 1708
 
1709 1709
 	//handling for WordPress CPT actions (trash, restore, delete)
1710
-	public function trash_cpt_item( $post_id ) {
1710
+	public function trash_cpt_item($post_id) {
1711 1711
 		$this->_req_data['EVT_ID'] = $post_id;
1712
-		$this->_trash_or_restore_event( 'trash', FALSE );
1712
+		$this->_trash_or_restore_event('trash', FALSE);
1713 1713
 	}
1714 1714
 
1715 1715
 
1716 1716
 
1717 1717
 
1718
-	public function restore_cpt_item( $post_id ) {
1718
+	public function restore_cpt_item($post_id) {
1719 1719
 		$this->_req_data['EVT_ID'] = $post_id;
1720
-		$this->_trash_or_restore_event( 'draft', FALSE );
1720
+		$this->_trash_or_restore_event('draft', FALSE);
1721 1721
 	}
1722 1722
 
1723 1723
 
1724
-	public function delete_cpt_item( $post_id ) {
1724
+	public function delete_cpt_item($post_id) {
1725 1725
 		$this->_req_data['EVT_ID'] = $post_id;
1726
-		$this->_delete_event( FALSE );
1726
+		$this->_delete_event(FALSE);
1727 1727
 	}
1728 1728
 
1729 1729
 
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 	 * @param  string $event_status
1736 1736
 	 * @return void
1737 1737
 	 */
1738
-	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1738
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) {
1739 1739
 		//determine the event id and set to array.
1740 1740
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1741 1741
 		// loop thru events
@@ -1743,7 +1743,7 @@  discard block
 block discarded – undo
1743 1743
 			// clean status
1744 1744
 			$event_status = sanitize_key($event_status);
1745 1745
 			// grab status
1746
-			if (!empty($event_status)) {
1746
+			if ( ! empty($event_status)) {
1747 1747
 				$success = $this->_change_event_status($EVT_ID, $event_status);
1748 1748
 			} else {
1749 1749
 				$success = FALSE;
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 		}
1758 1758
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1759 1759
 
1760
-		if ( $redirect_after )
1760
+		if ($redirect_after)
1761 1761
 			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1762 1762
 	}
1763 1763
 
@@ -1772,7 +1772,7 @@  discard block
 block discarded – undo
1772 1772
 		// clean status
1773 1773
 		$event_status = sanitize_key($event_status);
1774 1774
 		// grab status
1775
-		if (!empty($event_status)) {
1775
+		if ( ! empty($event_status)) {
1776 1776
 			$success = TRUE;
1777 1777
 			//determine the event id and set to array.
1778 1778
 			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -1807,15 +1807,15 @@  discard block
 block discarded – undo
1807 1807
 	 * @param  string $event_status
1808 1808
 	 * @return bool
1809 1809
 	 */
1810
-	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1810
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1811 1811
 		// grab event id
1812
-		if (!$EVT_ID) {
1812
+		if ( ! $EVT_ID) {
1813 1813
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1814 1814
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1815 1815
 			return FALSE;
1816 1816
 		}
1817 1817
 
1818
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1818
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1819 1819
 
1820 1820
 		// clean status
1821 1821
 		$event_status = sanitize_key($event_status);
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 				$hook = FALSE;
1842 1842
 		}
1843 1843
 		//use class to change status
1844
-		$this->_cpt_model_obj->set_status( $event_status );
1844
+		$this->_cpt_model_obj->set_status($event_status);
1845 1845
 		$success = $this->_cpt_model_obj->save();
1846 1846
 
1847 1847
 		if ($success === FALSE) {
@@ -1863,15 +1863,15 @@  discard block
 block discarded – undo
1863 1863
 	 * @access protected
1864 1864
 	 * @param bool $redirect_after
1865 1865
 	 */
1866
-	protected function _delete_event( $redirect_after = TRUE ) {
1866
+	protected function _delete_event($redirect_after = TRUE) {
1867 1867
 		//determine the event id and set to array.
1868 1868
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL;
1869
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1869
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1870 1870
 
1871 1871
 
1872 1872
 		// loop thru events
1873 1873
 		if ($EVT_ID) {
1874
-			$success = $this->_permanently_delete_event( $EVT_ID );
1874
+			$success = $this->_permanently_delete_event($EVT_ID);
1875 1875
 			// get list of events with no prices
1876 1876
 			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1877 1877
 			// remove this event from the list of events with no prices
@@ -1885,7 +1885,7 @@  discard block
 block discarded – undo
1885 1885
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1886 1886
 		}
1887 1887
 
1888
-		if ( $redirect_after )
1888
+		if ($redirect_after)
1889 1889
 			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1890 1890
 	}
1891 1891
 
@@ -1903,12 +1903,12 @@  discard block
 block discarded – undo
1903 1903
 		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1904 1904
 		// loop thru events
1905 1905
 		foreach ($EVT_IDs as $EVT_ID) {
1906
-			$EVT_ID = absint( $EVT_ID );
1907
-			if ( $EVT_ID ) {
1908
-				$results = $this->_permanently_delete_event( $EVT_ID );
1906
+			$EVT_ID = absint($EVT_ID);
1907
+			if ($EVT_ID) {
1908
+				$results = $this->_permanently_delete_event($EVT_ID);
1909 1909
 				$success = $results !== FALSE ? $success : FALSE;
1910 1910
 				// remove this event from the list of events with no prices
1911
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1911
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1912 1912
 			} else {
1913 1913
 				$success = FALSE;
1914 1914
 				$msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso');
@@ -1928,21 +1928,21 @@  discard block
 block discarded – undo
1928 1928
 	 * @param  int $EVT_ID
1929 1929
 	 * @return bool
1930 1930
 	 */
1931
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
1931
+	private function _permanently_delete_event($EVT_ID = 0) {
1932 1932
 		// grab event id
1933
-		if ( ! $EVT_ID ) {
1933
+		if ( ! $EVT_ID) {
1934 1934
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1935 1935
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1936 1936
 			return FALSE;
1937 1937
 		}
1938
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1938
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1939 1939
 
1940 1940
 		//need to delete related tickets and prices first.
1941 1941
 		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
1942
-		foreach ( $datetimes as $datetime ) {
1942
+		foreach ($datetimes as $datetime) {
1943 1943
 			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
1944 1944
 			$tickets = $datetime->get_many_related('Ticket');
1945
-			foreach ( $tickets as $ticket ) {
1945
+			foreach ($tickets as $ticket) {
1946 1946
 				$ticket->_remove_relation_to($datetime, 'Datetime');
1947 1947
 				$ticket->delete_related_permanently('Price');
1948 1948
 				$ticket->delete_permanently();
@@ -1952,14 +1952,14 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		//what about related venues or terms?
1954 1954
 		$venues = $this->_cpt_model_obj->get_many_related('Venue');
1955
-		foreach ( $venues as $venue ) {
1955
+		foreach ($venues as $venue) {
1956 1956
 			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
1957 1957
 		}
1958 1958
 
1959 1959
 		//any attached question groups?
1960 1960
 		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
1961
-		if ( !empty( $question_groups ) ) {
1962
-			foreach ( $question_groups as $question_group ) {
1961
+		if ( ! empty($question_groups)) {
1962
+			foreach ($question_groups as $question_group) {
1963 1963
 				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
1964 1964
 			}
1965 1965
 		}
@@ -1968,12 +1968,12 @@  discard block
 block discarded – undo
1968 1968
 
1969 1969
 
1970 1970
 		//Message Template Groups
1971
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
1971
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
1972 1972
 
1973 1973
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
1974 1974
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
1975 1975
 
1976
-		foreach ( $term_taxonomies as $term_taxonomy ) {
1976
+		foreach ($term_taxonomies as $term_taxonomy) {
1977 1977
 			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
1978 1978
 		}
1979 1979
 
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1988 1988
 			return FALSE;
1989 1989
 		}
1990
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted' );
1990
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted');
1991 1991
 		return TRUE;
1992 1992
 	}
1993 1993
 
@@ -2004,7 +2004,7 @@  discard block
 block discarded – undo
2004 2004
 	 */
2005 2005
 	public function total_events() {
2006 2006
 
2007
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2007
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2008 2008
 		return $count;
2009 2009
 	}
2010 2010
 
@@ -2019,10 +2019,10 @@  discard block
 block discarded – undo
2019 2019
 	 */
2020 2020
 	public function total_events_draft() {
2021 2021
 		$where = array(
2022
-			'status' => array( 'IN', array('draft', 'auto-draft' ) )
2022
+			'status' => array('IN', array('draft', 'auto-draft'))
2023 2023
 			);
2024 2024
 
2025
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2025
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2026 2026
 		return $count;
2027 2027
 	}
2028 2028
 
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 			'status' => 'trash'
2042 2042
 			);
2043 2043
 
2044
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2044
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2045 2045
 		return $count;
2046 2046
 	}
2047 2047
 
@@ -2069,11 +2069,11 @@  discard block
 block discarded – undo
2069 2069
 			// translated
2070 2070
 			TRUE
2071 2071
 		);
2072
-		$this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment;
2072
+		$this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment;
2073 2073
 
2074 2074
 		$this->_set_add_edit_form_tags('update_default_event_settings');
2075 2075
 		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
2076
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE);
2076
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE);
2077 2077
 		$this->display_admin_page_with_sidebar();
2078 2078
 	}
2079 2079
 
@@ -2099,9 +2099,9 @@  discard block
 block discarded – undo
2099 2099
 
2100 2100
 	protected function _template_settings() {
2101 2101
 		$this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso');
2102
-		$this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />';
2103
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>';
2104
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2102
+		$this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />';
2103
+		$this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>';
2104
+		$this->display_admin_caf_preview_page('template_settings_tab');
2105 2105
 	}
2106 2106
 
2107 2107
 
@@ -2114,22 +2114,22 @@  discard block
 block discarded – undo
2114 2114
 	 * @return void
2115 2115
 	 */
2116 2116
 	private function _set_category_object() {
2117
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2117
+		if (isset($this->_category->id) && ! empty($this->_category->id))
2118 2118
 			return; //already have the category object so get out.
2119 2119
 
2120 2120
 		//set default category object
2121 2121
 		$this->_set_empty_category_object();
2122 2122
 
2123 2123
 		//only set if we've got an id
2124
-		if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) {
2124
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2125 2125
 			return;
2126 2126
 		}
2127 2127
 
2128 2128
 		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2129 2129
 
2130
-		$term = get_term( $category_id, 'espresso_event_categories' );
2130
+		$term = get_term($category_id, 'espresso_event_categories');
2131 2131
 
2132
-		if ( !empty( $term ) ) {
2132
+		if ( ! empty($term)) {
2133 2133
 			$this->_category->category_name = $term->name;
2134 2134
 			$this->_category->category_identifier = $term->slug;
2135 2135
 			$this->_category->category_desc = $term->description;
@@ -2143,13 +2143,13 @@  discard block
 block discarded – undo
2143 2143
 
2144 2144
 	private function _set_empty_category_object() {
2145 2145
 		$this->_category = new stdClass();
2146
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
2146
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2147 2147
 		$this->_category->id = $this->_category->parent = 0;
2148 2148
 	}
2149 2149
 
2150 2150
 
2151 2151
 	protected function _category_list_table() {
2152
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2152
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2153 2153
 		$this->_search_btn_label = __('Categories', 'event_espresso');
2154 2154
 		$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2');
2155 2155
 		$this->display_admin_list_table_page_with_sidebar();
@@ -2159,22 +2159,22 @@  discard block
 block discarded – undo
2159 2159
 	protected function _category_details($view) {
2160 2160
 
2161 2161
 		//load formatter helper
2162
-		EE_Registry::instance()->load_helper( 'Formatter' );
2162
+		EE_Registry::instance()->load_helper('Formatter');
2163 2163
 		//load field generator helper
2164
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
2164
+		EE_Registry::instance()->load_helper('Form_Fields');
2165 2165
 
2166 2166
 		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2167 2167
 		$this->_set_add_edit_form_tags($route);
2168 2168
 
2169 2169
 		$this->_set_category_object();
2170
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
2170
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2171 2171
 
2172 2172
 		$delete_action = 'delete_category';
2173 2173
 
2174 2174
 		//custom redirect
2175
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url );
2175
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
2176 2176
 
2177
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2177
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2178 2178
 
2179 2179
 		//take care of contents
2180 2180
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -2188,25 +2188,25 @@  discard block
 block discarded – undo
2188 2188
 			'type' => 'wp_editor',
2189 2189
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
2190 2190
 			'class' => 'my_editor_custom',
2191
-			'wpeditor_args' => array('media_buttons' => FALSE )
2191
+			'wpeditor_args' => array('media_buttons' => FALSE)
2192 2192
 		);
2193
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2193
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2194 2194
 
2195
-		$all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
2195
+		$all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
2196 2196
 
2197 2197
 		//setup category select for term parents.
2198 2198
 		$category_select_values[] = array(
2199 2199
 			'text' => __('No Parent', 'event_espresso'),
2200 2200
 			'id' => 0
2201 2201
 			);
2202
-		foreach ( $all_terms as $term ) {
2202
+		foreach ($all_terms as $term) {
2203 2203
 			$category_select_values[] = array(
2204 2204
 				'text' => $term->name,
2205 2205
 				'id' => $term->term_id
2206 2206
 				);
2207 2207
 		}
2208 2208
 
2209
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
2209
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
2210 2210
 
2211 2211
 		$template_args = array(
2212 2212
 			'category' => $this->_category,
@@ -2216,15 +2216,15 @@  discard block
 block discarded – undo
2216 2216
 			'disable' => '',
2217 2217
 			'disabled_message' => FALSE
2218 2218
 			);
2219
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2220
-		return EEH_Template::display_template($template, $template_args, TRUE );
2219
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2220
+		return EEH_Template::display_template($template, $template_args, TRUE);
2221 2221
 	}
2222 2222
 
2223 2223
 
2224 2224
 	protected function _delete_categories() {
2225
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2225
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2226 2226
 
2227
-		foreach ( $cat_ids as $cat_id ) {
2227
+		foreach ($cat_ids as $cat_id) {
2228 2228
 			$this->_delete_category($cat_id);
2229 2229
 		}
2230 2230
 
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
 		$query_args = array(
2233 2233
 			'action' => 'category_list'
2234 2234
 			);
2235
-		$this->_redirect_after_action(0,'','',$query_args);
2235
+		$this->_redirect_after_action(0, '', '', $query_args);
2236 2236
 
2237 2237
 	}
2238 2238
 
@@ -2242,61 +2242,61 @@  discard block
 block discarded – undo
2242 2242
 
2243 2243
 	protected function _delete_category($cat_id) {
2244 2244
 		global $wpdb;
2245
-		$cat_id = absint( $cat_id );
2246
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2245
+		$cat_id = absint($cat_id);
2246
+		wp_delete_term($cat_id, 'espresso_event_categories');
2247 2247
 	}
2248 2248
 
2249 2249
 
2250 2250
 
2251 2251
 	protected function _insert_or_update_category($new_category) {
2252 2252
 
2253
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
2253
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
2254 2254
 		$success = 0; //we already have a success message so lets not send another.
2255 2255
 
2256
-		if ( $cat_id ) {
2256
+		if ($cat_id) {
2257 2257
 			$query_args = array(
2258 2258
 				'action'     => 'edit_category',
2259 2259
 				'EVT_CAT_ID' => $cat_id
2260 2260
 			);
2261 2261
 		} else {
2262
-			$query_args = array( 'action' => 'add_category' );
2262
+			$query_args = array('action' => 'add_category');
2263 2263
 		}
2264
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
2264
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
2265 2265
 
2266 2266
 	}
2267 2267
 
2268 2268
 
2269 2269
 
2270
-	private function _insert_category( $update = FALSE ) {
2270
+	private function _insert_category($update = FALSE) {
2271 2271
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2272
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2273
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2274
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2272
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2273
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2274
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2275 2275
 
2276
-		if ( empty( $category_name ) ) {
2277
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
2278
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2276
+		if (empty($category_name)) {
2277
+			$msg = __('You must add a name for the category.', 'event_espresso');
2278
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2279 2279
 			return false;
2280 2280
 		}
2281 2281
 
2282
-		$term_args=array(
2282
+		$term_args = array(
2283 2283
 			'name'=>$category_name,
2284 2284
 			'description'=>$category_desc,
2285 2285
 			'parent'=>$category_parent
2286 2286
 		);
2287 2287
 		//was the category_identifier input disabled?
2288
-		if(isset($this->_req_data['category_identifier'])){
2288
+		if (isset($this->_req_data['category_identifier'])) {
2289 2289
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2290 2290
 		}
2291
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2291
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2292 2292
 
2293
-		if ( !is_array( $insert_ids ) ) {
2294
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
2295
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2293
+		if ( ! is_array($insert_ids)) {
2294
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
2295
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2296 2296
 		} else {
2297 2297
 			$cat_id = $insert_ids['term_id'];
2298
-			$msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name );
2299
-			EE_Error::add_success( $msg );
2298
+			$msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name);
2299
+			EE_Error::add_success($msg);
2300 2300
 		}
2301 2301
 
2302 2302
 		return $cat_id;
@@ -2305,32 +2305,32 @@  discard block
 block discarded – undo
2305 2305
 
2306 2306
 
2307 2307
 
2308
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
2308
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
2309 2309
 		global $wpdb;
2310 2310
 
2311 2311
 		//testing term stuff
2312
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2313
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2314
-		$limit = ($current_page-1)*$per_page;
2312
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2313
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2314
+		$limit = ($current_page - 1) * $per_page;
2315 2315
 
2316
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2316
+		$where = array('taxonomy' => 'espresso_event_categories');
2317 2317
 
2318
-		if ( isset( $this->_req_data['s'] ) ) {
2319
-			$sstr = '%' . $this->_req_data['s'] . '%';
2318
+		if (isset($this->_req_data['s'])) {
2319
+			$sstr = '%'.$this->_req_data['s'].'%';
2320 2320
 			$where['OR'] = array(
2321
-				'Term.name' => array( 'LIKE', $sstr),
2322
-				'description' => array( 'LIKE', $sstr )
2321
+				'Term.name' => array('LIKE', $sstr),
2322
+				'description' => array('LIKE', $sstr)
2323 2323
 				);
2324 2324
 		}
2325 2325
 
2326 2326
 		$query_params = array(
2327
-			$where ,
2328
-			'order_by' => array( $orderby => $order ),
2329
-			'limit' => $limit . ',' . $per_page,
2327
+			$where,
2328
+			'order_by' => array($orderby => $order),
2329
+			'limit' => $limit.','.$per_page,
2330 2330
 			'force_join' => array('Term')
2331 2331
 			);
2332 2332
 
2333
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
2333
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
2334 2334
 
2335 2335
 		return $categories;
2336 2336
 	}
Please login to merge, or discard this patch.