Completed
Branch ENH-9127-optimize-get-active-s... (f84f1d)
by
unknown
300:00 queued 282:07
created
core/db_models/EEM_Datetime.model.php 1 patch
Spacing   +125 added lines, -125 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_Datetime.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime.class.php');
26 26
 
27 27
 class EEM_Datetime extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,27 +35,27 @@  discard block
 block discarded – undo
35 35
 	 *		@access private
36 36
 	 *		@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)
37 37
 	 */
38
-	protected function __construct( $timezone ) {
39
-		$this->singular_item = __('Datetime','event_espresso');
40
-		$this->plural_item = __('Datetimes','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Datetime', 'event_espresso');
40
+		$this->plural_item = __('Datetimes', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Datetime'=>array(
47
-				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')),
48
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
47
+				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
48
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
49 49
 				'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''),
50 50
 				'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''),
51
-				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ),
52
-				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ),
53
-				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF),
54
-				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ),
55
-				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false),
51
+				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone),
52
+				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone),
53
+				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
54
+				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0),
55
+				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false),
56 56
 				'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0),
57
-				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ),
58
-				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ),
57
+				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0),
58
+				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false),
59 59
 			));
60 60
 		$this->_model_relations = array(
61 61
 			'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		);
65 65
 		$this->_model_chain_to_wp_user = 'Event';
66 66
 		//this model is generally available for reading
67
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' );
68
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
69
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
70
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit );
71
-		parent::__construct( $timezone );
67
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
68
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
69
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
70
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
71
+		parent::__construct($timezone);
72 72
 	}
73 73
 
74 74
 
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 	public function create_new_blank_datetime() {
84 84
 		$blank_datetime = EE_Datetime::new_instance(
85 85
 			array(
86
-				'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30),
87
-				'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30),
86
+				'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30),
87
+				'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30),
88 88
 				'DTT_order' => 1,
89 89
 				'DTT_reg_limit' => EE_INF
90 90
 			),
91 91
 			$this->_timezone
92 92
 		);
93
-		$blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) );
94
-		$blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) );
95
-		return array( $blank_datetime );
93
+		$blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone));
94
+		$blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
95
+		return array($blank_datetime);
96 96
 	}
97 97
 
98 98
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	* 		@param		int 			$EVT_ID
107 107
 	*		@return 		EE_Datetime[]		array on success, FALSE on fail
108 108
 	*/
109
-	public function get_all_event_dates( $EVT_ID = 0 ) {
110
-		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
109
+	public function get_all_event_dates($EVT_ID = 0) {
110
+		if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
111 111
 			return $this->create_new_blank_datetime();
112 112
 		}
113
-		$results =  $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
113
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
114 114
 
115
-		if ( empty( $results ) ) {
115
+		if (empty($results)) {
116 116
 			return $this->create_new_blank_datetime();
117 117
 		}
118 118
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 	 *                        	the given number
134 134
 	 * @return EE_Datetime[]
135 135
 	 */
136
-	public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL  ) {
136
+	public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) {
137 137
 
138 138
 		//sanitize EVT_ID
139
-		$EVT_ID = intval( $EVT_ID );
139
+		$EVT_ID = intval($EVT_ID);
140 140
 
141 141
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
142
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
143
-		$where_params = array( 'Event.EVT_ID' => $EVT_ID );
142
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
143
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
144 144
 
145
-		$query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' );
145
+		$query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none');
146 146
 
147
-		if( ! $include_expired){
148
-			$query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) );
147
+		if ( ! $include_expired) {
148
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
149 149
 		}
150
-		if( $include_deleted){
151
-			$query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE ));
150
+		if ($include_deleted) {
151
+			$query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE));
152 152
 		}
153 153
 
154
-		$result = $this->get_all( $query_params );
155
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
154
+		$result = $this->get_all($query_params);
155
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
156 156
 		return $result;
157 157
 	}
158 158
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @param int $limit
168 168
 	 * @return EE_Datetime[]
169 169
 	 */
170
-	public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){
171
-		return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID),
170
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) {
171
+		return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID),
172 172
 			'limit'=>$limit,
173 173
 			'order_by'=>array('DTT_EVT_start'=>'ASC'),
174 174
 			'default_where_conditions' => 'none'));
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param boolean $include_deleted
184 184
 	 * @return EE_Datetime
185 185
 	 */
