Completed
Branch old/BUG-7514-7935-7936-price-o... (518ae6)
by
unknown
25:14 queued 22:51
created
core/db_classes/EE_Datetime.class.php 2 patches
Spacing   +122 added lines, -122 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
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 	 * @param string $timezone
72 72
 	 * @return EE_Datetime
73 73
 	 */
74
-	public static function new_instance( $props_n_values = array(), $timezone = NULL ) {
75
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
76
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
74
+	public static function new_instance($props_n_values = array(), $timezone = NULL) {
75
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
76
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
77 77
 	}
78 78
 
79 79
 
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 * @param null  $timezone
84 84
 	 * @return EE_Datetime
85 85
 	 */
86
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = NULL ) {
87
-		return new self( $props_n_values, TRUE, $timezone );
86
+	public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) {
87
+		return new self($props_n_values, TRUE, $timezone);
88 88
 	}
89 89
 
90 90
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	/**
93 93
 	 * @param $name
94 94
 	 */
95
-	public function set_name( $name ) {
96
-		$this->set( 'DTT_name', $name );
95
+	public function set_name($name) {
96
+		$this->set('DTT_name', $name);
97 97
 	}
98 98
 
99 99
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @param $description
103 103
 	 */
104
-	public function set_description( $description ) {
105
-		$this->set( 'DTT_description', $description );
104
+	public function set_description($description) {
105
+		$this->set('DTT_description', $description);
106 106
 	}
107 107
 
108 108
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @access        public
116 116
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
117 117
 	 */
118
-	public function set_start_date( $date ) {
119
-		$this->_set_date_for( $date, 'DTT_EVT_start' );
118
+	public function set_start_date($date) {
119
+		$this->_set_date_for($date, 'DTT_EVT_start');
120 120
 	}
121 121
 
122 122
 
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * @access        public
130 130
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
131 131
 	 */
132
-	public function set_start_time( $time ) {
133
-		$this->_set_time_for( $time, 'DTT_EVT_start' );
132
+	public function set_start_time($time) {
133
+		$this->_set_time_for($time, 'DTT_EVT_start');
134 134
 	}
135 135
 
136 136
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 	 * @access        public
144 144
 	 * @param        string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
145 145
 	 */
146
-	public function set_end_date( $date ) {
147
-		$this->_set_date_for( $date, 'DTT_EVT_end' );
146
+	public function set_end_date($date) {
147
+		$this->_set_date_for($date, 'DTT_EVT_end');
148 148
 	}
149 149
 
150 150
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @access        public
158 158
 	 * @param        string $time a string representation of the event time ex:  9am  or  7:30 PM
159 159
 	 */
160
-	public function set_end_time( $time ) {
161
-		$this->_set_time_for( $time, 'DTT_EVT_end' );
160
+	public function set_end_time($time) {
161
+		$this->_set_time_for($time, 'DTT_EVT_end');
162 162
 	}
163 163
 
164 164
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @access        public
172 172
 	 * @param        int $reg_limit
173 173
 	 */
174
-	public function set_reg_limit( $reg_limit ) {
175
-		$this->set( 'DTT_reg_limit', $reg_limit );
174
+	public function set_reg_limit($reg_limit) {
175
+		$this->set('DTT_reg_limit', $reg_limit);
176 176
 	}
177 177
 
178 178
 
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 * @access        public
184 184
 	 * @param        int $sold
185 185
 	 */
186
-	public function set_sold( $sold ) {
187
-		$this->set( 'DTT_sold', $sold );
186
+	public function set_sold($sold) {
187
+		$this->set('DTT_sold', $sold);
188 188
 	}
189 189
 
190 190
 
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * increments sold by amount passed by $qty
194 194
 	 * @param int $qty
195 195
 	 */
196
-	function increase_sold( $qty = 1 ) {
197
-		$sold = $this->get_raw( 'DTT_sold' ) + $qty;
198
-		$this->set_sold( $sold );
196
+	function increase_sold($qty = 1) {
197
+		$sold = $this->get_raw('DTT_sold') + $qty;
198
+		$this->set_sold($sold);
199 199
 	}
200 200
 
201 201
 
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 * decrements (subtracts) sold amount passed by $qty
205 205
 	 * @param int $qty
206 206
 	 */
207
-	function decrease_sold( $qty = 1 ) {
208
-		$sold = $this->get_raw( 'DTT_sold' ) - $qty;
207
+	function decrease_sold($qty = 1) {
208
+		$sold = $this->get_raw('DTT_sold') - $qty;
209 209
 		// sold can not go below zero
210
-		$sold = max( 0, $sold );
211
-		$this->set_sold( $sold );
210
+		$sold = max(0, $sold);
211
+		$this->set_sold($sold);
212 212
 	}
213 213
 
214 214
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @return string
219 219
 	 */
220 220
 	public function name() {
221
-		return $this->get( 'DTT_name' );
221
+		return $this->get('DTT_name');
222 222
 	}
223 223
 
224 224
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @return string
229 229
 	 */
230 230
 	public function description() {
231
-		return $this->get( 'DTT_description' );
231
+		return $this->get('DTT_description');
232 232
 	}
233 233
 
234 234
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @return boolean          TRUE if is primary, FALSE if not.
239 239
 	 */
240 240
 	public function is_primary() {
241
-		return $this->get( 'DTT_is_primary' );
241
+		return $this->get('DTT_is_primary');
242 242
 	}
243 243
 
244 244
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @return int         The order of the datetime for this event.
249 249
 	 */
250 250
 	public function order() {
251
-		return $this->get( 'DTT_order' );
251
+		return $this->get('DTT_order');
252 252
 	}
253 253
 
254 254
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @return int
259 259
 	 */
260 260
 	public function parent() {
261
-		return $this->get( 'DTT_parent' );
261
+		return $this->get('DTT_parent');
262 262
 	}
263 263
 
264 264
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 * @param    bool   $echo         - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats)
275 275
 	 * @return    string|bool|void  string on success, FALSE on fail
276 276
 	 */
277
-	private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) {
277
+	private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) {
278 278
 		$field_name = "DTT_EVT_{$start_or_end}";
279
-		$dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo );
280
-		if ( !$echo ) {
279
+		$dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo);
280
+		if ( ! $echo) {
281 281
 			return $dtt;
282 282
 		}
283 283
 	}
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 * @internal      param string $dt_format - string representation of date format defaults to 'F j, Y'
294 294
 	 * @return        mixed        string on success, FALSE on fail
295 295
 	 */
296
-	public function start_date( $dt_frmt = NULL ) {
297
-		return $this->_show_datetime( 'D', 'start', $dt_frmt );
296
+	public function start_date($dt_frmt = NULL) {
297
+		return $this->_show_datetime('D', 'start', $dt_frmt);
298 298
 	}
299 299
 
300 300
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * Echoes start_date()
304 304
 	 * @param string $dt_frmt
305 305
 	 */
306
-	public function e_start_date( $dt_frmt = NULL ) {
307
-		$this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE );
306
+	public function e_start_date($dt_frmt = NULL) {
307
+		$this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE);
308 308
 	}
309 309
 
310 310
 
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 * @internal      param string $dt_format - string representation of date format defaults to 'F j, Y'
319 319
 	 * @return        mixed        string on success, FALSE on fail
320 320
 	 */
321
-	public function end_date( $dt_frmt = NULL ) {
322
-		return $this->_show_datetime( 'D', 'end', $dt_frmt );
321
+	public function end_date($dt_frmt = NULL) {
322
+		return $this->_show_datetime('D', 'end', $dt_frmt);
323 323
 	}
324 324
 
325 325
 
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * Echoes the end date. See end_date()
329 329
 	 * @param string $dt_frmt
330 330
 	 */
331
-	public function e_end_date( $dt_frmt = NULL ) {
332
-		$this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE );
331
+	public function e_end_date($dt_frmt = NULL) {
332
+		$this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE);
333 333
 	}
334 334
 
335 335
 
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
 	 * @internal      param string $dt_format - string representation of date format defaults to WP settings
344 344
 	 * @return        mixed        string on success, FALSE on fail
345 345
 	 */
346
-	public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
347
-		$dt_frmt = !empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt;
348
-		$start = str_replace( ' ', '&nbsp;', date_i18n( $dt_frmt, strtotime( $this->_show_datetime( 'D', 'start', NULL, NULL ) ) ) );
349
-		$end = str_replace( ' ', '&nbsp;', date_i18n( $dt_frmt, strtotime( $this->_show_datetime( 'D', 'end', NULL, NULL ) ) ) );
350
-		return $start != $end ? $start . $conjunction . $end : $start;
346
+	public function date_range($dt_frmt = NULL, $conjunction = ' - ') {
347
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
348
+		$start = str_replace(' ', '&nbsp;', date_i18n($dt_frmt, strtotime($this->_show_datetime('D', 'start', NULL, NULL))));
349
+		$end = str_replace(' ', '&nbsp;', date_i18n($dt_frmt, strtotime($this->_show_datetime('D', 'end', NULL, NULL))));
350
+		return $start != $end ? $start.$conjunction.$end : $start;
351 351
 	}
352 352
 
353 353
 
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param null   $dt_frmt
357 357
 	 * @param string $conjunction
358 358
 	 */
359
-	public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) {
360
-		echo $this->date_range( $dt_frmt, $conjunction );
359
+	public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') {
360
+		echo $this->date_range($dt_frmt, $conjunction);
361 361
 	}
362 362
 
363 363
 
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
370 370
 	 * @return        mixed        string on success, FALSE on fail
371 371
 	 */
372
-	public function start_time( $tm_format = NULL ) {
373
-		return $this->_show_datetime( 'T', 'start', NULL, $tm_format );
372
+	public function start_time($tm_format = NULL) {
373
+		return $this->_show_datetime('T', 'start', NULL, $tm_format);
374 374
 	}
375 375
 
376 376
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	/**
379 379
 	 * @param null $tm_format
380 380
 	 */
381
-	public function e_start_time( $tm_format = NULL ) {
382
-		$this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE );
381
+	public function e_start_time($tm_format = NULL) {
382
+		$this->_show_datetime('T', 'start', NULL, $tm_format, TRUE);
383 383
 	}
384 384
 
385 385
 
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 * @param        string $tm_format - string representation of time format defaults to 'g:i a'
392 392
 	 * @return        mixed        string on success, FALSE on fail
393 393
 	 */
394
-	public function end_time( $tm_format = NULL ) {
395
-		return $this->_show_datetime( 'T', 'end', NULL, $tm_format );
394
+	public function end_time($tm_format = NULL) {
395
+		return $this->_show_datetime('T', 'end', NULL, $tm_format);
396 396
 	}
397 397
 
398 398
 
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	/**
401 401
 	 * @param null $tm_format
402 402
 	 */
403
-	public function e_end_time( $tm_format = NULL ) {
404
-		$this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE );
403
+	public function e_end_time($tm_format = NULL) {
404
+		$this->_show_datetime('T', 'end', NULL, $tm_format, TRUE);
405 405
 	}
406 406
 
407 407
 
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 * @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
415 415
 	 * @return        mixed        string on success, FALSE on fail
416 416
 	 */
417
-	public function time_range( $tm_format = NULL, $conjunction = ' - ' ) {
418
-		$tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt;
419
-		$start = str_replace( ' ', '&nbsp;', date_i18n( $tm_format, strtotime( $this->_show_datetime( 'T', 'start', NULL, NULL ) ) ) );
420
-		$end = str_replace( ' ', '&nbsp;', date_i18n( $tm_format, strtotime( $this->_show_datetime( 'T', 'end', NULL, NULL ) ) ) );
421
-		return $start != $end ? $start . $conjunction . $end : $start;
417
+	public function time_range($tm_format = NULL, $conjunction = ' - ') {
418
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
419
+		$start = str_replace(' ', '&nbsp;', date_i18n($tm_format, strtotime($this->_show_datetime('T', 'start', NULL, NULL))));
420
+		$end = str_replace(' ', '&nbsp;', date_i18n($tm_format, strtotime($this->_show_datetime('T', 'end', NULL, NULL))));
421
+		return $start != $end ? $start.$conjunction.$end : $start;
422 422
 	}
423 423
 
424 424
 
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param null   $tm_format
428 428
 	 * @param string $conjunction
429 429
 	 */
430
-	public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) {
431
-		echo $this->time_range( $tm_format, $conjunction );
430
+	public function e_time_range($tm_format = NULL, $conjunction = ' - ') {
431
+		echo $this->time_range($tm_format, $conjunction);
432 432
 	}
433 433
 
434 434
 
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @internal      param string $dt_format - string representation of date format defaults to 'F j, Y'
443 443
 	 * @return        mixed        string on success, FALSE on fail
444 444
 	 */
445
-	public function start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) {
446
-		return $this->_show_datetime( '', 'start', $dt_frmt, $tm_format );
445
+	public function start_date_and_time($dt_frmt = NULL, $tm_format = NULL) {
446
+		return $this->_show_datetime('', 'start', $dt_frmt, $tm_format);
447 447
 	}
448 448
 
449 449
 
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param null $dt_frmt
453 453
 	 * @param null $tm_format
454 454
 	 */
455
-	public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) {
456
-		$this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE );
455
+	public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) {
456
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE);
457 457
 	}
458 458
 
459 459
 
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
 	 * @param bool   $round_up
468 468
 	 * @return float|int|mixed
469 469
 	 */
470
-	public function length( $units = 'seconds', $round_up = FALSE ) {
471
-		$start = $this->get_raw( 'DTT_EVT_start' );
472
-		$end = $this->get_raw( 'DTT_EVT_end' );
470
+	public function length($units = 'seconds', $round_up = FALSE) {
471
+		$start = $this->get_raw('DTT_EVT_start');
472
+		$end = $this->get_raw('DTT_EVT_end');
473 473
 		$length_in_units = $end - $start;
474
-		switch ( $units ) {
474
+		switch ($units) {
475 475
 			//NOTE: We purposefully don't use "break;"
476 476
 			//in order to chain the divisions
477 477
 			case 'days':
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
 				$length_in_units /= 60;
483 483
 			case 'seconds':
484 484
 			default:
485
-				$length_in_units = ceil( $length_in_units );
485
+				$length_in_units = ceil($length_in_units);
486 486
 		}
487
-		if ( $round_up ) {
488
-			$length_in_units = max( $length_in_units, 1 );
487
+		if ($round_up) {
488
+			$length_in_units = max($length_in_units, 1);
489 489
 		}
490 490
 		return $length_in_units;
491 491
 	}
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @internal      param string $dt_format - string representation of date format defaults to 'F j, Y'
502 502
 	 * @return        mixed        string on success, FALSE on fail
503 503
 	 */
504
-	public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
505
-		return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format );
504
+	public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
505
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
506 506
 	}
507 507
 
508 508
 
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @param bool $dt_frmt
512 512
 	 * @param bool $tm_format
513 513
 	 */
514
-	public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) {
515
-		$this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE );
514
+	public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) {
515
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE);
516 516
 	}
517 517
 
518 518
 
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 	 * @return        int
525 525
 	 */
526 526
 	public function start() {
527
-		return $this->get_raw( 'DTT_EVT_start' );
527
+		return $this->get_raw('DTT_EVT_start');
528 528
 	}
529 529
 
530 530
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 * @return        int
537 537
 	 */
538 538
 	public function end() {
539
-		return $this->get_raw( 'DTT_EVT_end' );
539
+		return $this->get_raw('DTT_EVT_end');
540 540
 	}
541 541
 
542 542
 
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	 * @return        mixed        int on success, FALSE on fail
549 549
 	 */
550 550
 	public function reg_limit() {
551
-		return $this->get_raw( 'DTT_reg_limit' );
551
+		return $this->get_raw('DTT_reg_limit');
552 552
 	}
553 553
 
554 554
 
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	 * @return        mixed        int on success, FALSE on fail
561 561
 	 */
562 562
 	public function sold() {
563
-		return $this->get_raw( 'DTT_sold' );
563
+		return $this->get_raw('DTT_sold');
564 564
 	}
565 565
 
566 566
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 	 * @return        boolean
573 573
 	 */
574 574
 	public function sold_out() {
575
-		return $this->get( 'DTT_reg_limit' ) > 0 && $this->get( 'DTT_sold' ) >= $this->get( 'DTT_reg_limit' ) ? TRUE : FALSE;
575
+		return $this->get('DTT_reg_limit') > 0 && $this->get('DTT_sold') >= $this->get('DTT_reg_limit') ? TRUE : FALSE;
576 576
 	}
577 577
 
578 578
 
@@ -585,15 +585,15 @@  discard block
 block discarded – undo
585 585
 	 * @param      bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left (because if all tickets attached to this datetime have no spaces left, then this datetime IS effectively sold out)  However, there are cases where we just want to know the spaces remaining for this particular datetime hence the flag.
586 586
 	 * @return        int
587 587
 	 */
588
-	public function spaces_remaining( $consider_tickets = FALSE ) {
588
+	public function spaces_remaining($consider_tickets = FALSE) {
589 589
 		// tickets remaining availalbe for purchase
590 590
 		//no need for special checks for infinite, because if DTT_reg_limit == INF, then INF - x = INF
591
-		$dtt_remaining = $this->get( 'DTT_reg_limit' ) - $this->get( 'DTT_sold' );
592
-		if ( !$consider_tickets ) {
591
+		$dtt_remaining = $this->get('DTT_reg_limit') - $this->get('DTT_sold');
592
+		if ( ! $consider_tickets) {
593 593
 			return $dtt_remaining;
594 594
 		}
595 595
 		$tickets_remaining = $this->tickets_remaining();
596
-		return min( $dtt_remaining, $tickets_remaining );
596
+		return min($dtt_remaining, $tickets_remaining);
597 597
 	}
598 598
 
599 599
 
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 	 * @param array $query_params like EEM_Base::get_all's
605 605
 	 * @return int
606 606
 	 */
607
-	public function tickets_remaining( $query_params = array() ) {
608
-		return EEM_Ticket::instance()->sum_tickets_currently_available_at_datetime( $this->ID(), $query_params );
607
+	public function tickets_remaining($query_params = array()) {
608
+		return EEM_Ticket::instance()->sum_tickets_currently_available_at_datetime($this->ID(), $query_params);
609 609
 	}
610 610
 
611 611
 
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 	 * @param array $query_params like EEM_Base::get_all's
617 617
 	 * @return int
618 618
 	 */
619
-	public function sum_tickets_initially_available( $query_params = array() ) {
620
-		return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' );
619
+	public function sum_tickets_initially_available($query_params = array()) {
620
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
621 621
 	}
622 622
 
623 623
 
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	 * @return int
630 630
 	 */
631 631
 	public function total_tickets_available_at_this_datetime() {
632
-		return min( array( $this->tickets_remaining(), $this->spaces_remaining() ) );
632
+		return min(array($this->tickets_remaining(), $this->spaces_remaining()));
633 633
 	}
634 634
 
635 635
 
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	 * @return boolean
641 641
 	 */
642 642
 	public function is_upcoming() {
643
-		return ( $this->get_raw( 'DTT_EVT_start' ) > time() );
643
+		return ($this->get_raw('DTT_EVT_start') > time());
644 644
 	}
645 645
 
646 646
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 * @return boolean
651 651
 	 */
652 652
 	public function is_active() {
653
-		return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() );
653
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
654 654
 	}
655 655
 
656 656
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	 * @return boolean
661 661
 	 */
662 662
 	public function is_expired() {
663
-		return ( $this->get_raw( 'DTT_EVT_end' ) < time() );
663
+		return ($this->get_raw('DTT_EVT_end') < time());
664 664
 	}
665 665
 
666 666
 
@@ -671,16 +671,16 @@  discard block
 block discarded – undo
671 671
 	 */
672 672
 	public function get_active_status() {
673 673
 		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
674
-		if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) {
674
+		if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) {
675 675
 			return EE_Datetime::sold_out;
676 676
 		}
677
-		if ( $this->is_expired() ) {
677
+		if ($this->is_expired()) {
678 678
 			return EE_Datetime::expired;
679 679
 		}
680
-		if ( $this->is_upcoming() ) {
680
+		if ($this->is_upcoming()) {
681 681
 			return EE_Datetime::upcoming;
682 682
 		}
683
-		if ( $this->is_active() ) {
683
+		if ($this->is_active()) {
684 684
 			return EE_Datetime::active;
685 685
 		}
686 686
 	}
@@ -693,24 +693,24 @@  discard block
 block discarded – undo
693 693
 	 * @param  boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
694 694
 	 * @return string
695 695
 	 */
696
-	public function get_dtt_display_name( $use_dtt_name = FALSE ) {
697
-		if ( $use_dtt_name ) {
696
+	public function get_dtt_display_name($use_dtt_name = FALSE) {
697
+		if ($use_dtt_name) {
698 698
 			$dttname = $this->name();
699
-			if ( !empty( $dttname ) ) {
699
+			if ( ! empty($dttname)) {
700 700
 				return $dttname;
701 701
 			}
702 702
 		}
703 703
 		//first condition is to see if the months are different
704
-		if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) {
705
-			$displaydate = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' );
704
+		if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) {
705
+			$displaydate = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
706 706
 			//next condition is if its the same month but different day
707 707
 		}
708 708
 		else {
709
-			if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) {
710
-				$displaydate = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' );
709
+			if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) {
710
+				$displaydate = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
711 711
 			}
712 712
 			else {
713
-				$displaydate = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' );
713
+				$displaydate = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a');
714 714
 			}
715 715
 		}
716 716
 		return $displaydate;
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	 * @param array $query_params see EEM_Base::get_all()
724 724
 	 * @return EE_Datetime
725 725
 	 */
726
-	public function tickets( $query_params = array() ) {
727
-		return $this->get_many_related( 'Ticket', $query_params );
726
+	public function tickets($query_params = array()) {
727
+		return $this->get_many_related('Ticket', $query_params);
728 728
 	}
729 729
 
730 730
 
@@ -734,17 +734,17 @@  discard block
 block discarded – undo
734 734
 	 * @param array $query_params like EEM_Base::get_all's
735 735
 	 * @return EE_Ticket[]
736 736
 	 */
737
-	public function ticket_types_available_for_purchase( $query_params = array() ) {
737
+	public function ticket_types_available_for_purchase($query_params = array()) {
738 738
 		// first check if datetime is valid
739
-		if ( !( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) {
739
+		if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) {
740 740
 			return array();
741 741
 		}
742
-		if ( empty( $query_params ) ) {
743
-			$query_params = array( array( 'TKT_start_date' => array( '<=', current_time( 'mysql' ) ), 'TKT_end_date' => array( '>=', current_time( 'mysql' ) ), 'TKT_deleted' => FALSE ) );
742
+		if (empty($query_params)) {
743
+			$query_params = array(array('TKT_start_date' => array('<=', current_time('mysql')), 'TKT_end_date' => array('>=', current_time('mysql')), 'TKT_deleted' => FALSE));
744 744
 		}
745 745
 		//		$query_params[0]['TKT_start_date'] = array('<=',current_time('mysql'));
746 746
 		//		$query_params[0]['TKT_end_date'] = array('>=',current_time('mysql'));
747
-		return $this->tickets( $query_params );
747
+		return $this->tickets($query_params);
748 748
 	}
749 749
 
750 750
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	 * @return EE_Event
755 755
 	 */
756 756
 	public function event() {
757
-		return $this->get_first_related( 'Event' );
757
+		return $this->get_first_related('Event');
758 758
 	}
759 759
 
760 760
 
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 	 * @return int
766 766
 	 */
767 767
 	public function update_sold() {
768
-		$count_regs_for_this_datetime = EEM_Registration::instance()->count( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'Ticket.Datetime.DTT_ID' => $this->ID(), 'REG_deleted' => 0 ) ) );
769
-		$this->set( 'DTT_sold', $count_regs_for_this_datetime );
768
+		$count_regs_for_this_datetime = EEM_Registration::instance()->count(array(array('STS_ID' => EEM_Registration::status_id_approved, 'Ticket.Datetime.DTT_ID' => $this->ID(), 'REG_deleted' => 0)));
769
+		$this->set('DTT_sold', $count_regs_for_this_datetime);
770 770
 		$this->save();
771 771
 		return $count_regs_for_this_datetime;
772 772
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -704,12 +704,10 @@
 block discarded – undo
704 704
 		if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) {
705 705
 			$displaydate = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' );
706 706
 			//next condition is if its the same month but different day
707
-		}
708
-		else {
707
+		} else {
709 708
 			if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) {
710 709
 				$displaydate = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' );
711
-			}
712
-			else {
710
+			} else {
713 711
 				$displaydate = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' );
714 712
 			}
715 713
 		}
Please login to merge, or discard this patch.
core/db_classes/EE_State.class.php 1 patch
Spacing   +20 added lines, -20 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
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 * @param array $props_n_values
33 33
 	 * @return EE_State|mixed
34 34
 	 */
35
-	public static function new_instance( $props_n_values = array() ) {
36
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
37
-		return $has_object ? $has_object : new self( $props_n_values );
35
+	public static function new_instance($props_n_values = array()) {
36
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
37
+		return $has_object ? $has_object : new self($props_n_values);
38 38
 	}
39 39
 
40 40
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @param array $props_n_values
44 44
 	 * @return EE_State
45 45
 	 */
46
-	public static function new_instance_from_db( $props_n_values = array() ) {
47
-		return new self( $props_n_values, TRUE );
46
+	public static function new_instance_from_db($props_n_values = array()) {
47
+		return new self($props_n_values, TRUE);
48 48
 	}
49 49
 
50 50
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 * @return bool
54 54
 	 */
55 55
 	public function country_iso() {
56
-		return $this->get( 'CNT_ISO' );
56
+		return $this->get('CNT_ISO');
57 57
 	}
58 58
 
59 59
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return bool
63 63
 	 */
64 64
 	public function abbrev() {
65
-		return $this->get( 'STA_abbrev' );
65
+		return $this->get('STA_abbrev');
66 66
 	}
67 67
 
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @return bool
72 72
 	 */
73 73
 	public function active() {
74
-		return $this->get( 'STA_active' );
74
+		return $this->get('STA_active');
75 75
 	}
76 76
 
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @return bool
81 81
 	 */
82 82
 	public function name() {
83
-		return $this->get( 'STA_name' );
83
+		return $this->get('STA_name');
84 84
 	}
85 85
 
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return EE_Country
90 90
 	 */
91 91
 	public function country() {
92
-		return $this->get_first_related( 'Country' );
92
+		return $this->get_first_related('Country');
93 93
 	}
94 94
 
95 95
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	/**
98 98
 	 * @param $iso
99 99
 	 */
100
-	public function set_country_iso( $iso ) {
101
-		$this->set( 'CNT_ISO', $iso );
100
+	public function set_country_iso($iso) {
101
+		$this->set('CNT_ISO', $iso);
102 102
 	}
103 103
 
104 104
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	/**
107 107
 	 * @param $abbrev
108 108
 	 */
109
-	public function set_abbrev( $abbrev ) {
110
-		$this->set( 'STA_abbrev', $abbrev );
109
+	public function set_abbrev($abbrev) {
110
+		$this->set('STA_abbrev', $abbrev);
111 111
 	}
112 112
 
113 113
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	/**
116 116
 	 * @param $active
117 117
 	 */
118
-	public function set_active( $active ) {
119
-		$this->set( 'STA_active', $active );
118
+	public function set_active($active) {
119
+		$this->set('STA_active', $active);
120 120
 	}
121 121
 
122 122
 
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	/**
125 125
 	 * @param $name
126 126
 	 */
127
-	public function set_name( $name ) {
128
-		$this->set( 'STA_name', $name );
127
+	public function set_name($name) {
128
+		$this->set('STA_name', $name);
129 129
 	}
130 130
 }
131 131
 
Please login to merge, or discard this patch.