@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $props_n_values incoming values |
16 | 16 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
17 | 17 | * used.) |
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
18 | + * @param string[] $date_formats incoming date_formats in an array where the first value is the |
|
19 | 19 | * date_format and the second value is the time format |
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Gets all the extra meta info on this payment |
591 | 591 | * |
592 | 592 | * @param array $query_params like EEM_Base::get_all |
593 | - * @return EE_Extra_Meta |
|
593 | + * @return EE_Base_Class[] |
|
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | 596 | public function extra_meta( $query_params = array() ) { |
@@ -662,11 +662,11 @@ discard block |
||
662 | 662 | $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
663 | 663 | } |
664 | 664 | $form = EEH_HTML::nl( 1 ) |
665 | - . '<form method="' |
|
666 | - . $method |
|
667 | - . '" name="gateway_form" action="' |
|
668 | - . $redirect_url |
|
669 | - . '">'; |
|
665 | + . '<form method="' |
|
666 | + . $method |
|
667 | + . '" name="gateway_form" action="' |
|
668 | + . $redirect_url |
|
669 | + . '">'; |
|
670 | 670 | $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
671 | 671 | $form .= $inside_form_html; |
672 | 672 | $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | EE_Registry::instance()->load_helper( 'HTML' ); |
705 | 705 | foreach ( $args as $name => $value ) { |
706 | 706 | $html .= EEH_HTML::nl( 0 ) |
707 | - . '<input type="hidden" name="' |
|
708 | - . $name |
|
709 | - . '" value="' |
|
710 | - . esc_attr( $value ) |
|
711 | - . '"/>'; |
|
707 | + . '<input type="hidden" name="' |
|
708 | + . $name |
|
709 | + . '" value="' |
|
710 | + . esc_attr( $value ) |
|
711 | + . '"/>'; |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | return $html; |
@@ -1,5 +1,5 @@ discard block |
||
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 | /** |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
22 | 22 | */ |
23 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
24 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
25 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @return EE_Payment |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
38 | - return new self( $props_n_values, true, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $TXN_ID |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
51 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
50 | + public function set_transaction_id($TXN_ID = 0) { |
|
51 | + $this->set('TXN_ID', $TXN_ID); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | 62 | public function transaction() { |
63 | - return $this->get_first_related( 'Transaction' ); |
|
63 | + return $this->get_first_related('Transaction'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $STS_ID |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function set_status( $STS_ID = '' ) { |
|
76 | - $this->set( 'STS_ID', $STS_ID ); |
|
75 | + public function set_status($STS_ID = '') { |
|
76 | + $this->set('STS_ID', $STS_ID); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $timestamp |
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | - public function set_timestamp( $timestamp = 0 ) { |
|
89 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
88 | + public function set_timestamp($timestamp = 0) { |
|
89 | + $this->set('PAY_timestamp', $timestamp); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $PAY_source |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - public function set_source( $PAY_source = '' ) { |
|
102 | - $this->set( 'PAY_source', $PAY_source ); |
|
101 | + public function set_source($PAY_source = '') { |
|
102 | + $this->set('PAY_source', $PAY_source); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function set_amount( $amount = 0.00 ) { |
|
115 | - $this->set( 'PAY_amount', (float)$amount ); |
|
114 | + public function set_amount($amount = 0.00) { |
|
115 | + $this->set('PAY_amount', (float) $amount); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $gateway_response |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function set_gateway_response( $gateway_response = '' ) { |
|
128 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
127 | + public function set_gateway_response($gateway_response = '') { |
|
128 | + $this->set('PAY_gateway_response', $gateway_response); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ), |
149 | 149 | '4.6.0' |
150 | 150 | ); |
151 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
151 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string $txn_id_chq_nmbr |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
164 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
163 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
164 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $po_number |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_po_number( $po_number = '' ) { |
|
177 | - $this->set( 'PAY_po_number', $po_number ); |
|
176 | + public function set_po_number($po_number = '') { |
|
177 | + $this->set('PAY_po_number', $po_number); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string $extra_accntng |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
190 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
189 | + public function set_extra_accntng($extra_accntng = '') { |
|
190 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param bool $via_admin |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_payment_made_via_admin( $via_admin = false ) { |
|
203 | - if ( $via_admin ) { |
|
204 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_admin ); |
|
202 | + public function set_payment_made_via_admin($via_admin = false) { |
|
203 | + if ($via_admin) { |
|
204 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
205 | 205 | } else { |
206 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_cart ); |
|
206 | + $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string|array $details |
217 | 217 | * @throws \EE_Error |
218 | 218 | */ |
219 | - public function set_details( $details = '' ) { |
|
220 | - if ( is_array( $details ) ) { |
|
221 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' ) ); |
|
219 | + public function set_details($details = '') { |
|
220 | + if (is_array($details)) { |
|
221 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
222 | 222 | } else { |
223 | - $details = wp_strip_all_tags( $details ); |
|
223 | + $details = wp_strip_all_tags($details); |
|
224 | 224 | } |
225 | - $this->set( 'PAY_details', $details ); |
|
225 | + $this->set('PAY_details', $details); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $redirect_url |
234 | 234 | * @throws \EE_Error |
235 | 235 | */ |
236 | - public function set_redirect_url( $redirect_url ) { |
|
237 | - $this->set( 'PAY_redirect_url', $redirect_url ); |
|
236 | + public function set_redirect_url($redirect_url) { |
|
237 | + $this->set('PAY_redirect_url', $redirect_url); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array $redirect_args |
246 | 246 | * @throws \EE_Error |
247 | 247 | */ |
248 | - public function set_redirect_args( $redirect_args ) { |
|
249 | - $this->set( 'PAY_redirect_args', $redirect_args ); |
|
248 | + public function set_redirect_args($redirect_args) { |
|
249 | + $this->set('PAY_redirect_args', $redirect_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function TXN_ID() { |
261 | - return $this->get( 'TXN_ID' ); |
|
261 | + return $this->get('TXN_ID'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @throws \EE_Error |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - return $this->get( 'STS_ID' ); |
|
273 | + return $this->get('STS_ID'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | 284 | public function STS_ID() { |
285 | - return $this->get( 'STS_ID' ); |
|
285 | + return $this->get('STS_ID'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @return string |
297 | 297 | * @throws \EE_Error |
298 | 298 | */ |
299 | - public function timestamp( $dt_frmt = '', $tm_frmt = '' ) { |
|
300 | - return $this->get_i18n_datetime( 'PAY_timestamp', trim( $dt_frmt . ' ' . $tm_frmt) ); |
|
299 | + public function timestamp($dt_frmt = '', $tm_frmt = '') { |
|
300 | + return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt.' '.$tm_frmt)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | 311 | public function source() { |
312 | - return $this->get( 'PAY_source' ); |
|
312 | + return $this->get('PAY_source'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | 324 | public function amount() { |
325 | - return (float)$this->get( 'PAY_amount' ); |
|
325 | + return (float) $this->get('PAY_amount'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @throws \EE_Error |
333 | 333 | */ |
334 | 334 | public function amount_no_code() { |
335 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
335 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws \EE_Error |
345 | 345 | */ |
346 | 346 | public function gateway_response() { |
347 | - return $this->get( 'PAY_gateway_response' ); |
|
347 | + return $this->get('PAY_gateway_response'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @throws \EE_Error |
357 | 357 | */ |
358 | 358 | public function txn_id_chq_nmbr() { |
359 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
359 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | 370 | public function po_number() { |
371 | - return $this->get( 'PAY_po_number' ); |
|
371 | + return $this->get('PAY_po_number'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @throws \EE_Error |
381 | 381 | */ |
382 | 382 | public function extra_accntng() { |
383 | - return $this->get( 'PAY_extra_accntng' ); |
|
383 | + return $this->get('PAY_extra_accntng'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | 394 | public function payment_made_via_admin() { |
395 | - return ( $this->get( 'PAY_source' ) === EEM_Payment_Method::scope_admin ); |
|
395 | + return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @throws \EE_Error |
405 | 405 | */ |
406 | 406 | public function details() { |
407 | - return $this->get( 'PAY_details' ); |
|
407 | + return $this->get('PAY_details'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function redirect_url() { |
419 | - return $this->get( 'PAY_redirect_url' ); |
|
419 | + return $this->get('PAY_redirect_url'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | 430 | public function redirect_args() { |
431 | - return $this->get( 'PAY_redirect_args' ); |
|
431 | + return $this->get('PAY_redirect_args'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | - public function e_pretty_status( $show_icons = false ) { |
|
444 | - echo $this->pretty_status( $show_icons ); |
|
443 | + public function e_pretty_status($show_icons = false) { |
|
444 | + echo $this->pretty_status($show_icons); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return string |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - public function pretty_status( $show_icons = false ) { |
|
456 | + public function pretty_status($show_icons = false) { |
|
457 | 457 | $status = EEM_Status::instance()->localized_status( |
458 | - array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), |
|
458 | + array($this->STS_ID() => __('unknown', 'event_espresso')), |
|
459 | 459 | false, |
460 | 460 | 'sentence' |
461 | 461 | ); |
462 | 462 | $icon = ''; |
463 | - switch ( $this->STS_ID() ) { |
|
463 | + switch ($this->STS_ID()) { |
|
464 | 464 | case EEM_Payment::status_id_approved: |
465 | 465 | $icon = $show_icons |
466 | 466 | ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | : ''; |
483 | 483 | break; |
484 | 484 | } |
485 | - return $icon . $status[ $this->STS_ID() ]; |
|
485 | + return $icon.$status[$this->STS_ID()]; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | 496 | public function is_approved() { |
497 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
497 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return boolean whether the status of this payment equals the status id |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function status_is( $STS_ID ) { |
|
511 | + protected function status_is($STS_ID) { |
|
512 | 512 | return $STS_ID === $this->STS_ID() ? true : false; |
513 | 513 | } |
514 | 514 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function is_pending() { |
524 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
524 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | 535 | public function is_cancelled() { |
536 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
536 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \EE_Error |
546 | 546 | */ |
547 | 547 | public function is_declined() { |
548 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
548 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | 559 | public function is_failed() { |
560 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
560 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | 583 | public function status_obj() { |
584 | - return $this->get_first_related( 'Status' ); |
|
584 | + return $this->get_first_related('Status'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * @return EE_Extra_Meta |
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | - public function extra_meta( $query_params = array() ) { |
|
597 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
596 | + public function extra_meta($query_params = array()) { |
|
597 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function payment_method() { |
611 | - return $this->get_first_related( 'Payment_Method' ); |
|
611 | + return $this->get_first_related('Payment_Method'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @return string html |
627 | 627 | * @throws \EE_Error |
628 | 628 | */ |
629 | - public function redirect_form( $inside_form_html = null ) { |
|
629 | + public function redirect_form($inside_form_html = null) { |
|
630 | 630 | $redirect_url = $this->redirect_url(); |
631 | - if ( ! empty( $redirect_url ) ) { |
|
631 | + if ( ! empty($redirect_url)) { |
|
632 | 632 | // what ? no inner form content? |
633 | - if ( $inside_form_html === null ) { |
|
633 | + if ($inside_form_html === null) { |
|
634 | 634 | $inside_form_html = EEH_HTML::p( |
635 | 635 | sprintf( |
636 | 636 | __( |
637 | 637 | 'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', |
638 | 638 | 'event_espresso' |
639 | 639 | ), |
640 | - EEH_HTML::br( 2 ), |
|
640 | + EEH_HTML::br(2), |
|
641 | 641 | '<input type="submit" value="', |
642 | 642 | '">' |
643 | 643 | ), |
@@ -653,22 +653,22 @@ discard block |
||
653 | 653 | ); |
654 | 654 | //if it's a GET request, we need to remove all the GET params in the querystring |
655 | 655 | //and put them into the form instead |
656 | - if ( $method === 'GET' ) { |
|
657 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
656 | + if ($method === 'GET') { |
|
657 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
658 | 658 | $get_params = null; |
659 | - parse_str( $querystring, $get_params ); |
|
660 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
661 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
659 | + parse_str($querystring, $get_params); |
|
660 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
661 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
662 | 662 | } |
663 | - $form = EEH_HTML::nl( 1 ) |
|
663 | + $form = EEH_HTML::nl(1) |
|
664 | 664 | . '<form method="' |
665 | 665 | . $method |
666 | 666 | . '" name="gateway_form" action="' |
667 | 667 | . $redirect_url |
668 | 668 | . '">'; |
669 | - $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
|
669 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
670 | 670 | $form .= $inside_form_html; |
671 | - $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
|
671 | + $form .= EEH_HTML::nl( -1 ).'</form>'.EEH_HTML::nl( -1 ); |
|
672 | 672 | return $form; |
673 | 673 | } else { |
674 | 674 | return null; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function redirect_args_as_inputs() { |
688 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
688 | + return $this->_args_as_inputs($this->redirect_args()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param array $args key-value pairs |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - protected function _args_as_inputs( $args ) { |
|
700 | + protected function _args_as_inputs($args) { |
|
701 | 701 | $html = ''; |
702 | - if ( $args !== null && is_array( $args ) ) { |
|
703 | - foreach ( $args as $name => $value ) { |
|
704 | - $html .= EEH_HTML::nl( 0 ) |
|
702 | + if ($args !== null && is_array($args)) { |
|
703 | + foreach ($args as $name => $value) { |
|
704 | + $html .= EEH_HTML::nl(0) |
|
705 | 705 | . '<input type="hidden" name="' |
706 | 706 | . $name |
707 | 707 | . '" value="' |
708 | - . esc_attr( $value ) |
|
708 | + . esc_attr($value) |
|
709 | 709 | . '"/>'; |
710 | 710 | } |
711 | 711 | } |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @access private |
735 | 735 | * @param mixed $item |
736 | 736 | */ |
737 | - private function _strip_all_tags_within_array( &$item ) { |
|
738 | - if ( is_object( $item ) ) { |
|
739 | - $item = (array)$item; |
|
737 | + private function _strip_all_tags_within_array(&$item) { |
|
738 | + if (is_object($item)) { |
|
739 | + $item = (array) $item; |
|
740 | 740 | } |
741 | - if ( is_array( $item ) ) { |
|
742 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
741 | + if (is_array($item)) { |
|
742 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
743 | 743 | } else { |
744 | - $item = wp_strip_all_tags( $item ); |
|
744 | + $item = wp_strip_all_tags($item); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $original_status = EEH_Array::is_set( |
759 | 759 | $this->_props_n_values_provided_in_constructor, |
760 | 760 | 'STS_ID', |
761 | - $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() |
|
761 | + $this->get_model()->field_settings_for('STS_ID')->get_default_value() |
|
762 | 762 | ); |
763 | 763 | $current_status = $this->status(); |
764 | 764 | if ( |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | * @return mixed |
785 | 785 | * @throws \EE_Error |
786 | 786 | */ |
787 | - public function get_pretty( $field_name, $extra_cache_ref = null ) { |
|
788 | - if ( $field_name === 'PAY_gateway' ) { |
|
789 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
787 | + public function get_pretty($field_name, $extra_cache_ref = null) { |
|
788 | + if ($field_name === 'PAY_gateway') { |
|
789 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
790 | 790 | } |
791 | - return $this->_get_cached_property( $field_name, true, $extra_cache_ref ); |
|
791 | + return $this->_get_cached_property($field_name, true, $extra_cache_ref); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @return EE_Registration_Payment[] |
801 | 801 | * @throws \EE_Error |
802 | 802 | */ |
803 | - public function registration_payments( $query_params = array() ) { |
|
804 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
803 | + public function registration_payments($query_params = array()) { |
|
804 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 |
@@ -48,7 +48,7 @@ |
||
48 | 48 | * @param array $props_n_values incoming values from the database |
49 | 49 | * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
50 | 50 | * the website will be used. |
51 | - * @return EE_Attendee |
|
51 | + * @return EE_Venue |
|
52 | 52 | */ |
53 | 53 | public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
54 | 54 | return new self( $props_n_values, TRUE, $timezone ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * date_format and the second value is the time format |
38 | 38 | * @return EE_Attendee |
39 | 39 | */ |
40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * the website will be used. |
51 | 51 | * @return EE_Attendee |
52 | 52 | */ |
53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
54 | + return new self($props_n_values, TRUE, $timezone); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | function name() { |
64 | - return $this->get( 'VNU_name' ); |
|
64 | + return $this->get('VNU_name'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return string |
71 | 71 | */ |
72 | 72 | function phone() { |
73 | - return $this->get( 'VNU_phone' ); |
|
73 | + return $this->get('VNU_phone'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return string |
81 | 81 | */ |
82 | 82 | function venue_url() { |
83 | - return $this->get( 'VNU_url' ); |
|
83 | + return $this->get('VNU_url'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @return string |
90 | 90 | */ |
91 | 91 | function description() { |
92 | - return $this->get( 'VNU_desc' ); |
|
92 | + return $this->get('VNU_desc'); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return string |
100 | 100 | */ |
101 | 101 | function excerpt() { |
102 | - return $this->get( 'VNU_short_desc' ); |
|
102 | + return $this->get('VNU_short_desc'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return string |
110 | 110 | */ |
111 | 111 | function identifier() { |
112 | - return $this->get( 'VNU_identifier' ); |
|
112 | + return $this->get('VNU_identifier'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return string |
120 | 120 | */ |
121 | 121 | function address() { |
122 | - return $this->get( 'VNU_address' ); |
|
122 | + return $this->get('VNU_address'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string |
130 | 130 | */ |
131 | 131 | function address2() { |
132 | - return $this->get( 'VNU_address2' ); |
|
132 | + return $this->get('VNU_address2'); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return string |
141 | 141 | */ |
142 | 142 | function city() { |
143 | - return $this->get( 'VNU_city' ); |
|
143 | + return $this->get('VNU_city'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return int |
149 | 149 | */ |
150 | 150 | function state_ID() { |
151 | - return $this->get( 'STA_ID' ); |
|
151 | + return $this->get('STA_ID'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | */ |
168 | 168 | public function state_name() { |
169 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
169 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : ''; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @return EE_State |
177 | 177 | */ |
178 | 178 | function state_obj() { |
179 | - return $this->get_first_related( 'State' ); |
|
179 | + return $this->get_first_related('State'); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @return string |
189 | 189 | */ |
190 | 190 | public function state() { |
191 | - if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) { |
|
191 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
192 | 192 | return $this->state_abbrev(); |
193 | 193 | } else { |
194 | 194 | return $this->state_name(); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @return string |
203 | 203 | */ |
204 | 204 | function country_ID() { |
205 | - return $this->get( 'CNT_ISO' ); |
|
205 | + return $this->get('CNT_ISO'); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return string |
212 | 212 | */ |
213 | 213 | public function country_name() { |
214 | - return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
214 | + return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : ''; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @return EE_Country |
222 | 222 | */ |
223 | 223 | function country_obj() { |
224 | - return $this->get_first_related( 'Country' ); |
|
224 | + return $this->get_first_related('Country'); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @return string |
234 | 234 | */ |
235 | 235 | public function country() { |
236 | - if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) { |
|
236 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
237 | 237 | return $this->country_ID(); |
238 | 238 | } else { |
239 | 239 | return $this->country_name(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return string |
248 | 248 | */ |
249 | 249 | function zip() { |
250 | - return $this->get( 'VNU_zip' ); |
|
250 | + return $this->get('VNU_zip'); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return int |
258 | 258 | */ |
259 | 259 | function capacity() { |
260 | - return $this->get_pretty( 'VNU_capacity', 'symbol' ); |
|
260 | + return $this->get_pretty('VNU_capacity', 'symbol'); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string |
268 | 268 | */ |
269 | 269 | function created() { |
270 | - return $this->get( 'VNU_created' ); |
|
270 | + return $this->get('VNU_created'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @return string |
278 | 278 | */ |
279 | 279 | function modified() { |
280 | - return $this->get( 'VNU_modified' ); |
|
280 | + return $this->get('VNU_modified'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @return int |
288 | 288 | */ |
289 | 289 | function order() { |
290 | - return $this->get( 'VNU_order' ); |
|
290 | + return $this->get('VNU_order'); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return int |
298 | 298 | */ |
299 | 299 | function wp_user() { |
300 | - return $this->get( 'VNU_wp_user' ); |
|
300 | + return $this->get('VNU_wp_user'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return string |
307 | 307 | */ |
308 | 308 | function virtual_phone() { |
309 | - return $this->get( 'VNU_virtual_phone' ); |
|
309 | + return $this->get('VNU_virtual_phone'); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | function virtual_url() { |
318 | - return $this->get( 'VNU_virtual_url' ); |
|
318 | + return $this->get('VNU_virtual_url'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @return bool |
325 | 325 | */ |
326 | 326 | function enable_for_gmap() { |
327 | - return $this->get( 'VNU_enable_for_gmap' ); |
|
327 | + return $this->get('VNU_enable_for_gmap'); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return string |
334 | 334 | */ |
335 | 335 | function google_map_link() { |
336 | - return $this->get( 'VNU_google_map_link' ); |
|
336 | + return $this->get('VNU_google_map_link'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | |
@@ -345,16 +345,16 @@ discard block |
||
345 | 345 | * @param bool $upcoming |
346 | 346 | * @return EE_Event[] |
347 | 347 | */ |
348 | - function events( $query_params = array(), $upcoming = FALSE ) { |
|
349 | - if ( $upcoming ) { |
|
348 | + function events($query_params = array(), $upcoming = FALSE) { |
|
349 | + if ($upcoming) { |
|
350 | 350 | $query_params = array( |
351 | 351 | array( |
352 | 352 | 'status' => 'publish', |
353 | - 'Datetime.DTT_EVT_start' => array( '>', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_start' ) ) |
|
353 | + 'Datetime.DTT_EVT_start' => array('>', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start')) |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
357 | - return $this->get_many_related( 'Event', $query_params ); |
|
357 | + return $this->get_many_related('Event', $query_params); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * Sets address |
374 | 374 | */ |
375 | - function set_address( $address = '' ) { |
|
376 | - $this->set( 'VNU_address', $address ); |
|
375 | + function set_address($address = '') { |
|
376 | + $this->set('VNU_address', $address); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | /** |
382 | 382 | * @param string $address2 |
383 | 383 | */ |
384 | - function set_address2( $address2 = '' ) { |
|
385 | - $this->set( 'VNU_address2', $address2 ); |
|
384 | + function set_address2($address2 = '') { |
|
385 | + $this->set('VNU_address2', $address2); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | /** |
391 | 391 | * @param string $city |
392 | 392 | */ |
393 | - function set_city( $city = '' ) { |
|
394 | - $this->set( 'VNU_city', $city ); |
|
393 | + function set_city($city = '') { |
|
394 | + $this->set('VNU_city', $city); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @param int $state |
401 | 401 | */ |
402 | - function set_state_ID( $state = 0 ) { |
|
403 | - $this->set( 'STA_ID', $state ); |
|
402 | + function set_state_ID($state = 0) { |
|
403 | + $this->set('STA_ID', $state); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param EE_State /int $state_id_or_obj |
412 | 412 | * @return EE_State |
413 | 413 | */ |
414 | - function set_state_obj( $state_id_or_obj ) { |
|
415 | - return $this->_add_relation_to( $state_id_or_obj, 'State' ); |
|
414 | + function set_state_obj($state_id_or_obj) { |
|
415 | + return $this->_add_relation_to($state_id_or_obj, 'State'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param int $country_ID |
422 | 422 | */ |
423 | - function set_country_ID( $country_ID = 0 ) { |
|
424 | - $this->set( 'CNT_ISO', $country_ID ); |
|
423 | + function set_country_ID($country_ID = 0) { |
|
424 | + $this->set('CNT_ISO', $country_ID); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @param EE_Country /string $country_id_or_obj |
431 | 431 | * @return EE_Country |
432 | 432 | */ |
433 | - function set_country_obj( $country_id_or_obj ) { |
|
433 | + function set_country_obj($country_id_or_obj) { |
|
434 | 434 | return $this->_add_relation_to($country_id_or_obj, 'Country'); |
435 | 435 | } |
436 | 436 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | /** |
440 | 440 | * @param string $zip |
441 | 441 | */ |
442 | - function set_zip( $zip = '' ) { |
|
443 | - $this->set( 'VNU_zip', $zip ); |
|
442 | + function set_zip($zip = '') { |
|
443 | + $this->set('VNU_zip', $zip); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | /** |
449 | 449 | * @param int $capacity |
450 | 450 | */ |
451 | - function set_capacity( $capacity = 0 ) { |
|
452 | - $this->set( 'VNU_capacity', $capacity ); |
|
451 | + function set_capacity($capacity = 0) { |
|
452 | + $this->set('VNU_capacity', $capacity); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * @param string $created |
459 | 459 | */ |
460 | - function set_created( $created = '' ) { |
|
461 | - $this->set( 'VNU_created', $created ); |
|
460 | + function set_created($created = '') { |
|
461 | + $this->set('VNU_created', $created); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | /** |
467 | 467 | * @param string $desc |
468 | 468 | */ |
469 | - function set_description( $desc = '' ) { |
|
470 | - $this->set( 'VNU_desc', $desc ); |
|
469 | + function set_description($desc = '') { |
|
470 | + $this->set('VNU_desc', $desc); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -475,8 +475,8 @@ discard block |
||
475 | 475 | /** |
476 | 476 | * @param string $identifier |
477 | 477 | */ |
478 | - function set_identifier( $identifier = '' ) { |
|
479 | - $this->set( 'VNU_identifier', $identifier ); |
|
478 | + function set_identifier($identifier = '') { |
|
479 | + $this->set('VNU_identifier', $identifier); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * @param string $modified |
486 | 486 | */ |
487 | - function set_modified( $modified = '' ) { |
|
488 | - $this->set( 'VNU_modified', $modified ); |
|
487 | + function set_modified($modified = '') { |
|
488 | + $this->set('VNU_modified', $modified); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * @param string $name |
495 | 495 | */ |
496 | - function set_name( $name = '' ) { |
|
497 | - $this->set( 'VNU_name', $name ); |
|
496 | + function set_name($name = '') { |
|
497 | + $this->set('VNU_name', $name); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | /** |
503 | 503 | * @param int $order |
504 | 504 | */ |
505 | - function set_order( $order = 0 ) { |
|
506 | - $this->set( 'VNU_order', $order ); |
|
505 | + function set_order($order = 0) { |
|
506 | + $this->set('VNU_order', $order); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | |
@@ -511,8 +511,8 @@ discard block |
||
511 | 511 | /** |
512 | 512 | * @param string $phone |
513 | 513 | */ |
514 | - function set_phone( $phone = '' ) { |
|
515 | - $this->set( 'VNU_phone', $phone ); |
|
514 | + function set_phone($phone = '') { |
|
515 | + $this->set('VNU_phone', $phone); |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | /** |
521 | 521 | * @param int $wp_user |
522 | 522 | */ |
523 | - function set_wp_user( $wp_user = 1 ) { |
|
524 | - $this->set( 'VNU_wp_user', $wp_user ); |
|
523 | + function set_wp_user($wp_user = 1) { |
|
524 | + $this->set('VNU_wp_user', $wp_user); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | /** |
530 | 530 | * @param string $url |
531 | 531 | */ |
532 | - function set_venue_url( $url = '' ) { |
|
533 | - $this->set( 'VNU_url', $url ); |
|
532 | + function set_venue_url($url = '') { |
|
533 | + $this->set('VNU_url', $url); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * @param string $phone |
540 | 540 | */ |
541 | - function set_virtual_phone( $phone = '' ) { |
|
542 | - $this->set( 'VNU_virtual_phone', $phone ); |
|
541 | + function set_virtual_phone($phone = '') { |
|
542 | + $this->set('VNU_virtual_phone', $phone); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -547,8 +547,8 @@ discard block |
||
547 | 547 | /** |
548 | 548 | * @param string $url |
549 | 549 | */ |
550 | - function set_virtual_url( $url = '' ) { |
|
551 | - $this->set( 'VNU_virtual_url', $url ); |
|
550 | + function set_virtual_url($url = '') { |
|
551 | + $this->set('VNU_virtual_url', $url); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | |
@@ -556,8 +556,8 @@ discard block |
||
556 | 556 | /** |
557 | 557 | * @param string $enable |
558 | 558 | */ |
559 | - function set_enable_for_gmap( $enable = '' ) { |
|
560 | - $this->set( 'VNU_enable_for_gmap', $enable ); |
|
559 | + function set_enable_for_gmap($enable = '') { |
|
560 | + $this->set('VNU_enable_for_gmap', $enable); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -565,8 +565,8 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * @param string $google_map_link |
567 | 567 | */ |
568 | - function set_google_map_link( $google_map_link = '' ) { |
|
569 | - $this->set( 'VNU_google_map_link', $google_map_link ); |
|
568 | + function set_google_map_link($google_map_link = '') { |
|
569 | + $this->set('VNU_google_map_link', $google_map_link); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | * @param float $amount |
311 | 311 | * @param string $name |
312 | 312 | * @param string $description |
313 | - * @param string $code |
|
314 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | - * set the taxes to match $amount |
|
313 | + * @param string $code |
|
314 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | + * set the taxes to match $amount |
|
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | 319 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
320 | 320 | |
321 | - /** |
|
322 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | - * Does NOT save the line items |
|
324 | - * @param EE_Line_Item $line_item |
|
325 | - * @param boolean $taxable |
|
326 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | - * it will be whitelisted (ie, except from becoming taxable) |
|
328 | - */ |
|
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
321 | + /** |
|
322 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | + * Does NOT save the line items |
|
324 | + * @param EE_Line_Item $line_item |
|
325 | + * @param boolean $taxable |
|
326 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | + * it will be whitelisted (ie, except from becoming taxable) |
|
328 | + */ |
|
329 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | */ |
357 | 357 | interface EEHI_Money{ |
358 | 358 | /** |
359 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | - * This should be used to compare floats instead of normal '==' because floats |
|
361 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | - * but actually differ by 0.00000001. |
|
363 | - * @param float $float1 |
|
364 | - * @param float $float2 |
|
365 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | - * @return boolean whether the equation is true or false |
|
367 | - */ |
|
359 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | + * This should be used to compare floats instead of normal '==' because floats |
|
361 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | + * but actually differ by 0.00000001. |
|
363 | + * @param float $float1 |
|
364 | + * @param float $float2 |
|
365 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | + * @return boolean whether the equation is true or false |
|
367 | + */ |
|
368 | 368 | public function compare_floats( $float1, $float2, $operator='=' ); |
369 | 369 | } |
370 | 370 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param EE_Response $response |
91 | 91 | * @return EE_Response |
92 | 92 | */ |
93 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
93 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param EE_Request $request |
107 | 107 | * @param EE_Response $response |
108 | 108 | */ |
109 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
109 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param string $country |
287 | 287 | * @param string $CNT_ISO |
288 | 288 | */ |
289 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
289 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | /** |
297 | 297 | * Interface EEHI_Line_Item |
298 | 298 | */ |
299 | -interface EEHI_Line_Item{ |
|
299 | +interface EEHI_Line_Item { |
|
300 | 300 | /** |
301 | 301 | * Adds an item to the purchase in the right spot |
302 | 302 | * @param EE_Line_Item $total_line_item |
303 | 303 | * @param EE_Line_Item $line_item |
304 | 304 | */ |
305 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
305 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
306 | 306 | /** |
307 | 307 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
308 | 308 | * tax and updates the total line item accordingly |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * set the taxes to match $amount |
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
319 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
327 | 327 | * it will be whitelisted (ie, except from becoming taxable) |
328 | 328 | */ |
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
329 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
341 | 341 | * @return boolean success |
342 | 342 | */ |
343 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
343 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Gets the line item for the taxes subtotal |
347 | 347 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
348 | 348 | * @return \EE_Line_Item |
349 | 349 | */ |
350 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
350 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Money-related helper |
356 | 356 | */ |
357 | -interface EEHI_Money{ |
|
357 | +interface EEHI_Money { |
|
358 | 358 | /** |
359 | 359 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
360 | 360 | * This should be used to compare floats instead of normal '==' because floats |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
366 | 366 | * @return boolean whether the equation is true or false |
367 | 367 | */ |
368 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
368 | + public function compare_floats($float1, $float2, $operator = '='); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Interface EEHI_Template |
373 | 373 | */ |
374 | -interface EEHI_Template{ |
|
374 | +interface EEHI_Template { |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * EEH_Template::format_currency |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string $cur_code_span_class |
385 | 385 | * @return string the html output for the formatted money value |
386 | 386 | */ |
387 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
387 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param array $options |
400 | 400 | * @return mixed |
401 | 401 | */ |
402 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
402 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws EE_Error |
417 | 417 | * @return bool |
418 | 418 | */ |
419 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
419 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * ensure_folder_exists_and_is_writable |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @throws EE_Error |
426 | 426 | * @return bool |
427 | 427 | */ |
428 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
428 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // End of file EEI_Interfaces.php |
@@ -151,8 +151,8 @@ |
||
151 | 151 | } |
152 | 152 | $query_params = $this->_disable_default_where_conditions_on_query_param($query_params); |
153 | 153 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() |
154 | - . "." |
|
155 | - . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
154 | + . "." |
|
155 | + . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
156 | 156 | $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
157 | 157 | $query_params[0][$query_param_where_this_model_pk] = $model_object_id; |
158 | 158 | return $this->get_other_model()->get_all($query_params); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @subpackage core |
14 | 14 | * @author Michael Nelson |
15 | 15 | */ |
16 | -abstract class EE_Model_Relation_Base{ |
|
16 | +abstract class EE_Model_Relation_Base { |
|
17 | 17 | /** |
18 | 18 | * The model name of which this relation is a component (ie, the model that called new EE_Model_Relation_Base) |
19 | 19 | * @var string eg Event, Question_Group, Registration |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param boolean $block_deletes if there are related models across this relation, block (prevent and add an error) the deletion of this model |
49 | 49 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
50 | 50 | */ |
51 | - public function __construct($block_deletes, $blocking_delete_error_message){ |
|
51 | + public function __construct($block_deletes, $blocking_delete_error_message) { |
|
52 | 52 | $this->_blocking_delete = $block_deletes; |
53 | - $this->_blocking_delete_error_message=$blocking_delete_error_message; |
|
53 | + $this->_blocking_delete_error_message = $blocking_delete_error_message; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param $other_model_name |
61 | 61 | * @throws EE_Error |
62 | 62 | */ |
63 | - public function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
63 | + public function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
64 | 64 | $this->_this_model_name = $this_model_name; |
65 | 65 | $this->_other_model_name = $other_model_name; |
66 | - if(is_string($this->_blocking_delete)){ |
|
66 | + if (is_string($this->_blocking_delete)) { |
|
67 | 67 | throw new EE_Error(sprintf(__("When instantiating the relation of type %s from %s to %s, the \$block_deletes argument should be a boolean, not a string (%s)", "event_espresso"), |
68 | - get_class($this),$this_model_name,$other_model_name,$this->_blocking_delete)); |
|
68 | + get_class($this), $this_model_name, $other_model_name, $this->_blocking_delete)); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * Gets the model where this relation is defined. |
76 | 76 | * @return EEM_Base |
77 | 77 | */ |
78 | - public function get_this_model(){ |
|
78 | + public function get_this_model() { |
|
79 | 79 | return $this->_get_model($this->_this_model_name); |
80 | 80 | } |
81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * this relation object was defined on get_this_model(), get_other_model() is the other one) |
87 | 87 | * @return EEM_Base |
88 | 88 | */ |
89 | - public function get_other_model(){ |
|
89 | + public function get_other_model() { |
|
90 | 90 | return $this->_get_model($this->_other_model_name); |
91 | 91 | } |
92 | 92 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
98 | 98 | * @return EEM_Base |
99 | 99 | */ |
100 | - protected function _get_model($model_name){ |
|
101 | - $modelInstance = EE_Registry::instance()->load_model( $model_name ); |
|
102 | - $modelInstance->set_timezone( $this->_timezone ); |
|
100 | + protected function _get_model($model_name) { |
|
101 | + $modelInstance = EE_Registry::instance()->load_model($model_name); |
|
102 | + $modelInstance->set_timezone($this->_timezone); |
|
103 | 103 | return $modelInstance; |
104 | 104 | } |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * entirely possible that relations may be called from a model and we need to make sure those relations have their timezone set correctly. |
110 | 110 | * @param string $timezone timezone to set. |
111 | 111 | */ |
112 | - public function set_timezone( $timezone ) { |
|
113 | - if($timezone !== NULL){ |
|
112 | + public function set_timezone($timezone) { |
|
113 | + if ($timezone !== NULL) { |
|
114 | 114 | $this->_timezone = $timezone; |
115 | 115 | } |
116 | 116 | } |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $extra_join_sql |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected function _left_join($other_table,$other_table_alias,$other_table_column,$this_table_alias,$this_table_join_column, $extra_join_sql = ''){ |
|
130 | - return " LEFT JOIN ".$other_table." AS ".$other_table_alias. " ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column. ($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
129 | + protected function _left_join($other_table, $other_table_alias, $other_table_column, $this_table_alias, $this_table_join_column, $extra_join_sql = '') { |
|
130 | + return " LEFT JOIN ".$other_table." AS ".$other_table_alias." ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column.($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @return EE_Base_Class[] |
146 | 146 | * @throws \EE_Error |
147 | 147 | */ |
148 | - public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ){ |
|
149 | - if( $values_already_prepared_by_model_object !== false ) { |
|
150 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
148 | + public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
|
149 | + if ($values_already_prepared_by_model_object !== false) { |
|
150 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
151 | 151 | } |
152 | 152 | $query_params = $this->_disable_default_where_conditions_on_query_param($query_params); |
153 | 153 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() |
154 | 154 | . "." |
155 | 155 | . $this->get_this_model()->get_primary_key_field()->get_name(); |
156 | - $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
|
156 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
157 | 157 | $query_params[0][$query_param_where_this_model_pk] = $model_object_id; |
158 | 158 | return $this->get_other_model()->get_all($query_params); |
159 | 159 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param string $query_params |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - protected function _disable_default_where_conditions_on_query_param($query_params){ |
|
169 | - if( ! isset($query_params['default_where_conditions'])){ |
|
170 | - $query_params['default_where_conditions']='none'; |
|
168 | + protected function _disable_default_where_conditions_on_query_param($query_params) { |
|
169 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
170 | + $query_params['default_where_conditions'] = 'none'; |
|
171 | 171 | } |
172 | 172 | return $query_params; |
173 | 173 | } |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * @return int of how many related models got deleted |
186 | 186 | * @throws \EE_Error |
187 | 187 | */ |
188 | - public function delete_all_related($model_object_or_id,$query_params = array()){ |
|
188 | + public function delete_all_related($model_object_or_id, $query_params = array()) { |
|
189 | 189 | //for each thing we would delete, |
190 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
190 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
191 | 191 | //determine if it's blocked by anything else before it can be deleted |
192 | 192 | $deleted_count = 0; |
193 | - foreach($related_model_objects as $related_model_object){ |
|
193 | + foreach ($related_model_objects as $related_model_object) { |
|
194 | 194 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
195 | 195 | /* @var $model_object_or_id EE_Base_Class */ |
196 | - if( ! $delete_is_blocked ){ |
|
196 | + if ( ! $delete_is_blocked) { |
|
197 | 197 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
198 | 198 | $related_model_object->delete(); |
199 | 199 | $deleted_count++; |
@@ -215,27 +215,27 @@ discard block |
||
215 | 215 | * @return int of how many related models got deleted |
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | - public function delete_related_permanently($model_object_or_id,$query_params = array()){ |
|
218 | + public function delete_related_permanently($model_object_or_id, $query_params = array()) { |
|
219 | 219 | //for each thing we would delete, |
220 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
220 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
221 | 221 | //determine if it's blocked by anything else before it can be deleted |
222 | 222 | $deleted_count = 0; |
223 | - foreach($related_model_objects as $related_model_object){ |
|
223 | + foreach ($related_model_objects as $related_model_object) { |
|
224 | 224 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
225 | 225 | /* @var $model_object_or_id EE_Base_Class */ |
226 | - if( $related_model_object instanceof EE_Soft_Delete_Base_Class ){ |
|
226 | + if ($related_model_object instanceof EE_Soft_Delete_Base_Class) { |
|
227 | 227 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
228 | 228 | $deleted_count++; |
229 | - if( ! $delete_is_blocked ){ |
|
229 | + if ( ! $delete_is_blocked) { |
|
230 | 230 | $related_model_object->delete_permanently(); |
231 | - }else{ |
|
231 | + } else { |
|
232 | 232 | //delete is blocked |
233 | 233 | //brent and darren, in this case, wanted to just soft delete it then |
234 | 234 | $related_model_object->delete(); |
235 | 235 | } |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | //its not a soft-deletable thing anyways. do the normal logic. |
238 | - if( ! $delete_is_blocked ){ |
|
238 | + if ( ! $delete_is_blocked) { |
|
239 | 239 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
240 | 240 | $related_model_object->delete(); |
241 | 241 | $deleted_count++; |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function _get_model_object_id($model_object_or_id) { |
257 | 257 | $model_object_id = $model_object_or_id; |
258 | - if($model_object_or_id instanceof EE_Base_Class){ |
|
258 | + if ($model_object_or_id instanceof EE_Base_Class) { |
|
259 | 259 | $model_object_id = $model_object_or_id->ID(); |
260 | 260 | } |
261 | - if( ! $model_object_id){ |
|
262 | - throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"),$this->get_other_model()->get_this_model_name(),$this->get_this_model()->get_this_model_name())); |
|
261 | + if ( ! $model_object_id) { |
|
262 | + throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"), $this->get_other_model()->get_this_model_name(), $this->get_this_model()->get_this_model_name())); |
|
263 | 263 | } |
264 | 264 | return $model_object_id; |
265 | 265 | } |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @return EE_Base_Class[] |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function remove_relations($this_obj_or_id,$where_query_param = array()){ |
|
317 | - $related_things = $this->get_all_related($this_obj_or_id,array($where_query_param)); |
|
316 | + public function remove_relations($this_obj_or_id, $where_query_param = array()) { |
|
317 | + $related_things = $this->get_all_related($this_obj_or_id, array($where_query_param)); |
|
318 | 318 | $objs_removed = array(); |
319 | - foreach($related_things as $related_thing){ |
|
319 | + foreach ($related_things as $related_thing) { |
|
320 | 320 | $objs_removed[] = $this->remove_relation_to($this_obj_or_id, $related_thing); |
321 | 321 | } |
322 | 322 | return $objs_removed; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * related objects exist, returns false. |
330 | 330 | * @return boolean |
331 | 331 | */ |
332 | - public function block_delete_if_related_models_exist(){ |
|
332 | + public function block_delete_if_related_models_exist() { |
|
333 | 333 | return $this->_blocking_delete; |
334 | 334 | } |
335 | 335 | |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | * Gets the error message to show |
339 | 339 | * @return string |
340 | 340 | */ |
341 | - public function get_deletion_error_message(){ |
|
342 | - if($this->_blocking_delete_error_message){ |
|
341 | + public function get_deletion_error_message() { |
|
342 | + if ($this->_blocking_delete_error_message) { |
|
343 | 343 | return $this->_blocking_delete_error_message; |
344 | - }else{ |
|
344 | + } else { |
|
345 | 345 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
346 | 346 | return sprintf( |
347 | - __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
347 | + __('This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
348 | 348 | $this->get_this_model()->item_name(1), |
349 | 349 | $this->get_other_model()->item_name(1), |
350 | 350 | $this->get_other_model()->item_name(2) |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | $deleted_count++; |
229 | 229 | if( ! $delete_is_blocked ){ |
230 | 230 | $related_model_object->delete_permanently(); |
231 | - }else{ |
|
231 | + } else{ |
|
232 | 232 | //delete is blocked |
233 | 233 | //brent and darren, in this case, wanted to just soft delete it then |
234 | 234 | $related_model_object->delete(); |
235 | 235 | } |
236 | - }else{ |
|
236 | + } else{ |
|
237 | 237 | //its not a soft-deletable thing anyways. do the normal logic. |
238 | 238 | if( ! $delete_is_blocked ){ |
239 | 239 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function get_deletion_error_message(){ |
342 | 342 | if($this->_blocking_delete_error_message){ |
343 | 343 | return $this->_blocking_delete_error_message; |
344 | - }else{ |
|
344 | + } else{ |
|
345 | 345 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
346 | 346 | return sprintf( |
347 | 347 | __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @param $other_table |
122 | - * @param $other_table_alias |
|
122 | + * @param string $other_table_alias |
|
123 | 123 | * @param $other_table_column |
124 | - * @param $this_table_alias |
|
124 | + * @param string $this_table_alias |
|
125 | 125 | * @param $this_table_join_column |
126 | 126 | * @param string $extra_join_sql |
127 | 127 | * @return string |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * Alters the $query_params to disable default where conditions, unless otherwise specified |
165 | 165 | * @param string $query_params |
166 | - * @return array |
|
166 | + * @return string |
|
167 | 167 | */ |
168 | 168 | protected function _disable_default_where_conditions_on_query_param($query_params){ |
169 | 169 | if( ! isset($query_params['default_where_conditions'])){ |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
181 | 181 | * model objects will only be soft-deleted. |
182 | 182 | * |
183 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
183 | + * @param EE_Base_Class|null $model_object_or_id |
|
184 | 184 | * @param array $query_params |
185 | 185 | * @return int of how many related models got deleted |
186 | 186 | * @throws \EE_Error |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
211 | 211 | * model objects will only be soft-deleted. |
212 | 212 | * |
213 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
213 | + * @param EE_Base_Class|null $model_object_or_id |
|
214 | 214 | * @param array $query_params |
215 | 215 | * @return int of how many related models got deleted |
216 | 216 | * @throws \EE_Error |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
3 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
4 | 4 | |
5 | 5 | |
6 | 6 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage core |
12 | 12 | * @author Michael Nelson |
13 | 13 | */ |
14 | -class EE_HABTM_Relation extends EE_Model_Relation_Base{ |
|
14 | +class EE_HABTM_Relation extends EE_Model_Relation_Base { |
|
15 | 15 | /** |
16 | 16 | * Model which defines the relation between two other models. Eg, the EE_Event_Question_Group model, |
17 | 17 | * which joins EE_Event and EE_Question_Group |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
33 | 33 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
34 | 34 | */ |
35 | - public function __construct($joining_model_name,$block_deletes = true, $blocking_delete_error_message =''){ |
|
35 | + public function __construct($joining_model_name, $block_deletes = true, $blocking_delete_error_message = '') { |
|
36 | 36 | $this->_joining_model_name = $joining_model_name; |
37 | 37 | parent::__construct($block_deletes, $blocking_delete_error_message); |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * Gets the joining model's object |
41 | 41 | * @return EEM_Base |
42 | 42 | */ |
43 | - public function get_join_model(){ |
|
43 | + public function get_join_model() { |
|
44 | 44 | return $this->_get_model($this->_joining_model_name); |
45 | 45 | } |
46 | 46 | |
@@ -53,21 +53,21 @@ discard block |
||
53 | 53 | * @return string of SQL |
54 | 54 | * @throws \EE_Error |
55 | 55 | */ |
56 | - public function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
56 | + public function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
57 | 57 | //create sql like |
58 | 58 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
59 | 59 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
60 | 60 | //remember the model relation chain to the JOIN model, because we'll |
61 | 61 | //need it for get_join_statement() |
62 | 62 | $this->_model_relation_chain_to_join_model = $model_relation_chain; |
63 | - $this_table_pk_field = $this->get_this_model()->get_primary_key_field();//get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
63 | + $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); //get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
|
64 | 64 | $join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
65 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
65 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
66 | 66 | |
67 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
67 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
68 | 68 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
69 | 69 | //phew! ok, we have all the info we need, now we can create the SQL join string |
70 | - $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()) . $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
|
70 | + $SQL = $this->_left_join($join_table, $join_table_alias, $join_table_fk_field_to_this_table->get_table_column(), $this_table_alias, $this_table_pk_field->get_table_column()).$this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
|
71 | 71 | |
72 | 72 | return $SQL; |
73 | 73 | } |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | * @return string of SQL |
85 | 85 | * @throws \EE_Error |
86 | 86 | */ |
87 | - public function get_join_statement($model_relation_chain){ |
|
88 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
89 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
87 | + public function get_join_statement($model_relation_chain) { |
|
88 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
89 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
90 | 90 | } |
91 | 91 | $join_table_fk_field_to_this_table = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
92 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
92 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
93 | 93 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
94 | 94 | $join_table_fk_field_to_other_table = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
95 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
95 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
96 | 96 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
97 | 97 | |
98 | - $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
98 | + $SQL = $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $join_table_alias, $join_table_fk_field_to_other_table->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
|
99 | 99 | return $SQL; |
100 | 100 | } |
101 | 101 | |
@@ -112,37 +112,37 @@ discard block |
||
112 | 112 | * @return EE_Base_Class |
113 | 113 | * @throws \EE_Error |
114 | 114 | */ |
115 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
115 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
116 | 116 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
117 | 117 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
118 | 118 | //check if such a relationship already exists |
119 | 119 | $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
120 | 120 | $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
121 | 121 | |
122 | - $cols_n_values = array( |
|
122 | + $cols_n_values = array( |
|
123 | 123 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
124 | 124 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID()); |
125 | 125 | |
126 | 126 | //if $where_query exists lets add them to the query_params. |
127 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
127 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
128 | 128 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
129 | 129 | //make sure we strip THIS models name from the query param |
130 | 130 | $parsed_query = array(); |
131 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
132 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
131 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
132 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
133 | 133 | $parsed_query[$query_param] = $val; |
134 | 134 | } |
135 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
135 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
136 | 136 | } |
137 | 137 | |
138 | - $query_params = array( $cols_n_values ); |
|
138 | + $query_params = array($cols_n_values); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
142 | 142 | //if there is already an entry in the join table, indicating a relationship, we're done |
143 | 143 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
144 | 144 | //the other tables, use the joining model directly! |
145 | - if( ! $existing_entry_in_join_table ){ |
|
145 | + if ( ! $existing_entry_in_join_table) { |
|
146 | 146 | $this->get_join_model()->insert($cols_n_values); |
147 | 147 | } |
148 | 148 | return $other_model_obj; |
@@ -160,30 +160,30 @@ discard block |
||
160 | 160 | * @return EE_Base_Class |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
163 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
164 | 164 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
165 | 165 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
166 | 166 | //check if such a relationship already exists |
167 | 167 | $join_model_fk_to_this_model = $this->get_join_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
168 | 168 | $join_model_fk_to_other_model = $this->get_join_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
169 | 169 | |
170 | - $cols_n_values = array( |
|
170 | + $cols_n_values = array( |
|
171 | 171 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
172 | 172 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID()); |
173 | 173 | |
174 | 174 | //if $where_query exists lets add them to the query_params. |
175 | - if ( !empty( $where_query ) ) { |
|
175 | + if ( ! empty($where_query)) { |
|
176 | 176 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
177 | 177 | //make sure we strip THIS models name from the query param |
178 | 178 | $parsed_query = array(); |
179 | - foreach ( $where_query as $query_param => $val ) { |
|
180 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
179 | + foreach ($where_query as $query_param => $val) { |
|
180 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
181 | 181 | $parsed_query[$query_param] = $val; |
182 | 182 | } |
183 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
183 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
184 | 184 | } |
185 | 185 | |
186 | - $this->get_join_model()->delete( array($cols_n_values) ); |
|
186 | + $this->get_join_model()->delete(array($cols_n_values)); |
|
187 | 187 | return $other_model_obj; |
188 | 188 | } |
189 | 189 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage core |
9 | 9 | * @author Michael Nelson |
10 | 10 | */ |
11 | -class EE_HABTM_Any_Relation extends EE_HABTM_Relation{ |
|
11 | +class EE_HABTM_Any_Relation extends EE_HABTM_Relation { |
|
12 | 12 | /** |
13 | 13 | * |
14 | 14 | * @var string |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model |
23 | 23 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
24 | 24 | */ |
25 | - public function __construct( $block_deletes = true, $blocking_delete_error_message =''){ |
|
26 | - parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
25 | + public function __construct($block_deletes = true, $blocking_delete_error_message = '') { |
|
26 | + parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | * @param $other_model_name |
34 | 34 | * @throws EE_Error |
35 | 35 | */ |
36 | - public function _construct_finalize_set_models( $this_model_name, $other_model_name){ |
|
37 | - if( $this_model_name < $other_model_name ) { |
|
36 | + public function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
37 | + if ($this_model_name < $other_model_name) { |
|
38 | 38 | $this->_alphabetically_first_model_name = $this_model_name; |
39 | - } else{ |
|
39 | + } else { |
|
40 | 40 | $this->_alphabetically_first_model_name = $other_model_name; |
41 | 41 | } |
42 | - parent::_construct_finalize_set_models( $this_model_name, $other_model_name ); |
|
42 | + parent::_construct_finalize_set_models($this_model_name, $other_model_name); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * @return EE_Model_Field_Base |
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | - public function get_join_table_fk_field_to( $model_name, $id_or_name_field ) { |
|
53 | + public function get_join_table_fk_field_to($model_name, $id_or_name_field) { |
|
54 | 54 | $order = null; |
55 | - if( $model_name === $this->_alphabetically_first_model_name ) { |
|
55 | + if ($model_name === $this->_alphabetically_first_model_name) { |
|
56 | 56 | $order = 'first'; |
57 | 57 | } else { |
58 | 58 | $order = 'second'; |
59 | 59 | } |
60 | - return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field ); |
|
60 | + return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return string of SQL |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function get_join_to_intermediate_model_statement($model_relation_chain){ |
|
72 | + public function get_join_to_intermediate_model_statement($model_relation_chain) { |
|
73 | 73 | //create sql like |
74 | 74 | //LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this |
75 | 75 | //LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | $field_with_model_name = $this->get_join_table_fk_field_to( |
84 | 84 | $this->get_this_model()->get_this_model_name(), |
85 | 85 | 'name' ); |
86 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
87 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
86 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
87 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
88 | 88 | $join_table = $this->get_join_model()->get_table_for_alias($join_table_alias); |
89 | 89 | //phew! ok, we have all the info we need, now we can create the SQL join string |
90 | 90 | $SQL = $this->_left_join( |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $join_table_fk_field_to_this_table->get_table_column(), |
94 | 94 | $this_table_alias, |
95 | 95 | $this_table_pk_field->get_table_column(), |
96 | - $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) . |
|
96 | + $field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ). |
|
97 | 97 | $this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias); |
98 | 98 | |
99 | 99 | return $SQL; |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @return string of SQL |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function get_join_statement($model_relation_chain){ |
|
115 | - if( $this->_model_relation_chain_to_join_model === NULL ){ |
|
116 | - throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' ))); |
|
114 | + public function get_join_statement($model_relation_chain) { |
|
115 | + if ($this->_model_relation_chain_to_join_model === NULL) { |
|
116 | + throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso'))); |
|
117 | 117 | } |
118 | 118 | $join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to( |
119 | 119 | $this->get_this_model()->get_this_model_name(), |
@@ -125,10 +125,10 @@ discard block |
||
125 | 125 | $this->get_other_model()->get_this_model_name(), |
126 | 126 | 'name' ); |
127 | 127 | |
128 | - $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias(); |
|
128 | + $join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias(); |
|
129 | 129 | |
130 | 130 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
131 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
131 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
132 | 132 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
133 | 133 | |
134 | 134 | $SQL = $this->_left_join( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $join_table_alias, |
139 | 139 | $join_table_fk_field_to_other_table->get_table_column(), |
140 | 140 | $field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'" |
141 | - ) . |
|
141 | + ). |
|
142 | 142 | $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias); |
143 | 143 | return $SQL; |
144 | 144 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return EE_Base_Class |
155 | 155 | * @throws \EE_Error |
156 | 156 | */ |
157 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
157 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
158 | 158 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
159 | 159 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
160 | 160 | //check if such a relationship already exists |
@@ -171,32 +171,32 @@ discard block |
||
171 | 171 | $this->get_other_model()->get_this_model_name(), |
172 | 172 | 'name' ); |
173 | 173 | |
174 | - $cols_n_values = array( |
|
174 | + $cols_n_values = array( |
|
175 | 175 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
176 | 176 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
177 | 177 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
178 | 178 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
179 | 179 | |
180 | 180 | //if $where_query exists lets add them to the query_params. |
181 | - if ( !empty( $extra_join_model_fields_n_values ) ) { |
|
181 | + if ( ! empty($extra_join_model_fields_n_values)) { |
|
182 | 182 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
183 | 183 | //make sure we strip THIS models name from the query param |
184 | 184 | $parsed_query = array(); |
185 | - foreach ( $extra_join_model_fields_n_values as $query_param => $val ) { |
|
186 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
185 | + foreach ($extra_join_model_fields_n_values as $query_param => $val) { |
|
186 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
187 | 187 | $parsed_query[$query_param] = $val; |
188 | 188 | } |
189 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
189 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
190 | 190 | } |
191 | 191 | |
192 | - $query_params = array( $cols_n_values ); |
|
192 | + $query_params = array($cols_n_values); |
|
193 | 193 | |
194 | 194 | |
195 | 195 | $existing_entry_in_join_table = $this->get_join_model()->get_one($query_params); |
196 | 196 | //if there is already an entry in the join table, indicating a relationship, we're done |
197 | 197 | //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to |
198 | 198 | //the other tables, use the joining model directly! |
199 | - if( ! $existing_entry_in_join_table ){ |
|
199 | + if ( ! $existing_entry_in_join_table) { |
|
200 | 200 | $this->get_join_model()->insert($cols_n_values); |
201 | 201 | } |
202 | 202 | return $other_model_obj; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return EE_Base_Class |
215 | 215 | * @throws \EE_Error |
216 | 216 | */ |
217 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){ |
|
217 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
218 | 218 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
219 | 219 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
220 | 220 | //check if such a relationship already exists |
@@ -231,25 +231,25 @@ discard block |
||
231 | 231 | $this->get_other_model()->get_this_model_name(), |
232 | 232 | 'name' ); |
233 | 233 | |
234 | - $cols_n_values = array( |
|
234 | + $cols_n_values = array( |
|
235 | 235 | $join_model_fk_to_this_model->get_name() => $this_model_obj->ID(), |
236 | 236 | $join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(), |
237 | 237 | $join_model_fk_to_other_model->get_name() => $other_model_obj->ID(), |
238 | 238 | $join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() ); |
239 | 239 | |
240 | 240 | //if $where_query exists lets add them to the query_params. |
241 | - if ( !empty( $where_query ) ) { |
|
241 | + if ( ! empty($where_query)) { |
|
242 | 242 | //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name) |
243 | 243 | //make sure we strip THIS models name from the query param |
244 | 244 | $parsed_query = array(); |
245 | - foreach ( $where_query as $query_param => $val ) { |
|
246 | - $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param); |
|
245 | + foreach ($where_query as $query_param => $val) { |
|
246 | + $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param); |
|
247 | 247 | $parsed_query[$query_param] = $val; |
248 | 248 | } |
249 | - $cols_n_values = array_merge( $cols_n_values, $parsed_query ); |
|
249 | + $cols_n_values = array_merge($cols_n_values, $parsed_query); |
|
250 | 250 | } |
251 | 251 | |
252 | - $this->get_join_model()->delete( array($cols_n_values) ); |
|
252 | + $this->get_join_model()->delete(array($cols_n_values)); |
|
253 | 253 | return $other_model_obj; |
254 | 254 | } |
255 | 255 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php'); |
|
2 | +require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php'); |
|
3 | 3 | |
4 | 4 | |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage core |
12 | 12 | * @author Michael Nelson |
13 | 13 | */ |
14 | -class EE_Has_Many_Relation extends EE_Model_Relation_Base{ |
|
14 | +class EE_Has_Many_Relation extends EE_Model_Relation_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the foreign key |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model |
22 | 22 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
23 | 23 | */ |
24 | - public function __construct($block_deletes = true, $blocking_delete_error_message = null){ |
|
24 | + public function __construct($block_deletes = true, $blocking_delete_error_message = null) { |
|
25 | 25 | parent::__construct($block_deletes, $blocking_delete_error_message); |
26 | 26 | } |
27 | 27 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public function get_join_statement( $model_relation_chain){ |
|
37 | + public function get_join_statement($model_relation_chain) { |
|
38 | 38 | //create the sql string like |
39 | 39 | // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions |
40 | 40 | $this_table_pk_field = $this->get_this_model()->get_primary_key_field(); |
41 | 41 | $other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
42 | - $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias(); |
|
43 | - $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias(); |
|
42 | + $pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias(); |
|
43 | + $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_fk_field->get_table_alias(); |
|
44 | 44 | $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias); |
45 | 45 | |
46 | 46 | return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, $this_table_pk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return \EE_Base_Class |
58 | 58 | * @throws \EE_Error |
59 | 59 | */ |
60 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
60 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
61 | 61 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
62 | 62 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
63 | 63 | |
64 | 64 | //find the field on the other model which is a foreign key to this model |
65 | 65 | $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
66 | - if($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()){ |
|
66 | + if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) { |
|
67 | 67 | //set that field on the other model to this model's ID |
68 | 68 | $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID()); |
69 | 69 | $other_model_obj->save(); |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * @return \EE_Base_Class |
84 | 84 | * @throws \EE_Error |
85 | 85 | */ |
86 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){ |
|
86 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
87 | 87 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true); |
88 | 88 | //find the field on the other model which is a foreign key to this model |
89 | 89 | $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name()); |
90 | 90 | //set that field on the other model to this model's ID |
91 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null, true); |
|
91 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
92 | 92 | $other_model_obj->save(); |
93 | 93 | return $other_model_obj; |
94 | 94 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'relations/EE_Has_Many_Relation.php'); |
|
2 | +require_once(EE_MODELS.'relations/EE_Has_Many_Relation.php'); |
|
3 | 3 | |
4 | 4 | |
5 | 5 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage core |
12 | 12 | * @author Michael Nelson |
13 | 13 | */ |
14 | -class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation{ |
|
14 | +class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation { |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model |
45 | 45 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
46 | 46 | */ |
47 | - public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null){ |
|
47 | + public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null) { |
|
48 | 48 | $this->_primary_cpt_field = $primary_cpt_field; |
49 | 49 | $this->_parent_pk_relation_field = $parent_pk_relation_field; |
50 | 50 | parent::__construct($block_deletes, $blocking_delete_error_message); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return \EE_Base_Class |
62 | 62 | * @throws \EE_Error |
63 | 63 | */ |
64 | - public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){ |
|
64 | + public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) { |
|
65 | 65 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
66 | 66 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj); |
70 | 70 | |
71 | 71 | //if is array, then we've already done the add_relation so let's get out |
72 | - if ( is_array( $other_model_obj ) ){ |
|
72 | + if (is_array($other_model_obj)) { |
|
73 | 73 | return $other_model_obj[0]; |
74 | 74 | } |
75 | 75 | //find the field on the other model which is a foreign key to this model |
@@ -91,15 +91,15 @@ discard block |
||
91 | 91 | * @return \EE_Base_Class |
92 | 92 | * @throws \EE_Error |
93 | 93 | */ |
94 | - public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){ |
|
94 | + public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
|
95 | 95 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id); |
96 | 96 | $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
97 | 97 | //handle possible revisions |
98 | - $other_model_obj = $this->_check_for_revision( $this_model_obj, $other_model_obj, TRUE ); |
|
98 | + $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, TRUE); |
|
99 | 99 | |
100 | 100 | |
101 | 101 | //if is array, then we've already done the add_relation so let's get out |
102 | - if ( is_array( $other_model_obj ) ){ |
|
102 | + if (is_array($other_model_obj)) { |
|
103 | 103 | return $other_model_obj[0]; |
104 | 104 | } |
105 | 105 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | |
110 | 110 | //set that field on the other model to this model's ID |
111 | - if ( $this->_blocking_delete ) { |
|
112 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null,true); |
|
111 | + if ($this->_blocking_delete) { |
|
112 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
113 | 113 | $other_model_obj->save(); |
114 | 114 | } else { |
115 | 115 | $other_model_obj->delete(); |
116 | - $other_model_obj->set($fk_field_on_other_model->get_name(),null,true); |
|
116 | + $other_model_obj->set($fk_field_on_other_model->get_name(), null, true); |
|
117 | 117 | return $other_model_obj; |
118 | 118 | } |
119 | 119 | return $other_model_obj; |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | * @return EE_Base_Class[] |
131 | 131 | * @throws \EE_Error |
132 | 132 | */ |
133 | - public function get_all_related( $model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ) { |
|
134 | - if( $values_already_prepared_by_model_object !== false ) { |
|
135 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
133 | + public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
|
134 | + if ($values_already_prepared_by_model_object !== false) { |
|
135 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | //if this is an autosave then we're going to get things differently |
139 | - if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { |
|
140 | - return $this->_do_autosave_get_all($model_object_or_id, $query_params ); |
|
139 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
140 | + return $this->_do_autosave_get_all($model_object_or_id, $query_params); |
|
141 | 141 | } |
142 | 142 | |
143 | - return parent::get_all_related( $model_object_or_id, $query_params ); |
|
143 | + return parent::get_all_related($model_object_or_id, $query_params); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -156,22 +156,22 @@ discard block |
||
156 | 156 | * @return \EE_Base_Class[] |
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | - protected function _do_autosave_get_all( $model_object_or_id, $query_params, $deprecated = false ) { |
|
159 | + protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) { |
|
160 | 160 | |
161 | 161 | //first we check if the post_id for the incoming query is for an autosave. If it isn't that's what we want! |
162 | - $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
|
162 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
163 | 163 | |
164 | - $autosave = wp_get_post_autosave( $model_object_id ); |
|
164 | + $autosave = wp_get_post_autosave($model_object_id); |
|
165 | 165 | $id_to_use = $autosave ? $autosave->ID : $model_object_id; |
166 | 166 | |
167 | - $autosave_relations = parent::get_all_related( $id_to_use, $query_params ); |
|
167 | + $autosave_relations = parent::get_all_related($id_to_use, $query_params); |
|
168 | 168 | $parent_ids = $parents = array(); |
169 | 169 | $return_objs = array(); |
170 | 170 | |
171 | 171 | //k this is where things differ because NOW what we're going to do is get the PARENTS for the get all related (and we'll also start setting up the return_objs array containing related that DON'T have parent ids, for those that DON'T have parents to merge with our returned objects); |
172 | - foreach ( $autosave_relations as $a_r ) { |
|
172 | + foreach ($autosave_relations as $a_r) { |
|
173 | 173 | $pid = $a_r->parent(); |
174 | - if ( !empty( $pid ) ) { |
|
174 | + if ( ! empty($pid)) { |
|
175 | 175 | $parent_ids[] = $pid; |
176 | 176 | } else { |
177 | 177 | $return_objs[] = $a_r; |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | } |
180 | 180 | |
181 | 181 | //we have to make sure we also include the ORIGINAL values |
182 | - $originals = parent::get_all_related($model_object_or_id, $query_params ); |
|
182 | + $originals = parent::get_all_related($model_object_or_id, $query_params); |
|
183 | 183 | |
184 | 184 | //merge $originals with $return_objs |
185 | - if ( $originals ) { |
|
185 | + if ($originals) { |
|
186 | 186 | $return_objs = array_merge($originals, $return_objs); |
187 | 187 | } |
188 | 188 | |
189 | 189 | //now we setup the query to get all the parents |
190 | - if ( !empty( $parent_ids ) ) { |
|
190 | + if ( ! empty($parent_ids)) { |
|
191 | 191 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name(); |
192 | - $query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids ); |
|
192 | + $query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids); |
|
193 | 193 | $parents = $this->get_other_model()->get_all($query_params); |
194 | 194 | } |
195 | 195 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | //now merge parents with our current $return_objs and send back |
200 | - return array_merge( $parents, $return_objs ); |
|
200 | + return array_merge($parents, $return_objs); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
@@ -211,42 +211,42 @@ discard block |
||
211 | 211 | * @return EE_Base_Class. ($other_obj); |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - protected function _check_for_revision( $this_obj, $other_obj, $remove_relation = FALSE ) { |
|
214 | + protected function _check_for_revision($this_obj, $other_obj, $remove_relation = FALSE) { |
|
215 | 215 | $pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name(); |
216 | 216 | //now we need to determine if we're in a WP revision save cause if we are we need to do some special handling |
217 | - if ( $this_obj->post_type() === 'revision' ) { |
|
217 | + if ($this_obj->post_type() === 'revision') { |
|
218 | 218 | //first if $other_obj fk = this_obj pk then we know that this is a pk object, let's make sure there is a matching set for the autosave if there is then we save over it, if there isn't then we need to create a new one. |
219 | 219 | $parent_evt_id = $this_obj->parent(); |
220 | 220 | /*var_dump($parent_evt_id); |
221 | 221 | var_dump($this_obj); |
222 | 222 | var_dump($other_obj);/**/ |
223 | 223 | |
224 | - if ( !empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field) ) { |
|
224 | + if ( ! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) { |
|
225 | 225 | //let's do query on this objects model to see if the incoming pk value on the obj matches any parents in this objects table. |
226 | - $has_parent_obj = $this->get_other_model()->get_one( array( array( $this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID() ) ) ); |
|
226 | + $has_parent_obj = $this->get_other_model()->get_one(array(array($this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID()))); |
|
227 | 227 | |
228 | - if ( $has_parent_obj ) { |
|
228 | + if ($has_parent_obj) { |
|
229 | 229 | //this makes sure the update on the current obj happens to the revision's row NOT the parent row. |
230 | 230 | |
231 | - $other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID()); |
|
232 | - $other_obj->set($pk_on_related_model, $has_parent_obj->ID() ); |
|
231 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
232 | + $other_obj->set($pk_on_related_model, $has_parent_obj->ID()); |
|
233 | 233 | $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
234 | 234 | |
235 | - if ( !$remove_relation ) { |
|
235 | + if ( ! $remove_relation) { |
|
236 | 236 | $other_obj->save(); |
237 | - return array( $other_obj ); |
|
238 | - } elseif ( $remove_relation && !$this->_blocking_delete) { |
|
237 | + return array($other_obj); |
|
238 | + } elseif ($remove_relation && ! $this->_blocking_delete) { |
|
239 | 239 | $other_obj->delete(); |
240 | 240 | $other_obj->set($this->_parent_pk_relation_field, NULL, true); |
241 | 241 | return array($other_obj); |
242 | 242 | } |
243 | 243 | |
244 | 244 | } else { |
245 | - $other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() ); |
|
246 | - $other_obj->set( $this->_primary_cpt_field, $this_obj->ID() ); |
|
245 | + $other_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
246 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
247 | 247 | $other_obj->set($pk_on_related_model, NULL, true); //ensure we create a new row for the autosave with parent id the same as the incoming ID. |
248 | 248 | $other_obj->save(); //make sure we insert. |
249 | - return array( $other_obj ); |
|
249 | + return array($other_obj); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -259,24 +259,24 @@ discard block |
||
259 | 259 | } else { |
260 | 260 | |
261 | 261 | //we only need to do the below IF this is not a remove relation |
262 | - if ( !$remove_relation ) { |
|
262 | + if ( ! $remove_relation) { |
|
263 | 263 | //okay this is is a normal update/save/remove so, let's make sure the other object is not a revision of the current object. |
264 | 264 | //the other object will likely NOT have the correct fk on it (which is the primary_cpt_field_mame) so we must retrieve from the db to get that first. |
265 | 265 | $existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID()); |
266 | 266 | $potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : NULL; |
267 | 267 | |
268 | - if ( $parent_this_obj_id = wp_is_post_revision($potential_revision_id) ) { |
|
268 | + if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) { |
|
269 | 269 | //yes the OTHER object is linked to the revision of the parent, not the parent itself. That means we need to make the other_object an attachment of this_obj and then duplicate other_obj for the revision. |
270 | - $other_obj->set($this->_primary_cpt_field, $this_obj->ID() ); |
|
270 | + $other_obj->set($this->_primary_cpt_field, $this_obj->ID()); |
|
271 | 271 | $other_obj->save(); |
272 | 272 | |
273 | 273 | //now create a new other_obj and fill with details from existing object |
274 | 274 | $new_obj = $other_obj; |
275 | - $new_obj->set( $this->_primary_cpt_field, $potential_revision_id ); |
|
276 | - $new_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() ); |
|
277 | - $new_obj->set( $pk_on_related_model, NULL ); |
|
275 | + $new_obj->set($this->_primary_cpt_field, $potential_revision_id); |
|
276 | + $new_obj->set($this->_parent_pk_relation_field, $other_obj->ID()); |
|
277 | + $new_obj->set($pk_on_related_model, NULL); |
|
278 | 278 | $new_obj->save(); |
279 | - return array( $new_obj ); |
|
279 | + return array($new_obj); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'relations/EE_Belongs_To_Relation.php'); |
|
2 | +require_once(EE_MODELS.'relations/EE_Belongs_To_Relation.php'); |
|
3 | 3 | |
4 | 4 | |
5 | 5 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return string |
24 | 24 | * @throws \EE_Error |
25 | 25 | */ |
26 | - public function get_join_statement( $model_relation_chain) { |
|
26 | + public function get_join_statement($model_relation_chain) { |
|
27 | 27 | //create the sql string like |
28 | 28 | $this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
29 | 29 | //ALSO, need to get the field with the model name |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | |
33 | 33 | $other_table_pk_field = $this->get_other_model()->get_primary_key_field(); |
34 | - $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain,$this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias(); |
|
35 | - $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias(); |
|
34 | + $this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias(); |
|
35 | + $other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias(); |
|
36 | 36 | $other_table = $this->get_other_model()->get_table_for_alias($other_table_alias); |
37 | 37 | return $this->_left_join($other_table, |
38 | 38 | $other_table_alias, |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) { |
82 | 82 | $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true); |
83 | - $other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id ); |
|
83 | + $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id); |
|
84 | 84 | //find the field on the other model which is a foreign key to this model |
85 | 85 | $fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name()); |
86 | 86 | //set that field on the other model to this model's ID |
87 | 87 | $this_model_obj->set($fk_on_this_model->get_name(), null, true); |
88 | - $this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(),null,true); |
|
88 | + $this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(), null, true); |
|
89 | 89 | $this_model_obj->save(); |
90 | 90 | return $other_model_obj; |
91 | 91 | } |