186
-	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){
187
-		$results =  $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
-		if($results){
186
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) {
187
+		$results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
+		if ($results) {
189 189
 			return array_shift($results);
190
-		}else{
190
+		} else {
191 191
 			return NULL;
192 192
 		}
193 193
 	}
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * @param bool $try_to_exclude_deleted
202 202
 	 * @return \EE_Datetime
203 203
 	 */
204
-	public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){
205
-		if($try_to_exclude_expired){
206
-			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false);
207
-			if($non_expired){
204
+	public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) {
205
+		if ($try_to_exclude_expired) {
206
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
207
+			if ($non_expired) {
208 208
 				return $non_expired;
209 209
 			}
210 210
 		}
211
-		if($try_to_exclude_deleted){
211
+		if ($try_to_exclude_deleted) {
212 212
 			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
213
-			if($expired_even){
213
+			if ($expired_even) {
214 214
 				return $expired_even;
215 215
 			}
216 216
 		}
@@ -229,23 +229,23 @@  discard block
 block discarded – undo
229 229
 	 * @param int $limit
230 230
 	 * @return EE_Datetime[]
231 231
 	 */
232
-	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){
232
+	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
233 233
 		//sanitize EVT_ID
234
-		$EVT_ID = intval( $EVT_ID );
234
+		$EVT_ID = intval($EVT_ID);
235 235
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
236
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
237
-		$query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
238
-		if( ! $include_expired){
239
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
236
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
237
+		$query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
238
+		if ( ! $include_expired) {
239
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
240 240
 		}
241
-		if( $include_deleted){
242
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
241
+		if ($include_deleted) {
242
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
243 243
 		}
244
-		if($limit){
244
+		if ($limit) {
245 245
 			$query_params['limit'] = $limit;
246 246
 		}
247
-		$result = $this->get_all( $query_params );
248
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
247
+		$result = $this->get_all($query_params);
248
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
249 249
 		return $result;
250 250
 	}
251 251
 
@@ -258,23 +258,23 @@  discard block
 block discarded – undo
258 258
 	 * @param int $limit
259 259
 	 * @return EE_Datetime[]
260 260
 	 */
261
-	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
261
+	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
262 262
 		//sanitize TKT_ID
263
-		$TKT_ID =  intval( $TKT_ID );
263
+		$TKT_ID = intval($TKT_ID);
264 264
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
265
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
266
-		$query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
267
-		if( ! $include_expired){
268
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
265
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
266
+		$query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
267
+		if ( ! $include_expired) {
268
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
269 269
 		}
270
-		if( $include_deleted){
271
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
270
+		if ($include_deleted) {
271
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
272 272
 		}
273
-		if($limit){
273
+		if ($limit) {
274 274
 			$query_params['limit'] = $limit;
275 275
 		}
276
-		$result = $this->get_all( $query_params );
277
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
276
+		$result = $this->get_all($query_params);
277
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
278 278
 		return $result;
279 279
 	}
280 280
 
@@ -290,24 +290,24 @@  discard block
 block discarded – undo
290 290
 	 *                                  that number
291 291
 	 * @return EE_Datetime[]
292 292
 	 */
293
-	public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) {
293
+	public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
294 294
 		//sanitize id.
295
-		$TKT_ID =  intval( $TKT_ID );
295
+		$TKT_ID = intval($TKT_ID);
296 296
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
297
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
298
-		$where_params = array( 'Ticket.TKT_ID' => $TKT_ID );
299
-		$query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) );
300
-		if( ! $include_expired){
301
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
297
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
298
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
299
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
300
+		if ( ! $include_expired) {
301
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
302 302
 		}
303
-		if( $include_deleted){
304
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
303
+		if ($include_deleted) {
304
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
305 305
 		}
306
-		if($limit){
306
+		if ($limit) {
307 307
 			$query_params['limit'] = $limit;
308 308
 		}
309
-		$result = $this->get_all( $query_params );
310
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
309
+		$result = $this->get_all($query_params);
310
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
311 311
 		return $result;
312 312
 	}
313 313
 
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	 * @param int $EVT_ID
319 319
 	 * @return EE_Datetime
320 320
 	 */
321
-	public function get_most_important_datetime_for_event($EVT_ID){
321
+	public function get_most_important_datetime_for_event($EVT_ID) {
322 322
 		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
323
-		if($results){
323
+		if ($results) {
324 324
 			return array_shift($results);
325
-		}else{
325
+		} else {
326 326
 			return null;
327 327
 		}
328 328
 	}
@@ -341,71 +341,71 @@  discard block
 block discarded – undo
341 341
 	 * 			- inactive = Events that are either not published.
342 342
 	 * @return wpdb results array
343 343
 	 */
344
-	public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) {
344
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '') {
345 345
 
346
-		switch ( $evt_active_status ) {
346
+		switch ($evt_active_status) {
347 347
 			case 'upcoming' :
348 348
 					$where_params['Event.status'] = 'publish';
349 349
 					//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
350
-					if ( isset( $where_params['DTT_EVT_start'] ) ) {
350
+					if (isset($where_params['DTT_EVT_start'])) {
351 351
 						$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
352 352
 					}
353
-					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query( 'DTT_EVT_start' ) );
353
+					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query('DTT_EVT_start'));
354 354
 					break;
355 355
 
356 356
 			case 'expired' :
357
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
357
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
358 358
 				//get events to exclude
359
-				$exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) );
359
+				$exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $this->current_time_for_query('DTT_EVT_end'))));
360 360
 				//first get all events that have datetimes where its not expired.
361
-				$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' );
362
-				$event_ids = array_keys( $event_ids );
361
+				$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
362
+				$event_ids = array_keys($event_ids);
363 363
 
364
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
364
+				if (isset($where_params['DTT_EVT_end'])) {
365 365
 					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
366 366
 				}
367
-				$where_params['DTT_EVT_end'] = array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
368
-				$where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids );
367
+				$where_params['DTT_EVT_end'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
368
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
369 369
 				break;
370 370
 
371 371
 			case 'active' :
372 372
 				$where_params['Event.status'] = 'publish';
373
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
373
+				if (isset($where_params['DTT_EVT_start'])) {
374 374
 					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
375 375
 				}
376
-				if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
376
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
377 377
 					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
378 378
 				}
379
-				$where_params['DTT_EVT_start'] = array('<',  $this->current_time_for_query( 'DTT_EVT_start' ) );
380
-				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query( 'DTT_EVT_end' ) );
379
+				$where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query('DTT_EVT_start'));
380
+				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query('DTT_EVT_end'));
381 381
 				break;
382 382
 
383 383
 			case 'inactive' :
384
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
385
-				if ( isset( $where_params['OR'] ) ) {
384
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
385
+				if (isset($where_params['OR'])) {
386 386
 					$where_params['AND']['OR'] = $where_params['OR'];
387 387
 				}
388
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
388
+				if (isset($where_params['DTT_EVT_end'])) {
389 389
 					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
390
-					unset( $where_params['DTT_EVT_end'] );
390
+					unset($where_params['DTT_EVT_end']);
391 391
 				}
392 392
 
393
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
393
+				if (isset($where_params['DTT_EVT_start'])) {
394 394
 					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
395
-					unset( $where_params['DTT_EVT_start'] );
395
+					unset($where_params['DTT_EVT_start']);
396 396
 				}
397
-				$where_params['AND']['Event.status'] = array( '!=', 'publish' );
397
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
398 398
 				break;
399 399
 		}
400 400
 
401 401
 		$query_params[0] = $where_params;
402 402
 		$query_params['group_by'] = array('dtt_year', 'dtt_month');
403
-		$query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' );
403
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
404 404
 		$columns_to_select = array(
405 405
 			'dtt_year' => array('YEAR(DTT_EVT_start)', '%s'),
406 406
 			'dtt_month' => array('MONTHNAME(DTT_EVT_start)', '%s')
407 407
 			);
408
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
408
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
409 409
 	}
410 410
 
411 411
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * for the tickets for each datetime)
414 414
 	 * @param EE_Datetime[] $datetimes
415 415
 	 */
