Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created
core/db_models/fields/EE_Money_Field.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...)
4 4
  */
5
-class EE_Money_Field extends EE_Float_Field{
6
-	function get_wpdb_data_type(){
5
+class EE_Money_Field extends EE_Float_Field {
6
+	function get_wpdb_data_type() {
7 7
 		return '%f';
8 8
 	}
9 9
 	/**
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
 	 * @param type $schema
16 16
 	 * @return string
17 17
 	 */
18
-	function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){
18
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
19 19
 		$pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
20 20
 
21
-		if($schema == 'localized_float'){
21
+		if ($schema == 'localized_float') {
22 22
 			return $pretty_float;
23 23
 		}
24
-		if($schema == 'no_currency_code'){
24
+		if ($schema == 'no_currency_code') {
25 25
 //			echo "schema no currency!";
26 26
 			$display_code = false;
27
-		}else{
27
+		} else {
28 28
 			$display_code = true;
29 29
 		}
30 30
 		//we don't use the $pretty_float because format_currency will take care of it.
31
-		return EEH_Template::format_currency( $value_on_field_to_be_outputted, false, $display_code );
31
+		return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
32 32
 	}
33 33
 
34 34
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		//now it's a float-style string or number
48 48
 		$float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
49 49
 		//round to the correctly number of decimal places for this  currency
50
-		$rounded_value = round($float_val,  EE_Registry::instance()->CFG->currency->dec_plc);
50
+		$rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
51 51
 		return $rounded_value;
52 52
 	}
53 53
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Datetime_Field
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 * @param string 	$pretty_date_format
112 112
 	 * @param string 	$pretty_time_format
113 113
 	 */
114
-	public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){
114
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') {
115 115
 
116
-		$this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format');
117
-		$this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format');
118
-		$this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format');
119
-		$this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format');
116
+		$this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format');
117
+		$this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format');
118
+		$this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format');
119
+		$this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format');
120 120
 
121
-		parent::__construct( $table_column, $nice_name, $nullable, $default_value );
122
-		$this->set_timezone( $timezone_string );
121
+		parent::__construct($table_column, $nice_name, $nullable, $default_value);
122
+		$this->set_timezone($timezone_string);
123 123
 
124 124
 	}
125 125
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @return DateTimeZone
139 139
 	 */
140 140
 	public function get_UTC_DateTimeZone() {
141
-		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' );
141
+		return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC');
142 142
 	}
143 143
 
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return DateTimeZone
148 148
 	 */
149 149
 	public function get_blog_DateTimeZone() {
150
-		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' );
150
+		return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string('');
151 151
 	}
152 152
 
153 153
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp
158 158
 	 * @return DateTime
159 159
 	 */
160
-	public function prepare_for_set( $value_inputted_for_field_on_model_object ) {
161
-		return $this->_get_date_object( $value_inputted_for_field_on_model_object );
160
+	public function prepare_for_set($value_inputted_for_field_on_model_object) {
161
+		return $this->_get_date_object($value_inputted_for_field_on_model_object);
162 162
 	}
163 163
 
164 164
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 * @param bool $pretty If we're returning the pretty formats or standard format string.
175 175
 	 * @return string    The final assembled format string.
176 176
 	 */
177
-	protected function _get_date_time_output( $pretty = FALSE ) {
177
+	protected function _get_date_time_output($pretty = FALSE) {
178 178
 
179
-		switch ( $this->_date_time_output ) {
179
+		switch ($this->_date_time_output) {
180 180
 			case 'time' :
181 181
 				return $pretty ? $this->_pretty_time_format : $this->_time_format;
182 182
 				break;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 				break;
187 187
 
188 188
 			default :
189
-				return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format;
189
+				return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format;
190 190
 		}
191 191
 	}
192 192
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param string $what acceptable values are 'time' or 'date'.  Any other value will be set but will always result in both 'date' and 'time' being returned.
201 201
 	 * @return void
202 202
 	 */
203
-	public function set_date_time_output( $what = NULL ) {
203
+	public function set_date_time_output($what = NULL) {
204 204
 		$this->_date_time_output = $what;
205 205
 	}
206 206
 
@@ -216,15 +216,15 @@  discard block
 block discarded – undo
216 216
 	 * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
217 217
 	 * @return void
218 218
 	 */
219
-	public function set_timezone( $timezone_string ) {
220
-		if( empty( $timezone_string ) && $this->_timezone_string != NULL ){
219
+	public function set_timezone($timezone_string) {
220
+		if (empty($timezone_string) && $this->_timezone_string != NULL) {
221 221
 			// leave the timezone AS-IS if we already have one and
222 222
 			// the function arg didn't provide one
223 223
 			return;
224 224
 		}
225
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
226
-		$this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC';
227
-		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string );
225
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
226
+		$this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC';
227
+		$this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string);
228 228
 	}
229 229
 
230 230
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * @param string $timezone_string
237 237
 	 * @return \DateTimeZone
238 238
 	 */
239
-	protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) {
240
-		return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) );
239
+	protected function _create_timezone_object_from_timezone_string($timezone_string = '') {
240
+		return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string));
241 241
 	}
242 242
 
243 243
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @param bool   $pretty Whether to set pretty format or not.
263 263
 	 * @return void
264 264
 	 */
265
-	public function set_date_format( $format, $pretty = false ) {
266
-		if ( $pretty ) {
265
+	public function set_date_format($format, $pretty = false) {
266
+		if ($pretty) {
267 267
 			$this->_pretty_date_format = $format;
268 268
 		} else {
269 269
 			$this->_date_format = $format;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @param bool   $pretty Whether to get pretty format or not.
279 279
 	 * @return string
280 280
 	 */
281
-	public function get_date_format( $pretty = false ) {
281
+	public function get_date_format($pretty = false) {
282 282
 		return $pretty ? $this->_pretty_date_format : $this->_date_format;
283 283
 	}
284 284
 
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 * @param bool   $pretty Whether to set pretty format or not.
294 294
 	 * @return void
295 295
 	 */
296
-	public function set_time_format( $format, $pretty = false ) {
297
-		if ( $pretty ) {
296
+	public function set_time_format($format, $pretty = false) {
297
+		if ($pretty) {
298 298
 			$this->_pretty_time_format = $format;
299 299
 		} else {
300 300
 			$this->_time_format = $format;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @param bool   $pretty Whether to get pretty format or not.
310 310
 	 * @return string
311 311
 	 */
312
-	public function get_time_format( $pretty = false ) {
312
+	public function get_time_format($pretty = false) {
313 313
 		return $pretty ? $this->_pretty_time_format : $this->_time_format;
314 314
 	}
315 315
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
325 325
 	 * @return void
326 326
 	 */
327
-	public function set_pretty_date_format( $format ) {
327
+	public function set_pretty_date_format($format) {
328 328
 		$this->_pretty_date_format = $format;
329 329
 	}
330 330
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
342 342
 	 * @return void
343 343
 	 */
344
-	public function set_pretty_time_format( $format ) {
344
+	public function set_pretty_time_format($format) {
345 345
 		$this->_pretty_time_format = $format;
346 346
 	}
347 347
 
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 	 * @param DateTime    $current current DateTime object for the datetime field
354 354
 	 * @return DateTime
355 355
 	 */
356
-	public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){
356
+	public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) {
357 357
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
358
-		if ( $time_to_set_string instanceof DateTime ) {
358
+		if ($time_to_set_string instanceof DateTime) {
359 359
 			$parsed = array(
360 360
 				'hour' => $time_to_set_string->format('H'),
361 361
 				'minute' => $time_to_set_string->format('i'),
@@ -363,12 +363,12 @@  discard block
 block discarded – undo
363 363
 				);
364 364
 		} else {
365 365
 			//parse incoming string
366
-			$parsed = date_parse_from_format( $this->_time_format, $time_to_set_string );
366
+			$parsed = date_parse_from_format($this->_time_format, $time_to_set_string);
367 367
 		}
368 368
 
369 369
 		//make sure $current is in the correct timezone.
370
-		$current->setTimezone( $this->_DateTimeZone );
371
-		return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] );
370
+		$current->setTimezone($this->_DateTimeZone);
371
+		return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']);
372 372
 	}
373 373
 
374 374
 
@@ -379,9 +379,9 @@  discard block
 block discarded – undo
379 379
 	 * @param DateTime    $current current DateTime object for the datetime field
380 380
 	 * @return DateTime
381 381
 	 */
382
-	public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){
382
+	public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) {
383 383
 		//if $time_to_set_string is datetime object, then let's use it to set the parse array.  Otherwise parse the string.
384
-		if ( $date_to_set_string instanceof DateTime ) {
384
+		if ($date_to_set_string instanceof DateTime) {
385 385
 			$parsed = array(
386 386
 				'year' => $date_to_set_string->format('Y'),
387 387
 				'month' => $date_to_set_string->format('m'),
@@ -389,12 +389,12 @@  discard block
 block discarded – undo
389 389
 				);
390 390
 		} else {
391 391
 			//parse incoming string
392
-			$parsed = date_parse_from_format( $this->_date_format, $date_to_set_string );
392
+			$parsed = date_parse_from_format($this->_date_format, $date_to_set_string);
393 393
 		}
394 394
 
395 395
 		//make sure $current is in the correct timezone
396
-		$current->setTimezone( $this->_DateTimeZone );
397
-		return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] );
396
+		$current->setTimezone($this->_DateTimeZone);
397
+		return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']);
398 398
 	}
399 399
 
400 400
 
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 	 * @param  DateTime $DateTime
407 407
 	 * @return string formatted date time for given timezone
408 408
 	 */
409
-	public function prepare_for_get( $DateTime ) {
410
-		return $this->_prepare_for_display( $DateTime  );
409
+	public function prepare_for_get($DateTime) {
410
+		return $this->_prepare_for_display($DateTime);
411 411
 	}
412 412
 
413 413
 
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 * @param null     $schema
423 423
 	 * @return string
424 424
 	 */
425
-	public function prepare_for_pretty_echoing( $DateTime, $schema = null ) {
426
-		return $this->_prepare_for_display( $DateTime, $schema ? $schema : true );
425
+	public function prepare_for_pretty_echoing($DateTime, $schema = null) {
426
+		return $this->_prepare_for_display($DateTime, $schema ? $schema : true);
427 427
 	}
428 428
 
429 429
 
@@ -437,36 +437,36 @@  discard block
 block discarded – undo
437 437
 	 * @return string
438 438
 	 * @throws \EE_Error
439 439
 	 */
440
-	protected function _prepare_for_display( $DateTime, $schema = false ) {
441
-		if ( ! $DateTime instanceof DateTime  ) {
442
-			if ( $this->_nullable ) {
440
+	protected function _prepare_for_display($DateTime, $schema = false) {
441
+		if ( ! $DateTime instanceof DateTime) {
442
+			if ($this->_nullable) {
443 443
 				return '';
444 444
 			} else {
445
-				if ( WP_DEBUG ) {
446
-					throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) );
445
+				if (WP_DEBUG) {
446
+					throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename));
447 447
 				} else {
448
-					$DateTime = new DateTime( "now" );
449
-					EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) );
448
+					$DateTime = new DateTime("now");
449
+					EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.  When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename));
450 450
 				}
451 451
 			}
452 452
 		}
453
-		$format_string = $this->_get_date_time_output( $schema );
453
+		$format_string = $this->_get_date_time_output($schema);
454 454
 		//make sure datetime_value is in the correct timezone (in case that's been updated).
455
-		$DateTime->setTimezone( $this->_DateTimeZone );
456
-		if ( $schema ) {
457
-			if( $this->_display_timezone() ) {
455
+		$DateTime->setTimezone($this->_DateTimeZone);
456
+		if ($schema) {
457
+			if ($this->_display_timezone()) {
458 458
 				//must be explicit because schema could equal true.
459
-				if( $schema === 'no_html' ){
460
-					$timezone_string = ' (' . $DateTime->format( 'T' )  . ')';
461
-				}else{
462
-					$timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>';
459
+				if ($schema === 'no_html') {
460
+					$timezone_string = ' ('.$DateTime->format('T').')';
461
+				} else {
462
+					$timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>';
463 463
 				}
464 464
 			} else {
465 465
 				$timezone_string = '';
466 466
 			}
467
-			return $DateTime->format( $format_string ) . $timezone_string;
467
+			return $DateTime->format($format_string).$timezone_string;
468 468
 		} else {
469
-			return $DateTime->format( $format_string );
469
+			return $DateTime->format($format_string);
470 470
 		}
471 471
 	}
472 472
 
@@ -480,18 +480,18 @@  discard block
 block discarded – undo
480 480
 	 * @return string mysql timestamp in UTC
481 481
 	 * @throws \EE_Error
482 482
 	 */
483
-	public function prepare_for_use_in_db( $datetime_value ) {
483
+	public function prepare_for_use_in_db($datetime_value) {
484 484
 		//we allow an empty value or DateTime object, but nothing else.
485
-		if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) {
486
-			throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) );
485
+		if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) {
486
+			throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso'));
487 487
 		}
488 488
 
489
-		if ( $datetime_value instanceof DateTime ) {
490
-			return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format );
489
+		if ($datetime_value instanceof DateTime) {
490
+			return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format);
491 491
 		}
492 492
 
493 493
 		// if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true
494
-		return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null;
494
+		return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null;
495 495
 	}
496 496
 
497 497
 
@@ -504,20 +504,20 @@  discard block
 block discarded – undo
504 504
 	 * @param string $datetime_string mysql timestamp in UTC
505 505
 	 * @return  mixed null | DateTime
506 506
 	 */
507
-	public function prepare_for_set_from_db( $datetime_string ) {
507
+	public function prepare_for_set_from_db($datetime_string) {
508 508
 		//if $datetime_value is empty, and ! $this->_nullable, just use time()
509
-		if ( empty( $datetime_string) && $this->_nullable ) {
509
+		if (empty($datetime_string) && $this->_nullable) {
510 510
 			return null;
511 511
 		}
512 512
 		// datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating
513
-		$DateTime = empty( $datetime_string ) ? new DateTime( 'now', $this->get_UTC_DateTimeZone() ) : DateTime::createFromFormat( EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone() );
513
+		$DateTime = empty($datetime_string) ? new DateTime('now', $this->get_UTC_DateTimeZone()) : DateTime::createFromFormat(EE_Datetime_Field::mysql_timestamp_format, $datetime_string, $this->get_UTC_DateTimeZone());
514 514
 
515
-		if ( ! $DateTime instanceof DateTime ) {
515
+		if ( ! $DateTime instanceof DateTime) {
516 516
 			//if still no datetime object, then let's just use now
517
-			$DateTime = new DateTime( 'now', $this->get_UTC_DateTimeZone() );
517
+			$DateTime = new DateTime('now', $this->get_UTC_DateTimeZone());
518 518
 		}
519 519
 		// THEN apply the field's set DateTimeZone
520
-		$DateTime->setTimezone( $this->_DateTimeZone );
520
+		$DateTime->setTimezone($this->_DateTimeZone);
521 521
 		return $DateTime;
522 522
 	}
523 523
 
@@ -534,15 +534,15 @@  discard block
 block discarded – undo
534 534
 	protected function _display_timezone() {
535 535
 
536 536
 		// first let's do a comparison of timezone strings.  If they match then we can get out without any further calculations
537
-		$blog_string = get_option( 'timezone_string' );
538
-		if ( $blog_string == $this->_timezone_string ) {
537
+		$blog_string = get_option('timezone_string');
538
+		if ($blog_string == $this->_timezone_string) {
539 539
 			return FALSE;
540 540
 		}
541 541
 		// now we need to calc the offset for the timezone string so we can compare with the blog offset.
542
-		$this_offset = $this->get_timezone_offset( $this->_DateTimeZone );
543
-		$blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() );
542
+		$this_offset = $this->get_timezone_offset($this->_DateTimeZone);
543
+		$blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone());
544 544
 		// now compare
545
-		if ( $blog_offset === $this_offset ) {
545
+		if ($blog_offset === $this_offset) {
546 546
 			return FALSE;
547 547
 		}
548 548
 		return TRUE;
@@ -560,24 +560,24 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @return DateTime
562 562
 	 */
563
-	protected function _get_date_object( $date_string ) {
563
+	protected function _get_date_object($date_string) {
564 564
 		//first if this is an empty date_string and nullable is allowed, just return null.
565
-		if ( $this->_nullable && empty( $date_string ) ) {
565
+		if ($this->_nullable && empty($date_string)) {
566 566
 			return null;
567 567
 		}
568 568
 
569 569
 		// if incoming date
570
-		if ( $date_string instanceof DateTime ) {
571
-			$date_string->setTimezone( $this->_DateTimeZone );
570
+		if ($date_string instanceof DateTime) {
571
+			$date_string->setTimezone($this->_DateTimeZone);
572 572
 			return $date_string;
573 573
 		}
574 574
 		// if empty date_string and made it here.
575 575
 		// Return a datetime object for now in the given timezone.
576
-		if ( empty( $date_string ) ) {
577
-			return new DateTime( "now", $this->_DateTimeZone );
576
+		if (empty($date_string)) {
577
+			return new DateTime("now", $this->_DateTimeZone);
578 578
 		}
579 579
 		// if $date_string is matches something that looks like a Unix timestamp let's just use it.
580
-		if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) {
580
+		if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) {
581 581
 			try {
582 582
 				/**
583 583
 				 * This is operating under the assumption that the incoming Unix timestamp is
@@ -585,29 +585,29 @@  discard block
 block discarded – undo
585 585
 				 * current_time('timestamp');
586 586
 				 *
587 587
 				 */
588
-				$DateTime = new DateTime( "now", $this->_DateTimeZone );
589
-				return $DateTime->setTimestamp( $date_string );
590
-			 } catch ( Exception $e )  {
588
+				$DateTime = new DateTime("now", $this->_DateTimeZone);
589
+				return $DateTime->setTimestamp($date_string);
590
+			 } catch (Exception $e) {
591 591
 			 	// should be rare, but if things got fooled then let's just continue
592 592
 			 }
593 593
 		}
594 594
 		//not a unix timestamp.  So we will use the set format on this object and set timezone to
595 595
 		//create the DateTime object.
596
-		$format = $this->_date_format . ' ' . $this->_time_format;
596
+		$format = $this->_date_format.' '.$this->_time_format;
597 597
 		try {
598
-			$DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone );
599
-			if ( ! $DateTime instanceof DateTime ) {
598
+			$DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone);
599
+			if ( ! $DateTime instanceof DateTime) {
600 600
 				throw new EE_Error(
601 601
 					sprintf(
602
-						__( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ),
602
+						__('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'),
603 603
 						$date_string,
604 604
 						$format
605 605
 					)
606 606
 				);
607 607
 			}
608
-		} catch ( Exception $e ) {
608
+		} catch (Exception $e) {
609 609
 			// if we made it here then likely then something went really wrong.  Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone.
610
-			$DateTime = new DateTime( "now", $this->_DateTimeZone );
610
+			$DateTime = new DateTime("now", $this->_DateTimeZone);
611 611
 		}
612 612
 		return $DateTime;
613 613
 	}
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 	 * @param null          $time
622 622
 	 * @return mixed
623 623
 	 */
624
-	public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) {
625
-		$time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time();
626
-		$transitions = $DateTimeZone->getTransitions( $time );
624
+	public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) {
625
+		$time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
626
+		$transitions = $DateTimeZone->getTransitions($time);
627 627
 		return $transitions[0]['offset'];
628 628
 	}
629 629
 
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
 	 * @param  string $timezone_string
636 636
 	 * @return string           abbreviation
637 637
 	 */
638
-	public function get_timezone_abbrev( $timezone_string ) {
639
-		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string );
640
-		$dateTime = new DateTime( 'now', new DateTimeZone( $timezone_string ) );
641
-		return $dateTime->format( 'T' );
638
+	public function get_timezone_abbrev($timezone_string) {
639
+		$timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string);
640
+		$dateTime = new DateTime('now', new DateTimeZone($timezone_string));
641
+		return $dateTime->format('T');
642 642
 	}
643 643
 
644 644
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Serialized_Text_Field.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * However, when inserting into the DB, it should be serialized.
8 8
  * Upon retrieval from the DB, it should be unserialized back into an array.
9 9
  */
10
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
11
-class EE_Serialized_Text_Field extends EE_Text_Field_Base{
10
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
11
+class EE_Serialized_Text_Field extends EE_Text_Field_Base {
12 12
 	/**
13 13
 	 * Value SHOULD be an array, and we want to now convert it to a serialized string
14 14
 	 * @param array $value_of_field_on_model_object
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 		return maybe_serialize($value_of_field_on_model_object);
19 19
 	}
20 20
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
21
-		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize( $value_inputted_for_field_on_model_object );
22
-		if(is_string($value_inputted_for_field_on_model_object)){
21
+		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object);
22
+		if (is_string($value_inputted_for_field_on_model_object)) {
23 23
 			return parent::prepare_for_set($value_inputted_for_field_on_model_object);
24
-		}elseif(is_array($value_inputted_for_field_on_model_object)){
25
-			return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object);
26
-		}else{//so they passed NULL or an INT or something wack
24
+		}elseif (is_array($value_inputted_for_field_on_model_object)) {
25
+			return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object);
26
+		} else {//so they passed NULL or an INT or something wack
27 27
 			return $value_inputted_for_field_on_model_object;
28 28
 		}
29 29
 	}
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @return array
34 34
 	 */
35 35
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
36
-		return EEH_Array::maybe_unserialize( $value_found_in_db_for_model_object );
36
+		return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object);
37 37
 	}
38 38
 
39 39
 	/**
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 * @return string
44 44
 	 */
45 45
 	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
46
-		switch($schema){
46
+		switch ($schema) {
47 47
 			case 'print_r':
48
-				$pretty_value = print_r($value_on_field_to_be_outputted,true);
48
+				$pretty_value = print_r($value_on_field_to_be_outputted, true);
49 49
 				break;
50 50
 			case 'as_table':
51 51
 				$pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted);
52 52
 				break;
53 53
 			default:
54
-				$pretty_value = implode(", ",$value_on_field_to_be_outputted);
54
+				$pretty_value = implode(", ", $value_on_field_to_be_outputted);
55 55
 		}
56 56
 		return $pretty_value;
57 57
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Payment.model.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * Payment Model
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @author				Michael Nelson, Brent Christensen
10 10
  *
11 11
  */
12
-class EEM_Payment extends EEM_Base implements EEMI_Payment{
12
+class EEM_Payment extends EEM_Base implements EEMI_Payment {
13 13
 
14 14
   	// private instance of the Payment object
15 15
 	protected static $_instance = NULL;
@@ -57,28 +57,28 @@  discard block
 block discarded – undo
57 57
 	 *		@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)
58 58
 	 *		@return EEM_Payment
59 59
 	 */
60
-	protected function __construct( $timezone ) {
60
+	protected function __construct($timezone) {
61 61
 
62
-		$this->singular_item = __('Payment','event_espresso');
63
-		$this->plural_item = __('Payments','event_espresso');
62
+		$this->singular_item = __('Payment', 'event_espresso');
63
+		$this->plural_item = __('Payments', 'event_espresso');
64 64
 
65 65
 		$this->_tables = array(
66
-			'Payment'=>new EE_Primary_Table('esp_payment','PAY_ID')
66
+			'Payment'=>new EE_Primary_Table('esp_payment', 'PAY_ID')
67 67
 		);
68 68
 		$this->_fields = array(
69 69
 			'Payment'=>array(
70
-				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID','event_espresso')),
71
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
72
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
73
-				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted','event_espresso'), false, time(), $timezone ),
74
-				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment','event_espresso'), false, 'CART'),
75
-				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for','event_espresso'), false, 0),
70
+				'PAY_ID'=>new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')),
71
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
72
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'),
73
+				'PAY_timestamp'=> new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, time(), $timezone),
74
+				'PAY_source'=>new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'),
75
+				'PAY_amount'=>new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0),
76 76
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, NULL, 'Payment_Method'),
77
-				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment','event_espresso'), false, ''),
78
-				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number','event_espresso'), true, ''),
79
-				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number','event_espresso'), true, ''),
80
-				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info','event_espresso'), true, ''),
81
-				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment','event_espresso'), true, ''),
77
+				'PAY_gateway_response'=>new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''),
78
+				'PAY_txn_id_chq_nmbr'=>new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''),
79
+				'PAY_po_number'=>new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''),
80
+				'PAY_extra_accntng'=>new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''),
81
+				'PAY_details'=>new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''),
82 82
 				'PAY_redirect_url'=>new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true),
83 83
 				'PAY_redirect_args'=>new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)
84 84
 			)
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 			'Status'=> new EE_Belongs_To_Relation(),
89 89
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
90 90
 			'Registration_Payment' => new EE_Has_Many_Relation(),
91
-			'Registration' => new EE_HABTM_Relation( 'Registration_Payment' ),
91
+			'Registration' => new EE_HABTM_Relation('Registration_Payment'),
92 92
 		);
93 93
 		$this->_model_chain_to_wp_user = 'Payment_Method';
94 94
 		$this->_caps_slug = 'transactions';
95
-		parent::__construct( $timezone );
95
+		parent::__construct($timezone);
96 96
 	}
97 97
 
98 98
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $PAY_txn_id_chq_nmbr
105 105
 	 * @return EE_Payment
106 106
 	 */
107
-	public function get_payment_by_txn_id_chq_nmbr( $PAY_txn_id_chq_nmbr ){
107
+	public function get_payment_by_txn_id_chq_nmbr($PAY_txn_id_chq_nmbr) {
108 108
 		return $this->get_one(array(array('PAY_txn_id_chq_nmbr'=>$PAY_txn_id_chq_nmbr)));
109 109
 	}
110 110
 
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 	 *		@param	string	$status_of_payment one of EEM_Payment::status_id_*, like 'PAP','PCN',etc. If none is provided, gets payments with any status
121 121
 	*		@return		EE_Payment[]
122 122
 	*/
123
-	public function get_payments_for_transaction( $TXN_ID = FALSE, $status_of_payment = null ) {
123
+	public function get_payments_for_transaction($TXN_ID = FALSE, $status_of_payment = null) {
124 124
 		// all payments for a TXN ordered chronologically
125
-		$query_params = array( array( 'TXN_ID' => $TXN_ID ), 'order_by' => array( 'PAY_timestamp' => 'ASC' ));
125
+		$query_params = array(array('TXN_ID' => $TXN_ID), 'order_by' => array('PAY_timestamp' => 'ASC'));
126 126
 		// if provided with a status, search specifically for that status. Otherwise get them all
127
-		if ( $status_of_payment ){
127
+		if ($status_of_payment) {
128 128
 			$query_params[0]['STS_ID'] = $status_of_payment;
129 129
 		}
130 130
 		// retrieve payments
131
-		return $this->get_all ( $query_params );
131
+		return $this->get_all($query_params);
132 132
 	}
133 133
 
134 134
 
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 	 * @param int $TXN_ID
139 139
 	 * @return EE_Payment[]
140 140
 	 */
141
-	public function get_approved_payments_for_transaction( $TXN_ID = 0 ) {
142
-		return $this->get_payments_for_transaction( $TXN_ID, EEM_Payment::status_id_approved );
141
+	public function get_approved_payments_for_transaction($TXN_ID = 0) {
142
+		return $this->get_payments_for_transaction($TXN_ID, EEM_Payment::status_id_approved);
143 143
 
144 144
 	}
145 145
 
@@ -160,36 +160,36 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return EE_Payment[]
162 162
 	 */
163
-	public function get_payments_made_between_dates( $start_date = '', $end_date = '', $format = '', $timezone = '' ) {
164
-		$timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
163
+	public function get_payments_made_between_dates($start_date = '', $end_date = '', $format = '', $timezone = '') {
164
+		$timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
165 165
 		//if $start_date or $end date, verify $format is included.
166
-		if ( ( ! empty( $start_date ) || ! empty( $end_date ) ) && empty( $format ) ) {
167
-			throw new EE_Error( __('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso' ) );
166
+		if (( ! empty($start_date) || ! empty($end_date)) && empty($format)) {
167
+			throw new EE_Error(__('You included a start date and/or a end date for this method but did not include a format string.  The format string is needed for setting up the query', 'event_espresso'));
168 168
 		}
169
-		$now = new DateTime( 'now' );
169
+		$now = new DateTime('now');
170 170
 		// setup timezone objects once
171
-		$modelDateTimeZone = new DateTimeZone( $this->_timezone );
172
-		$passedDateTimeZone = new DateTimeZone( $timezone );
171
+		$modelDateTimeZone = new DateTimeZone($this->_timezone);
172
+		$passedDateTimeZone = new DateTimeZone($timezone);
173 173
 		// setup start date
174
-		$start_date = ! empty( $start_date ) ? date_create_from_format( $format, $start_date, $passedDateTimeZone ) : $now;
175
-		$start_date->setTimeZone( $modelDateTimeZone );
176
-		$start_date = $start_date->format( 'Y-m-d' ) . ' 00:00:00';
177
-		$start_date = strtotime( $start_date );
174
+		$start_date = ! empty($start_date) ? date_create_from_format($format, $start_date, $passedDateTimeZone) : $now;
175
+		$start_date->setTimeZone($modelDateTimeZone);
176
+		$start_date = $start_date->format('Y-m-d').' 00:00:00';
177
+		$start_date = strtotime($start_date);
178 178
 		// setup end date
179
-		$end_date = ! empty( $end_date ) ? date_create_from_format( $format, $end_date, $passedDateTimeZone ) : $now;
180
-		$end_date->setTimeZone( $modelDateTimeZone );
181
-		$end_date = $end_date->format('Y-m-d') . ' 23:59:59';
182
-		$end_date = strtotime( $end_date );
179
+		$end_date = ! empty($end_date) ? date_create_from_format($format, $end_date, $passedDateTimeZone) : $now;
180
+		$end_date->setTimeZone($modelDateTimeZone);
181
+		$end_date = $end_date->format('Y-m-d').' 23:59:59';
182
+		$end_date = strtotime($end_date);
183 183
 
184 184
 		// make sure our start date is the lowest value and vice versa
185
-		$start = min( $start_date, $end_date );
186
-		$end = max( $start_date, $end_date );
185
+		$start = min($start_date, $end_date);
186
+		$end = max($start_date, $end_date);
187 187
 
188 188
 		//yes we generated the date and time string in utc but we WANT this start date and time used in the set timezone on the model.
189
-		$start_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $start ) . ' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone() );
190
-		$end_date = $this->convert_datetime_for_query( 'PAY_timestamp', date( 'Y-m-d', $end) . ' 23:59:59' , 'Y-m-d H:i:s', $this->get_timezone() );
189
+		$start_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $start).' 00:00:00', 'Y-m-d H:i:s', $this->get_timezone());
190
+		$end_date = $this->convert_datetime_for_query('PAY_timestamp', date('Y-m-d', $end).' 23:59:59', 'Y-m-d H:i:s', $this->get_timezone());
191 191
 
192
-		return $this->get_all(array(array('PAY_timestamp'=>array('>=',$start_date),'PAY_timestamp*'=>array('<=',$end_date))));
192
+		return $this->get_all(array(array('PAY_timestamp'=>array('>=', $start_date), 'PAY_timestamp*'=>array('<=', $end_date))));
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,35 +199,35 @@  discard block
 block discarded – undo
199 199
 	 * returns a string for the approved status
200 200
 	 * @return 	string
201 201
 	 */
202
-	function approved_status(){
202
+	function approved_status() {
203 203
 		return self::status_id_approved;
204 204
 	}
205 205
 	/**
206 206
 	 * returns a string for the pending status
207 207
 	 * @return 	string
208 208
 	 */
209
-	function pending_status(){
209
+	function pending_status() {
210 210
 		return self::status_id_pending;
211 211
 	}
212 212
 	/**
213 213
 	 * returns a string for the cancelled status
214 214
 	 * @return 	string
215 215
 	 */
216
-	function cancelled_status(){
216
+	function cancelled_status() {
217 217
 		return self::status_id_cancelled;
218 218
 	}
219 219
 	/**
220 220
 	 * returns a string for the failed status
221 221
 	 * @return 	string
222 222
 	 */
223
-	function failed_status(){
223
+	function failed_status() {
224 224
 		return self::status_id_failed;
225 225
 	}
226 226
 	/**
227 227
 	 * returns a string for the declined status
228 228
 	 * @return 	string
229 229
 	 */
230
-	function declined_status(){
230
+	function declined_status() {
231 231
 		return self::status_id_declined;
232 232
 	}
233 233
 
Please login to merge, or discard this patch.
core/db_models/EEM_Payment_Method.model.php 1 patch
Spacing   +92 added lines, -92 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
  *
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
 	 * @access   protected
38 38
 	 * @return EEM_Payment_Method
39 39
 	 */
40
-	protected function __construct( $timezone = NULL ) {
41
-		$this->singlular_item = __( 'Payment Method', 'event_espresso' );
42
-		$this->plural_item = __( 'Payment Methods', 'event_espresso' );
43
-		$this->_tables = array( 'Payment_Method' => new EE_Primary_Table( 'esp_payment_method', 'PMD_ID' ) );
40
+	protected function __construct($timezone = NULL) {
41
+		$this->singlular_item = __('Payment Method', 'event_espresso');
42
+		$this->plural_item = __('Payment Methods', 'event_espresso');
43
+		$this->_tables = array('Payment_Method' => new EE_Primary_Table('esp_payment_method', 'PMD_ID'));
44 44
 		$this->_fields = array(
45 45
 			'Payment_Method' => array(
46
-				'PMD_ID' => new EE_Primary_Key_Int_Field( 'PMD_ID', __( "ID", 'event_espresso' ) ),
47
-				'PMD_type' => new EE_Plain_Text_Field( 'PMD_type', __( "Payment Method Type", 'event_espresso' ), FALSE, 'Admin_Only' ),
48
-				'PMD_name' => new EE_Plain_Text_Field( 'PMD_name', __( "Name", 'event_espresso' ), FALSE ),
49
-				'PMD_desc' => new EE_Post_Content_Field( 'PMD_desc', __( "Description", 'event_espresso' ), FALSE, '' ),
50
-				'PMD_admin_name' => new EE_Plain_Text_Field( 'PMD_admin_name', __( "Admin-Only Name", 'event_espresso' ), TRUE ),
51
-				'PMD_admin_desc' => new EE_Post_Content_Field( 'PMD_admin_desc', __( "Admin-Only Description", 'event_espresso' ), TRUE ),
52
-				'PMD_slug' => new EE_Slug_Field( 'PMD_slug', __( "Slug", 'event_espresso' ), FALSE ),
53
-				'PMD_order' => new EE_Integer_Field( 'PMD_order', __( "Order", 'event_espresso' ), FALSE, 0 ),
54
-				'PMD_debug_mode' => new EE_Boolean_Field( 'PMD_debug_mode', __( "Debug Mode On?", 'event_espresso' ), FALSE, FALSE ),
55
-				'PMD_wp_user' => new EE_WP_User_Field( 'PMD_wp_user', __( "Payment Method Creator ID", 'event_espresso' ), FALSE ),
56
-				'PMD_open_by_default' => new EE_Boolean_Field( 'PMD_open_by_default', __( "Open by Default?", 'event_espresso' ), FALSE, FALSE ), 'PMD_button_url' => new EE_Plain_Text_Field( 'PMD_button_url', __( "Button URL", 'event_espresso' ), TRUE, '' ),
57
-				'PMD_scope' => new EE_Serialized_Text_Field( 'PMD_scope', __( "Usable From?", 'event_espresso' ), FALSE, array() ), //possible values currently are 'CART','ADMIN','API'
46
+				'PMD_ID' => new EE_Primary_Key_Int_Field('PMD_ID', __("ID", 'event_espresso')),
47
+				'PMD_type' => new EE_Plain_Text_Field('PMD_type', __("Payment Method Type", 'event_espresso'), FALSE, 'Admin_Only'),
48
+				'PMD_name' => new EE_Plain_Text_Field('PMD_name', __("Name", 'event_espresso'), FALSE),
49
+				'PMD_desc' => new EE_Post_Content_Field('PMD_desc', __("Description", 'event_espresso'), FALSE, ''),
50
+				'PMD_admin_name' => new EE_Plain_Text_Field('PMD_admin_name', __("Admin-Only Name", 'event_espresso'), TRUE),
51
+				'PMD_admin_desc' => new EE_Post_Content_Field('PMD_admin_desc', __("Admin-Only Description", 'event_espresso'), TRUE),
52
+				'PMD_slug' => new EE_Slug_Field('PMD_slug', __("Slug", 'event_espresso'), FALSE),
53
+				'PMD_order' => new EE_Integer_Field('PMD_order', __("Order", 'event_espresso'), FALSE, 0),
54
+				'PMD_debug_mode' => new EE_Boolean_Field('PMD_debug_mode', __("Debug Mode On?", 'event_espresso'), FALSE, FALSE),
55
+				'PMD_wp_user' => new EE_WP_User_Field('PMD_wp_user', __("Payment Method Creator ID", 'event_espresso'), FALSE),
56
+				'PMD_open_by_default' => new EE_Boolean_Field('PMD_open_by_default', __("Open by Default?", 'event_espresso'), FALSE, FALSE), 'PMD_button_url' => new EE_Plain_Text_Field('PMD_button_url', __("Button URL", 'event_espresso'), TRUE, ''),
57
+				'PMD_scope' => new EE_Serialized_Text_Field('PMD_scope', __("Usable From?", 'event_espresso'), FALSE, array()), //possible values currently are 'CART','ADMIN','API'
58 58
 		) );
59 59
 		$this->_model_relations = array(
60 60
  //			'Event'=>new EE_HABTM_Relation('Event_Payment_Method'),
61 61
 			'Payment' => new EE_Has_Many_Relation(),
62
-			'Currency' => new EE_HABTM_Relation( 'Currency_Payment_Method' ),
62
+			'Currency' => new EE_HABTM_Relation('Currency_Payment_Method'),
63 63
 			'Transaction' => new EE_Has_Many_Relation(),
64 64
 			'WP_User' => new EE_Belongs_To_Relation(),
65 65
 		);
66
-		parent::__construct( $timezone );
66
+		parent::__construct($timezone);
67 67
 	}
68 68
 
69 69
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @param string $slug
74 74
 	 * @return EE_Payment_Method
75 75
 	 */
76
-	public function get_one_by_slug( $slug ) {
77
-		return $this->get_one( array( array( 'PMD_slug' => $slug ) ) );
76
+	public function get_one_by_slug($slug) {
77
+		return $this->get_one(array(array('PMD_slug' => $slug)));
78 78
 	}
79 79
 
80 80
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		return apply_filters(
89 89
 			'FHEE__EEM_Payment_Method__scopes',
90 90
 			array(
91
-				self::scope_cart 		=> __( "Front-end Registration Page", 'event_espresso' ),
92
-				self::scope_admin 	=> __( "Admin Registration Page (no online processing)", 'event_espresso' )
91
+				self::scope_cart 		=> __("Front-end Registration Page", 'event_espresso'),
92
+				self::scope_admin 	=> __("Admin Registration Page (no online processing)", 'event_espresso')
93 93
 			)
94 94
 		);
95 95
 	}
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 	 * @param string $scope like one of EEM_Payment_Method::instance()->scopes()
102 102
 	 * @return boolean
103 103
 	 */
104
-	public function is_valid_scope( $scope ) {
104
+	public function is_valid_scope($scope) {
105 105
 		$scopes = $this->scopes();
106
-		if ( isset( $scopes[ $scope ] ) ) {
106
+		if (isset($scopes[$scope])) {
107 107
 			return TRUE;
108 108
 		} else {
109 109
 			return FALSE;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	 * @throws EE_Error
120 120
 	 * @return EE_Payment_Method[]
121 121
 	 */
122
-	public function get_all_active( $scope = NULL, $query_params = array() ) {
123
-		if( ! isset( $query_params[ 'order_by' ] ) && ! isset( $query_params[ 'order' ] ) ) {
124
-			$query_params = array( 'order_by' => array( 'PMD_order' => 'ASC', 'PMD_ID' => 'ASC' ) );
122
+	public function get_all_active($scope = NULL, $query_params = array()) {
123
+		if ( ! isset($query_params['order_by']) && ! isset($query_params['order'])) {
124
+			$query_params = array('order_by' => array('PMD_order' => 'ASC', 'PMD_ID' => 'ASC'));
125 125
 		}
126
-		return $this->get_all( $this->_get_query_params_for_all_active( $scope, $query_params ) );
126
+		return $this->get_all($this->_get_query_params_for_all_active($scope, $query_params));
127 127
 	}
128 128
 
129 129
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @param array $query_params
133 133
 	 * @return int
134 134
 	 */
135
-	public function count_active( $scope = NULL, $query_params = array() ){
136
-		return $this->count( $this->_get_query_params_for_all_active( $scope, $query_params ) );
135
+	public function count_active($scope = NULL, $query_params = array()) {
136
+		return $this->count($this->_get_query_params_for_all_active($scope, $query_params));
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,21 +144,21 @@  discard block
 block discarded – undo
144 144
 	 * @return array like param of EEM_Base::get_all()
145 145
 	 * @throws EE_Error
146 146
 	 */
147
-	protected function _get_query_params_for_all_active( $scope = NULL, $query_params = array() ){
148
-		if ( $scope ) {
149
-			if ( $this->is_valid_scope( $scope ) ) {
150
-				return array_replace_recursive( array( array( 'PMD_scope' => array( 'LIKE', "%$scope%" ) ) ), $query_params );
147
+	protected function _get_query_params_for_all_active($scope = NULL, $query_params = array()) {
148
+		if ($scope) {
149
+			if ($this->is_valid_scope($scope)) {
150
+				return array_replace_recursive(array(array('PMD_scope' => array('LIKE', "%$scope%"))), $query_params);
151 151
 			} else {
152
-				throw new EE_Error( sprintf( __( "'%s' is not a valid scope for a payment method", "event_espresso" ), $scope ) );
152
+				throw new EE_Error(sprintf(__("'%s' is not a valid scope for a payment method", "event_espresso"), $scope));
153 153
 			}
154 154
 		} else {
155 155
 			$acceptable_scopes = array();
156 156
 			$count = 0;
157
-			foreach ( $this->scopes() as $scope_name => $desc ) {
157
+			foreach ($this->scopes() as $scope_name => $desc) {
158 158
 				$count++;
159
-				$acceptable_scopes[ 'PMD_scope*' . $count ] = array( 'LIKE', '%' . $scope_name . '%' );
159
+				$acceptable_scopes['PMD_scope*'.$count] = array('LIKE', '%'.$scope_name.'%');
160 160
 			}
161
-			return array_replace_recursive( array( array( 'OR*active_scope' => $acceptable_scopes ) ), $query_params );
161
+			return array_replace_recursive(array(array('OR*active_scope' => $acceptable_scopes)), $query_params);
162 162
 		}
163 163
 	}
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 * @return array like param of EEM_Base::get_all()
171 171
 	 * @throws EE_Error
172 172
 	 */
173
-	public function get_query_params_for_all_active( $scope = NULL, $query_params = array() ) {
174
-		return $this->_get_query_params_for_all_active( $scope, $query_params );
173
+	public function get_query_params_for_all_active($scope = NULL, $query_params = array()) {
174
+		return $this->_get_query_params_for_all_active($scope, $query_params);
175 175
 	}
176 176
 
177 177
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array  $query_params
182 182
 	 * @return EE_Payment_Method
183 183
 	 */
184
-	public function get_one_active( $scope = NULL, $query_params = array() ) {
185
-		return $this->get_one( $this->_get_query_params_for_all_active( $scope, $query_params ) );
184
+	public function get_one_active($scope = NULL, $query_params = array()) {
185
+		return $this->get_one($this->_get_query_params_for_all_active($scope, $query_params));
186 186
 	}
187 187
 
188 188
 
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param string $type
193 193
 	 * @return EE_Payment_Method
194 194
 	 */
195
-	public function get_one_of_type( $type ) {
196
-		return $this->get_one( array( array( 'PMD_type' => $type ) ) );
195
+	public function get_one_of_type($type) {
196
+		return $this->get_one(array(array('PMD_type' => $type)));
197 197
 	}
198 198
 
199 199
 
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
 	 * @return EE_Payment_Method
207 207
 	 * @throws EE_Error
208 208
 	 */
209
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ) {
209
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
210 210
 		//first: check if it's a slug
211
-		if( is_string( $base_class_obj_or_id ) ) {
212
-			$obj = $this->get_one_by_slug( $base_class_obj_or_id );
213
-			if( $obj ) {
211
+		if (is_string($base_class_obj_or_id)) {
212
+			$obj = $this->get_one_by_slug($base_class_obj_or_id);
213
+			if ($obj) {
214 214
 				return $obj;
215 215
 			}
216 216
 		}
217 217
 		//ok so it wasn't a slug we were passed. try the usual then (ie, it's an object or an ID)
218 218
 		try {
219
-			return parent::ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db );
219
+			return parent::ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db);
220 220
 		}
221
-		catch ( EE_Error $e ) {
221
+		catch (EE_Error $e) {
222 222
 			//handle it outside the catch
223 223
 		}
224
-		throw new EE_Error( sprintf( __( "'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso" ), $base_class_obj_or_id ) );
224
+		throw new EE_Error(sprintf(__("'%s' is neither a Payment Method ID, slug, nor object.", "event_espresso"), $base_class_obj_or_id));
225 225
 	}
226 226
 
227 227
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 * @param mixed $base_obj_or_id_or_slug
233 233
 	 * @return int
234 234
 	 */
235
-	function ensure_is_ID( $base_obj_or_id_or_slug ) {
236
-		if ( is_string( $base_obj_or_id_or_slug ) ) {
235
+	function ensure_is_ID($base_obj_or_id_or_slug) {
236
+		if (is_string($base_obj_or_id_or_slug)) {
237 237
 			//assume it's a slug
238
-			$base_obj_or_id_or_slug = $this->get_one_by_slug( $base_obj_or_id_or_slug );
238
+			$base_obj_or_id_or_slug = $this->get_one_by_slug($base_obj_or_id_or_slug);
239 239
 		}
240
-		return parent::ensure_is_ID( $base_obj_or_id_or_slug );
240
+		return parent::ensure_is_ID($base_obj_or_id_or_slug);
241 241
 	}
242 242
 
243 243
 
@@ -246,36 +246,36 @@  discard block
 block discarded – undo
246 246
 	 * Verifies the button urls on all the passed payment methods have a valid button url. If not, resets them to their default.
247 247
 	 * @param EE_Payment_Method[] $payment_methods. If NULL is provided defaults to all payment methods active in the cart
248 248
 	 */
249
-	function verify_button_urls( $payment_methods = NULL ) {
250
-		$payment_methods = is_array( $payment_methods ) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
-		foreach ( $payment_methods as $payment_method ) {
249
+	function verify_button_urls($payment_methods = NULL) {
250
+		$payment_methods = is_array($payment_methods) ? $payment_methods : $this->get_all_active(EEM_Payment_Method::scope_cart);
251
+		foreach ($payment_methods as $payment_method) {
252 252
 			try {
253 253
 				$current_button_url = $payment_method->button_url();
254
-				$buttons_urls_to_try = apply_filters( 'FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
-					'current_ssl' => str_replace( "http://", "https://", $current_button_url ),
256
-					'current' => str_replace( "https://", "http://", $current_button_url ),
257
-					'default_ssl' => str_replace( "http://", "https://", $payment_method->type_obj()->default_button_url() ),
258
-					'default' => str_replace( "https://", "http://", $payment_method->type_obj()->default_button_url() ),
259
-				) );
260
-				foreach( $buttons_urls_to_try as $button_url_to_try ) {
261
-					if(
254
+				$buttons_urls_to_try = apply_filters('FHEE__EEM_Payment_Method__verify_button_urls__button_urls_to_try', array(
255
+					'current_ssl' => str_replace("http://", "https://", $current_button_url),
256
+					'current' => str_replace("https://", "http://", $current_button_url),
257
+					'default_ssl' => str_replace("http://", "https://", $payment_method->type_obj()->default_button_url()),
258
+					'default' => str_replace("https://", "http://", $payment_method->type_obj()->default_button_url()),
259
+				));
260
+				foreach ($buttons_urls_to_try as $button_url_to_try) {
261
+					if (
262 262
 							(//this is the current url and it exists, regardless of SSL issues
263 263
 								$button_url_to_try == $current_button_url &&
264 264
 								EEH_URL::remote_file_exists(
265 265
 										$button_url_to_try,
266 266
 										array(
267 267
 											'sslverify' => false,
268
-											'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
268
+											'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
269 269
 											) )
270 270
 							)
271 271
 							||
272 272
 							(//this is NOT the current url and it exists with a working SSL cert
273 273
 								$button_url_to_try != $current_button_url &&
274
-								EEH_URL::remote_file_exists( $button_url_to_try )
274
+								EEH_URL::remote_file_exists($button_url_to_try)
275 275
 							) ) {
276
-						if( $current_button_url != $button_url_to_try ){
277
-							$payment_method->save( array( 'PMD_button_url' => $button_url_to_try ) );
278
-							EE_Error::add_attention( sprintf( __( "Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso" ), $payment_method->name(), $button_url_to_try ) );
276
+						if ($current_button_url != $button_url_to_try) {
277
+							$payment_method->save(array('PMD_button_url' => $button_url_to_try));
278
+							EE_Error::add_attention(sprintf(__("Payment Method %s's button url was set to %s, because the old image either didnt exist or SSL was recently enabled.", "event_espresso"), $payment_method->name(), $button_url_to_try));
279 279
 						}
280 280
 						//this image exists. So if wasn't set before, now it is;
281 281
 						//or if it was already set, we have nothing to do
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 					}
284 284
 				}
285 285
 			}
286
-			catch ( EE_Error $e ) {
287
-				$payment_method->set_active( FALSE );
286
+			catch (EE_Error $e) {
287
+				$payment_method->set_active(FALSE);
288 288
 			}
289 289
 		}
290 290
 	}
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 	 * @param array $rows
299 299
 	 * @return EE_Payment_Method[]
300 300
 	 */
301
-	protected function _create_objects( $rows = array() ) {
302
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
303
-		$payment_methods = parent::_create_objects( $rows );
301
+	protected function _create_objects($rows = array()) {
302
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
303
+		$payment_methods = parent::_create_objects($rows);
304 304
 		/* @var $payment_methods EE_Payment_Method[] */
305 305
 		$usable_payment_methods = array();
306
-		foreach ( $payment_methods as $key => $payment_method ) {
307
-			if ( EE_Payment_Method_Manager::instance()->payment_method_type_exists( $payment_method->type() ) ) {
308
-				$usable_payment_methods[ $key ] = $payment_method;
306
+		foreach ($payment_methods as $key => $payment_method) {
307
+			if (EE_Payment_Method_Manager::instance()->payment_method_type_exists($payment_method->type())) {
308
+				$usable_payment_methods[$key] = $payment_method;
309 309
 				//some payment methods enqueue their scripts in EE_PMT_*::__construct
310 310
 				//which is kinda a no-no (just because it's being constructed doesn't mean we need to enqueue
311 311
 				//its scripts). but for backwards-compat we should continue to do that
@@ -314,12 +314,12 @@  discard block
 block discarded – undo
314 314
 				$payment_method->deactivate();
315 315
 				$payment_method->save();
316 316
 				EE_Error::add_persistent_admin_notice(
317
-					'auto-deactivated-' . $payment_method->type(),
317
+					'auto-deactivated-'.$payment_method->type(),
318 318
 					sprintf(
319
-						__( 'The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso' ),
319
+						__('The payment method %1$s was automatically deactivated because it appears its associated Event Espresso Addon was recently deactivated.%2$sIt can be reactivated on the %3$sPlugins admin page%4$s, then you can reactivate the payment method.', 'event_espresso'),
320 320
 						$payment_method->admin_name(),
321 321
 						'<br />',
322
-						'<a href="' . admin_url('plugins.php') . '">',
322
+						'<a href="'.admin_url('plugins.php').'">',
323 323
 						'</a>'
324 324
 					),
325 325
 					true
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @param string 	$scope @see EEM_Payment_Method::get_all_for_events
340 340
 	 * @return EE_Payment_Method[]
341 341
 	 */
342
-	public function get_all_for_transaction( $transaction, $scope ) {
342
+	public function get_all_for_transaction($transaction, $scope) {
343 343
 		//@todo take relations between events and payment methods into account, once that relation exists
344
-		if ( $transaction instanceof EE_Transaction ) {
344
+		if ($transaction instanceof EE_Transaction) {
345 345
 			//@todo take the relation between transaction and currencies into account
346 346
 		}
347
-		$currencies_for_events = array( EE_Config::instance()->currency->code );
347
+		$currencies_for_events = array(EE_Config::instance()->currency->code);
348 348
 		//give addons a chance to override what payment methods are chosen based on the transaction
349 349
 		return apply_filters(
350 350
 			'FHEE__EEM_Payment_Method__get_all_for_transaction__payment_methods',
351
-			$this->get_all_active( $scope, array( array( 'Currency.CUR_code' => array( 'IN', $currencies_for_events ) ) ) ),
351
+			$this->get_all_active($scope, array(array('Currency.CUR_code' => array('IN', $currencies_for_events)))),
352 352
 			$transaction,
353 353
 			$scope
354 354
 		);
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 	 * @param EE_Registration|int $registration_or_reg_id  Either the EE_Registration object or the id for the registration.
365 365
 	 * @return EE_Payment|null
366 366
 	 */
367
-	public function get_last_used_for_registration( $registration_or_reg_id ) {
368
-		$registration_id = EEM_Registration::instance()->ensure_is_ID( $registration_or_reg_id );
367
+	public function get_last_used_for_registration($registration_or_reg_id) {
368
+		$registration_id = EEM_Registration::instance()->ensure_is_ID($registration_or_reg_id);
369 369
 
370 370
 		$query_params = array(
371 371
 			0 => array(
372 372
 				'Payment.Registration.REG_ID' => $registration_id,
373 373
 			),
374
-			'order_by' => array( 'Payment.PAY_ID' => 'DESC' )
374
+			'order_by' => array('Payment.PAY_ID' => 'DESC')
375 375
 		);
376
-		return $this->get_one( $query_params );
376
+		return $this->get_one($query_params);
377 377
 	}
378 378
 
379 379
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+require_once (EE_MODELS.'EEM_Base.model.php');
3 3
 /**
4 4
  *
5 5
  * Transaction Model
@@ -67,35 +67,35 @@  discard block
 block discarded – undo
67 67
 	 * @return EEM_Transaction
68 68
 	 * @throws \EE_Error
69 69
 	 */
70
-	protected function __construct( $timezone ) {
71
-		$this->singular_item = __('Transaction','event_espresso');
72
-		$this->plural_item = __('Transactions','event_espresso');
70
+	protected function __construct($timezone) {
71
+		$this->singular_item = __('Transaction', 'event_espresso');
72
+		$this->plural_item = __('Transactions', 'event_espresso');
73 73
 
74 74
 		$this->_tables = array(
75
-			'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID')
75
+			'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID')
76 76
 		);
77 77
 		$this->_fields = array(
78 78
 			'Transaction'=>array(
79
-				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')),
80
-				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ),
81
-				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0),
82
-				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0),
83
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
84
-				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''),
85
-				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''),
79
+				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
80
+				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone),
81
+				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0),
82
+				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
83
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
84
+				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''),
85
+				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''),
86 86
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'),
87
-				'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ),
87
+				'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()),
88 88
 			)
89 89
 		);
90 90
 		$this->_model_relations = array(
91 91
 			'Registration'=>new EE_Has_Many_Relation(),
92 92
 			'Payment'=>new EE_Has_Many_Relation(),
93 93
 			'Status'=>new EE_Belongs_To_Relation(),
94
-			'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items
94
+			'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items
95 95
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
96 96
 		);
97 97
 		$this->_model_chain_to_wp_user = 'Registration.Event';
98
-		parent::__construct( $timezone );
98
+		parent::__construct($timezone);
99 99
 
100 100
 	}
101 101
 
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
 	 * @param string $period
107 107
 	 * @return \stdClass[]
108 108
 	 */
109
-	public function get_revenue_per_day_report( $period = '-1 month' ) {
110
-		$sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', strtotime( $period ) ), 'Y-m-d H:i:s', 'UTC' );
109
+	public function get_revenue_per_day_report($period = '-1 month') {
110
+		$sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), 'Y-m-d H:i:s', 'UTC');
111 111
 
112
-		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'TXN_timestamp' );
112
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
113 113
 		return $this->_get_all_wpdb_results(
114 114
 			array(
115 115
 				array(
116
-					'TXN_timestamp' => array( '>=', $sql_date )
116
+					'TXN_timestamp' => array('>=', $sql_date)
117 117
 				),
118 118
 				'group_by' => 'txnDate',
119
-				'order_by' => array( 'TXN_timestamp' => 'ASC' )
119
+				'order_by' => array('TXN_timestamp' => 'ASC')
120 120
 			),
121 121
 			OBJECT,
122 122
 			array(
123
-				'txnDate' => array( 'DATE(' . $query_interval . ')', '%s' ),
124
-				'revenue' => array( 'SUM(Transaction.TXN_paid)', '%d' )
123
+				'txnDate' => array('DATE('.$query_interval.')', '%s'),
124
+				'revenue' => array('SUM(Transaction.TXN_paid)', '%d')
125 125
 			)
126 126
 		);
127 127
 	}
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 	 * @throws \EE_Error
137 137
 	 * @return mixed
138 138
 	 */
139
-	public function get_revenue_per_event_report( $period = '-1 month' ) {
139
+	public function get_revenue_per_event_report($period = '-1 month') {
140 140
 		global $wpdb;
141
-		$transaction_table = $wpdb->prefix . 'esp_transaction';
142
-		$registration_table = $wpdb->prefix . 'esp_registration';
141
+		$transaction_table = $wpdb->prefix.'esp_transaction';
142
+		$registration_table = $wpdb->prefix.'esp_registration';
143 143
 		$event_table = $wpdb->posts;
144
-		$payment_table = $wpdb->prefix . 'esp_payment';
145
-		$sql_date = date( 'Y-m-d H:i:s', strtotime( $period ) );
144
+		$payment_table = $wpdb->prefix.'esp_payment';
145
+		$sql_date = date('Y-m-d H:i:s', strtotime($period));
146 146
 		$approved_payment_status = EEM_Payment::status_id_approved;
147 147
 		$extra_event_on_join = '';
148 148
 		//exclude events not authored by user if permissions in effect
149
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
150
-			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
149
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
150
+			$extra_event_on_join = ' AND Event.post_author = '.get_current_user_id();
151 151
 		}
152 152
 
153 153
 		return $wpdb->get_results(
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	 * @param string $reg_url_link
188 188
 	 * @return EE_Transaction
189 189
 	 */
190
-	public function get_transaction_from_reg_url_link( $reg_url_link = '' ){
191
-		return $this->get_one( array(
190
+	public function get_transaction_from_reg_url_link($reg_url_link = '') {
191
+		return $this->get_one(array(
192 192
 			array(
193
-				'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' )
193
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '')
194 194
 			)
195 195
 		));
196 196
 	}
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 	 * @return boolean
208 208
 	 * @throws \EE_Error
209 209
 	 */
210
-	public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){
210
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) {
211 211
 		EE_Error::doing_it_wrong(
212
-			__CLASS__ . '::' . __FUNCTION__,
213
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
212
+			__CLASS__.'::'.__FUNCTION__,
213
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
214 214
 			'4.6.0'
215 215
 		);
216 216
 		/** @type EE_Transaction_Processor $transaction_processor */
217
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
217
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
218 218
 		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
219
-			$this->ensure_is_obj( $transaction_obj_or_id )
219
+			$this->ensure_is_obj($transaction_obj_or_id)
220 220
 		);
221 221
 	}
222 222
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			array(
249 249
 				0 => array(
250 250
 					'STS_ID' => EEM_Transaction::failed_status_code,
251
-					'TXN_timestamp' => array( '<', time() - $time_to_leave_alone )
251
+					'TXN_timestamp' => array('<', time() - $time_to_leave_alone)
252 252
 				)
253 253
 			),
254 254
 			$time_to_leave_alone
@@ -261,29 +261,29 @@  discard block
 block discarded – undo
261 261
 		 */
262 262
 		$txn_ids = apply_filters(
263 263
 			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
264
-			EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ),
264
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
265 265
 			$time_to_leave_alone
266 266
 		);
267 267
 		//now that we have the ids to delete
268
-		if ( ! empty( $txn_ids ) && is_array( $txn_ids ) ) {
268
+		if ( ! empty($txn_ids) && is_array($txn_ids)) {
269 269
 			// first, make sure these TXN's are removed the "ee_locked_transactions" array
270
-			EEM_Transaction::unset_locked_transactions( $txn_ids );
270
+			EEM_Transaction::unset_locked_transactions($txn_ids);
271 271
 			// let's get deletin'...
272 272
 			// Why no wpdb->prepare?  Because the data is trusted.
273 273
 			// We got the ids from the original query to get them FROM
274 274
 			// the db (which is sanitized) so no need to prepare them again.
275
-			$query   = '
275
+			$query = '
276 276
 				DELETE
277
-				FROM ' . $this->table() . '
277
+				FROM ' . $this->table().'
278 278
 				WHERE
279
-					TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')';
280
-			$deleted = $wpdb->query( $query );
279
+					TXN_ID IN ( ' . implode(",", $txn_ids).')';
280
+			$deleted = $wpdb->query($query);
281 281
 		}
282
-		if ( $deleted ) {
282
+		if ($deleted) {
283 283
 			/**
284 284
 			 * Allows code to do something after the transactions have been deleted.
285 285
 			 */
286
-			do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids );
286
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
287 287
 		}
288 288
 		return $deleted;
289 289
 	}
@@ -294,17 +294,17 @@  discard block
 block discarded – undo
294 294
 	 * @param array $transaction_IDs
295 295
 	 * @return bool
296 296
 	 */
297
-	public static function unset_locked_transactions( array $transaction_IDs ) {
298
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
297
+	public static function unset_locked_transactions(array $transaction_IDs) {
298
+		$locked_transactions = get_option('ee_locked_transactions', array());
299 299
 		$update = false;
300
-		foreach ( $transaction_IDs as $TXN_ID ) {
301
-			if ( isset( $locked_transactions[ $TXN_ID ] ) ) {
302
-				unset( $locked_transactions[ $TXN_ID ] );
300
+		foreach ($transaction_IDs as $TXN_ID) {
301
+			if (isset($locked_transactions[$TXN_ID])) {
302
+				unset($locked_transactions[$TXN_ID]);
303 303
 				$update = true;
304 304
 			}
305 305
 		}
306
-		if ( $update ) {
307
-			update_option( 'ee_locked_transactions', $locked_transactions );
306
+		if ($update) {
307
+			update_option('ee_locked_transactions', $locked_transactions);
308 308
 		}
309 309
 		return $update;
310 310
 	}
Please login to merge, or discard this patch.
core/EE_Cart.core.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );/**
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, __FUNCTION__, ''); /**
3 3
  *
4 4
  * Event Espresso
5 5
  *
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
 	  * @param EE_Line_Item $grand_total
60 60
 	  * @return \EE_Cart
61 61
 	  */
62
-	public static function instance( EE_Line_Item $grand_total = null ) {
62
+	public static function instance(EE_Line_Item $grand_total = null) {
63 63
 		// rest cart with new grand total ?
64
-		if ( ! empty( $grand_total ) ){
65
-			self::$_instance = new self( $grand_total );
64
+		if ( ! empty($grand_total)) {
65
+			self::$_instance = new self($grand_total);
66 66
 		}
67 67
 		// or maybe retrieve an existing one ?
68
-		if ( ! self::$_instance instanceof EE_Cart ) {
68
+		if ( ! self::$_instance instanceof EE_Cart) {
69 69
 			// try getting the cart out of the session
70 70
 			self::$_instance = EE_Registry::instance()->SSN->cart();
71 71
 		}
72 72
 		// verify that cart is ok and grand total line item exists
73
-		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item ) {
74
-			self::$_instance = new self( $grand_total );
73
+		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
74
+			self::$_instance = new self($grand_total);
75 75
 		}
76 76
 		self::$_instance->get_grand_total();
77 77
 		// once everything is all said and done, save the cart to the EE_Session
78
-		add_action( 'shutdown', array( self::$_instance, 'save_cart' ), 90 );
78
+		add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
79 79
 		return self::$_instance;
80 80
 	}
81 81
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	  * @param EE_Line_Item $grand_total
89 89
 	  * @return \EE_Cart
90 90
 	  */
91
-	 private function __construct( EE_Line_Item $grand_total = NULL ) {
92
-		 do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
93
-		 if ( ! defined( 'ESPRESSO_CART' )) {
94
-			 define( 'ESPRESSO_CART', TRUE );
91
+	 private function __construct(EE_Line_Item $grand_total = NULL) {
92
+		 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
93
+		 if ( ! defined('ESPRESSO_CART')) {
94
+			 define('ESPRESSO_CART', TRUE);
95 95
 		 }
96
-		 if ( $grand_total instanceof EE_Line_Item ) {
97
-			 $this->set_grand_total_line_item( $grand_total );
96
+		 if ($grand_total instanceof EE_Line_Item) {
97
+			 $this->set_grand_total_line_item($grand_total);
98 98
 		 }
99 99
 	 }
100 100
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	 * @param EE_Line_Item $grand_total
106 106
 	 * @return EE_Cart
107 107
 	 */
108
-	public static function reset( EE_Line_Item $grand_total = NULL ){
109
-		remove_action( 'shutdown', array( self::$_instance, 'save_cart'), 90 );
108
+	public static function reset(EE_Line_Item $grand_total = NULL) {
109
+		remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
110 110
 		EE_Registry::instance()->SSN->reset_cart();
111 111
 		self::$_instance = NULL;
112
-		return self::instance( $grand_total );
112
+		return self::instance($grand_total);
113 113
 	}
114 114
 
115 115
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	  * @param EE_Transaction $transaction
121 121
 	  * @return \EE_Cart
122 122
 	  */
123
-	public static function get_cart_from_txn( EE_Transaction $transaction ) {
123
+	public static function get_cart_from_txn(EE_Transaction $transaction) {
124 124
 		$grand_total = $transaction->total_line_item();
125 125
 		$grand_total->get_items();
126 126
 		$grand_total->tax_descendants();
127
-		return EE_Cart::instance( $grand_total );
127
+		return EE_Cart::instance($grand_total);
128 128
 	}
129 129
 
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
134 134
 	 * @return EE_Line_Item
135 135
 	 */
136
-	private function _create_grand_total(){
136
+	private function _create_grand_total() {
137 137
 		$this->_grand_total = EEH_Line_Item::create_total_line_item();
138 138
 		return $this->_grand_total;
139 139
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 *	@return \EE_Line_Item[]
147 147
 	 */
148 148
 	public function get_tickets() {
149
-		return EEH_Line_Item::get_ticket_line_items( $this->_grand_total );
149
+		return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
150 150
 	}
151 151
 
152 152
 
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	public function all_ticket_quantity_count() {
161 161
 		$tickets = $this->get_tickets();
162
-		if ( empty( $tickets )) {
162
+		if (empty($tickets)) {
163 163
 			return 0;
164 164
 		}
165 165
 		$count = 0;
166
-		foreach ( $tickets as $ticket ) {
166
+		foreach ($tickets as $ticket) {
167 167
 			$count = $count + $ticket->get('LIN_quantity');
168 168
 		}
169 169
 		return $count;
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 *  Gets all the tax line items
176 176
 	 * @return \EE_Line_Item[]
177 177
 	 */
178
-	public function get_taxes(){
179
-		return EEH_Line_Item::get_taxes_subtotal( $this->_grand_total )->children();
178
+	public function get_taxes() {
179
+		return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
180 180
 	}
181 181
 
182 182
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * Gets the total line item (which is a parent of all other line items) on this cart
186 186
 	 * @return EE_Line_Item
187 187
 	 */
188
-	public function get_grand_total(){
188
+	public function get_grand_total() {
189 189
 		return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
190 190
 	}
191 191
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 *	@param int $qty
199 199
 	 *	@return TRUE on success, FALSE on fail
200 200
 	 */
201
-	public function add_ticket_to_cart( EE_Ticket $ticket, $qty = 1 ) {
202
-		EEH_Line_Item::add_ticket_purchase( $this->get_grand_total(), $ticket, $qty );
201
+	public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) {
202
+		EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
203 203
 		return $this->save_cart() ? TRUE : FALSE;
204 204
 	}
205 205
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 *	@return float
223 223
 	 */
224 224
 	public function get_applied_taxes() {
225
-		return EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
225
+		return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
226 226
 	}
227 227
 
228 228
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 *	@return float
234 234
 	 */
235 235
 	public function get_cart_grand_total() {
236
-		EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
236
+		EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
237 237
 		return $this->get_grand_total()->total();
238 238
 	}
239 239
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	public function recalculate_all_cart_totals() {
248 248
 		$pre_tax_total = $this->get_cart_total_before_tax();
249
-		$taxes_total = EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
250
-		$this->_grand_total->set_total( $pre_tax_total + $taxes_total );
249
+		$taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
250
+		$this->_grand_total->set_total($pre_tax_total + $taxes_total);
251 251
 		$this->_grand_total->save_this_and_descendants_to_txn();
252 252
 		return $this->get_grand_total()->total();
253 253
 	}
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 *	@param mixed - string or array - line_item_ids
261 261
 	 *	@return int on success, FALSE on fail
262 262
 	 */
263
-	public function delete_items( $line_item_codes = FALSE ) {
264
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
265
-		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes );
263
+	public function delete_items($line_item_codes = FALSE) {
264
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
265
+		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
266 266
 	}
267 267
 
268 268
 
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	 *	@return bool
274 274
 	 */
275 275
 	public function empty_cart() {
276
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
276
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
277 277
 		$this->_grand_total = $this->_create_grand_total();
278
-		return $this->save_cart( TRUE );
278
+		return $this->save_cart(TRUE);
279 279
 	}
280 280
 
281 281
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 *	@return bool
287 287
 	 */
288 288
 	public function delete_cart() {
289
-		$deleted = EEH_Line_Item::delete_all_child_items( $this->_grand_total );
290
-		if ( $deleted ) {
289
+		$deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
290
+		if ($deleted) {
291 291
 			$deleted += $this->_grand_total->delete();
292 292
 			$this->_grand_total = null;
293 293
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 *  know the grand total line item on it
302 302
 	 * @param EE_Line_Item $line_item
303 303
 	 */
304
-	public function set_grand_total_line_item( EE_Line_Item $line_item ) {
304
+	public function set_grand_total_line_item(EE_Line_Item $line_item) {
305 305
 		$this->_grand_total = $line_item;
306 306
 	}
307 307
 
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 	  * @param bool $apply_taxes
314 314
 	  * @return TRUE on success, FALSE on fail
315 315
 	  */
316
-	public function save_cart( $apply_taxes = TRUE ) {
317
-		if ( $apply_taxes && $this->_grand_total instanceof EE_Line_Item ) {
318
-			EEH_Line_Item::ensure_taxes_applied( $this->_grand_total );
316
+	public function save_cart($apply_taxes = TRUE) {
317
+		if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
318
+			EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319 319
 			//make sure we don't cache the transaction because it can get stale
320
-			if( $this->_grand_total->get_one_from_cache( 'Transaction' ) instanceof EE_Transaction &&
321
-				$this->_grand_total->get_one_from_cache( 'Transaction' )->ID()) {
322
-				$this->_grand_total->clear_cache( 'Transaction', null, true );
320
+			if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction &&
321
+				$this->_grand_total->get_one_from_cache('Transaction')->ID()) {
322
+				$this->_grand_total->clear_cache('Transaction', null, true);
323 323
 			}
324 324
 		}
325
-		return EE_Registry::instance()->SSN->set_cart( $this );
325
+		return EE_Registry::instance()->SSN->set_cart($this);
326 326
 	}
327 327
 
328 328
 
Please login to merge, or discard this patch.
form_sections/strategies/validation/EE_URL_Validation_Strategy.strategy.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@  discard block
 block discarded – undo
8 8
  * @since 				4.6
9 9
  *
10 10
  */
11
-class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base{
11
+class EE_URL_Validation_Strategy extends EE_Validation_Strategy_Base {
12 12
 
13 13
 	/**
14 14
 	 * @param null $validation_error_message
15 15
 	 */
16
-	public function __construct( $validation_error_message = NULL ) {
17
-		if( ! $validation_error_message ){
16
+	public function __construct($validation_error_message = NULL) {
17
+		if ( ! $validation_error_message) {
18 18
 			$validation_error_message = __("Please enter a valid URL", "event_espresso");
19 19
 		}
20
-		parent::__construct( $validation_error_message );
20
+		parent::__construct($validation_error_message);
21 21
 	}
22 22
 
23 23
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	 * @throws \EE_Validation_Error
31 31
 	 */
32 32
 	function validate($normalized_value) {
33
-		if( $normalized_value ){
34
-			if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){
35
-				throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url');
36
-			}else{
37
-				if( ! EEH_URL::remote_file_exists(
33
+		if ($normalized_value) {
34
+			if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false) {
35
+				throw new EE_Validation_Error($this->get_validation_error_message(), 'invalid_url');
36
+			} else {
37
+				if ( ! EEH_URL::remote_file_exists(
38 38
 						$normalized_value,
39 39
 						array(
40 40
 							'sslverify' => false, 
41
-							'limit_response_size' => 4095,//we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
42
-						))){
41
+							'limit_response_size' => 4095, //we don't really care for a full response, but we do want headers at least. Lets just ask for a one block
42
+						))) {
43 43
 					throw new EE_Validation_Error(sprintf(__("That URL seems to be broken. Please enter a valid URL", "event_espresso")));
44 44
 				}
45 45
 			}
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @return array
53 53
 	 */
54
-	function get_jquery_validation_rule_array(){
55
-		return array( 'validUrl'=>true, 'messages' => array( 'validUrl' => $this->get_validation_error_message() ) );
54
+	function get_jquery_validation_rule_array() {
55
+		return array('validUrl'=>true, 'messages' => array('validUrl' => $this->get_validation_error_message()));
56 56
 	}
57 57
 }
58 58
 
Please login to merge, or discard this patch.
strategies/display/EE_Admin_File_Uploader_Display_Strategy.strategy.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since                4.6
9 9
  *
10 10
  */
11
-class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base{
11
+class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base {
12 12
 
13 13
 	/**
14 14
 	 * return EE_Admin_File_Uploader_Display_Strategy
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 * Besides that, no special consideration should be required to make the media uploader appear, besides having
30 30
 	 * this input displayed.
31 31
 	 */
32
-	static function enqueue_scripts(){
32
+	static function enqueue_scripts() {
33 33
 		wp_enqueue_media();
34 34
 		wp_enqueue_script('media-upload');
35
-		wp_enqueue_script('ee-payments',EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js');
35
+		wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js');
36 36
 	}
37 37
 
38 38
 
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	 * @return string of html to display the field
43 43
 	 */
44 44
 
45
-	function display(){
45
+	function display() {
46 46
 		// the actual input
47 47
 		$input = '<input type="text" size="34" ';
48
-		$input .= 'name="' . $this->_input->html_name() . '" ';
49
-		$input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' : 'class="large-text ee_media_url" ';
50
-		$input .= 'value="' . $this->_input->raw_value_in_form() . '">';
48
+		$input .= 'name="'.$this->_input->html_name().'" ';
49
+		$input .= $this->_input->html_class() != '' ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' : 'class="large-text ee_media_url" ';
50
+		$input .= 'value="'.$this->_input->raw_value_in_form().'">';
51 51
 		// image uploader
52
-		$uploader = EEH_HTML::link( '#', '<img src="' . admin_url( 'images/media-button-image.gif' ) . '" >', __( 'click to add an image', 'event_espresso' ), '', 'ee_media_upload' );
52
+		$uploader = EEH_HTML::link('#', '<img src="'.admin_url('images/media-button-image.gif').'" >', __('click to add an image', 'event_espresso'), '', 'ee_media_upload');
53 53
 		//only attempt to show the image if it at least exists
54
-		$image = $this->src_exists( $this->_input->raw_value() ) ? EEH_HTML::br(2) . EEH_HTML::img( $this->_input->raw_value(), __( 'logo', 'event_espresso' ), '', 'ee_media_image' ) : '';
54
+		$image = $this->src_exists($this->_input->raw_value()) ? EEH_HTML::br(2).EEH_HTML::img($this->_input->raw_value(), __('logo', 'event_espresso'), '', 'ee_media_image') : '';
55 55
 		// html string
56
-		return EEH_HTML::div( $input . EEH_HTML::nbsp() . $uploader . $image, '', 'ee_media_uploader_area' );
56
+		return EEH_HTML::div($input.EEH_HTML::nbsp().$uploader.$image, '', 'ee_media_uploader_area');
57 57
 	}
58 58
 
59 59
 
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 * @param string $src
65 65
 	 * @return boolean
66 66
 	 */
67
-	protected function src_exists( $src ){
68
-		$results = wp_remote_head( $src );
69
-		if( is_array( $results) && ! $results instanceof WP_Error){
70
-			return strpos($results['headers']['content-type'], "image" ) !== FALSE;
71
-		}else{
67
+	protected function src_exists($src) {
68
+		$results = wp_remote_head($src);
69
+		if (is_array($results) && ! $results instanceof WP_Error) {
70
+			return strpos($results['headers']['content-type'], "image") !== FALSE;
71
+		} else {
72 72
 			return FALSE;
73 73
 		}
74 74
 	}
Please login to merge, or discard this patch.