416
-	public function update_sold($datetimes){
417
-		foreach($datetimes as $datetime){
416
+	public function update_sold($datetimes) {
417
+		foreach ($datetimes as $datetime) {
418 418
 			$datetime->update_sold();
419 419
 		}
420 420
 	}
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 * @param array $query_params
430 430
 	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO tickets attached to datetime then FALSE is returned.
431 431
 	 */
432
-	public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) {
433
-		$datetime = $this->get_one_by_ID( $DTT_ID );
434
-		if ( $datetime instanceof EE_Datetime ) {
435
-			return $datetime->tickets_remaining( $query_params );
432
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
433
+		$datetime = $this->get_one_by_ID($DTT_ID);
434
+		if ($datetime instanceof EE_Datetime) {
435
+			return $datetime->tickets_remaining($query_params);
436 436
 		}
437 437
 		return 0;
438 438
 	}
@@ -451,28 +451,28 @@  discard block
 block discarded – undo
451 451
 	 *                EE_Datetime::upcoming
452 452
 	 *                EE_Datetime::expired
453 453
 	 */
454
-	public function get_datetime_counts_by_status( $query_params = array() ) {
454
+	public function get_datetime_counts_by_status($query_params = array()) {
455 455
 		//only accept where conditions for this query.
456
-		$_where = isset( $query_params[0] ) ? $query_params[0] : array();
456
+		$_where = isset($query_params[0]) ? $query_params[0] : array();
457 457
 		$status_query_args = array(
458 458
 				EE_Datetime::active => array_merge(
459 459
 						$_where,
460
-						array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) )
460
+						array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
461 461
 				),
462 462
 				EE_Datetime::upcoming => array_merge(
463 463
 						$_where,
464
-						array( 'DTT_EVT_start' => array( '>', time() ) )
464
+						array('DTT_EVT_start' => array('>', time()))
465 465
 				),
466 466
 				EE_Datetime::expired => array_merge(
467 467
 						$_where,
468
-						array( 'DTT_EVT_end' => array('<', time() ) )
468
+						array('DTT_EVT_end' => array('<', time()))
469 469
 				)
470 470
 		);
471 471
 
472 472
 		//loop through and query counts for each stati.
473 473
 		$status_query_results = array();
474
-		foreach( $status_query_args as $status => $status_where_conditions ) {
475
-			$status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true );
474
+		foreach ($status_query_args as $status => $status_where_conditions) {
475
+			$status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
476 476
 		}
477 477
 
478 478
 		return $status_query_results;
Please login to merge, or discard this patch.
core/db_classes/EE_Event.class.php 1 patch
Spacing   +197 added lines, -197 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
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 *                             		    date_format and the second value is the time format
51 51
 	 * @return EE_Event
52 52
 	 */
53
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
54
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
55
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
53
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
54
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
55
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
56 56
 	}
57 57
 
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *                          		the website will be used.
64 64
 	 * @return EE_Event
65 65
 	 */
66
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
67
-		return new self( $props_n_values, TRUE, $timezone );
66
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
67
+		return new self($props_n_values, TRUE, $timezone);
68 68
 	}
69 69
 
70 70
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 * @param array $query_params like EEM_Base::get_all
76 76
 	 * @return EE_Datetime[]
77 77
 	 */
78
-	public function datetimes( $query_params = array() ) {
79
-		return $this->get_many_related( 'Datetime', $query_params );
78
+	public function datetimes($query_params = array()) {
79
+		return $this->get_many_related('Datetime', $query_params);
80 80
 	}
81 81
 
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return EE_Datetime[]
88 88
 	 */
89 89
 	public function datetimes_in_chronological_order() {
90
-		return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
90
+		return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
91 91
 	}
92 92
 
93 93
 
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	 * @param null $limit
104 104
 	 * @return \EE_Datetime[]
105 105
 	 */
106
-	public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) {
107
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit );
106
+	public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) {
107
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit);
108 108
 	}
109 109
 
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return EE_Datetime
115 115
 	 */
116 116
 	public function first_datetime() {
117
-		return $this->get_first_related( 'Datetime' );
117
+		return $this->get_first_related('Datetime');
118 118
 	}
119 119
 
120 120
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 * @param bool $try_to_exclude_deleted
126 126
 	 * @return EE_Datetime
127 127
 	 */
128
-	public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) {
129
-		if ( !empty ( $this->_Primary_Datetime ) ) {
128
+	public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) {
129
+		if ( ! empty ($this->_Primary_Datetime)) {
130 130
 			return $this->_Primary_Datetime;
131 131
 		}
132
-		$this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted );
132
+		$this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted);
133 133
 		return $this->_Primary_Datetime;
134 134
 	}
135 135
 
@@ -140,30 +140,30 @@  discard block
 block discarded – undo
140 140
 	 * @param array $query_params like EEM_Base::get_all
141 141
 	 * @return EE_Ticket[]
142 142
 	 */
143
-	public function tickets( $query_params = array() ) {
143
+	public function tickets($query_params = array()) {
144 144
 		//first get all datetimes
145 145
 		$datetimes = $this->datetimes_ordered();
146
-		if ( ! $datetimes ) {
146
+		if ( ! $datetimes) {
147 147
 			return array();
148 148
 		}
149 149
 
150 150
 		$datetime_ids = array();
151
-		foreach ( $datetimes as $datetime ) {
151
+		foreach ($datetimes as $datetime) {
152 152
 			$datetime_ids[] = $datetime->ID();
153 153
 		}
154 154
 
155
-		$where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) );
155
+		$where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids));
156 156
 
157 157
 		//if incoming $query_params has where conditions let's merge but not override existing.
158
-		if ( is_array( $query_params ) && isset( $query_params[0]) ) {
159
-			$where_params = array_merge( $query_params[0], $where_params );
160
-			unset( $query_params[0] );
158
+		if (is_array($query_params) && isset($query_params[0])) {
159
+			$where_params = array_merge($query_params[0], $where_params);
160
+			unset($query_params[0]);
161 161
 		}
162 162
 
163 163
 		//now add $where_params to $query_params
164 164
 		$query_params[0] = $where_params;
165 165
 
166
-		return EEM_Ticket::instance()->get_all( $query_params );
166
+		return EEM_Ticket::instance()->get_all($query_params);
167 167
 	}
168 168
 
169 169
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @return bool
173 173
 	 */
174 174
 	function additional_limit() {
175
-		return $this->get( 'EVT_additional_limit' );
175
+		return $this->get('EVT_additional_limit');
176 176
 	}
177 177
 
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return bool
182 182
 	 */
183 183
 	function allow_overflow() {
184
-		return $this->get( 'EVT_allow_overflow' );
184
+		return $this->get('EVT_allow_overflow');
185 185
 	}
186 186
 
187 187
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @return bool
191 191
 	 */
192 192
 	function created() {
193
-		return $this->get( 'EVT_created' );
193
+		return $this->get('EVT_created');
194 194
 	}
195 195
 
196 196
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @return bool
200 200
 	 */
201 201
 	function description() {
202
-		return $this->get( 'EVT_desc' );
202
+		return $this->get('EVT_desc');
203 203
 	}
204 204
 
205 205
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string of html
210 210
 	 */
211 211
 	function description_filtered() {
212
-		return $this->get_pretty( 'EVT_desc' );
212
+		return $this->get_pretty('EVT_desc');
213 213
 	}
214 214
 
215 215
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @return bool
219 219
 	 */
220 220
 	function display_description() {
221
-		return $this->get( 'EVT_display_desc' );
221
+		return $this->get('EVT_display_desc');
222 222
 	}
223 223
 
224 224
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return bool
228 228
 	 */
229 229
 	function display_ticket_selector() {
230
-		return (bool)$this->get( 'EVT_display_ticket_selector' );
230
+		return (bool) $this->get('EVT_display_ticket_selector');
231 231
 	}
232 232
 
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @return bool
237 237
 	 */
238 238
 	function external_url() {
239
-		return $this->get( 'EVT_external_URL' );
239
+		return $this->get('EVT_external_URL');
240 240
 	}
241 241
 
242 242
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @return bool
246 246
 	 */
247 247
 	function member_only() {
248
-		return $this->get( 'EVT_member_only' );
248
+		return $this->get('EVT_member_only');
249 249
 	}
250 250
 
251 251
 
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 * @return bool
255 255
 	 */
256 256
 	function phone() {
257
-		return $this->get( 'EVT_phone' );
257
+		return $this->get('EVT_phone');
258 258
 	}
259 259
 
260 260
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * @return bool
264 264
 	 */
265 265
 	function modified() {
266
-		return $this->get( 'EVT_modified' );
266
+		return $this->get('EVT_modified');
267 267
 	}
268 268
 
269 269
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return bool
273 273
 	 */
274 274
 	function name() {
275
-		return $this->get( 'EVT_name' );
275
+		return $this->get('EVT_name');
276 276
 	}
277 277
 
278 278
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 * @return bool
282 282
 	 */
283 283
 	function order() {
284
-		return $this->get( 'EVT_order' );
284
+		return $this->get('EVT_order');
285 285
 	}
286 286
 
287 287
 
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @return bool|string
291 291
 	 */
292 292
 	function default_registration_status() {
293
-		$event_default_registration_status = $this->get( 'EVT_default_registration_status' );
294
-		return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
293
+		$event_default_registration_status = $this->get('EVT_default_registration_status');
294
+		return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID;
295 295
 	}
296 296
 
297 297
 
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 	 * @param bool $not_full_desc
303 303
 	 * @return bool|string
304 304
 	 */
305
-	function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) {
306
-		$short_desc = $this->get( 'EVT_short_desc' );
307
-		if ( !empty( $short_desc ) || $not_full_desc ) {
305
+	function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) {
306
+		$short_desc = $this->get('EVT_short_desc');
307
+		if ( ! empty($short_desc) || $not_full_desc) {
308 308
 			return $short_desc;
309 309
 		}
310 310
 		else {
311
-			$full_desc = $this->get( 'EVT_desc' );
312
-			return wp_trim_words( $full_desc, $num_words, $more );
311
+			$full_desc = $this->get('EVT_desc');
312
+			return wp_trim_words($full_desc, $num_words, $more);
313 313
 		}
314 314
 	}
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return bool
320 320
 	 */
321 321
 	function slug() {
322
-		return $this->get( 'EVT_slug' );
322
+		return $this->get('EVT_slug');
323 323
 	}
324 324
 
325 325
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return bool
329 329
 	 */
330 330
 	function timezone_string() {
331
-		return $this->get( 'EVT_timezone_string' );
331
+		return $this->get('EVT_timezone_string');
332 332
 	}
333 333
 
334 334
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 * @return bool
338 338
 	 */
339 339
 	function visible_on() {
340
-		return $this->get( 'EVT_visible_on' );
340
+		return $this->get('EVT_visible_on');
341 341
 	}
342 342
 
343 343
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 * @return bool
347 347
 	 */
348 348
 	function wp_user() {
349
-		return $this->get( 'EVT_wp_user' );
349
+		return $this->get('EVT_wp_user');
350 350
 	}
351 351
 
352 352
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return bool
356 356
 	 */
357 357
 	function donations() {
358
-		return $this->get( 'EVT_donations' );
358
+		return $this->get('EVT_donations');
359 359
 	}
360 360
 
361 361
 
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	/**
364 364
 	 * @param $limit
365 365
 	 */
366
-	function set_additional_limit( $limit ) {
367
-		$this->set( 'EVT_additional_limit', $limit );
366
+	function set_additional_limit($limit) {
367
+		$this->set('EVT_additional_limit', $limit);
368 368
 	}
369 369
 
370 370
 
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * @param $created
374 374
 	 */
375
-	function set_created( $created ) {
376
-		$this->set( 'EVT_created', $created );
375
+	function set_created($created) {
376
+		$this->set('EVT_created', $created);
377 377
 	}
378 378
 
379 379
 
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	/**
382 382
 	 * @param $desc
383 383
 	 */
384
-	function set_description( $desc ) {
385
-		$this->set( 'EVT_desc', $desc );
384
+	function set_description($desc) {
385
+		$this->set('EVT_desc', $desc);
386 386
 	}
387 387
 
388 388
 
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
 	/**
391 391
 	 * @param $display_desc
392 392
 	 */
393
-	function set_display_description( $display_desc ) {
394
-		$this->set( 'EVT_display_desc', $display_desc );
393
+	function set_display_description($display_desc) {
394
+		$this->set('EVT_display_desc', $display_desc);
395 395
 	}
396 396
 
397 397
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
 	/**
400 400
 	 * @param $display_ticket_selector
401 401
 	 */
402
-	function set_display_ticket_selector( $display_ticket_selector ) {
403
-		$this->set( 'EVT_display_ticket_selector', $display_ticket_selector );
402
+	function set_display_ticket_selector($display_ticket_selector) {
403
+		$this->set('EVT_display_ticket_selector', $display_ticket_selector);
404 404
 	}
405 405
 
406 406
 
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	/**
409 409
 	 * @param $external_url
410 410
 	 */
411
-	function set_external_url( $external_url ) {
412
-		$this->set( 'EVT_external_URL', $external_url );
411
+	function set_external_url($external_url) {
412
+		$this->set('EVT_external_URL', $external_url);
413 413
 	}
414 414
 
415 415
 
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 	/**
418 418
 	 * @param $member_only
419 419
 	 */
420
-	function set_member_only( $member_only ) {
421
-		$this->set( 'EVT_member_only', $member_only );
420
+	function set_member_only($member_only) {
421
+		$this->set('EVT_member_only', $member_only);
422 422
 	}
423 423
 
424 424
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	/**
427 427
 	 * @param $event_phone
428 428
 	 */
429
-	function set_event_phone( $event_phone ) {
430
-		$this->set( 'EVT_phone', $event_phone );
429
+	function set_event_phone($event_phone) {
430
+		$this->set('EVT_phone', $event_phone);
431 431
 	}
432 432
 
433 433
 
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	/**
436 436
 	 * @param $modified
437 437
 	 */
438
-	function set_modified( $modified ) {
439
-		$this->set( 'EVT_modified', $modified );
438
+	function set_modified($modified) {
439
+		$this->set('EVT_modified', $modified);
440 440
 	}
441 441
 
442 442
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	/**
445 445
 	 * @param $name
446 446
 	 */
447
-	function set_name( $name ) {
448
-		$this->set( 'EVT_name', $name );
447
+	function set_name($name) {
448
+		$this->set('EVT_name', $name);
449 449
 	}
450 450
 
451 451
 
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	/**
454 454
 	 * @param $order
455 455
 	 */
456
-	function set_order( $order ) {
457
-		$this->set( 'EVT_order', $order );
456
+	function set_order($order) {
457
+		$this->set('EVT_order', $order);
458 458
 	}
459 459
 
460 460
 
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	/**
463 463
 	 * @param $short_desc
464 464
 	 */
465
-	function set_short_description( $short_desc ) {
466
-		$this->set( 'EVT_short_desc', $short_desc );
465
+	function set_short_description($short_desc) {
466
+		$this->set('EVT_short_desc', $short_desc);
467 467
 	}
468 468
 
469 469
 
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	/**
472 472
 	 * @param $slug
473 473
 	 */
474
-	function set_slug( $slug ) {
475
-		$this->set( 'EVT_slug', $slug );
474
+	function set_slug($slug) {
475
+		$this->set('EVT_slug', $slug);
476 476
 	}
477 477
 
478 478
 
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	/**
481 481
 	 * @param $timezone_string
482 482
 	 */
483
-	function set_timezone_string( $timezone_string ) {
484
-		$this->set( 'EVT_timezone_string', $timezone_string );
483
+	function set_timezone_string($timezone_string) {
484
+		$this->set('EVT_timezone_string', $timezone_string);
485 485
 	}
486 486
 
487 487
 
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 	/**
490 490
 	 * @param $visible_on
491 491
 	 */
492
-	function set_visible_on( $visible_on ) {
493
-		$this->set( 'EVT_visible_on', $visible_on );
492
+	function set_visible_on($visible_on) {
493
+		$this->set('EVT_visible_on', $visible_on);
494 494
 	}
495 495
 
496 496
 
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 	/**
499 499
 	 * @param $wp_user
500 500
 	 */
501
-	function set_wp_user( $wp_user ) {
502
-		$this->set( 'EVT_wp_user', $wp_user );
501
+	function set_wp_user($wp_user) {
502
+		$this->set('EVT_wp_user', $wp_user);
503 503
 	}
504 504
 
505 505
 
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
 	/**
508 508
 	 * @param $default_registration_status
509 509
 	 */
510
-	function set_default_registration_status( $default_registration_status ) {
511
-		$this->set( 'EVT_default_registration_status', $default_registration_status );
510
+	function set_default_registration_status($default_registration_status) {
511
+		$this->set('EVT_default_registration_status', $default_registration_status);
512 512
 	}
513 513
 
514 514
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	/**
517 517
 	 * @param $donations
518 518
 	 */
519
-	function set_donations( $donations ) {
520
-		$this->set( 'EVT_donations', $donations );
519
+	function set_donations($donations) {
520
+		$this->set('EVT_donations', $donations);
521 521
 	}
522 522
 
523 523
 
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @param EE_Venue /int $venue_id_or_obj
528 528
 	 * @return EE_Venue
529 529
 	 */
530
-	function add_venue( $venue_id_or_obj ) {
531
-		return $this->_add_relation_to( $venue_id_or_obj, 'Venue' );
530
+	function add_venue($venue_id_or_obj) {
531
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
532 532
 	}
533 533
 
534 534
 
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * @param EE_Venue /int $venue_id_or_obj
539 539
 	 * @return EE_Venue
540 540
 	 */
541
-	function remove_venue( $venue_id_or_obj ) {
542
-		return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' );
541
+	function remove_venue($venue_id_or_obj) {
542
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
543 543
 	}
544 544
 
545 545
 
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @param array $query_params like EEM_Base::get_all's $query_params
550 550
 	 * @return EE_Venue[]
551 551
 	 */
552
-	function venues( $query_params = array() ) {
553
-		return $this->get_many_related( 'Venue', $query_params );
552
+	function venues($query_params = array()) {
553
+		return $this->get_many_related('Venue', $query_params);
554 554
 	}
555 555
 
556 556
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	 */
563 563
 	private function _has_ID_and_is_published() {
564 564
 		// first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses)
565
-		return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE;
565
+		return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE;
566 566
 	}
567 567
 
568 568
 
@@ -574,21 +574,21 @@  discard block
 block discarded – undo
574 574
 	 */
575 575
 	public function is_upcoming() {
576 576
 		// check if event id is present and if this event is published
577
-		if ( $this->is_inactive() ) {
577
+		if ($this->is_inactive()) {
578 578
 			return FALSE;
579 579
 		}
580 580
 		// set initial value
581 581
 		$upcoming = FALSE;
582 582
 		//next let's get all datetimes and loop through them
583 583
 		$datetimes = $this->datetimes_in_chronological_order();
584
-		foreach ( $datetimes as $datetime ) {
585
-			if ( $datetime instanceof EE_Datetime ) {
584
+		foreach ($datetimes as $datetime) {
585
+			if ($datetime instanceof EE_Datetime) {
586 586
 				//if this dtt is expired then we continue cause one of the other datetimes might be upcoming.
587
-				if ( $datetime->is_expired() ) {
587
+				if ($datetime->is_expired()) {
588 588
 					continue;
589 589
 				}
590 590
 				//if this dtt is active then we return false.
591
-				if ( $datetime->is_active() ) {
591
+				if ($datetime->is_active()) {
592 592
 					return FALSE;
593 593
 				}
594 594
 				//otherwise let's check upcoming status
@@ -605,21 +605,21 @@  discard block
 block discarded – undo
605 605
 	 */
606 606
 	public function is_active() {
607 607
 		// check if event id is present and if this event is published
608
-		if ( $this->is_inactive() ) {
608
+		if ($this->is_inactive()) {
609 609
 			return FALSE;
610 610
 		}
611 611
 		// set initial value
612 612
 		$active = FALSE;
613 613
 		//next let's get all datetimes and loop through them
614 614
 		$datetimes = $this->datetimes_in_chronological_order();
615
-		foreach ( $datetimes as $datetime ) {
616
-			if ( $datetime instanceof EE_Datetime ) {
615
+		foreach ($datetimes as $datetime) {
616
+			if ($datetime instanceof EE_Datetime) {
617 617
 				//if this dtt is expired then we continue cause one of the other datetimes might be active.
618
-				if ( $datetime->is_expired() ) {
618
+				if ($datetime->is_expired()) {
619 619
 					continue;
620 620
 				}
621 621
 				//if this dtt is upcoming then we return false.
622
-				if ( $datetime->is_upcoming() ) {
622
+				if ($datetime->is_upcoming()) {
623 623
 					return FALSE;
624 624
 				}
625 625
 				//otherwise let's check active status
@@ -636,17 +636,17 @@  discard block
 block discarded – undo
636 636
 	 */
637 637
 	public function is_expired() {
638 638
 		// check if event id is present and if this event is published
639
-		if ( $this->is_inactive() ) {
639
+		if ($this->is_inactive()) {
640 640
 			return FALSE;
641 641
 		}
642 642
 		// set initial value
643 643
 		$expired = FALSE;
644 644
 		//first let's get all datetimes and loop through them
645 645
 		$datetimes = $this->datetimes_in_chronological_order();
646
-		foreach ( $datetimes as $datetime ) {
647
-			if ( $datetime instanceof EE_Datetime ) {
646
+		foreach ($datetimes as $datetime) {
647
+			if ($datetime instanceof EE_Datetime) {
648 648
 				//if this dtt is upcoming or active then we return false.
649
-				if ( $datetime->is_upcoming() || $datetime->is_active() ) {
649
+				if ($datetime->is_upcoming() || $datetime->is_active()) {
650 650
 					return FALSE;
651 651
 				}
652 652
 				//otherwise let's check active status
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 */
664 664
 	public function is_inactive() {
665 665
 		// check if event id is present and if this event is published
666
-		if ( $this->_has_ID_and_is_published() ) {
666
+		if ($this->_has_ID_and_is_published()) {
667 667
 			return FALSE;
668 668
 		}
669 669
 		return TRUE;
@@ -681,26 +681,26 @@  discard block
 block discarded – undo
681 681
 	 */
682 682
 	public function perform_sold_out_status_check() {
683 683
 		// get all unexpired untrashed tickets
684
-		$tickets = $this->tickets( array(
684
+		$tickets = $this->tickets(array(
685 685
 			array(
686
-				'TKT_end_date'   => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ),
686
+				'TKT_end_date'   => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')),
687 687
 				'TKT_deleted'    => false
688 688
 			)
689 689
 		));
690 690
 		// if all the tickets are just expired, then don't update the event status to sold out
691
-		if ( empty( $tickets )) {
691
+		if (empty($tickets)) {
692 692
 			return true;
693 693
 		}
694 694
 		// set initial value
695 695
 		$spaces_remaining = 0;
696
-		foreach( $tickets as $ticket ) {
697
-			if ( $ticket instanceof EE_Ticket ) {
698
-				$spaces_remaining += $ticket->qty( 'saleable' );
696
+		foreach ($tickets as $ticket) {
697
+			if ($ticket instanceof EE_Ticket) {
698
+				$spaces_remaining += $ticket->qty('saleable');
699 699
 			}
700 700
 		}
701
-		if ( $spaces_remaining === 0 ) {
702
-			$this->set_status( EEM_Event::sold_out );
703
-			if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) {
701
+		if ($spaces_remaining === 0) {
702
+			$this->set_status(EEM_Event::sold_out);
703
+			if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) {
704 704
 				$this->save();
705 705
 			}
706 706
 			$sold_out = TRUE;
@@ -728,15 +728,15 @@  discard block
 block discarded – undo
728 728
 	 */
729 729
 	public function spaces_remaining_for_sale() {
730 730
 		//first get total available spaces including consideration for tickets that have already sold.
731
-		$spaces_available = $this->total_available_spaces( true );
731
+		$spaces_available = $this->total_available_spaces(true);
732 732
 
733 733
 		//if total available = 0, then exit right away because that means everything is expired.
734
-		if ( $spaces_available === 0 ) {
734
+		if ($spaces_available === 0) {
735 735
 			return 0;
736 736
 		}
737 737
 
738 738
 		//subtract total approved registrations from spaces available to get how many are remaining.
739
-		$spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true );
739
+		$spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true);
740 740
 		$spaces_remaining = $spaces_available - $spots_taken;
741 741
 
742 742
 		return $spaces_remaining > 0 ? $spaces_remaining : 0;
@@ -769,29 +769,29 @@  discard block
 block discarded – undo
769 769
 	 *
770 770
 	 * @return  int|float  (Note: if EE_INF is returned its considered a float by PHP)
771 771
 	 */
772
-	public function total_available_spaces( $current_total_available = false ) {
772
+	public function total_available_spaces($current_total_available = false) {
773 773
 		$spaces_available = 0;
774 774
 
775 775
 		//first get all tickets on the event and include expired tickets
776
-		$tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) );
776
+		$tickets = $this->tickets(array('default_where_conditions' => 'none'));
777 777
 		$ticket_sums = array();
778 778
 		$datetime_limits = array();
779 779
 
780 780
 		//loop through tickets and normalize them
781
-		foreach ( $tickets as $ticket ) {
782
-			$datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
781
+		foreach ($tickets as $ticket) {
782
+			$datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
783 783
 
784
-			if ( empty( $datetimes ) ) {
784
+			if (empty($datetimes)) {
785 785
 				continue;
786 786
 			}
787 787
 
788 788
 			//first datetime should be the lowest datetime
789
-			$least_datetime = reset( $datetimes );
789
+			$least_datetime = reset($datetimes);
790 790
 
791 791
 			//lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity
792 792
 			//IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit.
793
-			if ( $current_total_available ) {
794
-				if ( $ticket->is_remaining() ) {
793
+			if ($current_total_available) {
794
+				if ($ticket->is_remaining()) {
795 795
 					$remaining = $ticket->remaining();
796 796
 				} else {
797 797
 					$spaces_available += $ticket->sold();
@@ -799,23 +799,23 @@  discard block
 block discarded – undo
799 799
 					continue;
800 800
 				}
801 801
 			} else {
802
-				$remaining = min( $ticket->qty(), $least_datetime->reg_limit() );
802
+				$remaining = min($ticket->qty(), $least_datetime->reg_limit());
803 803
 			}
804 804
 
805 805
 			//if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts.
806
-			if ( $remaining == EE_INF ) {
806
+			if ($remaining == EE_INF) {
807 807
 				return EE_INF;
808 808
 			}
809 809
 
810 810
 			//multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum"
811 811
 			//also include the sum of all the datetime reg limits on the ticket for breaking ties.
812
-			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes );
812
+			$ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes);
813 813
 			$ticket_sums[$ticket->ID()]['datetime_sums'] = 0;
814
-			foreach ( $datetimes as $datetime ) {
815
-				if ( $datetime->reg_limit() === EE_INF ) {
814
+			foreach ($datetimes as $datetime) {
815
+				if ($datetime->reg_limit() === EE_INF) {
816 816
 					$ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF;
817 817
 				} else {
818
-					$ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
818
+					$ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
819 819
 				}
820 820
 				$datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit();
821 821
 			}
@@ -826,74 +826,74 @@  discard block
 block discarded – undo
826 826
 		//ticket quantity by the number of datetimes on the ticket).  For tie-breakers, then the next sort is based on the
827 827
 		//ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not
828 828
 		//$current_total_available ) for the datetimes on the ticket.
829
-		usort( $ticket_sums, function( $a, $b ) {
830
-			if ( $a['sum'] == $b['sum'] ) {
831
-				if ( $a['datetime_sums'] == $b['datetime_sums'] ) {
829
+		usort($ticket_sums, function($a, $b) {
830
+			if ($a['sum'] == $b['sum']) {
831
+				if ($a['datetime_sums'] == $b['datetime_sums']) {
832 832
 					return 0;
833 833
 				}
834 834
 
835 835
 				return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1;
836 836
 			}
837
-			return ( $a['sum'] < $b['sum'] ) ? -1 : 1;
837
+			return ($a['sum'] < $b['sum']) ? -1 : 1;
838 838
 		});
839 839
 
840 840
 		//now let's loop through the sorted tickets and simulate sellouts
841
-		foreach ( $ticket_sums as $ticket_info ) {
842
-			if ( $ticket_info['ticket'] instanceof EE_Ticket ) {
841
+		foreach ($ticket_sums as $ticket_info) {
842
+			if ($ticket_info['ticket'] instanceof EE_Ticket) {
843 843
 
844
-				$datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) );
844
+				$datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC')));
845 845
 				//need to sort these $datetimes by remaining (only if $current_total_available)
846 846
 				//setup datetimes for simulation
847 847
 				$ticket_datetimes_remaining = array();
848
-				foreach( $datetimes as $datetime ) {
848
+				foreach ($datetimes as $datetime) {
849 849
 					$ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()];
850 850
 					$ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime;
851 851
 				}
852
-				usort( $ticket_datetimes_remaining, function( $a, $b ) {
853
-					if ( $a['rem'] == $b['rem'] ) {
852
+				usort($ticket_datetimes_remaining, function($a, $b) {
853
+					if ($a['rem'] == $b['rem']) {
854 854
 						return 0;
855 855
 					}
856
-					return ( $a['rem'] < $b['rem'] ) ? -1 : 1;
856
+					return ($a['rem'] < $b['rem']) ? -1 : 1;
857 857
 				});
858 858
 
859 859
 
860 860
 				//get the remaining on the first datetime (which should be the one with the least remaining) and that is
861 861
 				//what we add to the spaces_available running total.  Then we need to decrease the remaining on our datetime tracker.
862
-				$lowest_datetime = reset( $ticket_datetimes_remaining );
862
+				$lowest_datetime = reset($ticket_datetimes_remaining);
863 863
 
864 864
 				//need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket.
865 865
 				// If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already
866 866
 				// been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue
867 867
 				// to the next ticket.
868
-				if ( $current_total_available ) {
869
-					$remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() );
868
+				if ($current_total_available) {
869
+					$remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining());
870 870
 				} else {
871
-					$remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() );
871
+					$remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty());
872 872
 				}
873 873
 
874 874
 				//if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all
875 875
 				//tickets have a quantity.  So we don't have to track datetimes, we can just use ticket quantities for total
876 876
 				//available.
877
-				if ( $remaining === EE_INF ) {
877
+				if ($remaining === EE_INF) {
878 878
 					$spaces_available += $ticket_info['ticket']->qty();
879 879
 					continue;
880 880
 				}
881 881
 
882 882
 				//if ticket has sold amounts then we also need to add that (but only if doing live counts)
883
-				if ( $current_total_available ) {
883
+				if ($current_total_available) {
884 884
 					$spaces_available += $ticket_info['ticket']->sold();
885 885
 				}
886 886
 
887
-				if ( $remaining <= 0 ) {
887
+				if ($remaining <= 0) {
888 888
 					continue;
889 889
 				} else {
890 890
 					$spaces_available += $remaining;
891 891
 				}
892 892
 
893 893
 				//loop through the datetimes and sell them out!
894
-				foreach ( $ticket_datetimes_remaining as $datetime_info ) {
895
-					if ( $datetime_info['datetime'] instanceof EE_Datetime ) {
896
-						$datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining;
894
+				foreach ($ticket_datetimes_remaining as $datetime_info) {
895
+					if ($datetime_info['datetime'] instanceof EE_Datetime) {
896
+						$datetime_limits[$datetime_info['datetime']->ID()] += - $remaining;
897 897
 					}
898 898
 				}
899 899
 			}
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 	 * @param  bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event
910 910
 	 * @return boolean
911 911
 	 */
912
-	public function is_sold_out( $actual = FALSE ) {
913
-		if ( ! $actual ) {
912
+	public function is_sold_out($actual = FALSE) {
913
+		if ( ! $actual) {
914 914
 			return $this->status() == EEM_Event::sold_out;
915 915
 		}
916 916
 		else {
@@ -955,31 +955,31 @@  discard block
 block discarded – undo
955 955
 	 *
956 956
 	 * @return bool | string - based on EE_Datetime active constants or FALSE if error.
957 957
 	 */
958
-	public function get_active_status( $reset = false ) {
958
+	public function get_active_status($reset = false) {
959 959
 		// if the active status has already been set, then just use that value (unless we are resetting it)
960
-		if ( ! empty( $this->_active_status ) && ! $reset ) {
960
+		if ( ! empty($this->_active_status) && ! $reset) {
961 961
 			return $this->_active_status;
962 962
 		}
963 963
 		//first check if event id is present on this object
964
-		if ( ! $this->ID() ) {
964
+		if ( ! $this->ID()) {
965 965
 			return false;
966 966
 		}
967 967
 
968 968
 		//let's get a count of datetimes for each status (this only returns results for Datetime Specific Statuses.
969
-		$datetime_count_by_status = EEM_Datetime::instance()->get_datetime_counts_by_status( array( array( 'EVT_ID' => $this->ID() ) ) );
969
+		$datetime_count_by_status = EEM_Datetime::instance()->get_datetime_counts_by_status(array(array('EVT_ID' => $this->ID())));
970 970
 
971 971
 		//if event is published:
972
-		if ( $this->status() === 'publish' ) {
972
+		if ($this->status() === 'publish') {
973 973
 			//active?
974
-			if ( $datetime_count_by_status[ EE_Datetime::active ] > 0 ) {
974
+			if ($datetime_count_by_status[EE_Datetime::active] > 0) {
975 975
 				$this->_active_status = EE_Datetime::active;
976 976
 			} else {
977 977
 				//upcoming?
978
-				if ( $datetime_count_by_status[ EE_Datetime::upcoming ] > 0 ) {
978
+				if ($datetime_count_by_status[EE_Datetime::upcoming] > 0) {
979 979
 					$this->_active_status = EE_Datetime::upcoming;
980 980
 				} else {
981 981
 					//expired?
982
-					if ( $datetime_count_by_status[ EE_Datetime::expired ] > 0 ) {
982
+					if ($datetime_count_by_status[EE_Datetime::expired] > 0) {
983 983
 						$this->_active_status = EE_Datetime::expired;
984 984
 					} else {
985 985
 						//it would be odd if things make it this far because it basically means there are no datetime's
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 			}
991 991
 		} else {
992 992
 			//the event is not published, so let's just set it's active status according to its' post status
993
-			switch ( $this->status() ) {
993
+			switch ($this->status()) {
994 994
 				case EEM_Event::sold_out :
995 995
 					$this->_active_status = EE_Datetime::sold_out;
996 996
 					break;
@@ -1016,10 +1016,10 @@  discard block
 block discarded – undo
1016 1016
 	 * @param boolean $echo     whether to return (FALSE), or echo out the result (TRUE)
1017 1017
 	 * @return mixed void|string
1018 1018
 	 */
1019
-	public function pretty_active_status( $echo = TRUE ) {
1019
+	public function pretty_active_status($echo = TRUE) {
1020 1020
 		$active_status = $this->get_active_status();
1021
-		$status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>';
1022
-		if ( $echo ) {
1021
+		$status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>';
1022
+		if ($echo) {
1023 1023
 			echo $status;
1024 1024
 			return '';
1025 1025
 		}
@@ -1033,12 +1033,12 @@  discard block
 block discarded – undo
1033 1033
 	 */
1034 1034
 	public function get_number_of_tickets_sold() {
1035 1035
 		$tkt_sold = 0;
1036
-		if ( !$this->ID() ) {
1036
+		if ( ! $this->ID()) {
1037 1037
 			return 0;
1038 1038
 		}
1039 1039
 		$datetimes = $this->datetimes();
1040
-		foreach ( $datetimes as $datetime ) {
1041
-			if ( $datetime instanceof EE_Datetime ) {
1040
+		foreach ($datetimes as $datetime) {
1041
+			if ($datetime instanceof EE_Datetime) {
1042 1042
 				$tkt_sold += $datetime->sold();
1043 1043
 			}
1044 1044
 		}
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	 * @return int
1054 1054
 	 */
1055 1055
 	public function get_count_of_all_registrations() {
1056
-		return EEM_Event::instance()->count_related( $this, 'Registration' );
1056
+		return EEM_Event::instance()->count_related($this, 'Registration');
1057 1057
 	}
1058 1058
 
1059 1059
 
@@ -1063,9 +1063,9 @@  discard block
 block discarded – undo
1063 1063
 	 * @return EE_Ticket
1064 1064
 	 */
1065 1065
 	public function get_ticket_with_earliest_start_time() {
1066
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1067
-		$query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) );
1068
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1066
+		$where['Datetime.EVT_ID'] = $this->ID();
1067
+		$query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC'));
1068
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1069 1069
 	}
1070 1070
 
1071 1071
 
@@ -1075,9 +1075,9 @@  discard block
 block discarded – undo
1075 1075
 	 * @return EE_Ticket
1076 1076
 	 */
1077 1077
 	public function get_ticket_with_latest_end_time() {
1078
-		$where[ 'Datetime.EVT_ID' ] = $this->ID();
1079
-		$query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) );
1080
-		return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params );
1078
+		$where['Datetime.EVT_ID'] = $this->ID();
1079
+		$query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC'));
1080
+		return EE_Registry::instance()->load_model('Ticket')->get_one($query_params);
1081 1081
 	}
1082 1082
 
1083 1083
 
@@ -1089,11 +1089,11 @@  discard block
 block discarded – undo
1089 1089
 	public function tickets_on_sale() {
1090 1090
 		$earliest_ticket = $this->get_ticket_with_earliest_start_time();
1091 1091
 		$latest_ticket = $this->get_ticket_with_latest_end_time();
1092
-		if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) {
1092
+		if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) {
1093 1093
 			return FALSE;
1094 1094
 		}
1095 1095
 		//check on sale for these two tickets.
1096
-		if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) {
1096
+		if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) {
1097 1097
 			return TRUE;
1098 1098
 		}
1099 1099
 		return FALSE;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 * @return string
1108 1108
 	 */
1109 1109
 	public function get_permalink() {
1110
-		if ( $this->external_url() ) {
1110
+		if ($this->external_url()) {
1111 1111
 			return $this->external_url();
1112 1112
 		}
1113 1113
 		else {
@@ -1122,10 +1122,10 @@  discard block
 block discarded – undo
1122 1122
 	 * @param array $query_params like EEM_Base::get_all
1123 1123
 	 * @return EE_Term
1124 1124
 	 */
1125
-	public function first_event_category( $query_params = array() ) {
1126
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1127
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1128
-		return EEM_Term::instance()->get_one( $query_params );
1125
+	public function first_event_category($query_params = array()) {
1126
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1127
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1128
+		return EEM_Term::instance()->get_one($query_params);
1129 1129
 	}
1130 1130
 
1131 1131
 
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
 	 * @param array $query_params
1136 1136
 	 * @return EE_Term[]
1137 1137
 	 */
1138
-	public function get_all_event_categories( $query_params = array() ) {
1139
-		$query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories';
1140
-		$query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID();
1141
-		return EEM_Term::instance()->get_all( $query_params );
1138
+	public function get_all_event_categories($query_params = array()) {
1139
+		$query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1140
+		$query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID();
1141
+		return EEM_Term::instance()->get_all($query_params);
1142 1142
 	}
1143 1143
 
1144 1144
 	/**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param array $query_params @see EEM_Base::get_all
1147 1147
 	 * @return EE_Question_Group[]
1148 1148
 	 */
1149
-	public function question_groups($query_params = array()){
1150
-		$query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' ));
1149
+	public function question_groups($query_params = array()) {
1150
+		$query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC'));
1151 1151
 		return $this->get_many_related('Question_Group', $query_params);
1152 1152
 	}
1153 1153
 
@@ -1187,12 +1187,12 @@  discard block
 block discarded – undo
1187 1187
 	 */
1188 1188
 	public function get_admin_edit_link() {
1189 1189
 		EE_Registry::instance()->load_helper('URL');
1190
-		return EEH_URL::add_query_args_and_nonce( array(
1190
+		return EEH_URL::add_query_args_and_nonce(array(
1191 1191
 			'page' => 'espresso_events',
1192 1192
 			'action' => 'edit',
1193 1193
 			'post' => $this->ID()
1194 1194
 			),
1195
-			admin_url( 'admin.php' )
1195
+			admin_url('admin.php')
1196 1196
 		);
1197 1197
 	}
1198 1198
 
@@ -1205,11 +1205,11 @@  discard block
 block discarded – undo
1205 1205
 	 */
1206 1206
 	public function get_admin_settings_link() {
1207 1207
 		EE_Registry::instance()->load_helper('URL');
1208
-		return EEH_URL::add_query_args_and_nonce( array(
1208
+		return EEH_URL::add_query_args_and_nonce(array(
1209 1209
 			'page' => 'espresso_events',
1210 1210
 			'action' => 'default_event_settings'
1211 1211
 			),
1212
-			admin_url( 'admin.php' )
1212
+			admin_url('admin.php')
1213 1213
 		);
1214 1214
 	}
1215 1215
 
@@ -1225,11 +1225,11 @@  discard block
 block discarded – undo
1225 1225
 	public function get_admin_overview_link() {
1226 1226
 
1227 1227
 		EE_Registry::instance()->load_helper('URL');
1228
-		return EEH_URL::add_query_args_and_nonce( array(
1228
+		return EEH_URL::add_query_args_and_nonce(array(
1229 1229
 			'page' => 'espresso_events',
1230 1230
 			'action' => 'default'
1231 1231
 		),
1232
-			admin_url( 'admin.php' )
1232
+			admin_url('admin.php')
1233 1233
 		);
1234 1234
 	}
1235 1235
 
Please login to merge, or discard this patch.