@@ -649,8 +649,9 @@ |
||
649 | 649 | * @return EE_Registration |
650 | 650 | */ |
651 | 651 | public function get_primary_registration() { |
652 | - if ( $this->is_primary_registrant() ) |
|
653 | - return $this; |
|
652 | + if ( $this->is_primary_registrant() ) { |
|
653 | + return $this; |
|
654 | + } |
|
654 | 655 | |
655 | 656 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
656 | 657 | $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | /** |
951 | 951 | * Sets deleted |
952 | 952 | * @param boolean $deleted |
953 | - * @return boolean |
|
953 | + * @return boolean|null |
|
954 | 954 | */ |
955 | 955 | public function set_deleted($deleted) { |
956 | 956 | $this->set( 'REG_deleted', $deleted ); |
@@ -994,6 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
996 | 996 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access. |
997 | + * @param integer $DTT_OR_ID |
|
997 | 998 | * |
998 | 999 | * @return bool |
999 | 1000 | */ |
@@ -1369,7 +1370,7 @@ discard block |
||
1369 | 1370 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
1370 | 1371 | * Note: if there are no payments on the registration there will be no payment method returned. |
1371 | 1372 | * |
1372 | - * @return EE_Payment_Method|null |
|
1373 | + * @return null|EE_Base_Class |
|
1373 | 1374 | */ |
1374 | 1375 | public function payment_method() { |
1375 | 1376 | return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
2 | 2 | |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * EE_Registration class |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * date_format and the second value is the time format |
44 | 44 | * @return EE_Registration |
45 | 45 | */ |
46 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
47 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
48 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
46 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
47 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
48 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * the website will be used. |
57 | 57 | * @return EE_Registration |
58 | 58 | */ |
59 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
60 | - return new self( $props_n_values, TRUE, $timezone ); |
|
59 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
60 | + return new self($props_n_values, TRUE, $timezone); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @access public |
69 | 69 | * @param int $EVT_ID Event ID |
70 | 70 | */ |
71 | - public function set_event( $EVT_ID = 0 ) { |
|
72 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
71 | + public function set_event($EVT_ID = 0) { |
|
72 | + $this->set('EVT_ID', $EVT_ID); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | * @param mixed $field_value |
81 | 81 | * @param bool $use_default |
82 | 82 | */ |
83 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
84 | - switch( $field_name ) { |
|
83 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
84 | + switch ($field_name) { |
|
85 | 85 | case 'REG_code' : |
86 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
87 | - $this->set_reg_code( $field_value, $use_default ); |
|
86 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
87 | + $this->set_reg_code($field_value, $use_default); |
|
88 | 88 | } |
89 | 89 | break; |
90 | 90 | case 'STS_ID' : |
91 | - $this->set_status( $field_value, $use_default ); |
|
91 | + $this->set_status($field_value, $use_default); |
|
92 | 92 | break; |
93 | 93 | default : |
94 | - parent::set( $field_name, $field_value, $use_default ); |
|
94 | + parent::set($field_name, $field_value, $use_default); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -109,42 +109,42 @@ discard block |
||
109 | 109 | * @return bool |
110 | 110 | * @throws \EE_Error |
111 | 111 | */ |
112 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
112 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
113 | 113 | // get current REG_Status |
114 | 114 | $old_STS_ID = $this->status_ID(); |
115 | 115 | // if status has changed |
116 | 116 | if ( |
117 | 117 | $this->ID() // ensure registration is in the db |
118 | 118 | && $old_STS_ID != $new_STS_ID // and that status has actually changed |
119 | - && ! empty( $old_STS_ID ) // and that old status is actually set |
|
120 | - && ! empty( $new_STS_ID ) // as well as the new status |
|
119 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
120 | + && ! empty($new_STS_ID) // as well as the new status |
|
121 | 121 | ) { |
122 | 122 | // TO approved |
123 | - if ( $new_STS_ID === EEM_Registration::status_id_approved ) { |
|
123 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
124 | 124 | // reserve a space by incrementing ticket and datetime sold values |
125 | 125 | $this->_reserve_registration_space(); |
126 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
126 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
127 | 127 | // OR FROM approved |
128 | - } else if ( $old_STS_ID === EEM_Registration::status_id_approved ) { |
|
128 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
129 | 129 | // release a space by decrementing ticket and datetime sold values |
130 | 130 | $this->_release_registration_space(); |
131 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
131 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
132 | 132 | } |
133 | 133 | // update status |
134 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
134 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
135 | 135 | /** @type EE_Registration_Processor $registration_processor */ |
136 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
136 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
137 | 137 | /** @type EE_Transaction_Processor $transaction_processor */ |
138 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
138 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
139 | 139 | /** @type EE_Transaction_Payments $transaction_payments */ |
140 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
140 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
141 | 141 | // these reg statuses should not be considered in any calculations involving monies owing |
142 | - $closed_reg_statuses = ! empty( $closed_reg_statuses ) |
|
142 | + $closed_reg_statuses = ! empty($closed_reg_statuses) |
|
143 | 143 | ? $closed_reg_statuses |
144 | 144 | : EEM_Registration::closed_reg_statuses(); |
145 | 145 | if ( |
146 | - in_array( $new_STS_ID, $closed_reg_statuses ) |
|
147 | - && ! in_array( $old_STS_ID, $closed_reg_statuses ) |
|
146 | + in_array($new_STS_ID, $closed_reg_statuses) |
|
147 | + && ! in_array($old_STS_ID, $closed_reg_statuses) |
|
148 | 148 | ) { |
149 | 149 | // cancelled or declined registration |
150 | 150 | $registration_processor->update_registration_after_being_canceled_or_declined( |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | false |
158 | 158 | ); |
159 | 159 | } else if ( |
160 | - in_array( $old_STS_ID, $closed_reg_statuses ) |
|
161 | - && ! in_array( $new_STS_ID, $closed_reg_statuses ) |
|
160 | + in_array($old_STS_ID, $closed_reg_statuses) |
|
161 | + && ! in_array($new_STS_ID, $closed_reg_statuses) |
|
162 | 162 | ) { |
163 | 163 | // reinstating cancelled or declined registration |
164 | 164 | $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
165 | 165 | $this, |
166 | 166 | $closed_reg_statuses |
167 | 167 | ); |
168 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( $this ); |
|
168 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration($this); |
|
169 | 169 | } |
170 | - $transaction_payments->recalculate_transaction_total( $this->transaction(), false ); |
|
171 | - $this->transaction()->update_status_based_on_total_paid( true ); |
|
172 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
170 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
171 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
172 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
173 | 173 | return TRUE; |
174 | 174 | } else { |
175 | 175 | //even though the old value matches the new value, it's still good to |
176 | 176 | //allow the parent set method to have a say |
177 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
177 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
178 | 178 | return TRUE; |
179 | 179 | } |
180 | 180 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @access public |
187 | 187 | */ |
188 | 188 | public function status_ID() { |
189 | - return $this->get( 'STS_ID' ); |
|
189 | + return $this->get('STS_ID'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | * @param boolean $include_archived whether to include archived tickets or not. |
212 | 212 | * @return EE_Ticket |
213 | 213 | */ |
214 | - public function ticket( $include_archived = TRUE ) { |
|
214 | + public function ticket($include_archived = TRUE) { |
|
215 | 215 | $query_params = array(); |
216 | - if ( $include_archived ) { |
|
217 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
216 | + if ($include_archived) { |
|
217 | + $query_params['default_where_conditions'] = 'none'; |
|
218 | 218 | } |
219 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
219 | + return $this->get_first_related('Ticket', $query_params); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function wp_user() { |
246 | 246 | $event = $this->event(); |
247 | - if ( $event instanceof EE_Event ) { |
|
247 | + if ($event instanceof EE_Event) { |
|
248 | 248 | return $event->wp_user(); |
249 | 249 | } |
250 | 250 | return 0; |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | * @access public |
271 | 271 | * @param int $ATT_ID Attendee ID |
272 | 272 | */ |
273 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
274 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
273 | + public function set_attendee_id($ATT_ID = 0) { |
|
274 | + $this->set('ATT_ID', $ATT_ID); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | * @access public |
283 | 283 | * @param int $TXN_ID Transaction ID |
284 | 284 | */ |
285 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
286 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
285 | + public function set_transaction_id($TXN_ID = 0) { |
|
286 | + $this->set('TXN_ID', $TXN_ID); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -294,8 +294,8 @@ discard block |
||
294 | 294 | * @access public |
295 | 295 | * @param string $REG_session PHP Session ID |
296 | 296 | */ |
297 | - public function set_session( $REG_session = '' ) { |
|
298 | - $this->set( 'REG_session', $REG_session ); |
|
297 | + public function set_session($REG_session = '') { |
|
298 | + $this->set('REG_session', $REG_session); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | * @access public |
307 | 307 | * @param string $REG_url_link Registration URL Link |
308 | 308 | */ |
309 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
310 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
309 | + public function set_reg_url_link($REG_url_link = '') { |
|
310 | + $this->set('REG_url_link', $REG_url_link); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @access public |
319 | 319 | * @param int $REG_count Primary Attendee |
320 | 320 | */ |
321 | - public function set_count( $REG_count = 1 ) { |
|
322 | - $this->set( 'REG_count', $REG_count ); |
|
321 | + public function set_count($REG_count = 1) { |
|
322 | + $this->set('REG_count', $REG_count); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | * @access public |
331 | 331 | * @param boolean $REG_group_size Group Registration |
332 | 332 | */ |
333 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
334 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
333 | + public function set_group_size($REG_group_size = FALSE) { |
|
334 | + $this->set('REG_group_size', $REG_group_size); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | * @access public |
415 | 415 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
416 | 416 | */ |
417 | - public function set_reg_date( $REG_date = FALSE ) { |
|
418 | - $this->set( 'REG_date', $REG_date ); |
|
417 | + public function set_reg_date($REG_date = FALSE) { |
|
418 | + $this->set('REG_date', $REG_date); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * @access public |
427 | 427 | * @param float $REG_final_price |
428 | 428 | */ |
429 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
430 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
429 | + public function set_final_price($REG_final_price = 0.00) { |
|
430 | + $this->set('REG_final_price', $REG_final_price); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @access public |
439 | 439 | * @param float $REG_paid |
440 | 440 | */ |
441 | - public function set_paid( $REG_paid = 0.00 ) { |
|
442 | - $this->set( 'REG_paid', $REG_paid ); |
|
441 | + public function set_paid($REG_paid = 0.00) { |
|
442 | + $this->set('REG_paid', $REG_paid); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | * @access public |
451 | 451 | * @param boolean $REG_att_is_going Attendee Is Going |
452 | 452 | */ |
453 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
454 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
453 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
454 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @return EE_Attendee |
462 | 462 | */ |
463 | 463 | public function attendee() { |
464 | - return $this->get_first_related( 'Attendee' ); |
|
464 | + return $this->get_first_related('Attendee'); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @access public |
472 | 472 | */ |
473 | 473 | public function event_ID() { |
474 | - return $this->get( 'EVT_ID' ); |
|
474 | + return $this->get('EVT_ID'); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | */ |
483 | 483 | public function event_name() { |
484 | 484 | $event = $this->event_obj(); |
485 | - if ( $event ) { |
|
485 | + if ($event) { |
|
486 | 486 | return $event->name(); |
487 | 487 | } else { |
488 | 488 | return NULL; |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | * @return EE_Event |
497 | 497 | */ |
498 | 498 | public function event_obj() { |
499 | - return $this->get_first_related( 'Event' ); |
|
499 | + return $this->get_first_related('Event'); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @access public |
507 | 507 | */ |
508 | 508 | public function attendee_ID() { |
509 | - return $this->get( 'ATT_ID' ); |
|
509 | + return $this->get('ATT_ID'); |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @access public |
517 | 517 | */ |
518 | 518 | public function session_ID() { |
519 | - return $this->get( 'REG_session' ); |
|
519 | + return $this->get('REG_session'); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
527 | 527 | * @return string |
528 | 528 | */ |
529 | - public function receipt_url( $messenger = 'html' ) { |
|
529 | + public function receipt_url($messenger = 'html') { |
|
530 | 530 | |
531 | 531 | /** |
532 | 532 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | * @since 4.5.0 |
535 | 535 | */ |
536 | 536 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
537 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
537 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
538 | 538 | |
539 | - if ( $has_custom ) { |
|
540 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
539 | + if ($has_custom) { |
|
540 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
541 | 541 | } |
542 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
542 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | |
@@ -550,28 +550,28 @@ discard block |
||
550 | 550 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
551 | 551 | * @return string |
552 | 552 | */ |
553 | - public function invoice_url( $messenger = 'html' ) { |
|
553 | + public function invoice_url($messenger = 'html') { |
|
554 | 554 | /** |
555 | 555 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
556 | 556 | * |
557 | 557 | * @since 4.5.0 |
558 | 558 | */ |
559 | 559 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
560 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
560 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
561 | 561 | |
562 | - if ( $has_custom ) { |
|
563 | - if ( $messenger == 'html' ) { |
|
564 | - return $this->invoice_url( 'launch' ); |
|
562 | + if ($has_custom) { |
|
563 | + if ($messenger == 'html') { |
|
564 | + return $this->invoice_url('launch'); |
|
565 | 565 | } |
566 | 566 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
567 | 567 | |
568 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
569 | - if ( $messenger == 'html' ) { |
|
568 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
569 | + if ($messenger == 'html') { |
|
570 | 570 | $query_args['html'] = TRUE; |
571 | 571 | } |
572 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
572 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
573 | 573 | } |
574 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
574 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @throws \EE_Error |
585 | 585 | */ |
586 | 586 | public function reg_url_link() { |
587 | - return (string)$this->get( 'REG_url_link' ); |
|
587 | + return (string) $this->get('REG_url_link'); |
|
588 | 588 | } |
589 | 589 | |
590 | 590 | |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
595 | 595 | * @return void |
596 | 596 | */ |
597 | - public function e_invoice_url( $type = 'launch' ) { |
|
598 | - echo $this->invoice_url( $type ); |
|
597 | + public function e_invoice_url($type = 'launch') { |
|
598 | + echo $this->invoice_url($type); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @return string |
616 | 616 | */ |
617 | 617 | public function payment_overview_url() { |
618 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
618 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @return string |
627 | 627 | */ |
628 | 628 | public function edit_attendee_information_url() { |
629 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
629 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * @return string |
637 | 637 | */ |
638 | 638 | public function get_admin_edit_url() { |
639 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
639 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @access public |
647 | 647 | */ |
648 | 648 | public function is_primary_registrant() { |
649 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
649 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | * This returns the primary registration object for this registration group (which may be this object). |
656 | 656 | * @return EE_Registration |
657 | 657 | */ |
658 | - public function get_primary_registration() { |
|
659 | - if ( $this->is_primary_registrant() ) |
|
658 | + public function get_primary_registration() { |
|
659 | + if ($this->is_primary_registrant()) |
|
660 | 660 | return $this; |
661 | 661 | |
662 | 662 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
663 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
663 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
664 | 664 | return $primary_registrant; |
665 | 665 | } |
666 | 666 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @access public |
672 | 672 | */ |
673 | 673 | public function count() { |
674 | - return $this->get( 'REG_count' ); |
|
674 | + return $this->get('REG_count'); |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @access public |
682 | 682 | */ |
683 | 683 | public function group_size() { |
684 | - return $this->get( 'REG_group_size' ); |
|
684 | + return $this->get('REG_group_size'); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | * @access public |
692 | 692 | */ |
693 | 693 | public function date() { |
694 | - return $this->get( 'REG_date' ); |
|
694 | + return $this->get('REG_date'); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * @param string $time_format |
703 | 703 | * @return string |
704 | 704 | */ |
705 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
706 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
705 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
706 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | * @return float |
717 | 717 | */ |
718 | 718 | public function final_price() { |
719 | - return $this->get( 'REG_final_price' ); |
|
719 | + return $this->get('REG_final_price'); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return string |
728 | 728 | */ |
729 | 729 | public function pretty_final_price() { |
730 | - return $this->get_pretty( 'REG_final_price' ); |
|
730 | + return $this->get_pretty('REG_final_price'); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 | |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | * @return float |
739 | 739 | */ |
740 | 740 | public function paid() { |
741 | - return $this->get( 'REG_paid' ); |
|
741 | + return $this->get('REG_paid'); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @return float |
750 | 750 | */ |
751 | 751 | public function pretty_paid() { |
752 | - return $this->get_pretty( 'REG_paid' ); |
|
752 | + return $this->get_pretty('REG_paid'); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | * @param array $requires_payment |
762 | 762 | * @return bool |
763 | 763 | */ |
764 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
764 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
765 | 765 | // these reg statuses require payment (if event is not free) |
766 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
766 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
767 | 767 | if ( |
768 | - in_array( $this->status_ID(), $requires_payment ) && |
|
768 | + in_array($this->status_ID(), $requires_payment) && |
|
769 | 769 | $this->final_price() != 0 && |
770 | 770 | $this->final_price() != $this->paid() |
771 | 771 | ) { |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | * @param bool $show_icons |
783 | 783 | * @return void |
784 | 784 | */ |
785 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
786 | - echo $this->pretty_status( $show_icons ); |
|
785 | + public function e_pretty_status($show_icons = FALSE) { |
|
786 | + echo $this->pretty_status($show_icons); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | |
@@ -794,10 +794,10 @@ discard block |
||
794 | 794 | * @param bool $show_icons |
795 | 795 | * @return string |
796 | 796 | */ |
797 | - public function pretty_status( $show_icons = FALSE ) { |
|
798 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
797 | + public function pretty_status($show_icons = FALSE) { |
|
798 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
799 | 799 | $icon = ''; |
800 | - switch ( $this->status_ID() ) { |
|
800 | + switch ($this->status_ID()) { |
|
801 | 801 | case EEM_Registration::status_id_approved: |
802 | 802 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
803 | 803 | break; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
821 | 821 | break; |
822 | 822 | } |
823 | - return $icon . $status[ $this->status_ID() ]; |
|
823 | + return $icon.$status[$this->status_ID()]; |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -830,7 +830,7 @@ discard block |
||
830 | 830 | * @access public |
831 | 831 | */ |
832 | 832 | public function att_is_going() { |
833 | - return $this->get( 'REG_att_is_going' ); |
|
833 | + return $this->get('REG_att_is_going'); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | * @param array $query_params like EEM_Base::get_all |
841 | 841 | * @return EE_Answer[] |
842 | 842 | */ |
843 | - public function answers( $query_params = NULL ) { |
|
844 | - return $this->get_many_related( 'Answer', $query_params ); |
|
843 | + public function answers($query_params = NULL) { |
|
844 | + return $this->get_many_related('Answer', $query_params); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | |
@@ -855,9 +855,9 @@ discard block |
||
855 | 855 | * (because the answer might be an array of answer values, so passing pretty_value=true |
856 | 856 | * will convert it into some kind of string) |
857 | 857 | */ |
858 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
858 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
859 | 859 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
860 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
860 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | |
@@ -870,13 +870,13 @@ discard block |
||
870 | 870 | */ |
871 | 871 | public function question_groups() { |
872 | 872 | $question_groups = array(); |
873 | - if ( $this->event() instanceof EE_Event ) { |
|
873 | + if ($this->event() instanceof EE_Event) { |
|
874 | 874 | $question_groups = $this->event()->question_groups( |
875 | 875 | array( |
876 | 876 | array( |
877 | 877 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
878 | 878 | ), |
879 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
879 | + 'order_by' => array('QSG_order' => 'ASC') |
|
880 | 880 | ) |
881 | 881 | ); |
882 | 882 | } |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | */ |
894 | 894 | public function count_question_groups() { |
895 | 895 | $qg_count = 0; |
896 | - if ( $this->event() instanceof EE_Event ) { |
|
896 | + if ($this->event() instanceof EE_Event) { |
|
897 | 897 | $qg_count = $this->event()->count_related( |
898 | 898 | 'Question_Group', |
899 | 899 | array( |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | * @return string |
915 | 915 | */ |
916 | 916 | public function reg_date() { |
917 | - return $this->get_datetime( 'REG_date' ); |
|
917 | + return $this->get_datetime('REG_date'); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | * @return EE_Datetime_Ticket |
927 | 927 | */ |
928 | 928 | public function datetime_ticket() { |
929 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
929 | + return $this->get_first_related('Datetime_Ticket'); |
|
930 | 930 | } |
931 | 931 | |
932 | 932 | |
@@ -936,15 +936,15 @@ discard block |
||
936 | 936 | * @param EE_Datetime_Ticket $datetime_ticket |
937 | 937 | * @return EE_Datetime_Ticket |
938 | 938 | */ |
939 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
940 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
939 | + public function set_datetime_ticket($datetime_ticket) { |
|
940 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
941 | 941 | } |
942 | 942 | /** |
943 | 943 | * Gets deleted |
944 | 944 | * @return boolean |
945 | 945 | */ |
946 | 946 | public function deleted() { |
947 | - return $this->get( 'REG_deleted' ); |
|
947 | + return $this->get('REG_deleted'); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | /** |
@@ -953,7 +953,7 @@ discard block |
||
953 | 953 | * @return boolean |
954 | 954 | */ |
955 | 955 | public function set_deleted($deleted) { |
956 | - $this->set( 'REG_deleted', $deleted ); |
|
956 | + $this->set('REG_deleted', $deleted); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | * @return EE_Status |
964 | 964 | */ |
965 | 965 | public function status_obj() { |
966 | - return $this->get_first_related( 'Status' ); |
|
966 | + return $this->get_first_related('Status'); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * @return int |
975 | 975 | */ |
976 | 976 | public function count_checkins() { |
977 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
977 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return int |
985 | 985 | */ |
986 | 986 | public function count_checkins_not_checkedout() { |
987 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
987 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
@@ -997,20 +997,20 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return bool |
999 | 999 | */ |
1000 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
1001 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
1000 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
1001 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1002 | 1002 | |
1003 | 1003 | //first check registration status |
1004 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
1004 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
1005 | 1005 | return false; |
1006 | 1006 | } |
1007 | 1007 | //is there a datetime ticket that matches this dtt_ID? |
1008 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
1008 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
1009 | 1009 | return false; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | //final check is against TKT_uses |
1013 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
1013 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | |
@@ -1023,10 +1023,10 @@ discard block |
||
1023 | 1023 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
1024 | 1024 | * @return bool true means can checkin. false means cannot checkin. |
1025 | 1025 | */ |
1026 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
1027 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
1026 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
1027 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
1028 | 1028 | |
1029 | - if ( ! $DTT_ID ) { |
|
1029 | + if ( ! $DTT_ID) { |
|
1030 | 1030 | return false; |
1031 | 1031 | } |
1032 | 1032 | |
@@ -1034,23 +1034,23 @@ discard block |
||
1034 | 1034 | |
1035 | 1035 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
1036 | 1036 | // or not. |
1037 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
1037 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
1038 | 1038 | return true; |
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
1042 | 1042 | //go ahead and toggle. |
1043 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
1043 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
1044 | 1044 | return true; |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
1048 | 1048 | //disallows further check-ins. |
1049 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
1049 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
1050 | 1050 | // checkins have already reached their max number of uses |
1051 | 1051 | // so registrant can NOT checkin |
1052 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1053 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1052 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1053 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1054 | 1054 | return false; |
1055 | 1055 | } |
1056 | 1056 | return true; |
@@ -1071,15 +1071,15 @@ discard block |
||
1071 | 1071 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1072 | 1072 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1073 | 1073 | */ |
1074 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1075 | - if ( empty( $DTT_ID ) ) { |
|
1074 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1075 | + if (empty($DTT_ID)) { |
|
1076 | 1076 | $datetime = $this->get_related_primary_datetime(); |
1077 | 1077 | $DTT_ID = $datetime->ID(); |
1078 | 1078 | // verify the registration can checkin for the given DTT_ID |
1079 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1079 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1080 | 1080 | EE_Error::add_error( |
1081 | 1081 | sprintf( |
1082 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1082 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1083 | 1083 | $this->ID(), |
1084 | 1084 | $DTT_ID |
1085 | 1085 | ), |
@@ -1093,8 +1093,8 @@ discard block |
||
1093 | 1093 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1094 | 1094 | ); |
1095 | 1095 | //start by getting the current status so we know what status we'll be changing to. |
1096 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1097 | - $status_to = $status_paths[ $cur_status ]; |
|
1096 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1097 | + $status_to = $status_paths[$cur_status]; |
|
1098 | 1098 | // database only records true for checked IN or false for checked OUT |
1099 | 1099 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1100 | 1100 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1102,24 +1102,24 @@ discard block |
||
1102 | 1102 | // because we are keeping track of Check-ins over time. |
1103 | 1103 | // Eventually we'll probably want to show a list table |
1104 | 1104 | // for the individual Check-ins so that they can be managed. |
1105 | - $checkin = EE_Checkin::new_instance( array( |
|
1105 | + $checkin = EE_Checkin::new_instance(array( |
|
1106 | 1106 | 'REG_ID' => $this->ID(), |
1107 | 1107 | 'DTT_ID' => $DTT_ID, |
1108 | 1108 | 'CHK_in' => $new_status |
1109 | - ) ); |
|
1109 | + )); |
|
1110 | 1110 | // if the record could not be saved then return false |
1111 | - if ( $checkin->save() === 0 ) { |
|
1112 | - if ( WP_DEBUG ) { |
|
1111 | + if ($checkin->save() === 0) { |
|
1112 | + if (WP_DEBUG) { |
|
1113 | 1113 | global $wpdb; |
1114 | 1114 | $error = sprintf( |
1115 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1115 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1116 | 1116 | '<br />', |
1117 | 1117 | $wpdb->last_error |
1118 | 1118 | ); |
1119 | 1119 | } else { |
1120 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1120 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1121 | 1121 | } |
1122 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1122 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1123 | 1123 | return false; |
1124 | 1124 | } |
1125 | 1125 | return $status_to; |
@@ -1143,19 +1143,19 @@ discard block |
||
1143 | 1143 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1144 | 1144 | * @return int Integer representing Check-in status. |
1145 | 1145 | */ |
1146 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1147 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1146 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1147 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1148 | 1148 | $datetime = $this->get_related_primary_datetime(); |
1149 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1149 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1150 | 1150 | return 0; |
1151 | 1151 | } |
1152 | 1152 | $DTT_ID = $datetime->ID(); |
1153 | 1153 | //verify the registration can checkin for the given DTT_ID |
1154 | 1154 | } |
1155 | 1155 | //get checkin object (if exists) |
1156 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1157 | - if ( $checkin instanceof EE_Checkin ) { |
|
1158 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1156 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1157 | + if ($checkin instanceof EE_Checkin) { |
|
1158 | + if ($checkin->get('CHK_in')) { |
|
1159 | 1159 | return EE_Registration::checkin_status_in; //checked in |
1160 | 1160 | } else { |
1161 | 1161 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1173,28 +1173,28 @@ discard block |
||
1173 | 1173 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1174 | 1174 | * @return string internationalized message |
1175 | 1175 | */ |
1176 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1176 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1177 | 1177 | //let's get the attendee first so we can include the name of the attendee |
1178 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1179 | - if ( $attendee instanceof EE_Attendee ) { |
|
1180 | - if ( $error ) { |
|
1181 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1178 | + $attendee = $this->get_first_related('Attendee'); |
|
1179 | + if ($attendee instanceof EE_Attendee) { |
|
1180 | + if ($error) { |
|
1181 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1182 | 1182 | } |
1183 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1183 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1184 | 1184 | //what is the status message going to be? |
1185 | - switch ( $cur_status ) { |
|
1185 | + switch ($cur_status) { |
|
1186 | 1186 | case EE_Registration::checkin_status_never : |
1187 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1187 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1188 | 1188 | break; |
1189 | 1189 | case EE_Registration::checkin_status_in : |
1190 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1190 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1191 | 1191 | break; |
1192 | 1192 | case EE_Registration::checkin_status_out : |
1193 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1193 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1194 | 1194 | break; |
1195 | 1195 | } |
1196 | 1196 | } |
1197 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1197 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | 1200 | |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | * @access public |
1220 | 1220 | */ |
1221 | 1221 | public function reg_code() { |
1222 | - return $this->get( 'REG_code' ); |
|
1222 | + return $this->get('REG_code'); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | |
@@ -1229,7 +1229,7 @@ discard block |
||
1229 | 1229 | * @access public |
1230 | 1230 | */ |
1231 | 1231 | public function transaction_ID() { |
1232 | - return $this->get( 'TXN_ID' ); |
|
1232 | + return $this->get('TXN_ID'); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * @return int |
1239 | 1239 | */ |
1240 | 1240 | public function ticket_ID() { |
1241 | - return $this->get( 'TKT_ID' ); |
|
1241 | + return $this->get('TKT_ID'); |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | |
@@ -1250,17 +1250,17 @@ discard block |
||
1250 | 1250 | * @param string $REG_code Registration Code |
1251 | 1251 | * @param boolean $use_default |
1252 | 1252 | */ |
1253 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1254 | - if ( empty( $REG_code )) { |
|
1255 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1253 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1254 | + if (empty($REG_code)) { |
|
1255 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1256 | 1256 | return; |
1257 | 1257 | } |
1258 | - if ( ! $this->reg_code() ) { |
|
1259 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1258 | + if ( ! $this->reg_code()) { |
|
1259 | + parent::set('REG_code', $REG_code, $use_default); |
|
1260 | 1260 | } else { |
1261 | 1261 | EE_Error::doing_it_wrong( |
1262 | - __CLASS__ . '::' . __FUNCTION__, |
|
1263 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1262 | + __CLASS__.'::'.__FUNCTION__, |
|
1263 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1264 | 1264 | '4.6.0' |
1265 | 1265 | ); |
1266 | 1266 | } |
@@ -1280,17 +1280,17 @@ discard block |
||
1280 | 1280 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1281 | 1281 | */ |
1282 | 1282 | public function get_all_other_registrations_in_group() { |
1283 | - if ( $this->group_size() < 2 ) { |
|
1283 | + if ($this->group_size() < 2) { |
|
1284 | 1284 | return array(); |
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | $query[0] = array( |
1288 | 1288 | 'TXN_ID' => $this->transaction_ID(), |
1289 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1289 | + 'REG_ID' => array('!=', $this->ID()), |
|
1290 | 1290 | 'TKT_ID' => $this->ticket_ID() |
1291 | 1291 | ); |
1292 | 1292 | |
1293 | - $registrations = $this->get_model()->get_all( $query ); |
|
1293 | + $registrations = $this->get_model()->get_all($query); |
|
1294 | 1294 | return $registrations; |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1299,14 +1299,14 @@ discard block |
||
1299 | 1299 | * @return string |
1300 | 1300 | */ |
1301 | 1301 | public function get_admin_details_link() { |
1302 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1302 | + EE_Registry::instance()->load_helper('URL'); |
|
1303 | 1303 | return EEH_URL::add_query_args_and_nonce( |
1304 | 1304 | array( |
1305 | 1305 | 'page' => 'espresso_registrations', |
1306 | 1306 | 'action' => 'view_registration', |
1307 | 1307 | '_REG_ID' => $this->ID() |
1308 | 1308 | ), |
1309 | - admin_url( 'admin.php' ) |
|
1309 | + admin_url('admin.php') |
|
1310 | 1310 | ); |
1311 | 1311 | } |
1312 | 1312 | |
@@ -1331,12 +1331,12 @@ discard block |
||
1331 | 1331 | * @return string |
1332 | 1332 | */ |
1333 | 1333 | public function get_admin_overview_link() { |
1334 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
1334 | + EE_Registry::instance()->load_helper('URL'); |
|
1335 | 1335 | return EEH_URL::add_query_args_and_nonce( |
1336 | 1336 | array( |
1337 | 1337 | 'page' => 'espresso_registrations' |
1338 | 1338 | ), |
1339 | - admin_url( 'admin.php' ) |
|
1339 | + admin_url('admin.php') |
|
1340 | 1340 | ); |
1341 | 1341 | } |
1342 | 1342 | |
@@ -1347,8 +1347,8 @@ discard block |
||
1347 | 1347 | * @return \EE_Registration[] |
1348 | 1348 | * @throws \EE_Error |
1349 | 1349 | */ |
1350 | - public function payments( $query_params = array() ) { |
|
1351 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1350 | + public function payments($query_params = array()) { |
|
1351 | + return $this->get_many_related('Payment', $query_params); |
|
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | |
@@ -1358,8 +1358,8 @@ discard block |
||
1358 | 1358 | * @return \EE_Registration_Payment[] |
1359 | 1359 | * @throws \EE_Error |
1360 | 1360 | */ |
1361 | - public function registration_payments( $query_params = array() ) { |
|
1362 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1361 | + public function registration_payments($query_params = array()) { |
|
1362 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1363 | 1363 | } |
1364 | 1364 | |
1365 | 1365 | |
@@ -1372,7 +1372,7 @@ discard block |
||
1372 | 1372 | * @return EE_Payment_Method|null |
1373 | 1373 | */ |
1374 | 1374 | public function payment_method() { |
1375 | - return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
|
1375 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Paypal_Pro extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Paypal_Pro extends EE_Onsite_Gateway { |
|
29 | 29 | /** |
30 | 30 | * |
31 | 31 | * @var $_paypal_api_username string |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | * } @see parent::do_direct_payment for more info |
89 | 89 | * @return \EE_Payment|\EEI_Payment |
90 | 90 | */ |
91 | - public function do_direct_payment($payment,$billing_info = null){ |
|
91 | + public function do_direct_payment($payment, $billing_info = null) { |
|
92 | 92 | $transaction = $payment->transaction(); |
93 | 93 | $primary_registrant = $transaction->primary_registration(); |
94 | - $order_description = sprintf(__("Event Registrations from %s", "event_espresso"),get_bloginfo('name')); |
|
94 | + $order_description = sprintf(__("Event Registrations from %s", "event_espresso"), get_bloginfo('name')); |
|
95 | 95 | //charge for the full amount. Show itemized list |
96 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
96 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
97 | 97 | $item_num = 1; |
98 | 98 | $total_line_item = $transaction->total_line_item(); |
99 | 99 | $order_items = array(); |
100 | 100 | foreach ($total_line_item->get_items() as $line_item) { |
101 | 101 | //ignore line items with a quantity of 0 |
102 | - if( $line_item->quantity() == 0 ) { |
|
102 | + if ($line_item->quantity() == 0) { |
|
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | $item = array( |
106 | 106 | // Item Name. 127 char max. |
107 | - 'l_name' => substr($line_item->name(),0,127), |
|
107 | + 'l_name' => substr($line_item->name(), 0, 127), |
|
108 | 108 | // Item description. 127 char max. |
109 | - 'l_desc' => substr($line_item->desc(),0,127), |
|
109 | + 'l_desc' => substr($line_item->desc(), 0, 127), |
|
110 | 110 | // Cost of individual item. |
111 | 111 | 'l_amt' => $line_item->unit_price(), |
112 | 112 | // Item Number. 127 char max. |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | } |
128 | 128 | $item_amount = $total_line_item->get_items_total(); |
129 | 129 | $tax_amount = $total_line_item->get_total_tax(); |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | $order_items = array(); |
132 | 132 | $item_amount = $payment->amount(); |
133 | - $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
133 | + $single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
134 | 134 | $tax_amount = 0; |
135 | - array_push($order_items,array( |
|
135 | + array_push($order_items, array( |
|
136 | 136 | // Item Name. 127 char max. |
137 | - 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'),$primary_registrant->reg_code()), |
|
137 | + 'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'), $primary_registrant->reg_code()), |
|
138 | 138 | // Item description. 127 char max. |
139 | 139 | 'l_desc' => $single_item_desc, |
140 | 140 | // Cost of individual item. |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | // Payer's salutation. 20 char max. |
182 | 182 | 'salutation' => '', |
183 | 183 | // Payer's first name. 25 char max. |
184 | - 'firstname' => substr($billing_info['first_name'],0,25), |
|
184 | + 'firstname' => substr($billing_info['first_name'], 0, 25), |
|
185 | 185 | // Payer's middle name. 25 char max. |
186 | 186 | 'middlename' => '', |
187 | 187 | // Payer's last name. 25 char max. |
188 | - 'lastname' => substr($billing_info['last_name'],0,25), |
|
188 | + 'lastname' => substr($billing_info['last_name'], 0, 25), |
|
189 | 189 | // Payer's suffix. 12 char max. |
190 | 190 | 'suffix' => '' |
191 | 191 | ); |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | // Required. Name of City. |
199 | 199 | 'city' => $billing_info['city'], |
200 | 200 | // Required. Name of State or Province. |
201 | - 'state' => substr( $billing_info['state'], 0, 40 ), |
|
201 | + 'state' => substr($billing_info['state'], 0, 40), |
|
202 | 202 | // Required. Country code. |
203 | 203 | 'countrycode' => $billing_info['country'], |
204 | 204 | // Required. Postal code of payer. |
205 | 205 | 'zip' => $billing_info['zip'], |
206 | 206 | // Phone Number of payer. 20 char max. |
207 | - 'shiptophonenum' => substr($billing_info['phone'],0,20) |
|
207 | + 'shiptophonenum' => substr($billing_info['phone'], 0, 20) |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // Required. Three-letter currency code. Default is USD. |
215 | 215 | 'currencycode' => $payment->currency_code(), |
216 | 216 | // Required if you include itemized cart details. (L_AMTn, etc.) Subtotal of items not including S&H, or tax. |
217 | - 'itemamt' => $this->format_currency($item_amount),// |
|
217 | + 'itemamt' => $this->format_currency($item_amount), // |
|
218 | 218 | // Total shipping costs for the order. If you specify shippingamt, you must also specify itemamt. |
219 | 219 | 'shippingamt' => '', |
220 | 220 | // Total handling costs for the order. If you specify handlingamt, you must also specify itemamt. |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | // Free-form field for your own use. 256 char max. |
227 | 227 | 'custom' => $primary_registrant ? $primary_registrant->ID() : '', |
228 | 228 | // Your own invoice or tracking number |
229 | - 'invnum' => wp_generate_password(12,false),//$transaction->ID(), |
|
229 | + 'invnum' => wp_generate_password(12, false), //$transaction->ID(), |
|
230 | 230 | // URL for receiving Instant Payment Notifications. This overrides what your profile is set to use. |
231 | 231 | 'notifyurl' => '', |
232 | - 'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this |
|
232 | + 'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this |
|
233 | 233 | ); |
234 | 234 | // Wrap all data arrays into a single, "master" array which will be passed into the class function. |
235 | 235 | $PayPalRequestData = array( |
@@ -242,32 +242,32 @@ discard block |
||
242 | 242 | 'OrderItems' => $order_items, |
243 | 243 | ); |
244 | 244 | $this->_log_clean_request($PayPalRequestData, $payment); |
245 | - try{ |
|
245 | + try { |
|
246 | 246 | $PayPalResult = $this->prep_and_curl_request($PayPalRequestData); |
247 | 247 | //remove PCI-sensitive data so it doesn't get stored |
248 | - $PayPalResult = $this->_log_clean_response($PayPalResult,$payment); |
|
248 | + $PayPalResult = $this->_log_clean_response($PayPalResult, $payment); |
|
249 | 249 | |
250 | 250 | $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK']; |
251 | - if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) { |
|
252 | - $payment->set_status( $this->_pay_model->failed_status() ) ; |
|
253 | - $payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) ); |
|
251 | + if (empty($PayPalResult['RAWRESPONSE'])) { |
|
252 | + $payment->set_status($this->_pay_model->failed_status()); |
|
253 | + $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso')); |
|
254 | 254 | $payment->set_details($PayPalResult); |
255 | - }else{ |
|
256 | - if($this->_APICallSuccessful($PayPalResult)){ |
|
255 | + } else { |
|
256 | + if ($this->_APICallSuccessful($PayPalResult)) { |
|
257 | 257 | $payment->set_status($this->_pay_model->approved_status()); |
258 | - }else{ |
|
258 | + } else { |
|
259 | 259 | $payment->set_status($this->_pay_model->declined_status()); |
260 | 260 | } |
261 | 261 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
262 | - $payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0); |
|
262 | + $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0); |
|
263 | 263 | $payment->set_gateway_response($message); |
264 | - $payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null); |
|
264 | + $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null); |
|
265 | 265 | |
266 | 266 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
267 | 267 | $payment->set_extra_accntng($primary_registration_code); |
268 | 268 | $payment->set_details($PayPalResult); |
269 | 269 | } |
270 | - }catch(Exception $e){ |
|
270 | + } catch (Exception $e) { |
|
271 | 271 | $payment->set_status($this->_pay_model->failed_status()); |
272 | 272 | $payment->set_gateway_response($e->getMessage()); |
273 | 273 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @param EEI_Payment $payment |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - private function _log_clean_request($request,$payment){ |
|
287 | + private function _log_clean_request($request, $payment) { |
|
288 | 288 | $cleaned_request_data = $request; |
289 | 289 | unset($cleaned_request_data['CCDetails']['acct']); |
290 | 290 | unset($cleaned_request_data['CCDetails']['cvv2']); |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | * @param EEI_Payment $payment |
301 | 301 | * @return array cleaned |
302 | 302 | */ |
303 | - private function _log_clean_response($response,$payment){ |
|
303 | + private function _log_clean_response($response, $payment) { |
|
304 | 304 | unset($response['REQUESTDATA']['CREDITCARDTYPE']); |
305 | 305 | unset($response['REQUESTDATA']['ACCT']); |
306 | 306 | unset($response['REQUESTDATA']['EXPDATE']); |
307 | 307 | unset($response['REQUESTDATA']['CVV2']); |
308 | 308 | unset($response['RAWREQUEST']); |
309 | - $this->log(array('Paypal Response'=>$response),$payment); |
|
309 | + $this->log(array('Paypal Response'=>$response), $payment); |
|
310 | 310 | return $response; |
311 | 311 | } |
312 | 312 | |
@@ -331,32 +331,32 @@ discard block |
||
331 | 331 | // DP Fields |
332 | 332 | $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array(); |
333 | 333 | foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) |
334 | - $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal); |
|
334 | + $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal); |
|
335 | 335 | |
336 | 336 | // CC Details Fields |
337 | 337 | $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array(); |
338 | 338 | foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) |
339 | - $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal); |
|
339 | + $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal); |
|
340 | 340 | |
341 | 341 | // PayerInfo Type Fields |
342 | 342 | $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array(); |
343 | 343 | foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) |
344 | - $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal); |
|
344 | + $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal); |
|
345 | 345 | |
346 | 346 | // Payer Name Fields |
347 | 347 | $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array(); |
348 | 348 | foreach ($PayerName as $PayerNameVar => $PayerNameVal) |
349 | - $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal); |
|
349 | + $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal); |
|
350 | 350 | |
351 | 351 | // Address Fields (Billing) |
352 | 352 | $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array(); |
353 | 353 | foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) |
354 | - $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal); |
|
354 | + $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal); |
|
355 | 355 | |
356 | 356 | // Payment Details Type Fields |
357 | 357 | $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array(); |
358 | 358 | foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) |
359 | - $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal); |
|
359 | + $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal); |
|
360 | 360 | |
361 | 361 | // Payment Details Item Type Fields |
362 | 362 | $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array(); |
@@ -364,22 +364,22 @@ discard block |
||
364 | 364 | foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) { |
365 | 365 | $CurrentItem = $OrderItems[$OrderItemsVar]; |
366 | 366 | foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) |
367 | - $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal); |
|
367 | + $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal); |
|
368 | 368 | $n++; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Ship To Address Fields |
372 | 372 | $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array(); |
373 | 373 | foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) |
374 | - $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal); |
|
374 | + $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal); |
|
375 | 375 | |
376 | 376 | // 3D Secure Fields |
377 | 377 | $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array(); |
378 | 378 | foreach ($Secure3D as $Secure3DVar => $Secure3DVal) |
379 | - $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal); |
|
379 | + $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal); |
|
380 | 380 | |
381 | 381 | // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string |
382 | - $NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP; |
|
382 | + $NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP; |
|
383 | 383 | $NVPResponse = $this->_CURLRequest($NVPRequest); |
384 | 384 | $NVPRequestArray = $this->_NVPToArray($NVPRequest); |
385 | 385 | $NVPResponseArray = $this->_NVPToArray($NVPResponse); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | private function _CURLRequest($Request) { |
404 | 404 | $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; |
405 | 405 | $curl = curl_init(); |
406 | - curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) ); |
|
406 | + curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE)); |
|
407 | 407 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); |
408 | 408 | curl_setopt($curl, CURLOPT_TIMEOUT, 60); |
409 | 409 | curl_setopt($curl, CURLOPT_URL, $EndPointURL); |
@@ -453,9 +453,9 @@ discard block |
||
453 | 453 | private function _APICallSuccessful($PayPalResult) { |
454 | 454 | $approved = false; |
455 | 455 | // check main response message from PayPal |
456 | - if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) { |
|
456 | + if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) { |
|
457 | 457 | $ack = strtoupper($PayPalResult['ACK']); |
458 | - $approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false; |
|
458 | + $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false; |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | return $approved; |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | |
472 | 472 | $Errors = array(); |
473 | 473 | $n = 0; |
474 | - while (isset($DataArray['L_ERRORCODE' . $n . ''])) { |
|
475 | - $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : ''; |
|
476 | - $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : ''; |
|
477 | - $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : ''; |
|
478 | - $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : ''; |
|
474 | + while (isset($DataArray['L_ERRORCODE'.$n.''])) { |
|
475 | + $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : ''; |
|
476 | + $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : ''; |
|
477 | + $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : ''; |
|
478 | + $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : ''; |
|
479 | 479 | |
480 | 480 | $CurrentItem = array( |
481 | 481 | 'L_ERRORCODE' => $LErrorCode, |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | elseif ($CurrentErrorVar == 'L_SEVERITYCODE') |
516 | 516 | $CurrentVarName = 'Severity Code'; |
517 | 517 | |
518 | - $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal; |
|
518 | + $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | return $error; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEG_Aim extends EE_Onsite_Gateway{ |
|
28 | +class EEG_Aim extends EE_Onsite_Gateway { |
|
29 | 29 | |
30 | 30 | const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll'; //Authnet URL |
31 | 31 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | * @param EEG_Aim $gateway_object |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function possibly_use_deprecated_aim_server( $url, EEG_Aim $gateway_object ) { |
|
161 | - if( $gateway_object->_server === 'authorize.net' |
|
162 | - && ! $gateway_object->_debug_mode ) { |
|
160 | + public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object) { |
|
161 | + if ($gateway_object->_server === 'authorize.net' |
|
162 | + && ! $gateway_object->_debug_mode) { |
|
163 | 163 | return 'https://secure.authorize.net/gateway/transact.dll'; |
164 | 164 | } else { |
165 | 165 | return $url; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | |
184 | 184 | public function do_direct_payment($payment, $billing_info = null) { |
185 | - add_filter( 'FHEE__EEG_Aim___get_server_url', array( $this, 'possibly_use_deprecated_aim_server' ), 10, 2 ); |
|
185 | + add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2); |
|
186 | 186 | // Enable test mode if needed |
187 | 187 | //4007000000027 <-- test successful visa |
188 | 188 | //4222222222222 <-- test failure card number |
@@ -193,21 +193,21 @@ discard block |
||
193 | 193 | $primary_registrant = $transaction->primary_registration(); |
194 | 194 | //if we're are charging for the full amount, show the normal line items |
195 | 195 | //and the itemized total adds up properly |
196 | - if( $this->_can_easily_itemize_transaction_for( $payment ) ){ |
|
196 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
197 | 197 | $total_line_item = $transaction->total_line_item(); |
198 | 198 | foreach ($total_line_item->get_items() as $line_item) { |
199 | 199 | //ignore line items with a quantity of 0 |
200 | - if( $line_item->quantity() == 0 ){ |
|
200 | + if ($line_item->quantity() == 0) { |
|
201 | 201 | continue; |
202 | 202 | } |
203 | 203 | $this->addLineItem($item_num++, $line_item->name(), $line_item->desc(), $line_item->quantity(), $line_item->unit_price(), 'N'); |
204 | 204 | $order_description .= $line_item->desc().', '; |
205 | 205 | } |
206 | - foreach($total_line_item->tax_descendants() as $tax_line_item){ |
|
206 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
207 | 207 | $this->addLineItem($item_num++, $tax_line_item->name(), $tax_line_item->desc(), 1, $tax_line_item->total(), 'N'); |
208 | 208 | } |
209 | - }else{//partial payment |
|
210 | - $order_description = sprintf(__("Payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code()); |
|
209 | + } else {//partial payment |
|
210 | + $order_description = sprintf(__("Payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code()); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | //start transaction |
217 | 217 | //if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id |
218 | 218 | $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363'; |
219 | - $this->setField( 'solution_id', $partner_id ); |
|
219 | + $this->setField('solution_id', $partner_id); |
|
220 | 220 | $this->setField('amount', $this->format_currency($payment->amount())); |
221 | - $this->setField('description',substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | - $this->_set_sensitive_billing_data( $billing_info ); |
|
221 | + $this->setField('description', substr(rtrim($order_description, ', '), 0, 255)); |
|
222 | + $this->_set_sensitive_billing_data($billing_info); |
|
223 | 223 | $this->setField('first_name', $billing_info['first_name']); |
224 | 224 | $this->setField('last_name', $billing_info['last_name']); |
225 | 225 | $this->setField('email', $billing_info['email']); |
226 | 226 | $this->setField('company', $billing_info['company']); |
227 | 227 | $this->setField('address', $billing_info['address'].' '.$billing_info['address2']); |
228 | 228 | $this->setField('city', $billing_info['city']); |
229 | - $this->setField('state', $billing_info['state'] ); |
|
230 | - $this->setField('country', $billing_info['country'] ); |
|
229 | + $this->setField('state', $billing_info['state']); |
|
230 | + $this->setField('country', $billing_info['country']); |
|
231 | 231 | $this->setField('zip', $billing_info['zip']); |
232 | 232 | $this->setField('fax', $billing_info['fax']); |
233 | 233 | $this->setField('cust_id', $primary_registrant->ID()); |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | //invoice_num would be nice to have it be unique per SPCO page-load, that way if users |
236 | 236 | //press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page |
237 | 237 | //in which case, we need to generate teh invoice num per request right here... |
238 | - $this->setField('invoice_num', wp_generate_password(12,false));//$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
238 | + $this->setField('invoice_num', wp_generate_password(12, false)); //$billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']); |
|
239 | 239 | //tell AIM that any duplicates sent in the next 5 minutes are to be ignored |
240 | - $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS ); |
|
240 | + $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS); |
|
241 | 241 | |
242 | 242 | |
243 | 243 | if ($this->_test_transactions) { |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | //Capture response |
248 | 248 | $this->type = "AUTH_CAPTURE"; |
249 | 249 | $response = $this->_sendRequest($payment); |
250 | - if (!empty($response)){ |
|
250 | + if ( ! empty($response)) { |
|
251 | 251 | if ($this->_debug_mode) { |
252 | 252 | $txn_id = $response->invoice_number; |
253 | 253 | } else { |
@@ -256,15 +256,15 @@ discard block |
||
256 | 256 | $payment_status = $response->approved ? $this->_pay_model->approved_status() : $this->_pay_model->declined_status(); |
257 | 257 | $payment->set_status($payment_status); |
258 | 258 | //make sure we interpret the AMT as a float, not an international string (where periods are thousand separators) |
259 | - $payment->set_amount( (float) $response->amount ); |
|
260 | - $payment->set_gateway_response(sprintf("%s (code: %s)",$response->response_reason_text,$response->response_reason_code)); |
|
261 | - $payment->set_txn_id_chq_nmbr( $txn_id ); |
|
259 | + $payment->set_amount((float) $response->amount); |
|
260 | + $payment->set_gateway_response(sprintf("%s (code: %s)", $response->response_reason_text, $response->response_reason_code)); |
|
261 | + $payment->set_txn_id_chq_nmbr($txn_id); |
|
262 | 262 | $payment->set_extra_accntng($primary_registrant->reg_code()); |
263 | - $payment->set_details(print_r($response,true)); |
|
263 | + $payment->set_details(print_r($response, true)); |
|
264 | 264 | } else { |
265 | 265 | $payment->set_status($this->_pay_model->failed_status()); |
266 | 266 | $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso')); |
267 | - $payment->set_details(print_r($response,true)); |
|
267 | + $payment->set_details(print_r($response, true)); |
|
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * what billing data gets sent |
276 | 276 | * @param array $billing_info |
277 | 277 | */ |
278 | - protected function _set_sensitive_billing_data( $billing_info ) { |
|
278 | + protected function _set_sensitive_billing_data($billing_info) { |
|
279 | 279 | $this->setField('card_num', $billing_info['credit_card']); |
280 | 280 | $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']); |
281 | 281 | $this->setField('card_code', $billing_info['cvv']); |
@@ -334,22 +334,22 @@ discard block |
||
334 | 334 | $this->_x_post_fields['tran_key'] = $this->_transaction_key; |
335 | 335 | $x_keys = array(); |
336 | 336 | foreach ($this->_x_post_fields as $key => $value) { |
337 | - $x_keys[] = "x_$key=" . urlencode($value); |
|
337 | + $x_keys[] = "x_$key=".urlencode($value); |
|
338 | 338 | } |
339 | 339 | // Add line items |
340 | 340 | foreach ($this->_additional_line_items as $key => $value) { |
341 | - $x_keys[] = "x_line_item=" . urlencode($value); |
|
341 | + $x_keys[] = "x_line_item=".urlencode($value); |
|
342 | 342 | } |
343 | 343 | $this->_log_clean_request($x_keys, $payment); |
344 | 344 | $post_url = $this->_get_server_url(); |
345 | 345 | $curl_request = curl_init($post_url); |
346 | - curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&",$x_keys)); |
|
346 | + curl_setopt($curl_request, CURLOPT_POSTFIELDS, implode("&", $x_keys)); |
|
347 | 347 | curl_setopt($curl_request, CURLOPT_HEADER, 0); |
348 | 348 | curl_setopt($curl_request, CURLOPT_TIMEOUT, 45); |
349 | 349 | curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1); |
350 | 350 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2); |
351 | 351 | if ($this->VERIFY_PEER) { |
352 | - curl_setopt($curl_request, CURLOPT_CAINFO, dirname( __DIR__ ) . '/ssl/cert.pem'); |
|
352 | + curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem'); |
|
353 | 353 | } else { |
354 | 354 | curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false); |
355 | 355 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | $response = curl_exec($curl_request); |
362 | 362 | |
363 | 363 | curl_close($curl_request); |
364 | - $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
364 | + $response_obj = new EE_AuthorizeNetAIM_Response($response); |
|
365 | 365 | |
366 | 366 | return $this->_log_and_clean_response($response_obj, $payment); |
367 | 367 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @param array $request_array |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | */ |
373 | - protected function _log_clean_request($request_array,$payment){ |
|
374 | - $keys_to_filter_out = array( 'x_card_num', 'x_card_code', 'x_exp_date' ); |
|
375 | - foreach($request_array as $index => $keyvaltogether ) { |
|
376 | - foreach( $keys_to_filter_out as $key ) { |
|
377 | - if( strpos( $keyvaltogether, $key ) === 0 ){ |
|
373 | + protected function _log_clean_request($request_array, $payment) { |
|
374 | + $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date'); |
|
375 | + foreach ($request_array as $index => $keyvaltogether) { |
|
376 | + foreach ($keys_to_filter_out as $key) { |
|
377 | + if (strpos($keyvaltogether, $key) === 0) { |
|
378 | 378 | //found it at the first character |
379 | 379 | //so its one of them |
380 | - unset( $request_array[ $index ] ); |
|
380 | + unset($request_array[$index]); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
384 | - $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url() ),$payment); |
|
384 | + $this->log(array('AIM Request sent:'=>$request_array, 'Server URL' => $this->_get_server_url()), $payment); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | * @param EE_Payment $payment |
394 | 394 | * @return \EE_AuthorizeNetAIM_Response |
395 | 395 | */ |
396 | - private function _log_and_clean_response($response_obj,$payment){ |
|
396 | + private function _log_and_clean_response($response_obj, $payment) { |
|
397 | 397 | $response_obj->account_number = ''; |
398 | - $this->log(array('AIM Response received:'=>$response_obj),$payment); |
|
398 | + $this->log(array('AIM Response received:'=>$response_obj), $payment); |
|
399 | 399 | return $response_obj; |
400 | 400 | } |
401 | 401 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | // Split Array |
495 | 495 | $this->response = $response; |
496 | 496 | if ($encap_char) { |
497 | - $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1)); |
|
497 | + $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1)); |
|
498 | 498 | } else { |
499 | 499 | $this->_response_array = explode($delimiter, $response); |
500 | 500 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $this->held = ($this->response_code === self::HELD); |
565 | 565 | |
566 | 566 | if ($this->error || $this->declined || $this->held) { |
567 | - $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />' . $this->response_reason_text . '<br /><span class="response_code">Response Code: ' . $this->response_code . '<br /></span><span class="response_subcode">Response Subcode: ' . $this->response_subcode . '</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
567 | + $this->error_message = '<p><strong class="credit_card_failure">Attention: your transaction was declined for the following reason(s):</strong><br />'.$this->response_reason_text.'<br /><span class="response_code">Response Code: '.$this->response_code.'<br /></span><span class="response_subcode">Response Subcode: '.$this->response_subcode.'</span></p><p>To try again, <a href="#payment_options">please click here</a>.</p> '; |
|
568 | 568 | |
569 | 569 | |
570 | 570 | /* $this->error_message = "AuthorizeNet Error: |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | -if ( ! class_exists( 'AuthorizeNetException' ) ) { |
|
586 | +if ( ! class_exists('AuthorizeNetException')) { |
|
587 | 587 | /** |
588 | 588 | * Class AuthorizeNetException |
589 | 589 | * |
@@ -599,8 +599,8 @@ discard block |
||
599 | 599 | * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0 |
600 | 600 | * @since 5.1.0 |
601 | 601 | */ |
602 | - public function __construct( $message = "", $code = 0, Exception $previous = null ) { |
|
603 | - parent::__construct( $message, $code, $previous ); |
|
602 | + public function __construct($message = "", $code = 0, Exception $previous = null) { |
|
603 | + parent::__construct($message, $code, $previous); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | 172 | public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
173 | + do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | 174 | if ( absint( $TXN_ID )) { |
175 | 175 | self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
176 | 176 | add_action( |
@@ -303,7 +303,6 @@ discard block |
||
303 | 303 | |
304 | 304 | /** |
305 | 305 | * finalize_abandoned_transactions |
306 | - |
|
307 | 306 | * loops through the self::$_abandoned_transactions array |
308 | 307 | * and attempts to finalize any TXNs that have not been completed |
309 | 308 | * but have had their sessions expired, most likely due to a user not |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return EE_Cron_Tasks |
29 | 29 | */ |
30 | 30 | public static function instance() { |
31 | - if ( ! self::$_instance instanceof EE_Cron_Tasks ) { |
|
31 | + if ( ! self::$_instance instanceof EE_Cron_Tasks) { |
|
32 | 32 | self::$_instance = new self(); |
33 | 33 | } |
34 | 34 | return self::$_instance; |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @return EE_Cron_Tasks |
42 | 42 | */ |
43 | 43 | private function __construct() { |
44 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
44 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
45 | 45 | // verify that WP Cron is enabled |
46 | - if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && is_admin() ) { |
|
46 | + if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && is_admin()) { |
|
47 | 47 | EE_Error::add_persistent_admin_notice( |
48 | 48 | 'wp_cron_disabled', |
49 | 49 | sprintf( |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | // UPDATE TRANSACTION WITH PAYMENT |
59 | 59 | add_action( |
60 | 60 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
61 | - array( 'EE_Cron_Tasks', 'setup_update_for_transaction_with_payment' ), |
|
61 | + array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'), |
|
62 | 62 | 10, 2 |
63 | 63 | ); |
64 | 64 | // FINALIZE ABANDONED TRANSACTIONS |
65 | 65 | add_action( |
66 | 66 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
67 | - array( 'EE_Cron_Tasks', 'check_for_abandoned_transactions' ), |
|
67 | + array('EE_Cron_Tasks', 'check_for_abandoned_transactions'), |
|
68 | 68 | 10, 1 |
69 | 69 | ); |
70 | 70 | // CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA |
71 | 71 | add_action( |
72 | 72 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
73 | - array( 'EE_Cron_Tasks', 'clean_out_junk_transactions' ) |
|
73 | + array('EE_Cron_Tasks', 'clean_out_junk_transactions') |
|
74 | 74 | ); |
75 | 75 | // logging |
76 | 76 | add_action( |
77 | 77 | 'AHEE__EE_System__load_core_configuration__complete', |
78 | - array( 'EE_Cron_Tasks', 'log_scheduled_ee_crons' ) |
|
78 | + array('EE_Cron_Tasks', 'log_scheduled_ee_crons') |
|
79 | 79 | ); |
80 | - EE_Registry::instance()->load_lib( 'Messages_Scheduler' ); |
|
80 | + EE_Registry::instance()->load_lib('Messages_Scheduler'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -92,17 +92,17 @@ discard block |
||
92 | 92 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
93 | 93 | 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions', |
94 | 94 | ); |
95 | - $crons = get_option( 'cron' ); |
|
96 | - if ( ! is_array( $crons ) ) { |
|
95 | + $crons = get_option('cron'); |
|
96 | + if ( ! is_array($crons)) { |
|
97 | 97 | return; |
98 | 98 | } |
99 | - foreach ( $crons as $timestamp => $cron ) { |
|
100 | - foreach ( $ee_crons as $ee_cron ) { |
|
101 | - if ( isset( $cron[ $ee_cron ] ) ) { |
|
102 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron' ); |
|
103 | - foreach ( $cron[ $ee_cron ] as $ee_cron_details ) { |
|
104 | - if ( ! empty( $ee_cron_details[ 'args' ] )) { |
|
105 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, print_r( $ee_cron_details[ 'args' ], true ), "$ee_cron args" ); |
|
99 | + foreach ($crons as $timestamp => $cron) { |
|
100 | + foreach ($ee_crons as $ee_cron) { |
|
101 | + if (isset($cron[$ee_cron])) { |
|
102 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron'); |
|
103 | + foreach ($cron[$ee_cron] as $ee_cron_details) { |
|
104 | + if ( ! empty($ee_cron_details['args'])) { |
|
105 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true), "$ee_cron args"); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | $TXN_ID, |
140 | 140 | $PAY_ID |
141 | 141 | ) { |
142 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
142 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
143 | 143 | // validate $TXN_ID and $timestamp |
144 | - $TXN_ID = absint( $TXN_ID ); |
|
145 | - $timestamp = absint( $timestamp ); |
|
146 | - if ( $TXN_ID && $timestamp ) { |
|
144 | + $TXN_ID = absint($TXN_ID); |
|
145 | + $timestamp = absint($timestamp); |
|
146 | + if ($TXN_ID && $timestamp) { |
|
147 | 147 | wp_schedule_single_event( |
148 | 148 | $timestamp, |
149 | 149 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2', |
150 | - array( $TXN_ID, $PAY_ID ) |
|
150 | + array($TXN_ID, $PAY_ID) |
|
151 | 151 | ); |
152 | 152 | } |
153 | 153 | } |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | * @param int $TXN_ID |
170 | 170 | * @param int $PAY_ID |
171 | 171 | */ |
172 | - public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) { |
|
173 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
174 | - if ( absint( $TXN_ID )) { |
|
175 | - self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID; |
|
172 | + public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) { |
|
173 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
174 | + if (absint($TXN_ID)) { |
|
175 | + self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID; |
|
176 | 176 | add_action( |
177 | 177 | 'shutdown', |
178 | - array( 'EE_Cron_Tasks', 'update_transaction_with_payment' ), |
|
178 | + array('EE_Cron_Tasks', 'update_transaction_with_payment'), |
|
179 | 179 | 5 |
180 | 180 | ); |
181 | 181 | } |
@@ -194,18 +194,18 @@ discard block |
||
194 | 194 | * @throws \EE_Error |
195 | 195 | */ |
196 | 196 | public static function update_transaction_with_payment() { |
197 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
197 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
198 | 198 | // are there any TXNs that need cleaning up ? |
199 | - if ( ! empty( self::$_update_transactions_with_payment ) ) { |
|
199 | + if ( ! empty(self::$_update_transactions_with_payment)) { |
|
200 | 200 | /** @type EE_Payment_Processor $payment_processor */ |
201 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
201 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
202 | 202 | // set revisit flag for payment processor |
203 | - $payment_processor->set_revisit( false ); |
|
203 | + $payment_processor->set_revisit(false); |
|
204 | 204 | // load EEM_Transaction |
205 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
206 | - foreach ( self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID ) { |
|
205 | + EE_Registry::instance()->load_model('Transaction'); |
|
206 | + foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) { |
|
207 | 207 | // reschedule the cron if we can't hit the db right now |
208 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
208 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
209 | 209 | // reset cron job for updating the TXN |
210 | 210 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
211 | 211 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -214,14 +214,14 @@ discard block |
||
214 | 214 | ); |
215 | 215 | continue; |
216 | 216 | } |
217 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
218 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
217 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
218 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
219 | 219 | // verify transaction |
220 | - if ( $transaction instanceof EE_Transaction && $payment instanceof EE_Payment ) { |
|
220 | + if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) { |
|
221 | 221 | // now try to update the TXN with any payments |
222 | - $payment_processor->update_txn_based_on_payment( $transaction, $payment, true, true ); |
|
222 | + $payment_processor->update_txn_based_on_payment($transaction, $payment, true, true); |
|
223 | 223 | } |
224 | - unset( self::$_update_transactions_with_payment[ $TXN_ID ] ); |
|
224 | + unset(self::$_update_transactions_with_payment[$TXN_ID]); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $TXN_ID |
259 | 259 | ) { |
260 | 260 | // validate $TXN_ID and $timestamp |
261 | - $TXN_ID = absint( $TXN_ID ); |
|
262 | - $timestamp = absint( $timestamp ); |
|
263 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
264 | - if ( $TXN_ID && $timestamp ) { |
|
261 | + $TXN_ID = absint($TXN_ID); |
|
262 | + $timestamp = absint($timestamp); |
|
263 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
264 | + if ($TXN_ID && $timestamp) { |
|
265 | 265 | wp_schedule_single_event( |
266 | 266 | $timestamp, |
267 | 267 | 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions', |
268 | - array( $TXN_ID ) |
|
268 | + array($TXN_ID) |
|
269 | 269 | ); |
270 | 270 | } |
271 | 271 | } |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param int $TXN_ID |
289 | 289 | */ |
290 | - public static function check_for_abandoned_transactions( $TXN_ID = 0 ) { |
|
291 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
292 | - if ( absint( $TXN_ID )) { |
|
293 | - self::$_abandoned_transactions[] = $TXN_ID; |
|
290 | + public static function check_for_abandoned_transactions($TXN_ID = 0) { |
|
291 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
292 | + if (absint($TXN_ID)) { |
|
293 | + self::$_abandoned_transactions[] = $TXN_ID; |
|
294 | 294 | add_action( |
295 | 295 | 'shutdown', |
296 | - array( 'EE_Cron_Tasks', 'finalize_abandoned_transactions' ), |
|
296 | + array('EE_Cron_Tasks', 'finalize_abandoned_transactions'), |
|
297 | 297 | 5 |
298 | 298 | ); |
299 | 299 | } |
@@ -312,21 +312,21 @@ discard block |
||
312 | 312 | * @throws \EE_Error |
313 | 313 | */ |
314 | 314 | public static function finalize_abandoned_transactions() { |
315 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
315 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
316 | 316 | // are there any TXNs that need cleaning up ? |
317 | - if ( ! empty( self::$_abandoned_transactions ) ) { |
|
317 | + if ( ! empty(self::$_abandoned_transactions)) { |
|
318 | 318 | /** @type EE_Transaction_Processor $transaction_processor */ |
319 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
319 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
320 | 320 | // set revisit flag for txn processor |
321 | - $transaction_processor->set_revisit( false ); |
|
321 | + $transaction_processor->set_revisit(false); |
|
322 | 322 | /** @type EE_Payment_Processor $payment_processor */ |
323 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
323 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
324 | 324 | // load EEM_Transaction |
325 | - EE_Registry::instance()->load_model( 'Transaction' ); |
|
326 | - foreach ( self::$_abandoned_transactions as $TXN_ID ) { |
|
327 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' ); |
|
325 | + EE_Registry::instance()->load_model('Transaction'); |
|
326 | + foreach (self::$_abandoned_transactions as $TXN_ID) { |
|
327 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID'); |
|
328 | 328 | // reschedule the cron if we can't hit the db right now |
329 | - if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
329 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
330 | 330 | // reset cron job for finalizing the TXN |
331 | 331 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
332 | 332 | time() + EE_Cron_Tasks::reschedule_timeout, |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | ); |
335 | 335 | continue; |
336 | 336 | } |
337 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
337 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
338 | 338 | // verify transaction |
339 | - if ( $transaction instanceof EE_Transaction ) { |
|
339 | + if ($transaction instanceof EE_Transaction) { |
|
340 | 340 | // don't finalize the TXN if it has already been completed |
341 | - if ( $transaction->all_reg_steps_completed() === true ) { |
|
341 | + if ($transaction->all_reg_steps_completed() === true) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | // let's simulate an IPN here which will trigger any notifications that need to go out |
345 | - $payment_processor->update_txn_based_on_payment( $transaction, $transaction->last_payment(), true, true ); |
|
345 | + $payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true); |
|
346 | 346 | } |
347 | - unset( self::$_abandoned_transactions[ $TXN_ID ] ); |
|
347 | + unset(self::$_abandoned_transactions[$TXN_ID]); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | //when a transaction is initially made, schedule this check. |
361 | 361 | //if it has NO REG data by the time it has expired, forget about it |
362 | 362 | public static function clean_out_junk_transactions() { |
363 | - if( EE_Maintenance_Mode::instance()->models_can_query() ) { |
|
363 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
364 | 364 | EEM_Transaction::instance('')->delete_junk_transactions(); |
365 | 365 | EEM_Registration::instance('')->delete_registrations_with_no_transaction(); |
366 | 366 | EEM_Line_Item::instance('')->delete_line_items_with_no_transaction(); |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | |
164 | 164 | /** |
165 | 165 | * grab url requests and route them |
166 | - * @access private |
|
167 | - * @return void |
|
168 | - */ |
|
166 | + * @access private |
|
167 | + * @return void |
|
168 | + */ |
|
169 | 169 | public function _set_page_routes() { |
170 | 170 | |
171 | 171 | $this->_get_registration_status_array(); |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | 'title' => __('Registrations Other', 'event_espresso'), |
438 | 438 | 'filename' => 'registrations_overview_other' |
439 | 439 | ) |
440 | - ), |
|
440 | + ), |
|
441 | 441 | 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | : $this->_admin_base_url, |
457 | 457 | 'persistent' => FALSE |
458 | 458 | ), |
459 | - 'help_tabs' => array( |
|
459 | + 'help_tabs' => array( |
|
460 | 460 | 'registrations_details_help_tab' => array( |
461 | 461 | 'title' => __('Registration Details', 'event_espresso'), |
462 | 462 | 'filename' => 'registrations_details' |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | 'order' => 20 |
521 | 521 | ), |
522 | 522 | 'list_table' => 'EE_Attendee_Contact_List_Table', |
523 | - 'help_tabs' => array( |
|
523 | + 'help_tabs' => array( |
|
524 | 524 | 'registrations_contact_list_help_tab' => array( |
525 | 525 | 'title' => __('Registrations Contact List', 'event_espresso'), |
526 | 526 | 'filename' => 'registrations_contact_list' |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | 'title' => __('Contact List Other', 'event_espresso'), |
538 | 538 | 'filename' => 'registrations_contact_list_other' |
539 | 539 | ) |
540 | - ), |
|
540 | + ), |
|
541 | 541 | 'help_tour' => array( 'Contact_List_Help_Tour' ), |
542 | 542 | 'metaboxes' => array(), |
543 | 543 | 'require_nonce' => FALSE |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | |
572 | 572 | /** |
573 | 573 | * get list of registration statuses |
574 | - * @access private |
|
575 | - * @return void |
|
576 | - */ |
|
574 | + * @access private |
|
575 | + * @return void |
|
576 | + */ |
|
577 | 577 | private function _get_registration_status_array() { |
578 | 578 | self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
579 | 579 | } |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | |
866 | 866 | |
867 | 867 | /** |
868 | - * @throws \EE_Error |
|
869 | - */ |
|
868 | + * @throws \EE_Error |
|
869 | + */ |
|
870 | 870 | protected function _registrations_overview_list_table() { |
871 | 871 | $this->_template_args['admin_page_header'] = ''; |
872 | 872 | $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | return TRUE; |
927 | 927 | } |
928 | 928 | |
929 | - $REG = EEM_Registration::instance(); |
|
929 | + $REG = EEM_Registration::instance(); |
|
930 | 930 | |
931 | 931 | $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
932 | 932 | |
@@ -1150,9 +1150,9 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | /** |
1152 | 1152 | * generates HTML for the View Registration Details Admin page |
1153 | - * @access protected |
|
1154 | - * @return void |
|
1155 | - */ |
|
1153 | + * @access protected |
|
1154 | + * @return void |
|
1155 | + */ |
|
1156 | 1156 | protected function _registration_details() { |
1157 | 1157 | |
1158 | 1158 | $this->_template_args = array(); |
@@ -1325,16 +1325,16 @@ discard block |
||
1325 | 1325 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
1326 | 1326 | //); |
1327 | 1327 | //Approved |
1328 | - //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
1328 | + //An approved registration allows payments and may have a transaction status of incomplete or complete . The registration is marked as active and a space is reserved for the registrant . |
|
1329 | 1329 | //Cancelled |
1330 | 1330 | // A { |
1331 | 1331 | // cancelled} registration is performed by the registrant . Payments are not allowed, the registration is inactive, and no space is reserved . |
1332 | 1332 | //Declined |
1333 | - //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
1333 | + //A declined registration is performed by the event admin . Payments are not allowed, the registration is inactive, and not space is reserved . |
|
1334 | 1334 | //Not Approved |
1335 | - //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
1335 | + //A not approved registration is performed by the event admin . Payments are not allowed, the registration is active, and no space is reserved . |
|
1336 | 1336 | //Pending Payment |
1337 | - //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
1337 | + //A pending registration allows payments . The status will be automatically toggled to approved if the { |
|
1338 | 1338 | // payment} is made in full by registrant . |
1339 | 1339 | |
1340 | 1340 | } |
@@ -1441,8 +1441,8 @@ discard block |
||
1441 | 1441 | */ |
1442 | 1442 | protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
1443 | 1443 | $result = ! empty( $STS_ID ) |
1444 | - ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
1445 | - : array( 'success' => false ); |
|
1444 | + ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
1445 | + : array( 'success' => false ); |
|
1446 | 1446 | $success = isset( $result['success'] ) && $result['success']; |
1447 | 1447 | //setup success message |
1448 | 1448 | if ( $success ) { |
@@ -1624,9 +1624,9 @@ discard block |
||
1624 | 1624 | |
1625 | 1625 | /** |
1626 | 1626 | * generates HTML for the Registration main meta box |
1627 | - * @access public |
|
1628 | - * @return void |
|
1629 | - */ |
|
1627 | + * @access public |
|
1628 | + * @return void |
|
1629 | + */ |
|
1630 | 1630 | public function _reg_details_meta_box() { |
1631 | 1631 | EEH_Autoloader::register_line_item_display_autoloaders(); |
1632 | 1632 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | * |
1761 | 1761 | * @access public |
1762 | 1762 | * @return void |
1763 | - */ |
|
1763 | + */ |
|
1764 | 1764 | public function _reg_questions_meta_box() { |
1765 | 1765 | //allow someone to override this method entirely |
1766 | 1766 | if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
@@ -1962,12 +1962,12 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | /** |
1964 | 1964 | * generates HTML for the Registration main meta box |
1965 | - * @access public |
|
1966 | - * @return void |
|
1967 | - */ |
|
1965 | + * @access public |
|
1966 | + * @return void |
|
1967 | + */ |
|
1968 | 1968 | public function _reg_attendees_meta_box() { |
1969 | 1969 | |
1970 | - $REG = EEM_Registration::instance(); |
|
1970 | + $REG = EEM_Registration::instance(); |
|
1971 | 1971 | //get all other registrations on this transaction, and cache |
1972 | 1972 | //the attendees for them so we don't have to run another query using force_join |
1973 | 1973 | $registrations = $REG->get_all(array( |
@@ -2019,9 +2019,9 @@ discard block |
||
2019 | 2019 | |
2020 | 2020 | /** |
2021 | 2021 | * generates HTML for the Edit Registration side meta box |
2022 | - * @access public |
|
2023 | - * @return void |
|
2024 | - */ |
|
2022 | + * @access public |
|
2023 | + * @return void |
|
2024 | + */ |
|
2025 | 2025 | public function _reg_registrant_side_meta_box() { |
2026 | 2026 | |
2027 | 2027 | /*@var $attendee EE_Attendee */ |
@@ -2402,9 +2402,9 @@ discard block |
||
2402 | 2402 | |
2403 | 2403 | /** |
2404 | 2404 | * set_reg_event |
2405 | - * @access private |
|
2406 | - * @return boolean |
|
2407 | - */ |
|
2405 | + * @access private |
|
2406 | + * @return boolean |
|
2407 | + */ |
|
2408 | 2408 | private function _set_reg_event() { |
2409 | 2409 | if ( is_object( $this->_reg_event )) { |
2410 | 2410 | return TRUE; |
@@ -2544,9 +2544,9 @@ discard block |
||
2544 | 2544 | |
2545 | 2545 | /** |
2546 | 2546 | * generates HTML for the Attendee Contact List |
2547 | - * @access protected |
|
2548 | - * @return void |
|
2549 | - */ |
|
2547 | + * @access protected |
|
2548 | + * @return void |
|
2549 | + */ |
|
2550 | 2550 | protected function _attendee_contact_list_table() { |
2551 | 2551 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
2552 | 2552 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
@@ -2560,9 +2560,9 @@ discard block |
||
2560 | 2560 | /** |
2561 | 2561 | * get_attendees |
2562 | 2562 | * @param bool $count whether to return count or data. |
2563 | - * @access public |
|
2564 | - * @return array |
|
2565 | - */ |
|
2563 | + * @access public |
|
2564 | + * @return array |
|
2565 | + */ |
|
2566 | 2566 | public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
2567 | 2567 | |
2568 | 2568 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -2894,9 +2894,9 @@ discard block |
||
2894 | 2894 | |
2895 | 2895 | /** |
2896 | 2896 | * _attendee_details |
2897 | - * @access protected |
|
2898 | - * @return void |
|
2899 | - */ |
|
2897 | + * @access protected |
|
2898 | + * @return void |
|
2899 | + */ |
|
2900 | 2900 | public function attendee_registrations_meta_box( $post ) { |
2901 | 2901 | |
2902 | 2902 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
@@ -2929,10 +2929,10 @@ discard block |
||
2929 | 2929 | |
2930 | 2930 | /** |
2931 | 2931 | * _trash_or_restore_attendee |
2932 | - * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
2933 | - * @access protected |
|
2934 | - * @return void |
|
2935 | - */ |
|
2932 | + * @param boolean $trash - whether to move item to trash (TRUE) or restore it (FALSE) |
|
2933 | + * @access protected |
|
2934 | + * @return void |
|
2935 | + */ |
|
2936 | 2936 | protected function _trash_or_restore_attendees( $trash = TRUE ) { |
2937 | 2937 | |
2938 | 2938 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Registrations_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
61 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | 66 | public function wp_loaded() { |
67 | 67 | // when adding a new registration... |
68 | - if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
|
68 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') { |
|
69 | 69 | EE_System::do_not_cache(); |
70 | 70 | if ( |
71 | - ! isset( $this->_req_data[ 'processing_registration' ] ) |
|
72 | - || absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
|
71 | + ! isset($this->_req_data['processing_registration']) |
|
72 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
73 | 73 | ) { |
74 | 74 | // and it's NOT the attendee information reg step |
75 | 75 | // force cookie expiration by setting time to last week |
76 | - setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
|
76 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
77 | 77 | // and update the global |
78 | - $_COOKIE[ 'ee_registration_added' ] = 0; |
|
78 | + $_COOKIE['ee_registration_added'] = 0; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | 'trash' => 'post.php' |
110 | 110 | ); |
111 | 111 | |
112 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
|
112 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
113 | 113 | //add filters so that the comment urls don't take users to a confusing 404 page |
114 | - add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
|
114 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | - public function clear_comment_link( $link, $comment, $args ) { |
|
118 | + public function clear_comment_link($link, $comment, $args) { |
|
119 | 119 | //gotta make sure this only happens on this route |
120 | - $post_type = get_post_type( $comment->comment_post_ID); |
|
121 | - if ( $post_type == 'espresso_attendees' ) |
|
120 | + $post_type = get_post_type($comment->comment_post_ID); |
|
121 | + if ($post_type == 'espresso_attendees') |
|
122 | 122 | return '#commentsdiv'; |
123 | 123 | return $link; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | protected function _ajax_hooks() { |
128 | 128 | //todo: all hooks for registrations ajax goes in here |
129 | - add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' )); |
|
129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | 'add-attendee' => __('Add Contact', 'event_espresso'), |
142 | 142 | 'edit' => __('Edit Contact', 'event_espresso'), |
143 | 143 | 'report'=> __("Event Registrations CSV Report", "event_espresso"), |
144 | - 'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ), |
|
145 | - 'contact_list_report' => __( 'Contact List Report', 'event_espresso' ), |
|
144 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
145 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
146 | 146 | 'contact_list_export'=> __("Export Data", "event_espresso"), |
147 | 147 | ), |
148 | 148 | 'publishbox' => array( |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | |
171 | 171 | $this->_get_registration_status_array(); |
172 | 172 | |
173 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
173 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
176 | 176 | |
177 | 177 | $this->_page_routes = array( |
178 | 178 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | 'restore_registrations' => array( |
207 | 207 | 'func' => '_trash_or_restore_registrations', |
208 | - 'args' => array( 'trash' => FALSE ), |
|
208 | + 'args' => array('trash' => FALSE), |
|
209 | 209 | 'noheader' => TRUE, |
210 | 210 | 'capability' => 'ee_delete_registrations' |
211 | 211 | ), |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'filename' => 'registrations_overview_other' |
439 | 439 | ) |
440 | 440 | ), |
441 | - 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
|
441 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
444 | 444 | 'require_nonce' => FALSE |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'order' => 15, |
451 | 451 | 'url' => isset($this->_req_data['_REG_ID']) |
452 | 452 | ? add_query_arg( |
453 | - array('_REG_ID' => $this->_req_data['_REG_ID'] ), |
|
453 | + array('_REG_ID' => $this->_req_data['_REG_ID']), |
|
454 | 454 | $this->_current_page_view_url |
455 | 455 | ) |
456 | 456 | : $this->_admin_base_url, |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | 'filename' => 'registrations_details_registrant_details' |
475 | 475 | ) |
476 | 476 | ), |
477 | - 'help_tour' => array( 'Registration_Details_Help_Tour' ), |
|
478 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
|
477 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
478 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')), |
|
479 | 479 | 'require_nonce' => FALSE |
480 | 480 | ), |
481 | 481 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | 'order' => 15, |
500 | 500 | 'persistent' => FALSE |
501 | 501 | ), |
502 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
|
502 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
503 | 503 | 'require_nonce' => FALSE |
504 | 504 | ), |
505 | 505 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | 'label' => __('Edit Contact', 'event_espresso'), |
509 | 509 | 'order' => 15, |
510 | 510 | 'persistent' => FALSE, |
511 | - 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
511 | + 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
512 | 512 | ), |
513 | 513 | 'metaboxes' => array('attendee_editor_metaboxes'), |
514 | 514 | 'require_nonce' => FALSE |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | 'filename' => 'registrations_contact_list_other' |
539 | 539 | ) |
540 | 540 | ), |
541 | - 'help_tour' => array( 'Contact_List_Help_Tour' ), |
|
541 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
542 | 542 | 'metaboxes' => array(), |
543 | 543 | 'require_nonce' => FALSE |
544 | 544 | ), |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | protected function _add_screen_options() {} |
558 | 558 | protected function _add_feature_pointers() {} |
559 | 559 | public function admin_init() { |
560 | - EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
|
560 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso'); |
|
561 | 561 | } |
562 | 562 | public function admin_notices() {} |
563 | 563 | public function admin_footer_scripts() {} |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @return void |
576 | 576 | */ |
577 | 577 | private function _get_registration_status_array() { |
578 | - self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
|
578 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | public function load_scripts_styles() { |
599 | 599 | //style |
600 | 600 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
601 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
601 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
602 | 602 | wp_enqueue_style('espresso_reg'); |
603 | 603 | |
604 | 604 | //script |
605 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
605 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
606 | 606 | wp_enqueue_script('espresso_reg'); |
607 | 607 | } |
608 | 608 | |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | public function load_scripts_styles_edit_attendee() { |
612 | 612 | //stuff to only show up on our attendee edit details page. |
613 | 613 | $attendee_details_translations = array( |
614 | - 'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') ) |
|
614 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created')) |
|
615 | 615 | ); |
616 | - wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations ); |
|
616 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
617 | 617 | wp_enqueue_script('jquery-validate'); |
618 | 618 | } |
619 | 619 | |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | //styles |
623 | 623 | wp_enqueue_style('espresso-ui-theme'); |
624 | 624 | //scripts |
625 | - $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
626 | - $this->_reg_custom_questions_form->wp_enqueue_scripts( true ); |
|
625 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
626 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | public function load_scripts_styles_contact_list() { |
635 | 635 | wp_deregister_style('espresso_reg'); |
636 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
636 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
637 | 637 | wp_enqueue_style('espresso_att'); |
638 | 638 | } |
639 | 639 | |
@@ -642,9 +642,9 @@ discard block |
||
642 | 642 | |
643 | 643 | |
644 | 644 | public function load_scripts_styles_new_registration() { |
645 | - wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
645 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
646 | 646 | wp_enqueue_script('ee-spco-for-admin'); |
647 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
647 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
648 | 648 | EE_Form_Section_Proper::wp_enqueue_scripts(); |
649 | 649 | EED_Ticket_Selector::load_tckt_slctr_assets(); |
650 | 650 | EE_Datepicker_Input::enqueue_styles_and_scripts(); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | //for notification related bulk actions we need to make sure only active messengers have an option. |
672 | 672 | EED_Messages::set_autoloaders(); |
673 | 673 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
674 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
674 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
675 | 675 | $active_mts = $message_resource_manager->list_of_active_message_types(); |
676 | 676 | //key= bulk_action_slug, value= message type. |
677 | 677 | $match_array = array( |
@@ -684,23 +684,23 @@ discard block |
||
684 | 684 | |
685 | 685 | /** setup reg status bulk actions **/ |
686 | 686 | $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
687 | - if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
687 | + if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
688 | 688 | $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso'); |
689 | 689 | } |
690 | 690 | $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
691 | - if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
691 | + if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
692 | 692 | $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso'); |
693 | 693 | } |
694 | 694 | $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
695 | - if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
695 | + if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
696 | 696 | $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso'); |
697 | 697 | } |
698 | 698 | $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
699 | - if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
699 | + if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
700 | 700 | $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso'); |
701 | 701 | } |
702 | 702 | $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
703 | - if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
703 | + if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
704 | 704 | $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso'); |
705 | 705 | } |
706 | 706 | |
@@ -709,29 +709,29 @@ discard block |
||
709 | 709 | 'slug' => 'all', |
710 | 710 | 'label' => __('View All Registrations', 'event_espresso'), |
711 | 711 | 'count' => 0, |
712 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
712 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
713 | 713 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
714 | - ) ) |
|
714 | + )) |
|
715 | 715 | ), |
716 | 716 | 'month' => array( |
717 | 717 | 'slug' => 'month', |
718 | 718 | 'label' => __('This Month', 'event_espresso'), |
719 | 719 | 'count' => 0, |
720 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
720 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
721 | 721 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
722 | 722 | )) |
723 | 723 | ), |
724 | 724 | 'today' => array( |
725 | 725 | 'slug' => 'today', |
726 | - 'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ), |
|
726 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
727 | 727 | 'count' => 0, |
728 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
728 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
729 | 729 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
730 | 730 | )) |
731 | 731 | ) |
732 | 732 | ); |
733 | 733 | |
734 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) { |
|
734 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) { |
|
735 | 735 | $this->_views['incomplete'] = array( |
736 | 736 | 'slug' => 'incomplete', |
737 | 737 | 'label' => __('Incomplete', 'event_espresso'), |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | ) |
768 | 768 | ); |
769 | 769 | |
770 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
|
770 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { |
|
771 | 771 | $this->_views['trash'] = array( |
772 | 772 | 'slug' => 'trash', |
773 | 773 | 'label' => __('Trash', 'event_espresso'), |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | 'desc' => __('View Transaction Invoice', 'event_espresso') |
807 | 807 | ), |
808 | 808 | ); |
809 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
809 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) { |
|
810 | 810 | $fc_items['resend_registration'] = array( |
811 | 811 | 'class' => 'dashicons dashicons-email-alt', |
812 | 812 | 'desc' => __('Resend Registration Details', 'event_espresso') |
813 | 813 | ); |
814 | 814 | } else { |
815 | - $fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' ); |
|
815 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
816 | 816 | } |
817 | 817 | |
818 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
819 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
820 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
818 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
819 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
820 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
821 | 821 | $fc_items['view_related_messages'] = array( |
822 | 822 | 'class' => $related_for_icon['css_class'], |
823 | 823 | 'desc' => $related_for_icon['label'], |
@@ -827,35 +827,35 @@ discard block |
||
827 | 827 | |
828 | 828 | $sc_items = array( |
829 | 829 | 'approved_status' => array( |
830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
831 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
832 | 832 | ), |
833 | 833 | 'pending_status' => array( |
834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
835 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
836 | 836 | ), |
837 | 837 | 'wait_list' => array( |
838 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
839 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) |
|
838 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
839 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') |
|
840 | 840 | ), |
841 | 841 | 'incomplete_status' => array( |
842 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
843 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' ) |
|
842 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
843 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence') |
|
844 | 844 | ), |
845 | 845 | 'not_approved' => array( |
846 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
847 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
846 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
847 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
848 | 848 | ), |
849 | 849 | 'declined_status' => array( |
850 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
851 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
850 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
851 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
852 | 852 | ), |
853 | 853 | 'cancelled_status' => array( |
854 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
855 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
854 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
855 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
856 | 856 | ) |
857 | 857 | ); |
858 | - return array_merge( $fc_items, $sc_items ); |
|
858 | + return array_merge($fc_items, $sc_items); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -869,45 +869,45 @@ discard block |
||
869 | 869 | */ |
870 | 870 | protected function _registrations_overview_list_table() { |
871 | 871 | $this->_template_args['admin_page_header'] = ''; |
872 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
|
873 | - if ( $EVT_ID ) { |
|
874 | - if ( EE_Registry::instance()->CAP->current_user_can( |
|
872 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
873 | + if ($EVT_ID) { |
|
874 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
875 | 875 | 'ee_edit_registrations', |
876 | 876 | 'espresso_registrations_new_registration', |
877 | 877 | $EVT_ID |
878 | 878 | ) |
879 | 879 | ) { |
880 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
880 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
881 | 881 | 'new_registration', |
882 | 882 | 'add-registrant', |
883 | - array( 'event_id' => $EVT_ID ), |
|
883 | + array('event_id' => $EVT_ID), |
|
884 | 884 | 'add-new-h2' |
885 | 885 | ); |
886 | 886 | } |
887 | - $event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
888 | - if ( $event instanceof EE_Event ) { |
|
887 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
888 | + if ($event instanceof EE_Event) { |
|
889 | 889 | $this->_template_args['admin_page_header'] = sprintf( |
890 | - __( '%s Viewing registrations for the event: %s%s', 'event_espresso' ), |
|
890 | + __('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
891 | 891 | '<h3 style="line-height:1.5em;">', |
892 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
893 | - array( 'action' => 'edit', 'post' => $event->ID() ), |
|
892 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
893 | + array('action' => 'edit', 'post' => $event->ID()), |
|
894 | 894 | EVENTS_ADMIN_URL |
895 | - ) . '"> ' . $event->get( 'EVT_name' ) . ' </a> ', |
|
895 | + ).'"> '.$event->get('EVT_name').' </a> ', |
|
896 | 896 | '</h3>' |
897 | 897 | ); |
898 | 898 | } |
899 | - $DTT_ID = ! empty( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : 0; |
|
900 | - $datetime = EEM_Datetime::instance()->get_one_by_ID( $DTT_ID ); |
|
901 | - if ( $datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '' ) { |
|
902 | - $this->_template_args['admin_page_header'] = substr( $this->_template_args['admin_page_header'], 0, -5 ); |
|
899 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
900 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
901 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
902 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
903 | 903 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
904 | 904 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
905 | 905 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
906 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
906 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
907 | 907 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
908 | 908 | } |
909 | 909 | } |
910 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() ); |
|
910 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
911 | 911 | $this->display_admin_list_table_page_with_no_sidebar(); |
912 | 912 | } |
913 | 913 | |
@@ -922,19 +922,19 @@ discard block |
||
922 | 922 | */ |
923 | 923 | private function _set_registration_object() { |
924 | 924 | //get out if we've already set the object |
925 | - if ( is_object( $this->_registration )) { |
|
925 | + if (is_object($this->_registration)) { |
|
926 | 926 | return TRUE; |
927 | 927 | } |
928 | 928 | |
929 | 929 | $REG = EEM_Registration::instance(); |
930 | 930 | |
931 | - $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
931 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
932 | 932 | |
933 | - if ( $this->_registration = $REG->get_one_by_ID( $REG_ID )) |
|
933 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) |
|
934 | 934 | return TRUE; |
935 | 935 | else { |
936 | - $error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID ); |
|
937 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
936 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID); |
|
937 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
938 | 938 | $this->_registration = NULL; |
939 | 939 | return FALSE; |
940 | 940 | } |
@@ -952,25 +952,25 @@ discard block |
||
952 | 952 | * @throws \EE_Error |
953 | 953 | * @return mixed (int|array) int = count || array of registration objects |
954 | 954 | */ |
955 | - public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
|
956 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
957 | - $CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
|
958 | - $DTT_ID = isset( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : null; |
|
959 | - $reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
|
960 | - $month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
|
961 | - $today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | - $this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
955 | + public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) { |
|
956 | + $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE; |
|
957 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE; |
|
958 | + $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
959 | + $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE; |
|
960 | + $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april |
|
961 | + $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | + $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
963 | 963 | $start_date = FALSE; |
964 | 964 | $end_date = FALSE; |
965 | 965 | $_where = array(); |
966 | - $trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | - $incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
966 | + $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | + $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
968 | 968 | |
969 | 969 | //set orderby |
970 | 970 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
971 | 971 | |
972 | 972 | |
973 | - switch ( $this->_req_data['orderby'] ) { |
|
973 | + switch ($this->_req_data['orderby']) { |
|
974 | 974 | case '_REG_ID': |
975 | 975 | $orderby = 'REG_ID'; |
976 | 976 | break; |
@@ -990,30 +990,30 @@ discard block |
||
990 | 990 | $orderby = 'REG_date'; |
991 | 991 | } |
992 | 992 | |
993 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
994 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
995 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
993 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
994 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
995 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
996 | 996 | |
997 | 997 | |
998 | - $offset = ($current_page-1)*$per_page; |
|
999 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
998 | + $offset = ($current_page - 1) * $per_page; |
|
999 | + $limit = $count ? NULL : array($offset, $per_page); |
|
1000 | 1000 | |
1001 | - if($EVT_ID){ |
|
1002 | - $_where['EVT_ID']=$EVT_ID; |
|
1001 | + if ($EVT_ID) { |
|
1002 | + $_where['EVT_ID'] = $EVT_ID; |
|
1003 | 1003 | } |
1004 | - if($CAT_ID){ |
|
1004 | + if ($CAT_ID) { |
|
1005 | 1005 | $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
1006 | 1006 | } |
1007 | 1007 | //if DTT is included we filter by that datetime. |
1008 | - if ( $DTT_ID ) { |
|
1008 | + if ($DTT_ID) { |
|
1009 | 1009 | $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
1010 | 1010 | } |
1011 | - if ( $incomplete ) { |
|
1011 | + if ($incomplete) { |
|
1012 | 1012 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
1013 | 1013 | } else if ( ! $trash) { |
1014 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
1014 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
1015 | 1015 | } |
1016 | - if($reg_status){ |
|
1016 | + if ($reg_status) { |
|
1017 | 1017 | $_where['STS_ID'] = $reg_status; |
1018 | 1018 | } |
1019 | 1019 | |
@@ -1025,103 +1025,103 @@ discard block |
||
1025 | 1025 | $time_start = ' 00:00:00'; |
1026 | 1026 | $time_end = ' 23:59:59'; |
1027 | 1027 | |
1028 | - if($today_a || $today ){ |
|
1028 | + if ($today_a || $today) { |
|
1029 | 1029 | $curdate = date('Y-m-d', current_time('timestamp')); |
1030 | - $_where['REG_date']= array('BETWEEN', |
|
1030 | + $_where['REG_date'] = array('BETWEEN', |
|
1031 | 1031 | array( |
1032 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
|
1033 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
|
1032 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'), |
|
1033 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'), |
|
1034 | 1034 | )); |
1035 | - }elseif($this_month_a || $this_month){ |
|
1035 | + }elseif ($this_month_a || $this_month) { |
|
1036 | 1036 | $this_month_r = date('m', current_time('timestamp')); |
1037 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
1038 | - $_where['REG_date']= array('BETWEEN', |
|
1037 | + $days_this_month = date('t', current_time('timestamp')); |
|
1038 | + $_where['REG_date'] = array('BETWEEN', |
|
1039 | 1039 | array( |
1040 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
|
1041 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
|
1040 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'), |
|
1041 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s') |
|
1042 | 1042 | )); |
1043 | - }elseif($month_range){ |
|
1043 | + }elseif ($month_range) { |
|
1044 | 1044 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1045 | - $month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
|
1046 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
|
1048 | - $_where['REG_date']= array('BETWEEN', |
|
1049 | - array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
|
1050 | - }elseif($start_date && $end_date){ |
|
1045 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
1046 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | + $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01')); |
|
1048 | + $_where['REG_date'] = array('BETWEEN', |
|
1049 | + array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'))); |
|
1050 | + }elseif ($start_date && $end_date) { |
|
1051 | 1051 | throw new EE_Error("not yet supported"); |
1052 | - }elseif($start_date){ |
|
1052 | + }elseif ($start_date) { |
|
1053 | 1053 | throw new EE_Error("not yet supported"); |
1054 | - }elseif($end_date){ |
|
1054 | + }elseif ($end_date) { |
|
1055 | 1055 | throw new EE_Error("not yet supported"); |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
1059 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1058 | + if ( ! empty($this->_req_data['s'])) { |
|
1059 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1060 | 1060 | $_where['OR'] = array( |
1061 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
1062 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
1063 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
1064 | - 'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
|
1065 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
1066 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
1067 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
1068 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
1069 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
1070 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
1071 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
1072 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
1073 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
1074 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
1075 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
1076 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
1077 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
|
1078 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
|
1061 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1062 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1063 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1064 | + 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
1065 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1066 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1067 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1068 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1069 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1070 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1071 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1072 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1073 | + 'REG_code' => array('LIKE', $sstr), |
|
1074 | + 'REG_count' => array('LIKE', $sstr), |
|
1075 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1076 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1077 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1078 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr) |
|
1079 | 1079 | ); |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | //capability checks |
1083 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
|
1083 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
1084 | 1084 | $_where['AND'] = array( |
1085 | 1085 | 'Event.EVT_wp_user' => get_current_user_id() |
1086 | 1086 | ); |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - if( $count ){ |
|
1090 | - if ( $trash ) { |
|
1091 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
1092 | - } else if ( $incomplete ) { |
|
1093 | - return EEM_Registration::instance()->count( array( $_where )); |
|
1089 | + if ($count) { |
|
1090 | + if ($trash) { |
|
1091 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
1092 | + } else if ($incomplete) { |
|
1093 | + return EEM_Registration::instance()->count(array($_where)); |
|
1094 | 1094 | } else { |
1095 | - return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
|
1095 | + return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only')); |
|
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | //make sure we remove default where conditions cause all registrations matching query are returned |
1099 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
|
1100 | - if ( $per_page !== -1 ) { |
|
1099 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only'); |
|
1100 | + if ($per_page !== -1) { |
|
1101 | 1101 | $query_params['limit'] = $limit; |
1102 | 1102 | } |
1103 | - $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1103 | + $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1104 | 1104 | |
1105 | - if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1105 | + if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1106 | 1106 | $first_registration = $registrations[0]; |
1107 | 1107 | //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1108 | 1108 | $event_name = $first_registration->event_obj()->name(); |
1109 | - $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1109 | + $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1110 | 1110 | // edit event link |
1111 | - if ( $event_name != '' ) { |
|
1112 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
1113 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
1114 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
1111 | + if ($event_name != '') { |
|
1112 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
1113 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1114 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
1118 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
1117 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
1118 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
1119 | 1119 | |
1120 | 1120 | $this->_template_args['before_admin_page_content'] = ' |
1121 | 1121 | <div id="admin-page-header"> |
1122 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
1123 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
1124 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1122 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1123 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1124 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1125 | 1125 | </div> |
1126 | 1126 | '; |
1127 | 1127 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | $this->_set_registration_object(); |
1161 | 1161 | |
1162 | - if ( is_object( $this->_registration )) { |
|
1162 | + if (is_object($this->_registration)) { |
|
1163 | 1163 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1164 | 1164 | $this->_session = $transaction->session_data(); |
1165 | 1165 | |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | |
1169 | 1169 | $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
1170 | - $this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' ); |
|
1170 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
1171 | 1171 | |
1172 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime( 'REG_date' ); |
|
1173 | - $this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' ); |
|
1172 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
1173 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
1174 | 1174 | |
1175 | 1175 | $this->_template_args['grand_total'] = $transaction->total(); |
1176 | 1176 | |
@@ -1178,20 +1178,20 @@ discard block |
||
1178 | 1178 | // link back to overview |
1179 | 1179 | $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
1180 | 1180 | $this->_template_args['registration'] = $this->_registration; |
1181 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL ); |
|
1182 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) ); |
|
1183 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) ); |
|
1181 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL); |
|
1182 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php')); |
|
1183 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php')); |
|
1184 | 1184 | |
1185 | 1185 | //next and previous links |
1186 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID' ); |
|
1187 | - $this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : ''; |
|
1188 | - $previous_reg = $this->_registration->previous( null, array(), 'REG_ID' ); |
|
1189 | - $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : ''; |
|
1186 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
1187 | + $this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
1188 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
1189 | + $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
1190 | 1190 | |
1191 | 1191 | // grab header |
1192 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1192 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
1193 | 1193 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1194 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1194 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1195 | 1195 | |
1196 | 1196 | } else { |
1197 | 1197 | |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | |
1211 | 1211 | |
1212 | 1212 | protected function _registration_details_metaboxes() { |
1213 | - do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this ); |
|
1213 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
1214 | 1214 | $this->_set_registration_object(); |
1215 | 1215 | $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
1216 | - add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1217 | - add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1218 | - if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) { |
|
1219 | - add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1216 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
1217 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1218 | + if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) { |
|
1219 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1220 | 1220 | } |
1221 | - add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' ); |
|
1222 | - if ( $this->_registration->group_size() > 1 ) { |
|
1223 | - add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1221 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
1222 | + if ($this->_registration->group_size() > 1) { |
|
1223 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1262,25 +1262,25 @@ discard block |
||
1262 | 1262 | 'html_id' => 'reg-status-change-form', |
1263 | 1263 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
1264 | 1264 | 'subsections' => array( |
1265 | - 'return' => new EE_Hidden_Input( array( |
|
1265 | + 'return' => new EE_Hidden_Input(array( |
|
1266 | 1266 | 'name' => 'return', |
1267 | 1267 | 'default' => 'view_registration' |
1268 | - ) ), |
|
1269 | - 'REG_ID' => new EE_Hidden_Input( array( |
|
1268 | + )), |
|
1269 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
1270 | 1270 | 'name' => 'REG_ID', |
1271 | 1271 | 'default' => $this->_registration->ID() |
1272 | - ) ), |
|
1272 | + )), |
|
1273 | 1273 | 'current_status' => new EE_Form_Section_HTML( |
1274 | 1274 | EEH_HTML::tr( |
1275 | 1275 | EEH_HTML::th( |
1276 | 1276 | EEH_HTML::label( |
1277 | - EEH_HTML::strong( __( 'Current Registration Status', 'event_espresso' ) ) |
|
1277 | + EEH_HTML::strong(__('Current Registration Status', 'event_espresso')) |
|
1278 | 1278 | ) |
1279 | - ) . |
|
1279 | + ). |
|
1280 | 1280 | EEH_HTML::td( |
1281 | 1281 | EEH_HTML::strong( |
1282 | 1282 | $this->_registration->pretty_status(), |
1283 | - '', 'status-' . $this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
1283 | + '', 'status-'.$this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
1284 | 1284 | ) |
1285 | 1285 | ) |
1286 | 1286 | ) |
@@ -1288,22 +1288,22 @@ discard block |
||
1288 | 1288 | 'reg_status' => new EE_Select_Input( |
1289 | 1289 | $this->_get_reg_statuses(), |
1290 | 1290 | array( |
1291 | - 'html_label_text' => __( 'Change Registration Status to', 'event_espresso' ), |
|
1291 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
1292 | 1292 | 'default' => $this->_registration->status_ID(), |
1293 | 1293 | ) |
1294 | 1294 | ), |
1295 | 1295 | 'send_notifications' => new EE_Yes_No_Input( |
1296 | 1296 | array( |
1297 | - 'html_label_text' => __( 'Send Related Messages', 'event_espresso' ), |
|
1297 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
1298 | 1298 | 'default' => false, |
1299 | - 'html_help_text' => __( 'If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso' ), |
|
1299 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso'), |
|
1300 | 1300 | ) |
1301 | 1301 | ), |
1302 | - 'submit' => new EE_Submit_Input( array( |
|
1302 | + 'submit' => new EE_Submit_Input(array( |
|
1303 | 1303 | 'html_class' => 'button-primary', |
1304 | 1304 | 'html_label_text' => ' ', |
1305 | - 'default' => __( 'Update Registration Status', 'event_espresso' ) |
|
1306 | - ) ), |
|
1305 | + 'default' => __('Update Registration Status', 'event_espresso') |
|
1306 | + )), |
|
1307 | 1307 | ), |
1308 | 1308 | ) |
1309 | 1309 | ); |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | * Returns an array of all the buttons for the various statuses and switch status actions |
1317 | 1317 | * @return string |
1318 | 1318 | */ |
1319 | - protected function _get_current_reg_status_help_text( $STS_ID = '' ) { |
|
1319 | + protected function _get_current_reg_status_help_text($STS_ID = '') { |
|
1320 | 1320 | //$reg_status_help_text = array( |
1321 | 1321 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
1322 | 1322 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
@@ -1349,14 +1349,14 @@ discard block |
||
1349 | 1349 | */ |
1350 | 1350 | protected function _get_reg_statuses() { |
1351 | 1351 | $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
1352 | - unset ( $reg_status_array[ EEM_Registration::status_id_incomplete ] ); |
|
1352 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
1353 | 1353 | // get current reg status |
1354 | 1354 | $current_status = $this->_registration->status_ID(); |
1355 | 1355 | // is registration for free event? This will determine whether to display the pending payment option |
1356 | - if ( $current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free() ) { |
|
1357 | - unset( $reg_status_array[ EEM_Registration::status_id_pending_payment ] ); |
|
1356 | + if ($current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free()) { |
|
1357 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
1358 | 1358 | } |
1359 | - return EEM_Status::instance()->localized_status( $reg_status_array, false, 'sentence' ); |
|
1359 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | |
@@ -1369,15 +1369,15 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @return array (array with reg_id(s) updated and whether update was successful. |
1371 | 1371 | */ |
1372 | - protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
|
1373 | - if ( isset( $this->_req_data[ 'reg_status_change_form' ] ) ) { |
|
1374 | - $REG_IDs = isset( $this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] ) |
|
1375 | - ? (array)$this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] |
|
1372 | + protected function _set_registration_status_from_request($status = false, $notify = false) { |
|
1373 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
1374 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
1375 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] |
|
1376 | 1376 | : array(); |
1377 | 1377 | } else { |
1378 | - $REG_IDs = isset( $this->_req_data[ '_REG_ID' ] ) ? (array)$this->_req_data[ '_REG_ID' ] : array(); |
|
1378 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
1379 | 1379 | } |
1380 | - $success = $this->_set_registration_status( $REG_IDs, $status ); |
|
1380 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
1381 | 1381 | //notify? |
1382 | 1382 | if ( |
1383 | 1383 | $success |
@@ -1404,21 +1404,21 @@ discard block |
||
1404 | 1404 | * @param bool $status |
1405 | 1405 | * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
1406 | 1406 | */ |
1407 | - protected function _set_registration_status( $REG_IDs = array(), $status = false ) { |
|
1407 | + protected function _set_registration_status($REG_IDs = array(), $status = false) { |
|
1408 | 1408 | $success = false; |
1409 | 1409 | // typecast $REG_IDs |
1410 | - $REG_IDs = (array)$REG_IDs; |
|
1411 | - if ( ! empty( $REG_IDs ) ) { |
|
1410 | + $REG_IDs = (array) $REG_IDs; |
|
1411 | + if ( ! empty($REG_IDs)) { |
|
1412 | 1412 | $success = true; |
1413 | 1413 | // set default status if none is passed |
1414 | 1414 | $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
1415 | 1415 | // sanitize $REG_IDs |
1416 | - $REG_IDs = array_filter( $REG_IDs, 'absint' ); |
|
1416 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
1417 | 1417 | //loop through REG_ID's and change status |
1418 | - foreach ( $REG_IDs as $REG_ID ) { |
|
1419 | - $registration = EEM_Registration::instance()->get_one_by_ID( $REG_ID ); |
|
1420 | - if ( $registration instanceof EE_Registration ) { |
|
1421 | - $registration->set_status( $status ); |
|
1418 | + foreach ($REG_IDs as $REG_ID) { |
|
1419 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1420 | + if ($registration instanceof EE_Registration) { |
|
1421 | + $registration->set_status($status); |
|
1422 | 1422 | $result = $registration->save(); |
1423 | 1423 | // verifying explicit fails because update *may* just return 0 for 0 rows affected |
1424 | 1424 | $success = $result !== false ? $success : false; |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | //reset _req_data['_REG_ID'] for any potential future messages notifications |
1429 | 1429 | $this->_req_data['_REG_ID'] = $REG_IDs; |
1430 | 1430 | //return $success and processed registrations |
1431 | - return array( 'REG_ID' => $REG_IDs, 'success' => $success ); |
|
1431 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | |
@@ -1440,49 +1440,49 @@ discard block |
||
1440 | 1440 | * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
1441 | 1441 | * @return void |
1442 | 1442 | */ |
1443 | - protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
|
1444 | - $result = ! empty( $STS_ID ) |
|
1445 | - ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
1446 | - : array( 'success' => false ); |
|
1447 | - $success = isset( $result['success'] ) && $result['success']; |
|
1443 | + protected function _reg_status_change_return($STS_ID, $notify = false) { |
|
1444 | + $result = ! empty($STS_ID) |
|
1445 | + ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
1446 | + : array('success' => false); |
|
1447 | + $success = isset($result['success']) && $result['success']; |
|
1448 | 1448 | //setup success message |
1449 | - if ( $success ) { |
|
1450 | - if ( is_array( $result[ 'REG_ID' ] ) && count( $result[ 'REG_ID' ] ) === 1 ) { |
|
1449 | + if ($success) { |
|
1450 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
1451 | 1451 | $msg = sprintf( |
1452 | - __( 'Registration status has been set to %s', 'event_espresso' ), |
|
1453 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
1452 | + __('Registration status has been set to %s', 'event_espresso'), |
|
1453 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
1454 | 1454 | ); |
1455 | 1455 | } else { |
1456 | 1456 | $msg = sprintf( |
1457 | - __( 'Registrations have been set to %s.', 'event_espresso' ), |
|
1458 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
1457 | + __('Registrations have been set to %s.', 'event_espresso'), |
|
1458 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
1459 | 1459 | ); |
1460 | 1460 | } |
1461 | - EE_Error::add_success( $msg ); |
|
1461 | + EE_Error::add_success($msg); |
|
1462 | 1462 | } else { |
1463 | 1463 | EE_Error::add_error( |
1464 | - __( 'Something went wrong, and the status was not changed', 'event_espresso' ), |
|
1464 | + __('Something went wrong, and the status was not changed', 'event_espresso'), |
|
1465 | 1465 | __FILE__, __LINE__, __FUNCTION__ |
1466 | 1466 | ); |
1467 | 1467 | } |
1468 | - if ( isset( $this->_req_data[ 'return' ] ) && $this->_req_data[ 'return' ] == 'view_registration' ) { |
|
1469 | - $route = array( 'action' => 'view_registration', '_REG_ID' => reset( $result[ 'REG_ID' ] ) ); |
|
1468 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
1469 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
1470 | 1470 | } else { |
1471 | - $route = array( 'action' => 'default' ); |
|
1471 | + $route = array('action' => 'default'); |
|
1472 | 1472 | } |
1473 | 1473 | //unset nonces |
1474 | - foreach ( $this->_req_data as $ref => $value ) { |
|
1475 | - if ( strpos( $ref, 'nonce' ) !== false ) { |
|
1476 | - unset( $this->_req_data[$ref] ); |
|
1474 | + foreach ($this->_req_data as $ref => $value) { |
|
1475 | + if (strpos($ref, 'nonce') !== false) { |
|
1476 | + unset($this->_req_data[$ref]); |
|
1477 | 1477 | continue; |
1478 | 1478 | } |
1479 | 1479 | |
1480 | - $value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value ); |
|
1480 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
1481 | 1481 | $this->_req_data[$ref] = $value; |
1482 | 1482 | } |
1483 | 1483 | //merge request vars so that the reloaded list table contains any existing filter query params |
1484 | - $route = array_merge( $this->_req_data, $route ); |
|
1485 | - $this->_redirect_after_action( $success, '', '', $route, true ); |
|
1484 | + $route = array_merge($this->_req_data, $route); |
|
1485 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | |
@@ -1493,51 +1493,51 @@ discard block |
||
1493 | 1493 | protected function _change_reg_status() { |
1494 | 1494 | $this->_req_data['return'] = 'view_registration'; |
1495 | 1495 | //set notify based on whether the send notifications toggle is set or not |
1496 | - $notify = ! empty( $this->_req_data['reg_status_change_form']['send_notifications'] ); |
|
1496 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
1497 | 1497 | //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
1498 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] = isset( |
|
1499 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
1498 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset( |
|
1499 | + $this->_req_data['reg_status_change_form']['reg_status'] |
|
1500 | 1500 | ) |
1501 | - ? $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
1501 | + ? $this->_req_data['reg_status_change_form']['reg_status'] |
|
1502 | 1502 | : ''; |
1503 | 1503 | |
1504 | - switch ( $this->_req_data[ 'reg_status_change_form' ]['reg_status'] ) { |
|
1504 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
1505 | 1505 | |
1506 | 1506 | case EEM_Registration::status_id_approved : |
1507 | - case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) : |
|
1508 | - $this->approve_registration( $notify ); |
|
1507 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
1508 | + $this->approve_registration($notify); |
|
1509 | 1509 | break; |
1510 | 1510 | |
1511 | 1511 | case EEM_Registration::status_id_pending_payment : |
1512 | - case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) : |
|
1513 | - $this->pending_registration( $notify ); |
|
1512 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
1513 | + $this->pending_registration($notify); |
|
1514 | 1514 | break; |
1515 | 1515 | |
1516 | 1516 | case EEM_Registration::status_id_not_approved : |
1517 | - case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) : |
|
1518 | - $this->not_approve_registration( $notify ); |
|
1517 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
1518 | + $this->not_approve_registration($notify); |
|
1519 | 1519 | break; |
1520 | 1520 | |
1521 | 1521 | case EEM_Registration::status_id_declined : |
1522 | - case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) : |
|
1523 | - $this->decline_registration( $notify ); |
|
1522 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
1523 | + $this->decline_registration($notify); |
|
1524 | 1524 | break; |
1525 | 1525 | |
1526 | 1526 | case EEM_Registration::status_id_cancelled : |
1527 | - case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) : |
|
1528 | - $this->cancel_registration( $notify ); |
|
1527 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
1528 | + $this->cancel_registration($notify); |
|
1529 | 1529 | break; |
1530 | 1530 | |
1531 | 1531 | case EEM_Registration::status_id_wait_list : |
1532 | - case EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) : |
|
1533 | - $this->waitlist_registration( $notify ); |
|
1532 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
1533 | + $this->waitlist_registration($notify); |
|
1534 | 1534 | break; |
1535 | 1535 | |
1536 | 1536 | case EEM_Registration::status_id_incomplete : |
1537 | 1537 | default : |
1538 | 1538 | $result['success'] = false; |
1539 | - unset( $this->_req_data['return'] ); |
|
1540 | - $this->_reg_status_change_return( '', false ); |
|
1539 | + unset($this->_req_data['return']); |
|
1540 | + $this->_reg_status_change_return('', false); |
|
1541 | 1541 | break; |
1542 | 1542 | } |
1543 | 1543 | } |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | * @param bool $notify whether or not to notify the registrant about their approval. |
1552 | 1552 | * @return void |
1553 | 1553 | */ |
1554 | - protected function approve_registration( $notify = false ) { |
|
1555 | - $this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
|
1554 | + protected function approve_registration($notify = false) { |
|
1555 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | |
@@ -1564,8 +1564,8 @@ discard block |
||
1564 | 1564 | * @param bool $notify whether or not to notify the registrant about their status change. |
1565 | 1565 | * @return void |
1566 | 1566 | */ |
1567 | - protected function decline_registration( $notify = false ) { |
|
1568 | - $this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
|
1567 | + protected function decline_registration($notify = false) { |
|
1568 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | |
@@ -1577,8 +1577,8 @@ discard block |
||
1577 | 1577 | * @param bool $notify whether or not to notify the registrant about their status change. |
1578 | 1578 | * @return void |
1579 | 1579 | */ |
1580 | - protected function cancel_registration( $notify = false ) { |
|
1581 | - $this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
|
1580 | + protected function cancel_registration($notify = false) { |
|
1581 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | |
@@ -1590,8 +1590,8 @@ discard block |
||
1590 | 1590 | * @param bool $notify whether or not to notify the registrant about their status change. |
1591 | 1591 | * @return void |
1592 | 1592 | */ |
1593 | - protected function not_approve_registration( $notify = false ) { |
|
1594 | - $this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
|
1593 | + protected function not_approve_registration($notify = false) { |
|
1594 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | |
@@ -1603,8 +1603,8 @@ discard block |
||
1603 | 1603 | * @param bool $notify whether or not to notify the registrant about their status change. |
1604 | 1604 | * @return void |
1605 | 1605 | */ |
1606 | - protected function pending_registration( $notify = false ) { |
|
1607 | - $this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
|
1606 | + protected function pending_registration($notify = false) { |
|
1607 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
1608 | 1608 | } |
1609 | 1609 | |
1610 | 1610 | |
@@ -1616,8 +1616,8 @@ discard block |
||
1616 | 1616 | * @param bool $notify whether or not to notify the registrant about their status change. |
1617 | 1617 | * @return void |
1618 | 1618 | */ |
1619 | - protected function waitlist_registration( $notify = false ) { |
|
1620 | - $this->_reg_status_change_return( EEM_Registration::status_id_wait_list, $notify ); |
|
1619 | + protected function waitlist_registration($notify = false) { |
|
1620 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | |
@@ -1631,14 +1631,14 @@ discard block |
||
1631 | 1631 | public function _reg_details_meta_box() { |
1632 | 1632 | EEH_Autoloader::register_line_item_display_autoloaders(); |
1633 | 1633 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
1634 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1634 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1635 | 1635 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1636 | 1636 | $this->_session = $transaction->session_data(); |
1637 | 1637 | |
1638 | 1638 | $filters = new EE_Line_Item_Filter_Collection(); |
1639 | 1639 | //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
1640 | - $filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) ); |
|
1641 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() ); |
|
1640 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
1641 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
1642 | 1642 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
1643 | 1643 | $line_item_display = new EE_Line_Item_Display( |
1644 | 1644 | 'reg_admin_table', |
@@ -1646,7 +1646,7 @@ discard block |
||
1646 | 1646 | ); |
1647 | 1647 | $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
1648 | 1648 | $filtered_line_item_tree, |
1649 | - array( 'EE_Registration' => $this->_registration ) |
|
1649 | + array('EE_Registration' => $this->_registration) |
|
1650 | 1650 | ); |
1651 | 1651 | $attendee = $this->_registration->attendee(); |
1652 | 1652 | |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | 'espresso_transactions_view_transaction' |
1657 | 1657 | ) |
1658 | 1658 | ) { |
1659 | - $this->_template_args[ 'view_transaction_button' ] = EEH_Template::get_button_or_link( |
|
1659 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
1660 | 1660 | EE_Admin_Page::add_query_args_and_nonce( |
1661 | 1661 | array( |
1662 | 1662 | 'action' => 'view_transaction', |
@@ -1664,12 +1664,12 @@ discard block |
||
1664 | 1664 | ), |
1665 | 1665 | TXN_ADMIN_URL |
1666 | 1666 | ), |
1667 | - esc_html__( ' View Transaction' ), |
|
1667 | + esc_html__(' View Transaction'), |
|
1668 | 1668 | 'button secondary-button right', |
1669 | 1669 | 'dashicons dashicons-cart' |
1670 | 1670 | ); |
1671 | 1671 | } else { |
1672 | - $this->_template_args[ 'view_transaction_button' ] = ''; |
|
1672 | + $this->_template_args['view_transaction_button'] = ''; |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | if ( |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | 'espresso_registrations_resend_registration' |
1680 | 1680 | ) |
1681 | 1681 | ) { |
1682 | - $this->_template_args[ 'resend_registration_button' ] = EEH_Template::get_button_or_link( |
|
1682 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
1683 | 1683 | EE_Admin_Page::add_query_args_and_nonce( |
1684 | 1684 | array( |
1685 | 1685 | 'action' => 'resend_registration', |
@@ -1688,55 +1688,55 @@ discard block |
||
1688 | 1688 | ), |
1689 | 1689 | REG_ADMIN_URL |
1690 | 1690 | ), |
1691 | - esc_html__( ' Resend Registration' ), |
|
1691 | + esc_html__(' Resend Registration'), |
|
1692 | 1692 | 'button secondary-button right', |
1693 | 1693 | 'dashicons dashicons-email-alt' |
1694 | 1694 | ); |
1695 | 1695 | } else { |
1696 | - $this->_template_args[ 'resend_registration_button' ] = ''; |
|
1696 | + $this->_template_args['resend_registration_button'] = ''; |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1700 | - $payment = $transaction->get_first_related( 'Payment' ); |
|
1700 | + $payment = $transaction->get_first_related('Payment'); |
|
1701 | 1701 | $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
1702 | - $payment_method = $payment->get_first_related( 'Payment_Method' ); |
|
1702 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
1703 | 1703 | $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method; |
1704 | 1704 | |
1705 | 1705 | $reg_details = array( |
1706 | 1706 | 'payment_method' => $payment_method->name(), |
1707 | 1707 | 'response_msg' => $payment->gateway_response(), |
1708 | - 'registration_id' => $this->_registration->get( 'REG_code' ), |
|
1708 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
1709 | 1709 | 'registration_session' => $this->_registration->session_ID(), |
1710 | - 'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '', |
|
1711 | - 'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '', |
|
1710 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
1711 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
1712 | 1712 | ); |
1713 | 1713 | |
1714 | 1714 | |
1715 | - if ( isset( $reg_details['registration_id'] )) { |
|
1715 | + if (isset($reg_details['registration_id'])) { |
|
1716 | 1716 | $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
1717 | - $this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' ); |
|
1717 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
1718 | 1718 | $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
1719 | 1719 | } |
1720 | 1720 | |
1721 | - if ( isset( $reg_details['payment_method'] ) ) { |
|
1721 | + if (isset($reg_details['payment_method'])) { |
|
1722 | 1722 | $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
1723 | - $this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' ); |
|
1723 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso'); |
|
1724 | 1724 | $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
1725 | 1725 | $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
1726 | - $this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' ); |
|
1726 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso'); |
|
1727 | 1727 | $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
1731 | - $this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
|
1731 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso'); |
|
1732 | 1732 | $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
1733 | 1733 | |
1734 | 1734 | $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
1735 | - $this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' ); |
|
1735 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso'); |
|
1736 | 1736 | $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
1737 | 1737 | |
1738 | 1738 | $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
1739 | - $this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
|
1739 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
1740 | 1740 | $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
1741 | 1741 | |
1742 | 1742 | $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
@@ -1749,8 +1749,8 @@ discard block |
||
1749 | 1749 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1750 | 1750 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
1751 | 1751 | |
1752 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1753 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1752 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1753 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1754 | 1754 | |
1755 | 1755 | } |
1756 | 1756 | |
@@ -1764,14 +1764,14 @@ discard block |
||
1764 | 1764 | */ |
1765 | 1765 | public function _reg_questions_meta_box() { |
1766 | 1766 | //allow someone to override this method entirely |
1767 | - if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
|
1768 | - $form = $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
1769 | - $this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : ''; |
|
1767 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) { |
|
1768 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
1769 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
1770 | 1770 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
1771 | 1771 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1772 | 1772 | |
1773 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1774 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1773 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1774 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | |
@@ -1785,12 +1785,12 @@ discard block |
||
1785 | 1785 | * @param string $output |
1786 | 1786 | * @return string |
1787 | 1787 | */ |
1788 | - public function form_before_question_group( $output ) { |
|
1788 | + public function form_before_question_group($output) { |
|
1789 | 1789 | EE_Error::doing_it_wrong( |
1790 | - __CLASS__ . '::' . __FUNCTION__, |
|
1791 | - __( 'This method would have been protected but was used on a filter callback' |
|
1790 | + __CLASS__.'::'.__FUNCTION__, |
|
1791 | + __('This method would have been protected but was used on a filter callback' |
|
1792 | 1792 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1793 | - 'event_espresso' ), |
|
1793 | + 'event_espresso'), |
|
1794 | 1794 | '4.8.32.rc.000' |
1795 | 1795 | ); |
1796 | 1796 | return ' |
@@ -1809,20 +1809,20 @@ discard block |
||
1809 | 1809 | * @param string $output |
1810 | 1810 | * @return string |
1811 | 1811 | */ |
1812 | - public function form_after_question_group( $output ) { |
|
1812 | + public function form_after_question_group($output) { |
|
1813 | 1813 | EE_Error::doing_it_wrong( |
1814 | - __CLASS__ . '::' . __FUNCTION__, |
|
1815 | - __( 'This method would have been protected but was used on a filter callback' |
|
1814 | + __CLASS__.'::'.__FUNCTION__, |
|
1815 | + __('This method would have been protected but was used on a filter callback' |
|
1816 | 1816 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1817 | - 'event_espresso' ), |
|
1817 | + 'event_espresso'), |
|
1818 | 1818 | '4.8.32.rc.000' |
1819 | 1819 | ); |
1820 | 1820 | return ' |
1821 | 1821 | <tr class="hide-if-no-js"> |
1822 | 1822 | <th> </th> |
1823 | 1823 | <td class="reg-admin-edit-attendee-question-td"> |
1824 | - <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
|
1825 | - <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
|
1824 | + <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'"> |
|
1825 | + <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span> |
|
1826 | 1826 | <div class="dashicons dashicons-edit"></div> |
1827 | 1827 | </a> |
1828 | 1828 | </td> |
@@ -1842,18 +1842,18 @@ discard block |
||
1842 | 1842 | * @param string $label |
1843 | 1843 | * @return string |
1844 | 1844 | */ |
1845 | - public function form_form_field_label_wrap( $label ) { |
|
1845 | + public function form_form_field_label_wrap($label) { |
|
1846 | 1846 | EE_Error::doing_it_wrong( |
1847 | - __CLASS__ . '::' . __FUNCTION__, |
|
1848 | - __( 'This method would have been protected but was used on a filter callback' |
|
1847 | + __CLASS__.'::'.__FUNCTION__, |
|
1848 | + __('This method would have been protected but was used on a filter callback' |
|
1849 | 1849 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1850 | - 'event_espresso' ), |
|
1850 | + 'event_espresso'), |
|
1851 | 1851 | '4.8.32.rc.000' |
1852 | 1852 | ); |
1853 | 1853 | return ' |
1854 | 1854 | <tr> |
1855 | 1855 | <th> |
1856 | - ' . $label . ' |
|
1856 | + ' . $label.' |
|
1857 | 1857 | </th>'; |
1858 | 1858 | } |
1859 | 1859 | |
@@ -1867,17 +1867,17 @@ discard block |
||
1867 | 1867 | * @param string $input |
1868 | 1868 | * @return string |
1869 | 1869 | */ |
1870 | - public function form_form_field_input__wrap( $input ) { |
|
1870 | + public function form_form_field_input__wrap($input) { |
|
1871 | 1871 | EE_Error::doing_it_wrong( |
1872 | - __CLASS__ . '::' . __FUNCTION__, |
|
1873 | - __( 'This method would have been protected but was used on a filter callback' |
|
1872 | + __CLASS__.'::'.__FUNCTION__, |
|
1873 | + __('This method would have been protected but was used on a filter callback' |
|
1874 | 1874 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1875 | - 'event_espresso' ), |
|
1875 | + 'event_espresso'), |
|
1876 | 1876 | '4.8.32.rc.000' |
1877 | 1877 | ); |
1878 | 1878 | return ' |
1879 | 1879 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
1880 | - ' . $input . ' |
|
1880 | + ' . $input.' |
|
1881 | 1881 | </td> |
1882 | 1882 | </tr>'; |
1883 | 1883 | } |
@@ -1891,14 +1891,14 @@ discard block |
||
1891 | 1891 | * @return void |
1892 | 1892 | */ |
1893 | 1893 | protected function _update_attendee_registration_form() { |
1894 | - do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this ); |
|
1895 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
1896 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
1897 | - $success = $this->_save_reg_custom_questions_form( $REG_ID ); |
|
1898 | - if( $success ) { |
|
1894 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
1895 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1896 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
1897 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
1898 | + if ($success) { |
|
1899 | 1899 | $what = __('Registration Form', 'event_espresso'); |
1900 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
1901 | - $this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
1900 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
1901 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | } |
@@ -1909,11 +1909,11 @@ discard block |
||
1909 | 1909 | * @param int $REG_ID |
1910 | 1910 | * @return EE_Registration_Custom_Questions_Form |
1911 | 1911 | */ |
1912 | - protected function _get_reg_custom_questions_form( $REG_ID ) { |
|
1913 | - if( ! $this->_reg_custom_questions_form ) { |
|
1914 | - require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' ); |
|
1915 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) ); |
|
1916 | - $this->_reg_custom_questions_form->_construct_finalize( null, null ); |
|
1912 | + protected function _get_reg_custom_questions_form($REG_ID) { |
|
1913 | + if ( ! $this->_reg_custom_questions_form) { |
|
1914 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
1915 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID)); |
|
1916 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
1917 | 1917 | } |
1918 | 1918 | return $this->_reg_custom_questions_form; |
1919 | 1919 | } |
@@ -1926,17 +1926,17 @@ discard block |
||
1926 | 1926 | * @param bool $REG_ID |
1927 | 1927 | * @return bool |
1928 | 1928 | */ |
1929 | - private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
|
1929 | + private function _save_reg_custom_questions_form($REG_ID = FALSE) { |
|
1930 | 1930 | |
1931 | 1931 | if ( ! $REG_ID) { |
1932 | - EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1932 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1933 | 1933 | } |
1934 | - $form = $this->_get_reg_custom_questions_form( $REG_ID ); |
|
1935 | - $form->receive_form_submission( $this->_req_data ); |
|
1934 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
1935 | + $form->receive_form_submission($this->_req_data); |
|
1936 | 1936 | $success = false; |
1937 | - if( $form->is_valid() ) { |
|
1938 | - foreach( $form->subforms() as $question_group_id => $question_group_form ) { |
|
1939 | - foreach( $question_group_form->inputs() as $question_id => $input ) { |
|
1937 | + if ($form->is_valid()) { |
|
1938 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
1939 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
1940 | 1940 | $where_conditions = array( |
1941 | 1941 | 'QST_ID' => $question_id, |
1942 | 1942 | 'REG_ID' => $REG_ID |
@@ -1944,19 +1944,19 @@ discard block |
||
1944 | 1944 | $possibly_new_values = array( |
1945 | 1945 | 'ANS_value' => $input->normalized_value() |
1946 | 1946 | ); |
1947 | - $answer = EEM_Answer::instance()->get_one( array( $where_conditions ) ); |
|
1948 | - if( $answer instanceof EE_Answer ) { |
|
1949 | - $success = $answer->save( $possibly_new_values ); |
|
1947 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
1948 | + if ($answer instanceof EE_Answer) { |
|
1949 | + $success = $answer->save($possibly_new_values); |
|
1950 | 1950 | } else { |
1951 | 1951 | //insert it then |
1952 | - $cols_n_vals = array_merge( $where_conditions, $possibly_new_values ); |
|
1953 | - $answer = EE_Answer::new_instance( $cols_n_vals ); |
|
1952 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
1953 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
1954 | 1954 | $success = $answer->save(); |
1955 | 1955 | } |
1956 | 1956 | } |
1957 | 1957 | } |
1958 | 1958 | } else { |
1959 | - EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1959 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
1960 | 1960 | } |
1961 | 1961 | return $success; |
1962 | 1962 | } |
@@ -1974,31 +1974,31 @@ discard block |
||
1974 | 1974 | $registrations = $REG->get_all(array( |
1975 | 1975 | array( |
1976 | 1976 | 'TXN_ID'=>$this->_registration->transaction_ID(), |
1977 | - 'REG_ID'=>array('!=',$this->_registration->ID()) |
|
1977 | + 'REG_ID'=>array('!=', $this->_registration->ID()) |
|
1978 | 1978 | ), |
1979 | 1979 | 'force_join'=>array('Attendee'))); |
1980 | 1980 | |
1981 | 1981 | $this->_template_args['attendees'] = array(); |
1982 | 1982 | $this->_template_args['attendee_notice'] = ''; |
1983 | - if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
|
1984 | - EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1983 | + if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) { |
|
1984 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1985 | 1985 | $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
1986 | 1986 | } else { |
1987 | 1987 | |
1988 | 1988 | $att_nmbr = 1; |
1989 | - foreach ( $registrations as $registration ) { |
|
1989 | + foreach ($registrations as $registration) { |
|
1990 | 1990 | /* @var $registration EE_Registration */ |
1991 | 1991 | $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
1992 | - $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID(); |
|
1993 | - $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1994 | - $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1995 | - $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1996 | - $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1992 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
1993 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1994 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1995 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1996 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1997 | 1997 | |
1998 | - $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
|
1998 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array()); |
|
1999 | 1999 | |
2000 | - $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
2001 | - $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name(); |
|
2000 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
2001 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
2002 | 2002 | |
2003 | 2003 | $att_nmbr++; |
2004 | 2004 | } |
@@ -2008,8 +2008,8 @@ discard block |
||
2008 | 2008 | |
2009 | 2009 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
2010 | 2010 | } |
2011 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
2012 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2011 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
2012 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2013 | 2013 | |
2014 | 2014 | } |
2015 | 2015 | |
@@ -2030,14 +2030,14 @@ discard block |
||
2030 | 2030 | $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
2031 | 2031 | |
2032 | 2032 | //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
2033 | - if ( ! $this->_registration->is_primary_registrant() ) { |
|
2033 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
2034 | 2034 | |
2035 | 2035 | $primary_registration = $this->_registration->get_primary_registration(); |
2036 | 2036 | $primary_attendee = $primary_registration instanceof EE_Registration |
2037 | 2037 | ? $primary_registration->attendee() |
2038 | 2038 | : null; |
2039 | 2039 | |
2040 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
|
2040 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
2041 | 2041 | //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
2042 | 2042 | $primary_registration = NULL; |
2043 | 2043 | } |
@@ -2046,27 +2046,27 @@ discard block |
||
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
2049 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
2050 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
2051 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
2049 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
2050 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
2051 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
2052 | 2052 | $this->_template_args['phone'] = $attendee->phone(); |
2053 | 2053 | |
2054 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
|
2054 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
2055 | 2055 | |
2056 | 2056 | |
2057 | 2057 | //edit link |
2058 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
2058 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
2059 | 2059 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
2060 | 2060 | |
2061 | 2061 | //create link |
2062 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
|
2062 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : ''; |
|
2063 | 2063 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
2064 | 2064 | |
2065 | 2065 | $this->_template_args['att_check'] = $att_check; |
2066 | 2066 | |
2067 | 2067 | |
2068 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2069 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2068 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2069 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | |
@@ -2079,7 +2079,7 @@ discard block |
||
2079 | 2079 | * @access protected |
2080 | 2080 | * @return void |
2081 | 2081 | */ |
2082 | - protected function _trash_or_restore_registrations( $trash = TRUE ) { |
|
2082 | + protected function _trash_or_restore_registrations($trash = TRUE) { |
|
2083 | 2083 | $REGM = EEM_Registration::instance(); |
2084 | 2084 | |
2085 | 2085 | $success = 1; |
@@ -2089,26 +2089,26 @@ discard block |
||
2089 | 2089 | $dtts = array(); |
2090 | 2090 | |
2091 | 2091 | //if empty _REG_ID then get out because there's nothing to do |
2092 | - if ( empty( $this->_req_data['_REG_ID'] ) ) { |
|
2092 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2093 | 2093 | $msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso'); |
2094 | - EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ ); |
|
2095 | - $this->_redirect_after_action(FALSE, '', '', array(), TRUE ); |
|
2094 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
2095 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
2096 | 2096 | } |
2097 | 2097 | |
2098 | 2098 | //Checkboxes |
2099 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2099 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2100 | 2100 | // if array has more than one element than success message should be plural |
2101 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
2101 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2102 | 2102 | // cycle thru checkboxes |
2103 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
2103 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2104 | 2104 | /** @var EE_Registration $REG */ |
2105 | - $REG = $REGM->get_one_by_ID( $REG_ID); |
|
2105 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
2106 | 2106 | $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
2107 | - if ( $payment_count > 0 ) { |
|
2108 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ); |
|
2107 | + if ($payment_count > 0) { |
|
2108 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso'); |
|
2109 | 2109 | $error = 1; |
2110 | 2110 | $success = 0; |
2111 | - EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2111 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
2112 | 2112 | continue; //can't trash this registration because it has payments. |
2113 | 2113 | } |
2114 | 2114 | $ticket = $REG->get_first_related('Ticket'); |
@@ -2117,7 +2117,7 @@ discard block |
||
2117 | 2117 | $dtts = array_merge($dtts, $dtt); |
2118 | 2118 | |
2119 | 2119 | $updated = $trash ? $REG->delete() : $REG->restore(); |
2120 | - if ( !$updated ) { |
|
2120 | + if ( ! $updated) { |
|
2121 | 2121 | $success = 0; |
2122 | 2122 | } else { |
2123 | 2123 | $success = 2; |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | $tickets[$ticket->ID()] = $ticket; |
2133 | 2133 | $dtts = $ticket->get_many_related('Datetime'); |
2134 | 2134 | $updated = $trash ? $REG->delete() : $REG->restore(); |
2135 | - if ( ! $updated ) { |
|
2135 | + if ( ! $updated) { |
|
2136 | 2136 | $success = 0; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2142,10 +2142,10 @@ discard block |
||
2142 | 2142 | EEM_Ticket::instance()->update_tickets_sold($tickets); |
2143 | 2143 | EEM_Datetime::instance()->update_sold($dtts); |
2144 | 2144 | |
2145 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
2146 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
2145 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2146 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2147 | 2147 | $overwrite_msgs = $error ? TRUE : FALSE; |
2148 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs ); |
|
2148 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
2149 | 2149 | } |
2150 | 2150 | |
2151 | 2151 | |
@@ -2169,16 +2169,16 @@ discard block |
||
2169 | 2169 | $success = 1; |
2170 | 2170 | |
2171 | 2171 | //Checkboxes |
2172 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2172 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2173 | 2173 | // if array has more than one element than success message should be plural |
2174 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
2174 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2175 | 2175 | // cycle thru checkboxes |
2176 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
2176 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2177 | 2177 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2178 | - if ( ! $REG instanceof EE_Registration ) |
|
2178 | + if ( ! $REG instanceof EE_Registration) |
|
2179 | 2179 | continue; |
2180 | 2180 | $deleted = $this->_delete_registration($REG); |
2181 | - if ( !$deleted ) { |
|
2181 | + if ( ! $deleted) { |
|
2182 | 2182 | $success = 0; |
2183 | 2183 | } |
2184 | 2184 | } |
@@ -2188,15 +2188,15 @@ discard block |
||
2188 | 2188 | $REG_ID = $this->_req_data['_REG_ID']; |
2189 | 2189 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2190 | 2190 | $deleted = $this->_delete_registration($REG); |
2191 | - if ( ! $deleted ) { |
|
2191 | + if ( ! $deleted) { |
|
2192 | 2192 | $success = 0; |
2193 | 2193 | } |
2194 | 2194 | |
2195 | 2195 | } |
2196 | 2196 | |
2197 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
2198 | - $action_desc = __( 'permanently deleted.', 'event_espresso' ); |
|
2199 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE ); |
|
2197 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2198 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
2199 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE); |
|
2200 | 2200 | } |
2201 | 2201 | |
2202 | 2202 | |
@@ -2208,31 +2208,31 @@ discard block |
||
2208 | 2208 | * @param EE_Registration $REG registration to be deleted permenantly |
2209 | 2209 | * @return boolean true = successful deletion, false = fail. |
2210 | 2210 | */ |
2211 | - protected function _delete_registration( EE_Registration $REG ) { |
|
2211 | + protected function _delete_registration(EE_Registration $REG) { |
|
2212 | 2212 | //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
2213 | 2213 | $TXN = $REG->get_first_related('Transaction'); |
2214 | 2214 | $REGS = $TXN->get_many_related('Registration'); |
2215 | 2215 | |
2216 | 2216 | $all_trashed = TRUE; |
2217 | - foreach ( $REGS as $registration ) { |
|
2218 | - if ( ! $registration->get('REG_deleted') ) |
|
2217 | + foreach ($REGS as $registration) { |
|
2218 | + if ( ! $registration->get('REG_deleted')) |
|
2219 | 2219 | $all_trashed = FALSE; |
2220 | 2220 | } |
2221 | 2221 | |
2222 | - if ( ! $all_trashed ) { |
|
2223 | - EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2222 | + if ( ! $all_trashed) { |
|
2223 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2224 | 2224 | return false; |
2225 | 2225 | } |
2226 | 2226 | |
2227 | 2227 | //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
2228 | - foreach ( $REGS as $registration ) { |
|
2228 | + foreach ($REGS as $registration) { |
|
2229 | 2229 | |
2230 | 2230 | //delete related answers |
2231 | 2231 | $registration->delete_related_permanently('Answer'); |
2232 | 2232 | |
2233 | 2233 | //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
2234 | 2234 | $attendee = $registration->get_first_related('Attendee'); |
2235 | - if ( $attendee instanceof EE_Attendee ) { |
|
2235 | + if ($attendee instanceof EE_Attendee) { |
|
2236 | 2236 | $registration->_remove_relation_to($attendee, 'Attendee'); |
2237 | 2237 | } |
2238 | 2238 | |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | //now delete permanently the checkins related to this registration. |
2243 | 2243 | $registration->delete_related_permanently('Checkin'); |
2244 | 2244 | |
2245 | - if ( $registration->ID() === $REG->ID() ) |
|
2245 | + if ($registration->ID() === $REG->ID()) |
|
2246 | 2246 | continue; //we don't want to delete permanently the existing registration just yet. |
2247 | 2247 | |
2248 | 2248 | //remove relation to transaction for these registrations if NOT the existing registrations |
@@ -2279,35 +2279,35 @@ discard block |
||
2279 | 2279 | * @return void |
2280 | 2280 | */ |
2281 | 2281 | public function new_registration() { |
2282 | - if ( ! $this->_set_reg_event() ) { |
|
2283 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') ); |
|
2282 | + if ( ! $this->_set_reg_event()) { |
|
2283 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso')); |
|
2284 | 2284 | } |
2285 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2285 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2286 | 2286 | // gotta start with a clean slate if we're not coming here via ajax |
2287 | 2287 | if ( |
2288 | - ! defined('DOING_AJAX' ) |
|
2289 | - && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) ) |
|
2288 | + ! defined('DOING_AJAX') |
|
2289 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
2290 | 2290 | ) { |
2291 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2291 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2292 | 2292 | } |
2293 | 2293 | |
2294 | - $this->_template_args['event_name'] = '' ; |
|
2294 | + $this->_template_args['event_name'] = ''; |
|
2295 | 2295 | // event name |
2296 | - if ( $this->_reg_event ) { |
|
2296 | + if ($this->_reg_event) { |
|
2297 | 2297 | $this->_template_args['event_name'] = $this->_reg_event->name(); |
2298 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL ); |
|
2299 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
2300 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
2298 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL); |
|
2299 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
2300 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
2304 | 2304 | |
2305 | - if ( defined('DOING_AJAX' ) ) { |
|
2305 | + if (defined('DOING_AJAX')) { |
|
2306 | 2306 | $this->_return_json(); |
2307 | 2307 | } |
2308 | 2308 | // grab header |
2309 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2310 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2309 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
2310 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2311 | 2311 | |
2312 | 2312 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
2313 | 2313 | // the details template wrapper |
@@ -2324,7 +2324,7 @@ discard block |
||
2324 | 2324 | * @return string html |
2325 | 2325 | */ |
2326 | 2326 | protected function _get_registration_step_content() { |
2327 | - if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) { |
|
2327 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
2328 | 2328 | $warning_msg = sprintf( |
2329 | 2329 | __( |
2330 | 2330 | '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
@@ -2340,7 +2340,7 @@ discard block |
||
2340 | 2340 | '</b>' |
2341 | 2341 | ); |
2342 | 2342 | return ' |
2343 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
2343 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
2344 | 2344 | <script > |
2345 | 2345 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
2346 | 2346 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2375,16 +2375,16 @@ discard block |
||
2375 | 2375 | $cart = EE_Registry::instance()->SSN->cart(); |
2376 | 2376 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2377 | 2377 | |
2378 | - switch ( $step ) { |
|
2378 | + switch ($step) { |
|
2379 | 2379 | case 'ticket' : |
2380 | 2380 | $hidden_fields['processing_registration']['value'] = 1; |
2381 | 2381 | $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
2382 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event ); |
|
2382 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
2383 | 2383 | $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso'); |
2384 | 2384 | $template_args['show_notification_toggle'] = FALSE; |
2385 | 2385 | break; |
2386 | 2386 | case 'questions' : |
2387 | - $hidden_fields[ 'processing_registration' ][ 'value' ] = 2; |
|
2387 | + $hidden_fields['processing_registration']['value'] = 2; |
|
2388 | 2388 | $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso'); |
2389 | 2389 | //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
2390 | 2390 | $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
@@ -2393,10 +2393,10 @@ discard block |
||
2393 | 2393 | break; |
2394 | 2394 | } |
2395 | 2395 | |
2396 | - $this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route. |
|
2396 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route. |
|
2397 | 2397 | |
2398 | 2398 | return EEH_Template::display_template( |
2399 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2399 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2400 | 2400 | ); |
2401 | 2401 | } |
2402 | 2402 | |
@@ -2411,11 +2411,11 @@ discard block |
||
2411 | 2411 | * @return boolean |
2412 | 2412 | */ |
2413 | 2413 | private function _set_reg_event() { |
2414 | - if ( is_object( $this->_reg_event )) { |
|
2414 | + if (is_object($this->_reg_event)) { |
|
2415 | 2415 | return TRUE; |
2416 | 2416 | } |
2417 | - $EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
2418 | - if ( ! $EVT_ID ) { |
|
2417 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE; |
|
2418 | + if ( ! $EVT_ID) { |
|
2419 | 2419 | return FALSE; |
2420 | 2420 | } |
2421 | 2421 | |
@@ -2436,80 +2436,80 @@ discard block |
||
2436 | 2436 | public function process_reg_step() { |
2437 | 2437 | EE_System::do_not_cache(); |
2438 | 2438 | $this->_set_reg_event(); |
2439 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2439 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2440 | 2440 | |
2441 | 2441 | //what step are we on? |
2442 | 2442 | $cart = EE_Registry::instance()->SSN->cart(); |
2443 | 2443 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2444 | 2444 | |
2445 | 2445 | //if doing ajax then we need to verify the nonce |
2446 | - if ( defined( 'DOING_AJAX' ) ) { |
|
2447 | - $nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : ''; |
|
2448 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
2446 | + if (defined('DOING_AJAX')) { |
|
2447 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
2448 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
2449 | 2449 | } |
2450 | 2450 | |
2451 | - switch ( $step ) { |
|
2451 | + switch ($step) { |
|
2452 | 2452 | |
2453 | 2453 | case 'ticket' : |
2454 | 2454 | //process ticket selection |
2455 | 2455 | $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
2456 | - if ( $success ) { |
|
2457 | - EE_Error::add_success( esc_html__( 'Tickets Selected. Now complete the registration.', 'event_espresso' ) ); |
|
2456 | + if ($success) { |
|
2457 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', 'event_espresso')); |
|
2458 | 2458 | } else { |
2459 | 2459 | $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; |
2460 | 2460 | } |
2461 | - if ( defined('DOING_AJAX') ) { |
|
2461 | + if (defined('DOING_AJAX')) { |
|
2462 | 2462 | $this->new_registration(); //display next step |
2463 | 2463 | } else { |
2464 | 2464 | $query_args['action'] = 'new_registration'; |
2465 | 2465 | $query_args['processing_registration'] = 1; |
2466 | 2466 | $query_args['event_id'] = $this->_reg_event->ID(); |
2467 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2467 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2468 | 2468 | } |
2469 | 2469 | break; |
2470 | 2470 | |
2471 | 2471 | case 'questions' : |
2472 | - if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) { |
|
2473 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
|
2472 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
2473 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
2474 | 2474 | } |
2475 | 2475 | //process registration |
2476 | 2476 | $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
2477 | - if ( $cart instanceof EE_Cart ) { |
|
2477 | + if ($cart instanceof EE_Cart) { |
|
2478 | 2478 | $grand_total = $cart->get_cart_grand_total(); |
2479 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
2479 | + if ($grand_total instanceof EE_Line_Item) { |
|
2480 | 2480 | $grand_total->save_this_and_descendants_to_txn(); |
2481 | 2481 | } |
2482 | 2482 | } |
2483 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
2483 | + if ( ! $transaction instanceof EE_Transaction) { |
|
2484 | 2484 | $query_args = array( |
2485 | 2485 | 'action' => 'new_registration', |
2486 | 2486 | 'processing_registration' => 2, |
2487 | 2487 | 'event_id' => $this->_reg_event->ID() |
2488 | 2488 | ); |
2489 | 2489 | |
2490 | - if ( defined('DOING_AJAX' )) { |
|
2490 | + if (defined('DOING_AJAX')) { |
|
2491 | 2491 | //display registration form again because there are errors (maybe validation?) |
2492 | 2492 | $this->new_registration(); |
2493 | 2493 | return; |
2494 | 2494 | } else { |
2495 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2495 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2496 | 2496 | return; |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | 2499 | // maybe update status, and make sure to save transaction if not done already |
2500 | - if ( ! $transaction->update_status_based_on_total_paid() ) { |
|
2500 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
2501 | 2501 | $transaction->save(); |
2502 | 2502 | } |
2503 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2503 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2504 | 2504 | $this->_req_data = array(); |
2505 | 2505 | $query_args = array( |
2506 | 2506 | 'action' => 'redirect_to_txn', |
2507 | 2507 | 'TXN_ID' => $transaction->ID(), |
2508 | 2508 | 'EVT_ID' => $this->_reg_event->ID(), |
2509 | - 'event_name' => urlencode( $this->_reg_event->name() ), |
|
2509 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
2510 | 2510 | 'redirect_from' => 'new_registration' |
2511 | 2511 | ); |
2512 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2512 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2513 | 2513 | break; |
2514 | 2514 | } |
2515 | 2515 | |
@@ -2526,21 +2526,21 @@ discard block |
||
2526 | 2526 | */ |
2527 | 2527 | public function redirect_to_txn() { |
2528 | 2528 | EE_System::do_not_cache(); |
2529 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2529 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2530 | 2530 | $query_args = array( |
2531 | 2531 | 'action' => 'view_transaction', |
2532 | - 'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] ) : 0, |
|
2532 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
2533 | 2533 | 'page' => 'espresso_transactions' |
2534 | 2534 | ); |
2535 | - if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) { |
|
2536 | - $query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ]; |
|
2537 | - $query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] ); |
|
2538 | - $query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ]; |
|
2535 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
2536 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
2537 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
2538 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
2539 | 2539 | } |
2540 | 2540 | EE_Error::add_success( |
2541 | - __( 'Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso' ) |
|
2541 | + __('Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso') |
|
2542 | 2542 | ); |
2543 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2543 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2544 | 2544 | } |
2545 | 2545 | |
2546 | 2546 | |
@@ -2551,7 +2551,7 @@ discard block |
||
2551 | 2551 | * @return void |
2552 | 2552 | */ |
2553 | 2553 | protected function _attendee_contact_list_table() { |
2554 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2554 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2555 | 2555 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
2556 | 2556 | $this->display_admin_list_table_page_with_no_sidebar(); |
2557 | 2557 | } |
@@ -2566,10 +2566,10 @@ discard block |
||
2566 | 2566 | * @access public |
2567 | 2567 | * @return array |
2568 | 2568 | */ |
2569 | - public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
|
2569 | + public function get_attendees($per_page, $count = FALSE, $trash = FALSE) { |
|
2570 | 2570 | |
2571 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2572 | - require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' ); |
|
2571 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2572 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
2573 | 2573 | $ATT_MDL = EEM_Attendee::instance(); |
2574 | 2574 | |
2575 | 2575 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
@@ -2597,47 +2597,47 @@ discard block |
||
2597 | 2597 | $orderby = 'ATT_lname'; |
2598 | 2598 | } |
2599 | 2599 | |
2600 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
2600 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
2601 | 2601 | |
2602 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
2603 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
2604 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
2602 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
2603 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
2604 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
2605 | 2605 | |
2606 | 2606 | $_where = array(); |
2607 | 2607 | |
2608 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
2609 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2608 | + if ( ! empty($this->_req_data['s'])) { |
|
2609 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2610 | 2610 | $_where['OR'] = array( |
2611 | - 'Registration.Event.EVT_name' => array( 'LIKE', $sstr), |
|
2612 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
2613 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
2614 | - 'ATT_fname' => array( 'LIKE', $sstr ), |
|
2615 | - 'ATT_lname' => array( 'LIKE', $sstr ), |
|
2616 | - 'ATT_short_bio' => array( 'LIKE', $sstr ), |
|
2617 | - 'ATT_email' => array('LIKE', $sstr ), |
|
2618 | - 'ATT_address' => array( 'LIKE', $sstr ), |
|
2619 | - 'ATT_address2' => array( 'LIKE', $sstr ), |
|
2620 | - 'ATT_city' => array( 'LIKE', $sstr ), |
|
2621 | - 'Country.CNT_name' => array( 'LIKE', $sstr ), |
|
2622 | - 'State.STA_name' => array('LIKE', $sstr ), |
|
2623 | - 'ATT_phone' => array( 'LIKE', $sstr ), |
|
2624 | - 'Registration.REG_final_price' => array( 'LIKE', $sstr ), |
|
2625 | - 'Registration.REG_code' => array( 'LIKE', $sstr ), |
|
2626 | - 'Registration.REG_count' => array( 'LIKE' , $sstr ), |
|
2627 | - 'Registration.REG_group_size' => array( 'LIKE' , $sstr ) |
|
2611 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
2612 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
2613 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
2614 | + 'ATT_fname' => array('LIKE', $sstr), |
|
2615 | + 'ATT_lname' => array('LIKE', $sstr), |
|
2616 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
2617 | + 'ATT_email' => array('LIKE', $sstr), |
|
2618 | + 'ATT_address' => array('LIKE', $sstr), |
|
2619 | + 'ATT_address2' => array('LIKE', $sstr), |
|
2620 | + 'ATT_city' => array('LIKE', $sstr), |
|
2621 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
2622 | + 'State.STA_name' => array('LIKE', $sstr), |
|
2623 | + 'ATT_phone' => array('LIKE', $sstr), |
|
2624 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
2625 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
2626 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
2627 | + 'Registration.REG_group_size' => array('LIKE', $sstr) |
|
2628 | 2628 | ); |
2629 | 2629 | } |
2630 | 2630 | |
2631 | 2631 | |
2632 | - $offset = ($current_page-1)*$per_page; |
|
2633 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
2632 | + $offset = ($current_page - 1) * $per_page; |
|
2633 | + $limit = $count ? NULL : array($offset, $per_page); |
|
2634 | 2634 | |
2635 | - if ( $trash ) { |
|
2636 | - $_where['status'] = array( '!=', 'publish' ); |
|
2637 | - $all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true ): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2635 | + if ($trash) { |
|
2636 | + $_where['status'] = array('!=', 'publish'); |
|
2637 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2638 | 2638 | } else { |
2639 | - $_where['status'] = array( 'IN', array( 'publish' ) ); |
|
2640 | - $all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit ), 'ATT_ID' , true ) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) ); |
|
2639 | + $_where['status'] = array('IN', array('publish')); |
|
2640 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | return $all_attendees; |
@@ -2654,10 +2654,10 @@ discard block |
||
2654 | 2654 | */ |
2655 | 2655 | protected function _resend_registration() { |
2656 | 2656 | $this->_process_resend_registration(); |
2657 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array( |
|
2657 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array( |
|
2658 | 2658 | 'action' => 'default' |
2659 | 2659 | ); |
2660 | - $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE ); |
|
2660 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | |
@@ -2665,26 +2665,26 @@ discard block |
||
2665 | 2665 | |
2666 | 2666 | |
2667 | 2667 | |
2668 | - public function _registrations_report(){ |
|
2669 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2670 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2668 | + public function _registrations_report() { |
|
2669 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2670 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2671 | 2671 | array( |
2672 | 2672 | 'page' => 'espresso_batch', |
2673 | 2673 | 'batch' => 'file', |
2674 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2675 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
|
2676 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2677 | - )) ); |
|
2674 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2675 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
2676 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2677 | + ))); |
|
2678 | 2678 | } else { |
2679 | 2679 | $new_request_args = array( |
2680 | 2680 | 'export' => 'report', |
2681 | 2681 | 'action' => 'registrations_report_for_event', |
2682 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2682 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2683 | 2683 | ); |
2684 | 2684 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
2685 | 2685 | |
2686 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2687 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2686 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2687 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2688 | 2688 | $EE_Export = EE_Export::instance($this->_req_data); |
2689 | 2689 | $EE_Export->export(); |
2690 | 2690 | } |
@@ -2693,26 +2693,26 @@ discard block |
||
2693 | 2693 | |
2694 | 2694 | |
2695 | 2695 | |
2696 | - public function _contact_list_export(){ |
|
2697 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2698 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2696 | + public function _contact_list_export() { |
|
2697 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2698 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2699 | 2699 | $EE_Export = EE_Export::instance($this->_req_data); |
2700 | 2700 | $EE_Export->export_attendees(); |
2701 | 2701 | } |
2702 | 2702 | } |
2703 | 2703 | |
2704 | - public function _contact_list_report(){ |
|
2705 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2706 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2704 | + public function _contact_list_report() { |
|
2705 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2706 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2707 | 2707 | array( |
2708 | 2708 | 'page' => 'espresso_batch', |
2709 | 2709 | 'batch' => 'file', |
2710 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
|
2711 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2712 | - )) ); |
|
2710 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
2711 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2712 | + ))); |
|
2713 | 2713 | } else { |
2714 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2715 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2714 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2715 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2716 | 2716 | $EE_Export = EE_Export::instance($this->_req_data); |
2717 | 2717 | $EE_Export->report_attendees(); |
2718 | 2718 | } |
@@ -2731,73 +2731,73 @@ discard block |
||
2731 | 2731 | * @return void |
2732 | 2732 | */ |
2733 | 2733 | protected function _duplicate_attendee() { |
2734 | - $action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default'; |
|
2734 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
2735 | 2735 | //verify we have necessary info |
2736 | - if ( empty($this->_req_data['_REG_ID'] ) ) { |
|
2737 | - EE_Error::add_error( __('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__ ); |
|
2738 | - $query_args = array( 'action' => $action ); |
|
2736 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2737 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
2738 | + $query_args = array('action' => $action); |
|
2739 | 2739 | $this->_redirect_after_action('', '', '', $query_args, TRUE); |
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
2743 | - $registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] ); |
|
2743 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
2744 | 2744 | $attendee = $registration->attendee(); |
2745 | 2745 | |
2746 | 2746 | //remove relation of existing attendee on registration |
2747 | - $registration->_remove_relation_to($attendee, 'Attendee' ); |
|
2747 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2748 | 2748 | //new attendee |
2749 | 2749 | $new_attendee = clone $attendee; |
2750 | - $new_attendee->set( 'ATT_ID', 0 ); |
|
2750 | + $new_attendee->set('ATT_ID', 0); |
|
2751 | 2751 | $new_attendee->save(); |
2752 | 2752 | |
2753 | 2753 | //add new attendee to reg |
2754 | - $registration->_add_relation_to( $new_attendee, 'Attendee'); |
|
2754 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
2755 | 2755 | |
2756 | - EE_Error::add_success( __('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso') ); |
|
2756 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso')); |
|
2757 | 2757 | |
2758 | 2758 | //redirect to edit page for attendee |
2759 | - $query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' ); |
|
2759 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
2760 | 2760 | |
2761 | - $this->_redirect_after_action( '', '', '', $query_args, TRUE ); |
|
2761 | + $this->_redirect_after_action('', '', '', $query_args, TRUE); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | |
2765 | 2765 | //related to cpt routes |
2766 | 2766 | protected function _insert_update_cpt_item($post_id, $post) { |
2767 | 2767 | $success = true; |
2768 | - $attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id ); |
|
2768 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
2769 | 2769 | //for attendee updates |
2770 | - if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) { |
|
2770 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
2771 | 2771 | //note we should only be UPDATING attendees at this point. |
2772 | 2772 | $updated_fields = array( |
2773 | 2773 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
2774 | 2774 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
2775 | - 'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2775 | + 'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
2776 | 2776 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
2777 | 2777 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
2778 | - 'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '', |
|
2779 | - 'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '', |
|
2780 | - 'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '', |
|
2781 | - 'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '', |
|
2782 | - 'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '', |
|
2783 | - 'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : '' |
|
2778 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
2779 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
2780 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
2781 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
2782 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
2783 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '' |
|
2784 | 2784 | ); |
2785 | - foreach ( $updated_fields as $field => $value ) { |
|
2785 | + foreach ($updated_fields as $field => $value) { |
|
2786 | 2786 | $attendee->set($field, $value); |
2787 | 2787 | } |
2788 | 2788 | |
2789 | 2789 | $success = $attendee->save(); |
2790 | 2790 | |
2791 | - $attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() ); |
|
2792 | - foreach ( $attendee_update_callbacks as $a_callback ) { |
|
2793 | - if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) { |
|
2794 | - throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback ) ); |
|
2791 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array()); |
|
2792 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
2793 | + if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
2794 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback)); |
|
2795 | 2795 | } |
2796 | 2796 | } |
2797 | 2797 | } |
2798 | 2798 | |
2799 | - if ( $success === FALSE ) |
|
2800 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2799 | + if ($success === FALSE) |
|
2800 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2801 | 2801 | |
2802 | 2802 | } |
2803 | 2803 | |
@@ -2817,17 +2817,17 @@ discard block |
||
2817 | 2817 | remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2818 | 2818 | remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2819 | 2819 | |
2820 | - if ( post_type_supports( 'espresso_attendees', 'excerpt') ) { |
|
2821 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' ); |
|
2820 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
2821 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal'); |
|
2822 | 2822 | } |
2823 | 2823 | |
2824 | - if ( post_type_supports( 'espresso_attendees', 'comments') ) { |
|
2824 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
2825 | 2825 | add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2826 | 2826 | } |
2827 | 2827 | |
2828 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
2829 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' ); |
|
2830 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2828 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
2829 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2830 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2831 | 2831 | } |
2832 | 2832 | |
2833 | 2833 | |
@@ -2836,10 +2836,10 @@ discard block |
||
2836 | 2836 | * @param WP_Post $post wp post object |
2837 | 2837 | * @return string attendee contact info ( and form ) |
2838 | 2838 | */ |
2839 | - public function attendee_contact_info( $post ) { |
|
2839 | + public function attendee_contact_info($post) { |
|
2840 | 2840 | //get attendee object ( should already have it ) |
2841 | 2841 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2842 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2842 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
2843 | 2843 | EEH_Template::display_template($template, $this->_template_args); |
2844 | 2844 | } |
2845 | 2845 | |
@@ -2855,12 +2855,12 @@ discard block |
||
2855 | 2855 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2856 | 2856 | $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
2857 | 2857 | new EE_Question_Form_Input( |
2858 | - EE_Question::new_instance( array( |
|
2858 | + EE_Question::new_instance(array( |
|
2859 | 2859 | 'QST_ID' => 0, |
2860 | 2860 | 'QST_display_text' => __('State/Province', 'event_espresso'), |
2861 | 2861 | 'QST_system' => 'admin-state' |
2862 | 2862 | )), |
2863 | - EE_Answer::new_instance( array( |
|
2863 | + EE_Answer::new_instance(array( |
|
2864 | 2864 | 'ANS_ID' => 0, |
2865 | 2865 | 'ANS_value' => $this->_cpt_model_obj->state_ID() |
2866 | 2866 | )), |
@@ -2873,12 +2873,12 @@ discard block |
||
2873 | 2873 | )); |
2874 | 2874 | $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
2875 | 2875 | new EE_Question_Form_Input( |
2876 | - EE_Question::new_instance( array( |
|
2876 | + EE_Question::new_instance(array( |
|
2877 | 2877 | 'QST_ID' => 0, |
2878 | 2878 | 'QST_display_text' => __('Country', 'event_espresso'), |
2879 | 2879 | 'QST_system' => 'admin-country' |
2880 | 2880 | )), |
2881 | - EE_Answer::new_instance( array( |
|
2881 | + EE_Answer::new_instance(array( |
|
2882 | 2882 | 'ANS_ID' => 0, |
2883 | 2883 | 'ANS_value' => $this->_cpt_model_obj->country_ID() |
2884 | 2884 | )), |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | 'append_qstn_id' => FALSE |
2890 | 2890 | ) |
2891 | 2891 | )); |
2892 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2893 | - EEH_Template::display_template($template, $this->_template_args ); |
|
2892 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
2893 | + EEH_Template::display_template($template, $this->_template_args); |
|
2894 | 2894 | |
2895 | 2895 | } |
2896 | 2896 | |
@@ -2900,11 +2900,11 @@ discard block |
||
2900 | 2900 | * @access protected |
2901 | 2901 | * @return void |
2902 | 2902 | */ |
2903 | - public function attendee_registrations_meta_box( $post ) { |
|
2903 | + public function attendee_registrations_meta_box($post) { |
|
2904 | 2904 | |
2905 | 2905 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2906 | 2906 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
2907 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2907 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
2908 | 2908 | EEH_Template::display_template($template, $this->_template_args); |
2909 | 2909 | |
2910 | 2910 | } |
@@ -2918,8 +2918,8 @@ discard block |
||
2918 | 2918 | * @return string html for new form. |
2919 | 2919 | */ |
2920 | 2920 | public function after_title_form_fields($post) { |
2921 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
2922 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2921 | + if ($post->post_type == 'espresso_attendees') { |
|
2922 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
2923 | 2923 | $template_args['attendee'] = $this->_cpt_model_obj; |
2924 | 2924 | EEH_Template::display_template($template, $template_args); |
2925 | 2925 | } |
@@ -2936,21 +2936,21 @@ discard block |
||
2936 | 2936 | * @access protected |
2937 | 2937 | * @return void |
2938 | 2938 | */ |
2939 | - protected function _trash_or_restore_attendees( $trash = TRUE ) { |
|
2939 | + protected function _trash_or_restore_attendees($trash = TRUE) { |
|
2940 | 2940 | |
2941 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2941 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2942 | 2942 | |
2943 | 2943 | $ATT_MDL = EEM_Attendee::instance(); |
2944 | 2944 | |
2945 | 2945 | $success = 1; |
2946 | 2946 | //Checkboxes |
2947 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2947 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2948 | 2948 | // if array has more than one element than success message should be plural |
2949 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2949 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2950 | 2950 | // cycle thru checkboxes |
2951 | - while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
2952 | - $updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID); |
|
2953 | - if ( !$updated ) { |
|
2951 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2952 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
2953 | + if ( ! $updated) { |
|
2954 | 2954 | $success = 0; |
2955 | 2955 | } |
2956 | 2956 | } |
@@ -2959,18 +2959,18 @@ discard block |
||
2959 | 2959 | // grab single id and delete |
2960 | 2960 | $ATT_ID = absint($this->_req_data['ATT_ID']); |
2961 | 2961 | //get attendee |
2962 | - $att = $ATT_MDL->get_one_by_ID( $ATT_ID ); |
|
2962 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
2963 | 2963 | $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
2964 | 2964 | $updated = $att->save(); |
2965 | - if ( ! $updated ) { |
|
2965 | + if ( ! $updated) { |
|
2966 | 2966 | $success = 0; |
2967 | 2967 | } |
2968 | 2968 | |
2969 | 2969 | } |
2970 | 2970 | |
2971 | - $what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' ); |
|
2972 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
2973 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) ); |
|
2971 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
2972 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2973 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
2974 | 2974 | |
2975 | 2975 | } |
2976 | 2976 |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | * Returns the name of the field's name that points to the WP_User table |
803 | 803 | * on this model (or follows the _model_chain_to_wp_user and uses that model's |
804 | 804 | * foreign key to the WP_User table) |
805 | - * @return string|boolean string on success, boolean false when there is no |
|
805 | + * @return string|false string on success, boolean false when there is no |
|
806 | 806 | * foreign key to the WP_User table |
807 | 807 | */ |
808 | 808 | public function wp_user_field_name() { |
@@ -897,6 +897,7 @@ discard block |
||
897 | 897 | * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array. |
898 | 898 | * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection |
899 | 899 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
900 | + * @param string $columns_to_select |
|
900 | 901 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
901 | 902 | * @throws \EE_Error |
902 | 903 | */ |
@@ -1242,7 +1243,7 @@ discard block |
||
1242 | 1243 | * @param bool $pretty Whether to return the pretty formats (true) or not (false). |
1243 | 1244 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1244 | 1245 | * |
1245 | - * @return array formats in an array with the date format first, and the time format last. |
|
1246 | + * @return string[] formats in an array with the date format first, and the time format last. |
|
1246 | 1247 | */ |
1247 | 1248 | public function get_formats_for( $field_name, $pretty = false ) { |
1248 | 1249 | $field_settings = $this->field_settings_for( $field_name ); |
@@ -1277,7 +1278,7 @@ discard block |
||
1277 | 1278 | * |
1278 | 1279 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1279 | 1280 | * |
1280 | - * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1281 | + * @return string|null If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1281 | 1282 | * exception is triggered. |
1282 | 1283 | */ |
1283 | 1284 | public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
@@ -1588,7 +1589,7 @@ discard block |
||
1588 | 1589 | * Wrapper for EEM_Base::delete_permanently() |
1589 | 1590 | * |
1590 | 1591 | * @param mixed $id |
1591 | - * @return boolean whether the row got deleted or not |
|
1592 | + * @return integer whether the row got deleted or not |
|
1592 | 1593 | * @throws \EE_Error |
1593 | 1594 | */ |
1594 | 1595 | public function delete_permanently_by_ID( $id ) { |
@@ -1607,7 +1608,7 @@ discard block |
||
1607 | 1608 | * Wrapper for EEM_Base::delete() |
1608 | 1609 | * |
1609 | 1610 | * @param mixed $id |
1610 | - * @return boolean whether the row got deleted or not |
|
1611 | + * @return integer whether the row got deleted or not |
|
1611 | 1612 | * @throws \EE_Error |
1612 | 1613 | */ |
1613 | 1614 | public function delete_by_ID( $id ){ |
@@ -2017,7 +2018,7 @@ discard block |
||
2017 | 2018 | /** |
2018 | 2019 | * Verifies the EE addons' database is up-to-date and records that we've done it on |
2019 | 2020 | * EEM_Base::$_db_verification_level |
2020 | - * @param $wpdb_method |
|
2021 | + * @param string $wpdb_method |
|
2021 | 2022 | * @param $arguments_to_provide |
2022 | 2023 | * @return string |
2023 | 2024 | */ |
@@ -2112,6 +2113,7 @@ discard block |
||
2112 | 2113 | * @return boolean of success |
2113 | 2114 | * @throws \EE_Error |
2114 | 2115 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
2116 | + * @param EE_Base_Class $id_or_obj |
|
2115 | 2117 | */ |
2116 | 2118 | public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
2117 | 2119 | $relation_obj = $this->related_settings_for($relationName); |
@@ -2121,7 +2123,7 @@ discard block |
||
2121 | 2123 | |
2122 | 2124 | |
2123 | 2125 | /** |
2124 | - * @param mixed $id_or_obj |
|
2126 | + * @param EE_Base_Class $id_or_obj |
|
2125 | 2127 | * @param string $relationName |
2126 | 2128 | * @param array $where_query_params |
2127 | 2129 | * @param EE_Base_Class[] objects to which relations were removed |
@@ -2160,7 +2162,7 @@ discard block |
||
2160 | 2162 | * However, if the model objects can't be deleted because of blocking related model objects, then |
2161 | 2163 | * they aren't deleted. (Unless the thing that would have been deleted can be soft-deleted, that still happens). |
2162 | 2164 | * |
2163 | - * @param EE_Base_Class|int|string $id_or_obj |
|
2165 | + * @param EE_Base_Class $id_or_obj |
|
2164 | 2166 | * @param string $model_name |
2165 | 2167 | * @param array $query_params |
2166 | 2168 | * @return int how many deleted |
@@ -2180,7 +2182,7 @@ discard block |
||
2180 | 2182 | * the model objects can't be hard deleted because of blocking related model objects, |
2181 | 2183 | * just does a soft-delete on them instead. |
2182 | 2184 | * |
2183 | - * @param EE_Base_Class|int|string $id_or_obj |
|
2185 | + * @param EE_Base_Class $id_or_obj |
|
2184 | 2186 | * @param string $model_name |
2185 | 2187 | * @param array $query_params |
2186 | 2188 | * @return int how many deleted |
@@ -2229,6 +2231,7 @@ discard block |
||
2229 | 2231 | * @param string $model_name like 'Event', or 'Registration' |
2230 | 2232 | * @param array $query_params like EEM_Base::get_all's |
2231 | 2233 | * @param string $field_to_sum name of field to count by. By default, uses primary key |
2234 | + * @param EE_Base_Class $id_or_obj |
|
2232 | 2235 | * @return float |
2233 | 2236 | * @throws \EE_Error |
2234 | 2237 | */ |
@@ -2638,7 +2641,7 @@ discard block |
||
2638 | 2641 | /** |
2639 | 2642 | * Finds all the fields that correspond to the given table |
2640 | 2643 | * @param string $table_alias, array key in EEM_Base::_tables |
2641 | - * @return EE_Model_Field_Base[] |
|
2644 | + * @return EE_Model_Field_Base |
|
2642 | 2645 | */ |
2643 | 2646 | public function _get_fields_for_table($table_alias){ |
2644 | 2647 | return $this->_fields[$table_alias]; |
@@ -3901,7 +3904,7 @@ discard block |
||
3901 | 3904 | /** |
3902 | 3905 | * gets the field object of type 'primary_key' from the fieldsSettings attribute. |
3903 | 3906 | * Eg, on EE_Answer that would be ANS_ID field object |
3904 | - * @param $field_obj |
|
3907 | + * @param EE_Model_Field_Base $field_obj |
|
3905 | 3908 | * @return boolean |
3906 | 3909 | */ |
3907 | 3910 | public function is_primary_key_field( $field_obj ){ |
@@ -3997,7 +4000,7 @@ discard block |
||
3997 | 4000 | * Gets the actual table for the table alias |
3998 | 4001 | * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe |
3999 | 4002 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
4000 | - * @return EE_Table_Base |
|
4003 | + * @return string |
|
4001 | 4004 | */ |
4002 | 4005 | public function get_table_for_alias($table_alias){ |
4003 | 4006 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
@@ -4543,7 +4546,7 @@ discard block |
||
4543 | 4546 | } |
4544 | 4547 | /** |
4545 | 4548 | * Read comments for assume_values_already_prepared_by_model_object() |
4546 | - * @return int |
|
4549 | + * @return boolean |
|
4547 | 4550 | */ |
4548 | 4551 | public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
4549 | 4552 | return $this->_values_already_prepared_by_model_object; |
@@ -653,11 +653,11 @@ discard block |
||
653 | 653 | * Gets all the EE_Base_Class objects which match the $query_params, by querying the DB. |
654 | 654 | * |
655 | 655 | * @param array $query_params { |
656 | - * @var array $0 (where) array { |
|
656 | + * @var array $0 (where) array { |
|
657 | 657 | * eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob') |
658 | - * becomes |
|
658 | + * becomes |
|
659 | 659 | * SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...") |
660 | - * To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name |
|
660 | + * To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name |
|
661 | 661 | * onto the field name. Eg, EEM_Event::instance()->get_all(array(array('Venue.VNU_ID'=>12))); |
662 | 662 | * becomes |
663 | 663 | * SQL >> "SELECT * FROM wp_posts AS Event_CPT |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | * SQL >> "...WHERE QST_display_text LIKE '%bob%' AND QST_ID < 34 AND QST_wp_user IN (1,2,7,23)...". |
678 | 678 | * Valid operators so far: =, !=, <, <=, >, >=, LIKE, NOT LIKE, IN (followed by numeric-indexed array), |
679 | 679 | * NOT IN (dido), BETWEEN (followed by an array with exactly 2 date strings), IS NULL, and IS NOT NULL |
680 | - * Values can be a string, int, or float. They can also be arrays IFF the operator is IN. |
|
680 | + * Values can be a string, int, or float. They can also be arrays IFF the operator is IN. |
|
681 | 681 | * Also, values can actually be field names. To indicate the value is a field, |
682 | 682 | * simply provide a third array item (true) to the operator-value array like so: |
683 | 683 | * eg: array( 'DTT_reg_limit' => array('>', 'DTT_sold', TRUE) ) |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * Note: you can also use related model field names like you would any other field name. |
687 | 687 | * eg: array('Datetime.DTT_reg_limit'=>array('=','Datetime.DTT_sold',TRUE) |
688 | 688 | * could be used if you were querying EEM_Tickets (because Datetime is directly related to tickets) |
689 | - * Also, by default all the where conditions are AND'd together. |
|
689 | + * Also, by default all the where conditions are AND'd together. |
|
690 | 690 | * To override this, add an array key 'OR' (or 'AND') and the array to be OR'd together |
691 | 691 | * eg: array('OR'=>array('TXN_ID' => 23 , 'TXN_timestamp__>' => 345678912)) |
692 | 692 | * becomes |
@@ -701,17 +701,17 @@ discard block |
||
701 | 701 | * eg array('OR'=>array('NOT'=>array('TXN_total' => 50, 'TXN_paid'=>23)),AND=>array('TXN_ID'=>1,'STS_ID'=>'TIN') |
702 | 702 | * becomes |
703 | 703 | * SQL >> "...where ! (TXN_total =50 OR TXN_paid =23) AND TXN_ID=1 AND STS_ID='TIN'" |
704 | - * They can be nested indefinitely. |
|
704 | + * They can be nested indefinitely. |
|
705 | 705 | * eg: array('OR'=>array('TXN_total' => 23, 'NOT'=> array( 'TXN_timestamp'=> 345678912, 'AND'=>array('TXN_paid' => 53, 'STS_ID' => 'TIN')))) |
706 | 706 | * becomes |
707 | 707 | * SQL >> "...WHERE TXN_total = 23 OR ! (TXN_timestamp = 345678912 OR (TXN_paid = 53 AND STS_ID = 'TIN'))..." |
708 | - * GOTCHA: |
|
708 | + * GOTCHA: |
|
709 | 709 | * because this is an array, array keys must be unique, making it impossible to place two or more where conditions applying to the same field. |
710 | 710 | * eg: array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp'=>array('<',$end_date),'PAY_timestamp'=>array('!=',$special_date)), |
711 | 711 | * as PHP enforces that the array keys must be unique, thus removing the first two array entries with key 'PAY_timestamp'. |
712 | 712 | * becomes |
713 | 713 | * SQL >> "PAY_timestamp != 4234232", ignoring the first two PAY_timestamp conditions). |
714 | - * To overcome this, you can add a '*' character to the end of the field's name, followed by anything. |
|
714 | + * To overcome this, you can add a '*' character to the end of the field's name, followed by anything. |
|
715 | 715 | * These will be removed when generating the SQL string, but allow for the array keys to be unique. |
716 | 716 | * eg: you could rewrite the previous query as: |
717 | 717 | * array('PAY_timestamp'=>array('>',$start_date),'PAY_timestamp*1st'=>array('<',$end_date),'PAY_timestamp*2nd'=>array('!=',$special_date)) |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | * You will probably only want to do this in hopes of increasing efficiency, as related models which belongs to the current model |
745 | 745 | * (ie, the current model has a foreign key to them, like how Registration belongs to Attendee) can be cached in order |
746 | 746 | * to avoid future queries |
747 | - * @var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out |
|
747 | + * @var string $default_where_conditions can be set to 'none', 'this_model_only', 'other_models_only', or 'all'. set this to 'none' to disable all default where conditions. Eg, usually soft-deleted objects are filtered-out |
|
748 | 748 | * if you want to include them, set this query param to 'none'. If you want to ONLY disable THIS model's default where conditions |
749 | 749 | * set it to 'other_models_only'. If you only want this model's default where conditions added to the query, use 'this_model_only'. |
750 | 750 | * If you want to use all default where conditions (default), set to 'all'. |
@@ -1014,7 +1014,6 @@ discard block |
||
1014 | 1014 | /** |
1015 | 1015 | * Gets a single item for this model from the DB, given the $query_params. Only returns a single class, not an array. If no item is found, |
1016 | 1016 | * null is returned. |
1017 | - |
|
1018 | 1017 | * |
1019 | 1018 | *@param array $query_params like EEM_Base's $query_params variable. |
1020 | 1019 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
@@ -1117,7 +1116,7 @@ discard block |
||
1117 | 1116 | * can indicate just the columns you |
1118 | 1117 | * want and a single array indexed by |
1119 | 1118 | * the columns will be returned. |
1120 | - * @return EE_Base_Class|null|array() |
|
1119 | + * @return EE_Base_Class|null|array() |
|
1121 | 1120 | * @throws EE_Error |
1122 | 1121 | */ |
1123 | 1122 | public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
@@ -1765,7 +1764,7 @@ discard block |
||
1765 | 1764 | //make sure there's no related objects blocking its deletion (if we're checking) |
1766 | 1765 | if ( |
1767 | 1766 | $allow_blocking |
1768 | - && $this->delete_is_blocked_by_related_models( |
|
1767 | + && $this->delete_is_blocked_by_related_models( |
|
1769 | 1768 | $delete_object[ $primary_table->get_fully_qualified_pk_column() ] |
1770 | 1769 | ) |
1771 | 1770 | ) { |
@@ -1813,8 +1812,8 @@ discard block |
||
1813 | 1812 | foreach($fields as $cpk_field){ |
1814 | 1813 | if ( $cpk_field instanceof EE_Model_Field_Base ){ |
1815 | 1814 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column() |
1816 | - . "=" |
|
1817 | - . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
1815 | + . "=" |
|
1816 | + . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
1818 | 1817 | } |
1819 | 1818 | } |
1820 | 1819 | $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
@@ -2930,8 +2929,8 @@ discard block |
||
2930 | 2929 | } |
2931 | 2930 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
2932 | 2931 | if ( ! array_key_exists( 'order_by', $query_params ) |
2933 | - && array_key_exists( 'order', $query_params ) |
|
2934 | - && ! empty( $query_params['order'] ) |
|
2932 | + && array_key_exists( 'order', $query_params ) |
|
2933 | + && ! empty( $query_params['order'] ) |
|
2935 | 2934 | ) { |
2936 | 2935 | $pk_field = $this->get_primary_key_field(); |
2937 | 2936 | $order = $this->_extract_order( $query_params['order'] ); |
@@ -4469,7 +4468,7 @@ discard block |
||
4469 | 4468 | $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
4470 | 4469 | } else if ( |
4471 | 4470 | $primary_key_field instanceof EE_Primary_Key_String_Field |
4472 | - && is_string( $base_class_obj_or_id ) |
|
4471 | + && is_string( $base_class_obj_or_id ) |
|
4473 | 4472 | ) { |
4474 | 4473 | // assume its a string representation of the object |
4475 | 4474 | $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @since EE4 |
24 | 24 | * |
25 | 25 | */ |
26 | -abstract class EEM_Base extends EE_Base{ |
|
26 | +abstract class EEM_Base extends EE_Base { |
|
27 | 27 | |
28 | 28 | //admin posty |
29 | 29 | //basic -> grants access to mine -> if they don't have it, select none |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * Flag indicating whether this model has a primary key or not |
244 | 244 | * @var boolean |
245 | 245 | */ |
246 | - protected $_has_primary_key_field=null; |
|
246 | + protected $_has_primary_key_field = null; |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Whether or not this model is based off a table in WP core only (CPTs should set |
@@ -305,19 +305,19 @@ discard block |
||
305 | 305 | * operators that work like 'BETWEEN'. Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'" |
306 | 306 | * @var array |
307 | 307 | */ |
308 | - protected $_between_style_operators = array( 'BETWEEN' ); |
|
308 | + protected $_between_style_operators = array('BETWEEN'); |
|
309 | 309 | |
310 | 310 | /** |
311 | 311 | * operators that are used for handling NUll and !NULL queries. Typically used for when checking if a row exists on a join table. |
312 | 312 | * @var array |
313 | 313 | */ |
314 | - protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL'); |
|
314 | + protected $_null_style_operators = array('IS NOT NULL', 'IS NULL'); |
|
315 | 315 | |
316 | 316 | /** |
317 | 317 | * Allowed values for $query_params['order'] for ordering in queries |
318 | 318 | * @var array |
319 | 319 | */ |
320 | - protected $_allowed_order_values = array('asc','desc','ASC','DESC'); |
|
320 | + protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC'); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * When these are keys in a WHERE or HAVING clause, they are handled much differently |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | * 'where', but 'where' clauses are so common that we thought we'd omit it |
332 | 332 | * @var array |
333 | 333 | */ |
334 | - private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps'); |
|
334 | + private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps'); |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * All the data types that can be used in $wpdb->prepare statements. |
338 | 338 | * @var array |
339 | 339 | */ |
340 | - private $_valid_wpdb_data_types = array('%d','%s','%f'); |
|
340 | + private $_valid_wpdb_data_types = array('%d', '%s', '%f'); |
|
341 | 341 | |
342 | 342 | /** |
343 | 343 | * EE_Registry Object |
@@ -370,17 +370,17 @@ discard block |
||
370 | 370 | /** |
371 | 371 | * constant used to show EEM_Base has not yet verified the db on this http request |
372 | 372 | */ |
373 | - const db_verified_none = 0; |
|
373 | + const db_verified_none = 0; |
|
374 | 374 | /** |
375 | 375 | * constant used to show EEM_Base has verified the EE core db on this http request, |
376 | 376 | * but not the addons' dbs |
377 | 377 | */ |
378 | - const db_verified_core = 1; |
|
378 | + const db_verified_core = 1; |
|
379 | 379 | /** |
380 | 380 | * constant used to show EEM_Base has verified the addons' dbs (and implicitly |
381 | 381 | * the EE core db too) |
382 | 382 | */ |
383 | - const db_verified_addons = 2; |
|
383 | + const db_verified_addons = 2; |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * indicates whether an EEM_Base child has already re-verified the DB |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | * @param null $timezone |
412 | 412 | * @throws \EE_Error |
413 | 413 | */ |
414 | - protected function __construct( $timezone = NULL ){ |
|
414 | + protected function __construct($timezone = NULL) { |
|
415 | 415 | // check that the model has not been loaded too soon |
416 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) { |
|
417 | - throw new EE_Error ( |
|
416 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons')) { |
|
417 | + throw new EE_Error( |
|
418 | 418 | sprintf( |
419 | - __( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ), |
|
420 | - get_class( $this ) |
|
419 | + __('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'), |
|
420 | + get_class($this) |
|
421 | 421 | ) |
422 | 422 | ); |
423 | 423 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | /** |
426 | 426 | * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set. |
427 | 427 | */ |
428 | - if ( empty( EEM_Base::$_model_query_blog_id ) ) { |
|
428 | + if (empty(EEM_Base::$_model_query_blog_id)) { |
|
429 | 429 | EEM_Base::set_model_query_blog_id(); |
430 | 430 | } |
431 | 431 | |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | * just use EE_Register_Model_Extension |
435 | 435 | * @var EE_Table_Base[] $_tables |
436 | 436 | */ |
437 | - $this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables ); |
|
438 | - foreach($this->_tables as $table_alias => $table_obj){ |
|
437 | + $this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables); |
|
438 | + foreach ($this->_tables as $table_alias => $table_obj) { |
|
439 | 439 | /** @var $table_obj EE_Table_Base */ |
440 | 440 | $table_obj->_construct_finalize_with_alias($table_alias); |
441 | - if( $table_obj instanceof EE_Secondary_Table ){ |
|
441 | + if ($table_obj instanceof EE_Secondary_Table) { |
|
442 | 442 | /** @var $table_obj EE_Secondary_Table */ |
443 | 443 | $table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table()); |
444 | 444 | } |
@@ -448,54 +448,54 @@ discard block |
||
448 | 448 | * EE_Register_Model_Extension |
449 | 449 | * @param EE_Model_Field_Base[] $_fields |
450 | 450 | */ |
451 | - $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields); |
|
451 | + $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields); |
|
452 | 452 | $this->_invalidate_field_caches(); |
453 | - foreach($this->_fields as $table_alias => $fields_for_table){ |
|
454 | - if ( ! array_key_exists( $table_alias, $this->_tables )){ |
|
455 | - throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields))); |
|
453 | + foreach ($this->_fields as $table_alias => $fields_for_table) { |
|
454 | + if ( ! array_key_exists($table_alias, $this->_tables)) { |
|
455 | + throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields))); |
|
456 | 456 | } |
457 | - foreach($fields_for_table as $field_name => $field_obj){ |
|
457 | + foreach ($fields_for_table as $field_name => $field_obj) { |
|
458 | 458 | /** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */ |
459 | 459 | //primary key field base has a slightly different _construct_finalize |
460 | 460 | /** @var $field_obj EE_Model_Field_Base */ |
461 | - $field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() ); |
|
461 | + $field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name()); |
|
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | 465 | // everything is related to Extra_Meta |
466 | - if( get_class($this) !== 'EEM_Extra_Meta'){ |
|
466 | + if (get_class($this) !== 'EEM_Extra_Meta') { |
|
467 | 467 | //make extra meta related to everything, but don't block deleting things just |
468 | 468 | //because they have related extra meta info. For now just orphan those extra meta |
469 | 469 | //in the future we should automatically delete them |
470 | - $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE ); |
|
470 | + $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE); |
|
471 | 471 | } |
472 | 472 | //and change logs |
473 | - if( get_class( $this) !== 'EEM_Change_Log' ) { |
|
474 | - $this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE ); |
|
473 | + if (get_class($this) !== 'EEM_Change_Log') { |
|
474 | + $this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE); |
|
475 | 475 | } |
476 | 476 | /** |
477 | 477 | * Filters the list of relations on a model. It is best to NOT use this directly and instead just use |
478 | 478 | * EE_Register_Model_Extension |
479 | 479 | * @param EE_Model_Relation_Base[] $_model_relations |
480 | 480 | */ |
481 | - $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations); |
|
482 | - foreach($this->_model_relations as $model_name => $relation_obj){ |
|
481 | + $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations); |
|
482 | + foreach ($this->_model_relations as $model_name => $relation_obj) { |
|
483 | 483 | /** @var $relation_obj EE_Model_Relation_Base */ |
484 | 484 | $relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name); |
485 | 485 | } |
486 | - foreach($this->_indexes as $index_name => $index_obj){ |
|
486 | + foreach ($this->_indexes as $index_name => $index_obj) { |
|
487 | 487 | /** @var $index_obj EE_Index */ |
488 | 488 | $index_obj->_construct_finalize($index_name, $this->get_this_model_name()); |
489 | 489 | } |
490 | 490 | |
491 | 491 | $this->set_timezone($timezone); |
492 | 492 | //finalize default where condition strategy, or set default |
493 | - if( ! $this->_default_where_conditions_strategy){ |
|
493 | + if ( ! $this->_default_where_conditions_strategy) { |
|
494 | 494 | //nothing was set during child constructor, so set default |
495 | 495 | $this->_default_where_conditions_strategy = new EE_Default_Where_Conditions(); |
496 | 496 | } |
497 | 497 | $this->_default_where_conditions_strategy->_finalize_construct($this); |
498 | - if( ! $this->_minimum_where_conditions_strategy){ |
|
498 | + if ( ! $this->_minimum_where_conditions_strategy) { |
|
499 | 499 | //nothing was set during child constructor, so set default |
500 | 500 | $this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions(); |
501 | 501 | } |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | |
504 | 504 | //if the cap slug hasn't been set, and we haven't set it to false on purpose |
505 | 505 | //to indicate to NOT set it, set it to the logical default |
506 | - if( $this->_caps_slug === null ) { |
|
507 | - $this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() ); |
|
506 | + if ($this->_caps_slug === null) { |
|
507 | + $this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name()); |
|
508 | 508 | } |
509 | 509 | //initialize the standard cap restriction generators if none were specified by the child constructor |
510 | - if( $this->_cap_restriction_generators !== false ){ |
|
511 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){ |
|
512 | - if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) { |
|
513 | - $this->_cap_restriction_generators[ $cap_context ] = apply_filters( |
|
510 | + if ($this->_cap_restriction_generators !== false) { |
|
511 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
512 | + if ( ! isset($this->_cap_restriction_generators[$cap_context])) { |
|
513 | + $this->_cap_restriction_generators[$cap_context] = apply_filters( |
|
514 | 514 | 'FHEE__EEM_Base___construct__standard_cap_restriction_generator', |
515 | 515 | new EE_Restriction_Generator_Protected(), |
516 | 516 | $cap_context, |
@@ -520,23 +520,23 @@ discard block |
||
520 | 520 | } |
521 | 521 | } |
522 | 522 | //if there are cap restriction generators, use them to make the default cap restrictions |
523 | - if( $this->_cap_restriction_generators !== false ){ |
|
524 | - foreach( $this->_cap_restriction_generators as $context => $generator_object ) { |
|
525 | - if( ! $generator_object ){ |
|
523 | + if ($this->_cap_restriction_generators !== false) { |
|
524 | + foreach ($this->_cap_restriction_generators as $context => $generator_object) { |
|
525 | + if ( ! $generator_object) { |
|
526 | 526 | continue; |
527 | 527 | } |
528 | - if( ! $generator_object instanceof EE_Restriction_Generator_Base ){ |
|
528 | + if ( ! $generator_object instanceof EE_Restriction_Generator_Base) { |
|
529 | 529 | throw new EE_Error( |
530 | 530 | sprintf( |
531 | - __( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ), |
|
531 | + __('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'), |
|
532 | 532 | $context, |
533 | 533 | $this->get_this_model_name() |
534 | 534 | ) |
535 | 535 | ); |
536 | 536 | } |
537 | - $action = $this->cap_action_for_context( $context ); |
|
538 | - if( ! $generator_object->construction_finalized() ){ |
|
539 | - $generator_object->_construct_finalize( $this, $action ); |
|
537 | + $action = $this->cap_action_for_context($context); |
|
538 | + if ( ! $generator_object->construction_finalized()) { |
|
539 | + $generator_object->_construct_finalize($this, $action); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | } |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | * @param string $context one of EEM_Base::valid_cap_contexts() |
551 | 551 | * @return EE_Default_Where_Conditions[] |
552 | 552 | */ |
553 | - protected function _generate_cap_restrictions( $context ){ |
|
554 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
555 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
|
556 | - return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
|
557 | - }else{ |
|
553 | + protected function _generate_cap_restrictions($context) { |
|
554 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
555 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) { |
|
556 | + return $this->_cap_restriction_generators[$context]->generate_restrictions(); |
|
557 | + } else { |
|
558 | 558 | return array(); |
559 | 559 | } |
560 | 560 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | * @param int $blog_id If provided then will set the blog_id for the models to this id. If not provided then the |
567 | 567 | * value for get_current_blog_id() will be used. |
568 | 568 | */ |
569 | - public static function set_model_query_blog_id( $blog_id = 0 ) { |
|
569 | + public static function set_model_query_blog_id($blog_id = 0) { |
|
570 | 570 | EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id(); |
571 | 571 | } |
572 | 572 | |
@@ -591,16 +591,16 @@ discard block |
||
591 | 591 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
592 | 592 | * @return static (as in the concrete child class) |
593 | 593 | */ |
594 | - public static function instance( $timezone = NULL ){ |
|
594 | + public static function instance($timezone = NULL) { |
|
595 | 595 | |
596 | 596 | // check if instance of Espresso_model already exists |
597 | 597 | if ( ! static::$_instance instanceof static) { |
598 | 598 | // instantiate Espresso_model |
599 | - static::$_instance = new static( $timezone ); |
|
599 | + static::$_instance = new static($timezone); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | //we might have a timezone set, let set_timezone decide what to do with it |
603 | - static::$_instance->set_timezone( $timezone ); |
|
603 | + static::$_instance->set_timezone($timezone); |
|
604 | 604 | |
605 | 605 | // Espresso_model object |
606 | 606 | return static::$_instance; |
@@ -613,11 +613,11 @@ discard block |
||
613 | 613 | * @param null | string $timezone |
614 | 614 | * @return static |
615 | 615 | */ |
616 | - public static function reset( $timezone = NULL ){ |
|
617 | - if ( ! is_null( static::$_instance ) ) { |
|
616 | + public static function reset($timezone = NULL) { |
|
617 | + if ( ! is_null(static::$_instance)) { |
|
618 | 618 | static::$_instance = null; |
619 | 619 | |
620 | - return self::instance( $timezone ); |
|
620 | + return self::instance($timezone); |
|
621 | 621 | } |
622 | 622 | return null; |
623 | 623 | } |
@@ -631,19 +631,19 @@ discard block |
||
631 | 631 | * @return array |
632 | 632 | * @throws \EE_Error |
633 | 633 | */ |
634 | - public function status_array( $translated = FALSE ) { |
|
635 | - if ( ! array_key_exists( 'Status', $this->_model_relations ) ) { |
|
634 | + public function status_array($translated = FALSE) { |
|
635 | + if ( ! array_key_exists('Status', $this->_model_relations)) { |
|
636 | 636 | return array(); |
637 | 637 | } |
638 | 638 | $model_name = $this->get_this_model_name(); |
639 | - $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) ); |
|
640 | - $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) ); |
|
639 | + $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name))); |
|
640 | + $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type))); |
|
641 | 641 | $status_array = array(); |
642 | - foreach ( $stati as $status ) { |
|
643 | - $status_array[ $status->ID() ] = $status->get( 'STS_code' ); |
|
642 | + foreach ($stati as $status) { |
|
643 | + $status_array[$status->ID()] = $status->get('STS_code'); |
|
644 | 644 | } |
645 | 645 | return $translated |
646 | - ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' ) |
|
646 | + ? EEM_Status::instance()->localized_status($status_array, false, 'sentence') |
|
647 | 647 | : $status_array; |
648 | 648 | } |
649 | 649 | |
@@ -776,10 +776,10 @@ discard block |
||
776 | 776 | * )); |
777 | 777 | * @throws \EE_Error |
778 | 778 | */ |
779 | - public function get_all($query_params = array()){ |
|
780 | - if( isset( $query_params[ 'limit' ] ) |
|
781 | - && ! isset( $query_params[ 'group_by' ] ) ) { |
|
782 | - $query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() ); |
|
779 | + public function get_all($query_params = array()) { |
|
780 | + if (isset($query_params['limit']) |
|
781 | + && ! isset($query_params['group_by'])) { |
|
782 | + $query_params['group_by'] = array_keys($this->get_combined_primary_key_fields()); |
|
783 | 783 | } |
784 | 784 | return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL)); |
785 | 785 | } |
@@ -790,10 +790,10 @@ discard block |
||
790 | 790 | * @param array $query_params @see EEM_Base::get_all() |
791 | 791 | * @return array like EEM_Base::get_all |
792 | 792 | */ |
793 | - public function alter_query_params_to_only_include_mine( $query_params = array() ) { |
|
793 | + public function alter_query_params_to_only_include_mine($query_params = array()) { |
|
794 | 794 | $wp_user_field_name = $this->wp_user_field_name(); |
795 | - if( $wp_user_field_name ){ |
|
796 | - $query_params[0][ $wp_user_field_name ] = get_current_user_id(); |
|
795 | + if ($wp_user_field_name) { |
|
796 | + $query_params[0][$wp_user_field_name] = get_current_user_id(); |
|
797 | 797 | } |
798 | 798 | return $query_params; |
799 | 799 | } |
@@ -806,19 +806,19 @@ discard block |
||
806 | 806 | * foreign key to the WP_User table |
807 | 807 | */ |
808 | 808 | public function wp_user_field_name() { |
809 | - try{ |
|
810 | - if( ! empty( $this->_model_chain_to_wp_user ) ) { |
|
811 | - $models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user ); |
|
812 | - $last_model_name = end( $models_to_follow_to_wp_users ); |
|
813 | - $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
|
814 | - $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
|
815 | - }else{ |
|
809 | + try { |
|
810 | + if ( ! empty($this->_model_chain_to_wp_user)) { |
|
811 | + $models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user); |
|
812 | + $last_model_name = end($models_to_follow_to_wp_users); |
|
813 | + $model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name); |
|
814 | + $model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.'; |
|
815 | + } else { |
|
816 | 816 | $model_with_fk_to_wp_users = $this; |
817 | 817 | $model_chain_to_wp_user = ''; |
818 | 818 | } |
819 | - $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
|
820 | - return $model_chain_to_wp_user . $wp_user_field->get_name(); |
|
821 | - }catch( EE_Error $e ) { |
|
819 | + $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User'); |
|
820 | + return $model_chain_to_wp_user.$wp_user_field->get_name(); |
|
821 | + } catch (EE_Error $e) { |
|
822 | 822 | return false; |
823 | 823 | } |
824 | 824 | } |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * (or transiently-related model) |
833 | 833 | * @return string |
834 | 834 | */ |
835 | - public function model_chain_to_wp_user(){ |
|
835 | + public function model_chain_to_wp_user() { |
|
836 | 836 | return $this->_model_chain_to_wp_user; |
837 | 837 | } |
838 | 838 | |
@@ -844,13 +844,13 @@ discard block |
||
844 | 844 | * @return boolean |
845 | 845 | */ |
846 | 846 | public function is_owned() { |
847 | - if( $this->model_chain_to_wp_user() ){ |
|
847 | + if ($this->model_chain_to_wp_user()) { |
|
848 | 848 | return true; |
849 | - }else{ |
|
850 | - try{ |
|
851 | - $this->get_foreign_key_to( 'WP_User' ); |
|
849 | + } else { |
|
850 | + try { |
|
851 | + $this->get_foreign_key_to('WP_User'); |
|
852 | 852 | return true; |
853 | - }catch( EE_Error $e ){ |
|
853 | + } catch (EE_Error $e) { |
|
854 | 854 | return false; |
855 | 855 | } |
856 | 856 | } |
@@ -872,17 +872,17 @@ discard block |
||
872 | 872 | * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
873 | 873 | * @throws \EE_Error |
874 | 874 | */ |
875 | - protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
875 | + protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
876 | 876 | // remember the custom selections, if any, and type cast as array |
877 | 877 | // (unless $columns_to_select is an object, then just set as an empty array) |
878 | 878 | // Note: (array) 'some string' === array( 'some string' ) |
879 | - $this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array(); |
|
880 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
879 | + $this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array(); |
|
880 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
881 | 881 | $select_expressions = $columns_to_select !== null |
882 | - ? $this->_construct_select_from_input( $columns_to_select ) |
|
883 | - : $this->_construct_default_select_sql( $model_query_info ); |
|
884 | - $SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info ); |
|
885 | - return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) ); |
|
882 | + ? $this->_construct_select_from_input($columns_to_select) |
|
883 | + : $this->_construct_default_select_sql($model_query_info); |
|
884 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
885 | + return $this->_do_wpdb_query('get_results', array($SQL, $output)); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
901 | 901 | * @throws \EE_Error |
902 | 902 | */ |
903 | - public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
903 | + public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
904 | 904 | return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select); |
905 | 905 | } |
906 | 906 | |
@@ -912,12 +912,12 @@ discard block |
||
912 | 912 | * @throws EE_Error |
913 | 913 | * @return string |
914 | 914 | */ |
915 | - private function _construct_select_from_input($columns_to_select){ |
|
916 | - if(is_array($columns_to_select)){ |
|
915 | + private function _construct_select_from_input($columns_to_select) { |
|
916 | + if (is_array($columns_to_select)) { |
|
917 | 917 | $select_sql_array = array(); |
918 | 918 | |
919 | - foreach($columns_to_select as $alias => $selection_and_datatype){ |
|
920 | - if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){ |
|
919 | + foreach ($columns_to_select as $alias => $selection_and_datatype) { |
|
920 | + if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) { |
|
921 | 921 | throw new EE_Error( |
922 | 922 | sprintf( |
923 | 923 | __( |
@@ -929,24 +929,24 @@ discard block |
||
929 | 929 | ) |
930 | 930 | ); |
931 | 931 | } |
932 | - if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){ |
|
932 | + if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) { |
|
933 | 933 | throw new EE_Error( |
934 | 934 | sprintf( |
935 | 935 | __( |
936 | 936 | "Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", |
937 | 937 | "event_espresso" |
938 | 938 | ), |
939 | - $selection_and_datatype[ 1 ], |
|
940 | - $selection_and_datatype[ 0 ], |
|
939 | + $selection_and_datatype[1], |
|
940 | + $selection_and_datatype[0], |
|
941 | 941 | $alias, |
942 | - implode( ",", $this->_valid_wpdb_data_types ) |
|
942 | + implode(",", $this->_valid_wpdb_data_types) |
|
943 | 943 | ) |
944 | 944 | ); |
945 | 945 | } |
946 | 946 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
947 | 947 | } |
948 | - $columns_to_select_string = implode(", ",$select_sql_array); |
|
949 | - }else{ |
|
948 | + $columns_to_select_string = implode(", ", $select_sql_array); |
|
949 | + } else { |
|
950 | 950 | $columns_to_select_string = $columns_to_select; |
951 | 951 | } |
952 | 952 | return $columns_to_select_string; |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * @return string |
962 | 962 | * @throws \EE_Error |
963 | 963 | */ |
964 | - public function primary_key_name(){ |
|
964 | + public function primary_key_name() { |
|
965 | 965 | return $this->get_primary_key_field()->get_name(); |
966 | 966 | } |
967 | 967 | |
@@ -973,14 +973,14 @@ discard block |
||
973 | 973 | * @param mixed $id int or string, depending on the type of the model's primary key |
974 | 974 | * @return EE_Base_Class |
975 | 975 | */ |
976 | - public function get_one_by_ID($id){ |
|
977 | - if( $this->get_from_entity_map( $id ) ){ |
|
978 | - return $this->get_from_entity_map( $id ); |
|
976 | + public function get_one_by_ID($id) { |
|
977 | + if ($this->get_from_entity_map($id)) { |
|
978 | + return $this->get_from_entity_map($id); |
|
979 | 979 | } |
980 | 980 | return $this->get_one( |
981 | 981 | $this->alter_query_params_to_restrict_by_ID( |
982 | 982 | $id, |
983 | - array( 'default_where_conditions' => 'minimum' ) |
|
983 | + array('default_where_conditions' => 'minimum') |
|
984 | 984 | ) |
985 | 985 | ); |
986 | 986 | } |
@@ -996,15 +996,15 @@ discard block |
||
996 | 996 | * @return array of normal query params, @see EEM_Base::get_all |
997 | 997 | * @throws \EE_Error |
998 | 998 | */ |
999 | - public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) { |
|
1000 | - if( ! isset( $query_params[ 0 ] ) ) { |
|
1001 | - $query_params[ 0 ] = array(); |
|
999 | + public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) { |
|
1000 | + if ( ! isset($query_params[0])) { |
|
1001 | + $query_params[0] = array(); |
|
1002 | 1002 | } |
1003 | - if( $this->has_primary_key_field ( ) ) { |
|
1004 | - $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
|
1005 | - }else{ |
|
1003 | + if ($this->has_primary_key_field( )) { |
|
1004 | + $query_params[0][$this->primary_key_name()] = $id; |
|
1005 | + } else { |
|
1006 | 1006 | //no primary key, so the $id must be from the get_index_primary_key_string() |
1007 | - $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
|
1007 | + $query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id)); |
|
1008 | 1008 | } |
1009 | 1009 | return $query_params; |
1010 | 1010 | } |
@@ -1020,16 +1020,16 @@ discard block |
||
1020 | 1020 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class|NULL |
1021 | 1021 | * @throws \EE_Error |
1022 | 1022 | */ |
1023 | - public function get_one($query_params = array()){ |
|
1024 | - if( ! is_array( $query_params ) ){ |
|
1025 | - EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1023 | + public function get_one($query_params = array()) { |
|
1024 | + if ( ! is_array($query_params)) { |
|
1025 | + EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1026 | 1026 | $query_params = array(); |
1027 | 1027 | } |
1028 | 1028 | $query_params['limit'] = 1; |
1029 | 1029 | $items = $this->get_all($query_params); |
1030 | - if(empty($items)){ |
|
1030 | + if (empty($items)) { |
|
1031 | 1031 | return null; |
1032 | - }else{ |
|
1032 | + } else { |
|
1033 | 1033 | return array_shift($items); |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | * @return EE_Base_Class[]|array |
1053 | 1053 | * @throws \EE_Error |
1054 | 1054 | */ |
1055 | - public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1056 | - return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
1055 | + public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1056 | + return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @return EE_Base_Class[]|array |
1075 | 1075 | * @throws \EE_Error |
1076 | 1076 | */ |
1077 | - public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1078 | - return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
1077 | + public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1078 | + return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
@@ -1096,9 +1096,9 @@ discard block |
||
1096 | 1096 | * @return EE_Base_Class|null|array() |
1097 | 1097 | * @throws \EE_Error |
1098 | 1098 | */ |
1099 | - public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
1100 | - $results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
1101 | - return empty( $results ) ? null : reset( $results ); |
|
1099 | + public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
1100 | + $results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
1101 | + return empty($results) ? null : reset($results); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1120,9 +1120,9 @@ discard block |
||
1120 | 1120 | * @return EE_Base_Class|null|array() |
1121 | 1121 | * @throws EE_Error |
1122 | 1122 | */ |
1123 | - public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
1124 | - $results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
1125 | - return empty( $results ) ? null : reset( $results ); |
|
1123 | + public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
1124 | + $results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
1125 | + return empty($results) ? null : reset($results); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | |
@@ -1143,42 +1143,42 @@ discard block |
||
1143 | 1143 | * @return EE_Base_Class[]|array |
1144 | 1144 | * @throws EE_Error |
1145 | 1145 | */ |
1146 | - protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1146 | + protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1147 | 1147 | //if $field_to_order_by is empty then let's assume we're ordering by the primary key. |
1148 | - if ( empty( $field_to_order_by ) ) { |
|
1149 | - if ( $this->has_primary_key_field() ) { |
|
1148 | + if (empty($field_to_order_by)) { |
|
1149 | + if ($this->has_primary_key_field()) { |
|
1150 | 1150 | $field_to_order_by = $this->get_primary_key_field()->get_name(); |
1151 | 1151 | } else { |
1152 | 1152 | |
1153 | - if ( WP_DEBUG ) { |
|
1154 | - throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) ); |
|
1153 | + if (WP_DEBUG) { |
|
1154 | + throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso')); |
|
1155 | 1155 | } |
1156 | - EE_Error::add_error( __('There was an error with the query.', 'event_espresso') ); |
|
1156 | + EE_Error::add_error(__('There was an error with the query.', 'event_espresso')); |
|
1157 | 1157 | return array(); |
1158 | 1158 | } |
1159 | 1159 | } |
1160 | 1160 | |
1161 | - if( ! is_array( $query_params ) ){ |
|
1162 | - EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1161 | + if ( ! is_array($query_params)) { |
|
1162 | + EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1163 | 1163 | $query_params = array(); |
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | //let's add the where query param for consecutive look up. |
1167 | - $query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value ); |
|
1167 | + $query_params[0][$field_to_order_by] = array($operand, $current_field_value); |
|
1168 | 1168 | $query_params['limit'] = $limit; |
1169 | 1169 | |
1170 | 1170 | //set direction |
1171 | - $incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array(); |
|
1171 | + $incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array(); |
|
1172 | 1172 | $query_params['order_by'] = $operand === '>' |
1173 | - ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby |
|
1174 | - : array( $field_to_order_by => 'DESC') + $incoming_orderby; |
|
1173 | + ? array($field_to_order_by => 'ASC') + $incoming_orderby |
|
1174 | + : array($field_to_order_by => 'DESC') + $incoming_orderby; |
|
1175 | 1175 | |
1176 | 1176 | //if $columns_to_select is empty then that means we're returning EE_Base_Class objects |
1177 | - if ( empty( $columns_to_select ) ) { |
|
1178 | - return $this->get_all( $query_params ); |
|
1177 | + if (empty($columns_to_select)) { |
|
1178 | + return $this->get_all($query_params); |
|
1179 | 1179 | } else { |
1180 | 1180 | //getting just the fields |
1181 | - return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select ); |
|
1181 | + return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select); |
|
1182 | 1182 | } |
1183 | 1183 | } |
1184 | 1184 | |
@@ -1189,18 +1189,18 @@ discard block |
||
1189 | 1189 | * This sets the _timezone property after model object has been instantiated. |
1190 | 1190 | * @param null | string $timezone valid PHP DateTimeZone timezone string |
1191 | 1191 | */ |
1192 | - public function set_timezone( $timezone ) { |
|
1193 | - if ( $timezone !== null ) { |
|
1192 | + public function set_timezone($timezone) { |
|
1193 | + if ($timezone !== null) { |
|
1194 | 1194 | $this->_timezone = $timezone; |
1195 | 1195 | } |
1196 | 1196 | //note we need to loop through relations and set the timezone on those objects as well. |
1197 | - foreach ( $this->_model_relations as $relation ) { |
|
1198 | - $relation->set_timezone( $timezone ); |
|
1197 | + foreach ($this->_model_relations as $relation) { |
|
1198 | + $relation->set_timezone($timezone); |
|
1199 | 1199 | } |
1200 | 1200 | //and finally we do the same for any datetime fields |
1201 | - foreach ( $this->_fields as $field ) { |
|
1202 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1203 | - $field->set_timezone( $timezone ); |
|
1201 | + foreach ($this->_fields as $field) { |
|
1202 | + if ($field instanceof EE_Datetime_Field) { |
|
1203 | + $field->set_timezone($timezone); |
|
1204 | 1204 | } |
1205 | 1205 | } |
1206 | 1206 | } |
@@ -1215,9 +1215,9 @@ discard block |
||
1215 | 1215 | */ |
1216 | 1216 | public function get_timezone() { |
1217 | 1217 | //first validate if timezone is set. If not, then let's set it be whatever is set on the model fields. |
1218 | - if ( empty( $this->_timezone ) ) { |
|
1219 | - foreach( $this->_fields as $field ) { |
|
1220 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1218 | + if (empty($this->_timezone)) { |
|
1219 | + foreach ($this->_fields as $field) { |
|
1220 | + if ($field instanceof EE_Datetime_Field) { |
|
1221 | 1221 | $this->set_timezone($field->get_timezone()); |
1222 | 1222 | break; |
1223 | 1223 | } |
@@ -1225,8 +1225,8 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | //if timezone STILL empty then return the default timezone for the site. |
1228 | - if ( empty( $this->_timezone ) ) { |
|
1229 | - $this->set_timezone( EEH_DTT_Helper::get_timezone() ); |
|
1228 | + if (empty($this->_timezone)) { |
|
1229 | + $this->set_timezone(EEH_DTT_Helper::get_timezone()); |
|
1230 | 1230 | } |
1231 | 1231 | return $this->_timezone; |
1232 | 1232 | } |
@@ -1244,19 +1244,19 @@ discard block |
||
1244 | 1244 | * |
1245 | 1245 | * @return array formats in an array with the date format first, and the time format last. |
1246 | 1246 | */ |
1247 | - public function get_formats_for( $field_name, $pretty = false ) { |
|
1248 | - $field_settings = $this->field_settings_for( $field_name ); |
|
1247 | + public function get_formats_for($field_name, $pretty = false) { |
|
1248 | + $field_settings = $this->field_settings_for($field_name); |
|
1249 | 1249 | |
1250 | 1250 | //if not a valid EE_Datetime_Field then throw error |
1251 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
1252 | - throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) ); |
|
1251 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
1252 | + throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name)); |
|
1253 | 1253 | } |
1254 | 1254 | |
1255 | 1255 | //while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on |
1256 | 1256 | //the field. |
1257 | 1257 | $this->_timezone = $field_settings->get_timezone(); |
1258 | 1258 | |
1259 | - return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) ); |
|
1259 | + return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty)); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
@@ -1280,25 +1280,25 @@ discard block |
||
1280 | 1280 | * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
1281 | 1281 | * exception is triggered. |
1282 | 1282 | */ |
1283 | - public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
|
1284 | - $formats = $this->get_formats_for( $field_name ); |
|
1283 | + public function current_time_for_query($field_name, $timestamp = false, $what = 'both') { |
|
1284 | + $formats = $this->get_formats_for($field_name); |
|
1285 | 1285 | |
1286 | - $DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) ); |
|
1286 | + $DateTime = new DateTime("now", new DateTimeZone($this->_timezone)); |
|
1287 | 1287 | |
1288 | - if ( $timestamp ) { |
|
1289 | - return $DateTime->format( 'U' ); |
|
1288 | + if ($timestamp) { |
|
1289 | + return $DateTime->format('U'); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | //not returning timestamp, so return formatted string in timezone. |
1293 | - switch( $what ) { |
|
1293 | + switch ($what) { |
|
1294 | 1294 | case 'time' : |
1295 | - return $DateTime->format( $formats[1] ); |
|
1295 | + return $DateTime->format($formats[1]); |
|
1296 | 1296 | break; |
1297 | 1297 | case 'date' : |
1298 | - return $DateTime->format( $formats[0] ); |
|
1298 | + return $DateTime->format($formats[0]); |
|
1299 | 1299 | break; |
1300 | 1300 | default : |
1301 | - return $DateTime->format( implode( ' ', $formats ) ); |
|
1301 | + return $DateTime->format(implode(' ', $formats)); |
|
1302 | 1302 | break; |
1303 | 1303 | } |
1304 | 1304 | } |
@@ -1320,17 +1320,17 @@ discard block |
||
1320 | 1320 | * @return DateTime |
1321 | 1321 | * @throws \EE_Error |
1322 | 1322 | */ |
1323 | - public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) { |
|
1323 | + public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') { |
|
1324 | 1324 | |
1325 | 1325 | //just using this to ensure the timezone is set correctly internally |
1326 | - $this->get_formats_for( $field_name ); |
|
1326 | + $this->get_formats_for($field_name); |
|
1327 | 1327 | |
1328 | 1328 | //load EEH_DTT_Helper |
1329 | - $set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1329 | + $set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1330 | 1330 | |
1331 | - $incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) ); |
|
1331 | + $incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone)); |
|
1332 | 1332 | |
1333 | - return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
1333 | + return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone)); |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects |
1341 | 1341 | * @return EE_Table_Base[] |
1342 | 1342 | */ |
1343 | - public function get_tables(){ |
|
1343 | + public function get_tables() { |
|
1344 | 1344 | return $this->_tables; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1376,9 +1376,9 @@ discard block |
||
1376 | 1376 | * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad) |
1377 | 1377 | * @throws \EE_Error |
1378 | 1378 | */ |
1379 | - public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){ |
|
1380 | - if( ! is_array( $query_params ) ){ |
|
1381 | - EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1379 | + public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
1380 | + if ( ! is_array($query_params)) { |
|
1381 | + EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1382 | 1382 | $query_params = array(); |
1383 | 1383 | } |
1384 | 1384 | /** |
@@ -1388,7 +1388,7 @@ discard block |
||
1388 | 1388 | * @param array $fields_n_values the updated fields and their new values |
1389 | 1389 | * @param array $query_params @see EEM_Base::get_all() |
1390 | 1390 | */ |
1391 | - do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params ); |
|
1391 | + do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params); |
|
1392 | 1392 | /** |
1393 | 1393 | * Filters the fields about to be updated given the query parameters. You can provide the |
1394 | 1394 | * $query_params to $this->get_all() to find exactly which records will be updated |
@@ -1396,10 +1396,10 @@ discard block |
||
1396 | 1396 | * @param EEM_Base $model the model being queried |
1397 | 1397 | * @param array $query_params see EEM_Base::get_all() |
1398 | 1398 | */ |
1399 | - $fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params ); |
|
1399 | + $fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params); |
|
1400 | 1400 | //need to verify that, for any entry we want to update, there are entries in each secondary table. |
1401 | 1401 | //to do that, for each table, verify that it's PK isn't null. |
1402 | - $tables= $this->get_tables(); |
|
1402 | + $tables = $this->get_tables(); |
|
1403 | 1403 | |
1404 | 1404 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1405 | 1405 | //NOTE: we should make this code more efficient by NOT querying twice |
@@ -1409,29 +1409,29 @@ discard block |
||
1409 | 1409 | //we want to make sure the default_where strategy is ignored |
1410 | 1410 | $this->_ignore_where_strategy = TRUE; |
1411 | 1411 | $wpdb_select_results = $this->_get_all_wpdb_results($query_params); |
1412 | - foreach( $wpdb_select_results as $wpdb_result ){ |
|
1412 | + foreach ($wpdb_select_results as $wpdb_result) { |
|
1413 | 1413 | // type cast stdClass as array |
1414 | - $wpdb_result = (array)$wpdb_result; |
|
1414 | + $wpdb_result = (array) $wpdb_result; |
|
1415 | 1415 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
1416 | - if( $this->has_primary_key_field() ){ |
|
1417 | - $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1418 | - }else{ |
|
1416 | + if ($this->has_primary_key_field()) { |
|
1417 | + $main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()]; |
|
1418 | + } else { |
|
1419 | 1419 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
1420 | 1420 | $main_table_pk_value = null; |
1421 | 1421 | } |
1422 | 1422 | //if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables |
1423 | 1423 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1424 | - if(count($tables) > 1){ |
|
1424 | + if (count($tables) > 1) { |
|
1425 | 1425 | //foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry |
1426 | 1426 | //in that table, and so we'll want to insert one |
1427 | - foreach($tables as $table_obj){ |
|
1427 | + foreach ($tables as $table_obj) { |
|
1428 | 1428 | $this_table_pk_column = $table_obj->get_fully_qualified_pk_column(); |
1429 | 1429 | //if there is no private key for this table on the results, it means there's no entry |
1430 | 1430 | //in this table, right? so insert a row in the current table, using any fields available |
1431 | - if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){ |
|
1431 | + if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) { |
|
1432 | 1432 | $success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value); |
1433 | 1433 | //if we died here, report the error |
1434 | - if( ! $success ) { |
|
1434 | + if ( ! $success) { |
|
1435 | 1435 | return false; |
1436 | 1436 | } |
1437 | 1437 | } |
@@ -1451,44 +1451,44 @@ discard block |
||
1451 | 1451 | //if this wasn't called from a model object (to update itself) |
1452 | 1452 | //then we want to make sure we keep all the existing |
1453 | 1453 | //model objects in sync with the db |
1454 | - if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
|
1455 | - if( $this->has_primary_key_field() ){ |
|
1456 | - $model_objs_affected_ids = $this->get_col( $query_params ); |
|
1457 | - }else{ |
|
1454 | + if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) { |
|
1455 | + if ($this->has_primary_key_field()) { |
|
1456 | + $model_objs_affected_ids = $this->get_col($query_params); |
|
1457 | + } else { |
|
1458 | 1458 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
1459 | - $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
|
1459 | + $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A); |
|
1460 | 1460 | $model_objs_affected_ids = array(); |
1461 | - foreach( $models_affected_key_columns as $row ){ |
|
1462 | - $combined_index_key = $this->get_index_primary_key_string( $row ); |
|
1463 | - $model_objs_affected_ids[ $combined_index_key ] = $combined_index_key; |
|
1461 | + foreach ($models_affected_key_columns as $row) { |
|
1462 | + $combined_index_key = $this->get_index_primary_key_string($row); |
|
1463 | + $model_objs_affected_ids[$combined_index_key] = $combined_index_key; |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if( ! $model_objs_affected_ids ){ |
|
1468 | + if ( ! $model_objs_affected_ids) { |
|
1469 | 1469 | //wait wait wait- if nothing was affected let's stop here |
1470 | 1470 | return 0; |
1471 | 1471 | } |
1472 | - foreach( $model_objs_affected_ids as $id ){ |
|
1473 | - $model_obj_in_entity_map = $this->get_from_entity_map( $id ); |
|
1474 | - if( $model_obj_in_entity_map ){ |
|
1475 | - foreach( $fields_n_values as $field => $new_value ){ |
|
1476 | - $model_obj_in_entity_map->set( $field, $new_value ); |
|
1472 | + foreach ($model_objs_affected_ids as $id) { |
|
1473 | + $model_obj_in_entity_map = $this->get_from_entity_map($id); |
|
1474 | + if ($model_obj_in_entity_map) { |
|
1475 | + foreach ($fields_n_values as $field => $new_value) { |
|
1476 | + $model_obj_in_entity_map->set($field, $new_value); |
|
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | } |
1480 | 1480 | //if there is a primary key on this model, we can now do a slight optimization |
1481 | - if( $this->has_primary_key_field() ){ |
|
1481 | + if ($this->has_primary_key_field()) { |
|
1482 | 1482 | //we already know what we want to update. So let's make the query simpler so it's a little more efficient |
1483 | 1483 | $query_params = array( |
1484 | - array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ), |
|
1485 | - 'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' ); |
|
1484 | + array($this->primary_key_name() => array('IN', $model_objs_affected_ids)), |
|
1485 | + 'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' ); |
|
1486 | 1486 | } |
1487 | 1487 | } |
1488 | 1488 | |
1489 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
1490 | - $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1491 | - $rows_affected = $this->_do_wpdb_query('query', array( $SQL ) ); |
|
1489 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
1490 | + $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1491 | + $rows_affected = $this->_do_wpdb_query('query', array($SQL)); |
|
1492 | 1492 | /** |
1493 | 1493 | * Action called after a model update call has been made. |
1494 | 1494 | * |
@@ -1497,8 +1497,8 @@ discard block |
||
1497 | 1497 | * @param array $query_params @see EEM_Base::get_all() |
1498 | 1498 | * @param int $rows_affected |
1499 | 1499 | */ |
1500 | - do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected ); |
|
1501 | - return $rows_affected;//how many supposedly got updated |
|
1500 | + do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected); |
|
1501 | + return $rows_affected; //how many supposedly got updated |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | |
@@ -1514,22 +1514,22 @@ discard block |
||
1514 | 1514 | * @return array just like $wpdb->get_col() |
1515 | 1515 | * @throws \EE_Error |
1516 | 1516 | */ |
1517 | - public function get_col( $query_params = array(), $field_to_select = NULL ){ |
|
1517 | + public function get_col($query_params = array(), $field_to_select = NULL) { |
|
1518 | 1518 | |
1519 | - if( $field_to_select ){ |
|
1520 | - $field = $this->field_settings_for( $field_to_select ); |
|
1521 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
1519 | + if ($field_to_select) { |
|
1520 | + $field = $this->field_settings_for($field_to_select); |
|
1521 | + }elseif ($this->has_primary_key_field( )) { |
|
1522 | 1522 | $field = $this->get_primary_key_field(); |
1523 | - }else{ |
|
1523 | + } else { |
|
1524 | 1524 | //no primary key, just grab the first column |
1525 | - $field = reset( $this->field_settings()); |
|
1525 | + $field = reset($this->field_settings()); |
|
1526 | 1526 | } |
1527 | 1527 | |
1528 | 1528 | |
1529 | 1529 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1530 | 1530 | $select_expressions = $field->get_qualified_column(); |
1531 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1532 | - return $this->_do_wpdb_query('get_col', array( $SQL ) ); |
|
1531 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1532 | + return $this->_do_wpdb_query('get_col', array($SQL)); |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | |
@@ -1542,12 +1542,12 @@ discard block |
||
1542 | 1542 | * @return string |
1543 | 1543 | * @throws \EE_Error |
1544 | 1544 | */ |
1545 | - public function get_var( $query_params = array(), $field_to_select = NULL ) { |
|
1546 | - $query_params[ 'limit' ] = 1; |
|
1547 | - $col = $this->get_col( $query_params, $field_to_select ); |
|
1548 | - if( ! empty( $col ) ) { |
|
1549 | - return reset( $col ); |
|
1550 | - }else{ |
|
1545 | + public function get_var($query_params = array(), $field_to_select = NULL) { |
|
1546 | + $query_params['limit'] = 1; |
|
1547 | + $col = $this->get_col($query_params, $field_to_select); |
|
1548 | + if ( ! empty($col)) { |
|
1549 | + return reset($col); |
|
1550 | + } else { |
|
1551 | 1551 | return NULL; |
1552 | 1552 | } |
1553 | 1553 | } |
@@ -1563,19 +1563,19 @@ discard block |
||
1563 | 1563 | * @return string of SQL |
1564 | 1564 | * @throws \EE_Error |
1565 | 1565 | */ |
1566 | - public function _construct_update_sql($fields_n_values){ |
|
1566 | + public function _construct_update_sql($fields_n_values) { |
|
1567 | 1567 | /** @type WPDB $wpdb */ |
1568 | 1568 | global $wpdb; |
1569 | 1569 | $cols_n_values = array(); |
1570 | - foreach($fields_n_values as $field_name => $value){ |
|
1570 | + foreach ($fields_n_values as $field_name => $value) { |
|
1571 | 1571 | $field_obj = $this->field_settings_for($field_name); |
1572 | 1572 | //if the value is NULL, we want to assign the value to that. |
1573 | 1573 | //wpdb->prepare doesn't really handle that properly |
1574 | - $prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values ); |
|
1575 | - $value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value ); |
|
1574 | + $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
|
1575 | + $value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value); |
|
1576 | 1576 | $cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql; |
1577 | 1577 | } |
1578 | - return implode(",",$cols_n_values); |
|
1578 | + return implode(",", $cols_n_values); |
|
1579 | 1579 | |
1580 | 1580 | } |
1581 | 1581 | |
@@ -1591,10 +1591,10 @@ discard block |
||
1591 | 1591 | * @return boolean whether the row got deleted or not |
1592 | 1592 | * @throws \EE_Error |
1593 | 1593 | */ |
1594 | - public function delete_permanently_by_ID( $id ) { |
|
1594 | + public function delete_permanently_by_ID($id) { |
|
1595 | 1595 | return $this->delete_permanently( |
1596 | 1596 | array( |
1597 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
1597 | + array($this->get_primary_key_field()->get_name() => $id), |
|
1598 | 1598 | 'limit' => 1 |
1599 | 1599 | ) |
1600 | 1600 | ); |
@@ -1610,10 +1610,10 @@ discard block |
||
1610 | 1610 | * @return boolean whether the row got deleted or not |
1611 | 1611 | * @throws \EE_Error |
1612 | 1612 | */ |
1613 | - public function delete_by_ID( $id ){ |
|
1613 | + public function delete_by_ID($id) { |
|
1614 | 1614 | return $this->delete( |
1615 | 1615 | array( |
1616 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
1616 | + array($this->get_primary_key_field()->get_name() => $id), |
|
1617 | 1617 | 'limit' => 1 |
1618 | 1618 | ) |
1619 | 1619 | ); |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | * @return int how many rows got deleted |
1633 | 1633 | * @throws \EE_Error |
1634 | 1634 | */ |
1635 | - public function delete($query_params,$allow_blocking = true){ |
|
1635 | + public function delete($query_params, $allow_blocking = true) { |
|
1636 | 1636 | return $this->delete_permanently($query_params, $allow_blocking); |
1637 | 1637 | } |
1638 | 1638 | |
@@ -1650,7 +1650,7 @@ discard block |
||
1650 | 1650 | * @return int how many rows got deleted |
1651 | 1651 | * @throws \EE_Error |
1652 | 1652 | */ |
1653 | - public function delete_permanently($query_params,$allow_blocking = true){ |
|
1653 | + public function delete_permanently($query_params, $allow_blocking = true) { |
|
1654 | 1654 | /** |
1655 | 1655 | * Action called just before performing a real deletion query. You can use the |
1656 | 1656 | * model and its $query_params to find exactly which items will be deleted |
@@ -1659,31 +1659,31 @@ discard block |
||
1659 | 1659 | * @param boolean $allow_blocking whether or not to allow related model objects |
1660 | 1660 | * to block (prevent) this deletion |
1661 | 1661 | */ |
1662 | - do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking ); |
|
1662 | + do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking); |
|
1663 | 1663 | //some MySQL databases may be running safe mode, which may restrict |
1664 | 1664 | //deletion if there is no KEY column used in the WHERE statement of a deletion. |
1665 | 1665 | //to get around this, we first do a SELECT, get all the IDs, and then run another query |
1666 | 1666 | //to delete them |
1667 | 1667 | $items_for_deletion = $this->_get_all_wpdb_results($query_params); |
1668 | - $deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking); |
|
1669 | - if($deletion_where){ |
|
1668 | + $deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking); |
|
1669 | + if ($deletion_where) { |
|
1670 | 1670 | //echo "objects for deletion:";var_dump($objects_for_deletion); |
1671 | 1671 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1672 | - $table_aliases = array_keys( $this->_tables ); |
|
1673 | - $SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1672 | + $table_aliases = array_keys($this->_tables); |
|
1673 | + $SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1674 | 1674 | |
1675 | 1675 | // /echo "delete sql:$SQL"; |
1676 | - $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
|
1677 | - }else{ |
|
1676 | + $rows_deleted = $this->_do_wpdb_query('query', array($SQL)); |
|
1677 | + } else { |
|
1678 | 1678 | $rows_deleted = 0; |
1679 | 1679 | } |
1680 | 1680 | |
1681 | 1681 | //and lastly make sure those items are removed from the entity map; if they could be put into it at all |
1682 | - if( $this->has_primary_key_field() ){ |
|
1683 | - foreach($items_for_deletion as $item_for_deletion_row ){ |
|
1684 | - $pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1685 | - if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){ |
|
1686 | - unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ); |
|
1682 | + if ($this->has_primary_key_field()) { |
|
1683 | + foreach ($items_for_deletion as $item_for_deletion_row) { |
|
1684 | + $pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()]; |
|
1685 | + if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) { |
|
1686 | + unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]); |
|
1687 | 1687 | } |
1688 | 1688 | } |
1689 | 1689 | } |
@@ -1695,8 +1695,8 @@ discard block |
||
1695 | 1695 | * @param array $query_params @see EEM_Base::get_all() |
1696 | 1696 | * @param int $rows_deleted |
1697 | 1697 | */ |
1698 | - do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted ); |
|
1699 | - return $rows_deleted;//how many supposedly got deleted |
|
1698 | + do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted); |
|
1699 | + return $rows_deleted; //how many supposedly got deleted |
|
1700 | 1700 | } |
1701 | 1701 | |
1702 | 1702 | |
@@ -1714,28 +1714,28 @@ discard block |
||
1714 | 1714 | * @return boolean |
1715 | 1715 | * @throws \EE_Error |
1716 | 1716 | */ |
1717 | - public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){ |
|
1717 | + public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) { |
|
1718 | 1718 | //first, if $ignore_this_model_obj was supplied, get its model |
1719 | - if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
|
1719 | + if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) { |
|
1720 | 1720 | $ignored_model = $ignore_this_model_obj->get_model(); |
1721 | - }else{ |
|
1721 | + } else { |
|
1722 | 1722 | $ignored_model = null; |
1723 | 1723 | } |
1724 | 1724 | //now check all the relations of $this_model_obj_or_id and see if there |
1725 | 1725 | //are any related model objects blocking it? |
1726 | 1726 | $is_blocked = false; |
1727 | - foreach($this->_model_relations as $relation_name => $relation_obj){ |
|
1728 | - if( $relation_obj->block_delete_if_related_models_exist()){ |
|
1727 | + foreach ($this->_model_relations as $relation_name => $relation_obj) { |
|
1728 | + if ($relation_obj->block_delete_if_related_models_exist()) { |
|
1729 | 1729 | //if $ignore_this_model_obj was supplied, then for the query |
1730 | 1730 | //on that model needs to be told to ignore $ignore_this_model_obj |
1731 | - if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){ |
|
1732 | - $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
|
1733 | - array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
|
1734 | - }else{ |
|
1731 | + if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) { |
|
1732 | + $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array( |
|
1733 | + array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID())))); |
|
1734 | + } else { |
|
1735 | 1735 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
1736 | 1736 | } |
1737 | 1737 | |
1738 | - if($related_model_objects){ |
|
1738 | + if ($related_model_objects) { |
|
1739 | 1739 | EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__); |
1740 | 1740 | $is_blocked = true; |
1741 | 1741 | } |
@@ -1755,75 +1755,75 @@ discard block |
||
1755 | 1755 | * @throws EE_Error |
1756 | 1756 | * @return string everything that comes after the WHERE statement. |
1757 | 1757 | */ |
1758 | - protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) { |
|
1759 | - if($this->has_primary_key_field()){ |
|
1758 | + protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) { |
|
1759 | + if ($this->has_primary_key_field()) { |
|
1760 | 1760 | $primary_table = $this->_get_main_table(); |
1761 | 1761 | $other_tables = $this->_get_other_tables(); |
1762 | 1762 | $deletes = $query = array(); |
1763 | - foreach ( $objects_for_deletion as $delete_object ) { |
|
1763 | + foreach ($objects_for_deletion as $delete_object) { |
|
1764 | 1764 | //before we mark this object for deletion, |
1765 | 1765 | //make sure there's no related objects blocking its deletion (if we're checking) |
1766 | 1766 | if ( |
1767 | 1767 | $allow_blocking |
1768 | 1768 | && $this->delete_is_blocked_by_related_models( |
1769 | - $delete_object[ $primary_table->get_fully_qualified_pk_column() ] |
|
1769 | + $delete_object[$primary_table->get_fully_qualified_pk_column()] |
|
1770 | 1770 | ) |
1771 | 1771 | ) { |
1772 | 1772 | continue; |
1773 | 1773 | } |
1774 | 1774 | //primary table deletes |
1775 | - if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) { |
|
1776 | - $deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ]; |
|
1775 | + if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) { |
|
1776 | + $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
|
1777 | 1777 | } |
1778 | 1778 | //other tables |
1779 | - if ( ! empty( $other_tables ) ) { |
|
1780 | - foreach ( $other_tables as $ot ) { |
|
1779 | + if ( ! empty($other_tables)) { |
|
1780 | + foreach ($other_tables as $ot) { |
|
1781 | 1781 | //first check if we've got the foreign key column here. |
1782 | - if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) { |
|
1783 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ]; |
|
1782 | + if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) { |
|
1783 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
|
1784 | 1784 | } |
1785 | 1785 | // wait! it's entirely possible that we'll have a the primary key |
1786 | 1786 | // for this table in here, if it's a foreign key for one of the other secondary tables |
1787 | - if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) { |
|
1788 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ]; |
|
1787 | + if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) { |
|
1788 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1789 | 1789 | } |
1790 | 1790 | // finally, it is possible that the fk for this table is found |
1791 | 1791 | // in the fully qualified pk column for the fk table, so let's see if that's there! |
1792 | - if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) { |
|
1793 | - $deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ]; |
|
1792 | + if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) { |
|
1793 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1794 | 1794 | } |
1795 | 1795 | } |
1796 | 1796 | } |
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | //we should have deletes now, so let's just go through and setup the where statement |
1800 | - foreach ( $deletes as $column => $values ) { |
|
1800 | + foreach ($deletes as $column => $values) { |
|
1801 | 1801 | //make sure we have unique $values; |
1802 | 1802 | $values = array_unique($values); |
1803 | - $query[] = $column . ' IN(' . implode(",",$values) . ')'; |
|
1803 | + $query[] = $column.' IN('.implode(",", $values).')'; |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | - return !empty($query) ? implode(' AND ', $query ) : ''; |
|
1807 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1806 | + return ! empty($query) ? implode(' AND ', $query) : ''; |
|
1807 | + }elseif (count($this->get_combined_primary_key_fields()) > 1) { |
|
1808 | 1808 | $ways_to_identify_a_row = array(); |
1809 | 1809 | $fields = $this->get_combined_primary_key_fields(); |
1810 | 1810 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
1811 | - foreach($objects_for_deletion as $delete_object){ |
|
1811 | + foreach ($objects_for_deletion as $delete_object) { |
|
1812 | 1812 | $values_for_each_cpk_for_a_row = array(); |
1813 | - foreach($fields as $cpk_field){ |
|
1814 | - if ( $cpk_field instanceof EE_Model_Field_Base ){ |
|
1813 | + foreach ($fields as $cpk_field) { |
|
1814 | + if ($cpk_field instanceof EE_Model_Field_Base) { |
|
1815 | 1815 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column() |
1816 | 1816 | . "=" |
1817 | - . $delete_object[ $cpk_field->get_qualified_column() ]; |
|
1817 | + . $delete_object[$cpk_field->get_qualified_column()]; |
|
1818 | 1818 | } |
1819 | 1819 | } |
1820 | - $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
|
1820 | + $ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")"; |
|
1821 | 1821 | } |
1822 | - return implode(" OR ",$ways_to_identify_a_row); |
|
1823 | - }else{ |
|
1822 | + return implode(" OR ", $ways_to_identify_a_row); |
|
1823 | + } else { |
|
1824 | 1824 | //so there's no primary key and no combined key... |
1825 | 1825 | //sorry, can't help you |
1826 | - throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
|
1826 | + throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this))); |
|
1827 | 1827 | } |
1828 | 1828 | } |
1829 | 1829 | |
@@ -1839,21 +1839,21 @@ discard block |
||
1839 | 1839 | * @return int |
1840 | 1840 | * @throws \EE_Error |
1841 | 1841 | */ |
1842 | - public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1842 | + public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1843 | 1843 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1844 | - if($field_to_count){ |
|
1844 | + if ($field_to_count) { |
|
1845 | 1845 | $field_obj = $this->field_settings_for($field_to_count); |
1846 | 1846 | $column_to_count = $field_obj->get_qualified_column(); |
1847 | - }elseif($this->has_primary_key_field ()){ |
|
1847 | + }elseif ($this->has_primary_key_field()) { |
|
1848 | 1848 | $pk_field_obj = $this->get_primary_key_field(); |
1849 | 1849 | $column_to_count = $pk_field_obj->get_qualified_column(); |
1850 | - }else{//there's no primary key |
|
1850 | + } else {//there's no primary key |
|
1851 | 1851 | $column_to_count = '*'; |
1852 | 1852 | } |
1853 | 1853 | |
1854 | - $column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count; |
|
1855 | - $SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1856 | - return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) ); |
|
1854 | + $column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count; |
|
1855 | + $SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1856 | + return (int) $this->_do_wpdb_query('get_var', array($SQL)); |
|
1857 | 1857 | } |
1858 | 1858 | |
1859 | 1859 | |
@@ -1866,24 +1866,24 @@ discard block |
||
1866 | 1866 | * @return float |
1867 | 1867 | * @throws \EE_Error |
1868 | 1868 | */ |
1869 | - public function sum($query_params, $field_to_sum = NULL){ |
|
1869 | + public function sum($query_params, $field_to_sum = NULL) { |
|
1870 | 1870 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1871 | 1871 | |
1872 | - if($field_to_sum){ |
|
1872 | + if ($field_to_sum) { |
|
1873 | 1873 | $field_obj = $this->field_settings_for($field_to_sum); |
1874 | 1874 | |
1875 | - }else{ |
|
1875 | + } else { |
|
1876 | 1876 | $field_obj = $this->get_primary_key_field(); |
1877 | 1877 | } |
1878 | 1878 | $column_to_count = $field_obj->get_qualified_column(); |
1879 | 1879 | |
1880 | - $SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1881 | - $return_value = $this->_do_wpdb_query('get_var',array( $SQL ) ); |
|
1880 | + $SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1881 | + $return_value = $this->_do_wpdb_query('get_var', array($SQL)); |
|
1882 | 1882 | $data_type = $field_obj->get_wpdb_data_type(); |
1883 | - if( $data_type === '%d' || $data_type === '%s' ){ |
|
1884 | - return (float)$return_value; |
|
1885 | - }else{//must be %f |
|
1886 | - return (float)$return_value; |
|
1883 | + if ($data_type === '%d' || $data_type === '%s') { |
|
1884 | + return (float) $return_value; |
|
1885 | + } else {//must be %f |
|
1886 | + return (float) $return_value; |
|
1887 | 1887 | } |
1888 | 1888 | } |
1889 | 1889 | |
@@ -1898,37 +1898,37 @@ discard block |
||
1898 | 1898 | * @global wpdb $wpdb |
1899 | 1899 | * @return mixed |
1900 | 1900 | */ |
1901 | - protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){ |
|
1901 | + protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1902 | 1902 | //if we're in maintenance mode level 2, DON'T run any queries |
1903 | 1903 | //because level 2 indicates the database needs updating and |
1904 | 1904 | //is probably out of sync with the code |
1905 | - if( ! EE_Maintenance_Mode::instance()->models_can_query()){ |
|
1905 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
1906 | 1906 | throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso"))); |
1907 | 1907 | } |
1908 | 1908 | /** @type WPDB $wpdb */ |
1909 | 1909 | global $wpdb; |
1910 | - if( ! method_exists( $wpdb, $wpdb_method ) ){ |
|
1911 | - throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) ); |
|
1910 | + if ( ! method_exists($wpdb, $wpdb_method)) { |
|
1911 | + throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method)); |
|
1912 | 1912 | } |
1913 | - if( WP_DEBUG ){ |
|
1913 | + if (WP_DEBUG) { |
|
1914 | 1914 | $old_show_errors_value = $wpdb->show_errors; |
1915 | - $wpdb->show_errors( FALSE ); |
|
1916 | - } |
|
1917 | - $result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1918 | - $this->show_db_query_if_previously_requested( $wpdb->last_query ); |
|
1919 | - if( WP_DEBUG ){ |
|
1920 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1921 | - if( ! empty( $wpdb->last_error ) ){ |
|
1922 | - throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
|
1923 | - }elseif( $result === false ){ |
|
1924 | - throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
|
1915 | + $wpdb->show_errors(FALSE); |
|
1916 | + } |
|
1917 | + $result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1918 | + $this->show_db_query_if_previously_requested($wpdb->last_query); |
|
1919 | + if (WP_DEBUG) { |
|
1920 | + $wpdb->show_errors($old_show_errors_value); |
|
1921 | + if ( ! empty($wpdb->last_error)) { |
|
1922 | + throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error)); |
|
1923 | + }elseif ($result === false) { |
|
1924 | + throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true))); |
|
1925 | 1925 | } |
1926 | - }elseif( $result === false ) { |
|
1926 | + }elseif ($result === false) { |
|
1927 | 1927 | EE_Error::add_error( |
1928 | 1928 | sprintf( |
1929 | - __( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ), |
|
1929 | + __('A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso'), |
|
1930 | 1930 | $wpdb_method, |
1931 | - var_export( $arguments_to_provide, true ), |
|
1931 | + var_export($arguments_to_provide, true), |
|
1932 | 1932 | $wpdb->last_error |
1933 | 1933 | ), |
1934 | 1934 | __FILE__, |
@@ -1950,26 +1950,26 @@ discard block |
||
1950 | 1950 | * @param array $arguments_to_provide |
1951 | 1951 | * @return mixed |
1952 | 1952 | */ |
1953 | - private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) { |
|
1953 | + private function _process_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1954 | 1954 | /** @type WPDB $wpdb */ |
1955 | 1955 | global $wpdb; |
1956 | 1956 | $wpdb->last_error = null; |
1957 | - $result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide ); |
|
1957 | + $result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide); |
|
1958 | 1958 | // was there an error running the query? but we don't care on new activations |
1959 | 1959 | // (we're going to setup the DB anyway on new activations) |
1960 | - if ( ( $result === false || ! empty( $wpdb->last_error ) ) |
|
1960 | + if (($result === false || ! empty($wpdb->last_error)) |
|
1961 | 1961 | && EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation |
1962 | 1962 | ) { |
1963 | - switch ( EEM_Base::$_db_verification_level ) { |
|
1963 | + switch (EEM_Base::$_db_verification_level) { |
|
1964 | 1964 | |
1965 | 1965 | case EEM_Base::db_verified_none : |
1966 | 1966 | // let's double-check core's DB |
1967 | - $error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide ); |
|
1967 | + $error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide); |
|
1968 | 1968 | break; |
1969 | 1969 | |
1970 | 1970 | case EEM_Base::db_verified_core : |
1971 | 1971 | // STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed |
1972 | - $error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide ); |
|
1972 | + $error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide); |
|
1973 | 1973 | break; |
1974 | 1974 | |
1975 | 1975 | case EEM_Base::db_verified_addons : |
@@ -1977,11 +1977,11 @@ discard block |
||
1977 | 1977 | return $result; |
1978 | 1978 | break; |
1979 | 1979 | } |
1980 | - if ( ! empty( $error_message ) ) { |
|
1981 | - EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' ); |
|
1982 | - trigger_error( $error_message ); |
|
1980 | + if ( ! empty($error_message)) { |
|
1981 | + EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error'); |
|
1982 | + trigger_error($error_message); |
|
1983 | 1983 | } |
1984 | - return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1984 | + return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1985 | 1985 | |
1986 | 1986 | } |
1987 | 1987 | |
@@ -1997,18 +1997,18 @@ discard block |
||
1997 | 1997 | * @param array $arguments_to_provide |
1998 | 1998 | * @return string |
1999 | 1999 | */ |
2000 | - private function _verify_core_db( $wpdb_method, $arguments_to_provide ){ |
|
2000 | + private function _verify_core_db($wpdb_method, $arguments_to_provide) { |
|
2001 | 2001 | /** @type WPDB $wpdb */ |
2002 | 2002 | global $wpdb; |
2003 | 2003 | //ok remember that we've already attempted fixing the core db, in case the problem persists |
2004 | 2004 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_core; |
2005 | 2005 | $error_message = sprintf( |
2006 | - __( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ), |
|
2006 | + __('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'), |
|
2007 | 2007 | $wpdb->last_error, |
2008 | 2008 | $wpdb_method, |
2009 | - json_encode( $arguments_to_provide ) |
|
2009 | + json_encode($arguments_to_provide) |
|
2010 | 2010 | ); |
2011 | - EE_System::instance()->initialize_db_if_no_migrations_required( false, true ); |
|
2011 | + EE_System::instance()->initialize_db_if_no_migrations_required(false, true); |
|
2012 | 2012 | return $error_message; |
2013 | 2013 | } |
2014 | 2014 | |
@@ -2021,16 +2021,16 @@ discard block |
||
2021 | 2021 | * @param $arguments_to_provide |
2022 | 2022 | * @return string |
2023 | 2023 | */ |
2024 | - private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) { |
|
2024 | + private function _verify_addons_db($wpdb_method, $arguments_to_provide) { |
|
2025 | 2025 | /** @type WPDB $wpdb */ |
2026 | 2026 | global $wpdb; |
2027 | 2027 | //ok remember that we've already attempted fixing the addons dbs, in case the problem persists |
2028 | 2028 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons; |
2029 | 2029 | $error_message = sprintf( |
2030 | - __( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ), |
|
2030 | + __('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'), |
|
2031 | 2031 | $wpdb->last_error, |
2032 | 2032 | $wpdb_method, |
2033 | - json_encode( $arguments_to_provide ) |
|
2033 | + json_encode($arguments_to_provide) |
|
2034 | 2034 | ); |
2035 | 2035 | EE_System::instance()->initialize_addons(); |
2036 | 2036 | return $error_message; |
@@ -2045,7 +2045,7 @@ discard block |
||
2045 | 2045 | * @param EE_Model_Query_Info_Carrier $model_query_info |
2046 | 2046 | * @return string |
2047 | 2047 | */ |
2048 | - private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){ |
|
2048 | + private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) { |
|
2049 | 2049 | return " FROM ".$model_query_info->get_full_join_sql(). |
2050 | 2050 | $model_query_info->get_where_sql(). |
2051 | 2051 | $model_query_info->get_group_by_sql(). |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | * Set to easily debug the next X queries ran from this model. |
2059 | 2059 | * @param int $count |
2060 | 2060 | */ |
2061 | - public function show_next_x_db_queries($count = 1){ |
|
2061 | + public function show_next_x_db_queries($count = 1) { |
|
2062 | 2062 | $this->_show_next_x_db_queries = $count; |
2063 | 2063 | } |
2064 | 2064 | |
@@ -2067,8 +2067,8 @@ discard block |
||
2067 | 2067 | /** |
2068 | 2068 | * @param $sql_query |
2069 | 2069 | */ |
2070 | - public function show_db_query_if_previously_requested($sql_query){ |
|
2071 | - if($this->_show_next_x_db_queries > 0){ |
|
2070 | + public function show_db_query_if_previously_requested($sql_query) { |
|
2071 | + if ($this->_show_next_x_db_queries > 0) { |
|
2072 | 2072 | echo $sql_query; |
2073 | 2073 | $this->_show_next_x_db_queries--; |
2074 | 2074 | } |
@@ -2092,9 +2092,9 @@ discard block |
||
2092 | 2092 | * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj |
2093 | 2093 | * @throws \EE_Error |
2094 | 2094 | */ |
2095 | - public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){ |
|
2095 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) { |
|
2096 | 2096 | $relation_obj = $this->related_settings_for($relationName); |
2097 | - return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
2097 | + return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
2098 | 2098 | } |
2099 | 2099 | |
2100 | 2100 | |
@@ -2113,9 +2113,9 @@ discard block |
||
2113 | 2113 | * @throws \EE_Error |
2114 | 2114 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
2115 | 2115 | */ |
2116 | - public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
|
2116 | + public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) { |
|
2117 | 2117 | $relation_obj = $this->related_settings_for($relationName); |
2118 | - return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query ); |
|
2118 | + return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query); |
|
2119 | 2119 | } |
2120 | 2120 | |
2121 | 2121 | |
@@ -2128,9 +2128,9 @@ discard block |
||
2128 | 2128 | * @return \EE_Base_Class[] |
2129 | 2129 | * @throws \EE_Error |
2130 | 2130 | */ |
2131 | - public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){ |
|
2131 | + public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) { |
|
2132 | 2132 | $relation_obj = $this->related_settings_for($relationName); |
2133 | - return $relation_obj->remove_relations($id_or_obj, $where_query_params ); |
|
2133 | + return $relation_obj->remove_relations($id_or_obj, $where_query_params); |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | |
@@ -2146,10 +2146,10 @@ discard block |
||
2146 | 2146 | * @return EE_Base_Class[] |
2147 | 2147 | * @throws \EE_Error |
2148 | 2148 | */ |
2149 | - public function get_all_related($id_or_obj, $model_name, $query_params = null){ |
|
2149 | + public function get_all_related($id_or_obj, $model_name, $query_params = null) { |
|
2150 | 2150 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2151 | 2151 | $relation_settings = $this->related_settings_for($model_name); |
2152 | - return $relation_settings->get_all_related($model_obj,$query_params); |
|
2152 | + return $relation_settings->get_all_related($model_obj, $query_params); |
|
2153 | 2153 | } |
2154 | 2154 | |
2155 | 2155 | |
@@ -2166,10 +2166,10 @@ discard block |
||
2166 | 2166 | * @return int how many deleted |
2167 | 2167 | * @throws \EE_Error |
2168 | 2168 | */ |
2169 | - public function delete_related($id_or_obj,$model_name, $query_params = array()){ |
|
2169 | + public function delete_related($id_or_obj, $model_name, $query_params = array()) { |
|
2170 | 2170 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2171 | 2171 | $relation_settings = $this->related_settings_for($model_name); |
2172 | - return $relation_settings->delete_all_related($model_obj,$query_params); |
|
2172 | + return $relation_settings->delete_all_related($model_obj, $query_params); |
|
2173 | 2173 | } |
2174 | 2174 | |
2175 | 2175 | |
@@ -2186,10 +2186,10 @@ discard block |
||
2186 | 2186 | * @return int how many deleted |
2187 | 2187 | * @throws \EE_Error |
2188 | 2188 | */ |
2189 | - public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){ |
|
2189 | + public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) { |
|
2190 | 2190 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2191 | 2191 | $relation_settings = $this->related_settings_for($model_name); |
2192 | - return $relation_settings->delete_related_permanently($model_obj,$query_params); |
|
2192 | + return $relation_settings->delete_related_permanently($model_obj, $query_params); |
|
2193 | 2193 | } |
2194 | 2194 | |
2195 | 2195 | |
@@ -2206,17 +2206,17 @@ discard block |
||
2206 | 2206 | * @return int |
2207 | 2207 | * @throws \EE_Error |
2208 | 2208 | */ |
2209 | - public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){ |
|
2209 | + public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) { |
|
2210 | 2210 | $related_model = $this->get_related_model_obj($model_name); |
2211 | 2211 | //we're just going to use the query params on the related model's normal get_all query, |
2212 | 2212 | //except add a condition to say to match the current mod |
2213 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2214 | - $query_params['default_where_conditions']='none'; |
|
2213 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2214 | + $query_params['default_where_conditions'] = 'none'; |
|
2215 | 2215 | } |
2216 | 2216 | $this_model_name = $this->get_this_model_name(); |
2217 | 2217 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2218 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2219 | - return $related_model->count($query_params,$field_to_count,$distinct); |
|
2218 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2219 | + return $related_model->count($query_params, $field_to_count, $distinct); |
|
2220 | 2220 | } |
2221 | 2221 | |
2222 | 2222 | |
@@ -2232,21 +2232,21 @@ discard block |
||
2232 | 2232 | * @return float |
2233 | 2233 | * @throws \EE_Error |
2234 | 2234 | */ |
2235 | - public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){ |
|
2235 | + public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) { |
|
2236 | 2236 | $related_model = $this->get_related_model_obj($model_name); |
2237 | - if( ! is_array( $query_params ) ){ |
|
2238 | - EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
2237 | + if ( ! is_array($query_params)) { |
|
2238 | + EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
2239 | 2239 | $query_params = array(); |
2240 | 2240 | } |
2241 | 2241 | //we're just going to use the query params on the related model's normal get_all query, |
2242 | 2242 | //except add a condition to say to match the current mod |
2243 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2244 | - $query_params['default_where_conditions']='none'; |
|
2243 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2244 | + $query_params['default_where_conditions'] = 'none'; |
|
2245 | 2245 | } |
2246 | 2246 | $this_model_name = $this->get_this_model_name(); |
2247 | 2247 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2248 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2249 | - return $related_model->sum($query_params,$field_to_sum); |
|
2248 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2249 | + return $related_model->sum($query_params, $field_to_sum); |
|
2250 | 2250 | } |
2251 | 2251 | |
2252 | 2252 | |
@@ -2260,12 +2260,12 @@ discard block |
||
2260 | 2260 | * @return EE_Base_Class |
2261 | 2261 | * @throws \EE_Error |
2262 | 2262 | */ |
2263 | - public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){ |
|
2264 | - $query_params['limit']=1; |
|
2265 | - $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
|
2266 | - if( $results ){ |
|
2263 | + public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) { |
|
2264 | + $query_params['limit'] = 1; |
|
2265 | + $results = $this->get_all_related($id_or_obj, $other_model_name, $query_params); |
|
2266 | + if ($results) { |
|
2267 | 2267 | return array_shift($results); |
2268 | - }else{ |
|
2268 | + } else { |
|
2269 | 2269 | return null; |
2270 | 2270 | } |
2271 | 2271 | |
@@ -2275,8 +2275,8 @@ discard block |
||
2275 | 2275 | * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event |
2276 | 2276 | * @return string |
2277 | 2277 | */ |
2278 | - public function get_this_model_name(){ |
|
2279 | - return str_replace("EEM_","",get_class($this)); |
|
2278 | + public function get_this_model_name() { |
|
2279 | + return str_replace("EEM_", "", get_class($this)); |
|
2280 | 2280 | } |
2281 | 2281 | |
2282 | 2282 | /** |
@@ -2284,14 +2284,14 @@ discard block |
||
2284 | 2284 | * @return EE_Any_Foreign_Model_Name_Field |
2285 | 2285 | * @throws EE_Error |
2286 | 2286 | */ |
2287 | - public function get_field_containing_related_model_name(){ |
|
2288 | - foreach($this->field_settings(true) as $field){ |
|
2289 | - if($field instanceof EE_Any_Foreign_Model_Name_Field){ |
|
2287 | + public function get_field_containing_related_model_name() { |
|
2288 | + foreach ($this->field_settings(true) as $field) { |
|
2289 | + if ($field instanceof EE_Any_Foreign_Model_Name_Field) { |
|
2290 | 2290 | $field_with_model_name = $field; |
2291 | 2291 | } |
2292 | 2292 | } |
2293 | - if( !isset($field_with_model_name) || !$field_with_model_name ){ |
|
2294 | - throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() )); |
|
2293 | + if ( ! isset($field_with_model_name) || ! $field_with_model_name) { |
|
2294 | + throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name())); |
|
2295 | 2295 | } |
2296 | 2296 | return $field_with_model_name; |
2297 | 2297 | } |
@@ -2312,19 +2312,19 @@ discard block |
||
2312 | 2312 | * @return int new primary key on main table that got inserted |
2313 | 2313 | * @throws EE_Error |
2314 | 2314 | */ |
2315 | - public function insert($field_n_values){ |
|
2315 | + public function insert($field_n_values) { |
|
2316 | 2316 | /** |
2317 | 2317 | * Filters the fields and their values before inserting an item using the models |
2318 | 2318 | * @param array $fields_n_values keys are the fields and values are their new values |
2319 | 2319 | * @param EEM_Base $model the model used |
2320 | 2320 | */ |
2321 | - $field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this ); |
|
2322 | - if($this->_satisfies_unique_indexes($field_n_values)){ |
|
2321 | + $field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this); |
|
2322 | + if ($this->_satisfies_unique_indexes($field_n_values)) { |
|
2323 | 2323 | $main_table = $this->_get_main_table(); |
2324 | 2324 | $new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false); |
2325 | - if( $new_id !== false ) { |
|
2326 | - foreach($this->_get_other_tables() as $other_table){ |
|
2327 | - $this->_insert_into_specific_table($other_table, $field_n_values,$new_id); |
|
2325 | + if ($new_id !== false) { |
|
2326 | + foreach ($this->_get_other_tables() as $other_table) { |
|
2327 | + $this->_insert_into_specific_table($other_table, $field_n_values, $new_id); |
|
2328 | 2328 | } |
2329 | 2329 | } |
2330 | 2330 | /** |
@@ -2334,9 +2334,9 @@ discard block |
||
2334 | 2334 | * @param array $fields_n_values fields and their values |
2335 | 2335 | * @param int|string the ID of the newly-inserted model object |
2336 | 2336 | */ |
2337 | - do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
|
2337 | + do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id); |
|
2338 | 2338 | return $new_id; |
2339 | - }else{ |
|
2339 | + } else { |
|
2340 | 2340 | return FALSE; |
2341 | 2341 | } |
2342 | 2342 | } |
@@ -2351,10 +2351,10 @@ discard block |
||
2351 | 2351 | * @return boolean |
2352 | 2352 | * @throws \EE_Error |
2353 | 2353 | */ |
2354 | - protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){ |
|
2355 | - foreach($this->unique_indexes() as $index_name => $index){ |
|
2354 | + protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') { |
|
2355 | + foreach ($this->unique_indexes() as $index_name => $index) { |
|
2356 | 2356 | $uniqueness_where_params = array_intersect_key($field_n_values, $index->fields()); |
2357 | - if($this->exists(array($uniqueness_where_params))){ |
|
2357 | + if ($this->exists(array($uniqueness_where_params))) { |
|
2358 | 2358 | EE_Error::add_error( |
2359 | 2359 | sprintf( |
2360 | 2360 | __( |
@@ -2364,8 +2364,8 @@ discard block |
||
2364 | 2364 | $action, |
2365 | 2365 | $this->_get_class_name(), |
2366 | 2366 | $index_name, |
2367 | - implode( ",", $index->field_names() ), |
|
2368 | - http_build_query( $uniqueness_where_params ) |
|
2367 | + implode(",", $index->field_names()), |
|
2368 | + http_build_query($uniqueness_where_params) |
|
2369 | 2369 | ), |
2370 | 2370 | __FILE__, |
2371 | 2371 | __FUNCTION__, |
@@ -2395,37 +2395,37 @@ discard block |
||
2395 | 2395 | * @throws EE_Error |
2396 | 2396 | * @return EE_Base_Class|array |
2397 | 2397 | */ |
2398 | - public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
|
2399 | - if($obj_or_fields_array instanceof EE_Base_Class){ |
|
2398 | + public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) { |
|
2399 | + if ($obj_or_fields_array instanceof EE_Base_Class) { |
|
2400 | 2400 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
2401 | - }elseif( is_array($obj_or_fields_array)){ |
|
2401 | + }elseif (is_array($obj_or_fields_array)) { |
|
2402 | 2402 | $fields_n_values = $obj_or_fields_array; |
2403 | - }else{ |
|
2403 | + } else { |
|
2404 | 2404 | throw new EE_Error( |
2405 | 2405 | sprintf( |
2406 | 2406 | __( |
2407 | 2407 | "%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", |
2408 | 2408 | "event_espresso" |
2409 | 2409 | ), |
2410 | - get_class( $this ), |
|
2410 | + get_class($this), |
|
2411 | 2411 | $obj_or_fields_array |
2412 | 2412 | ) |
2413 | 2413 | ); |
2414 | 2414 | } |
2415 | 2415 | $query_params = array(); |
2416 | - if( $this->has_primary_key_field() && |
|
2417 | - ( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2418 | - isset($fields_n_values[$this->primary_key_name()])){ |
|
2416 | + if ($this->has_primary_key_field() && |
|
2417 | + ($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2418 | + isset($fields_n_values[$this->primary_key_name()])) { |
|
2419 | 2419 | $query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()]; |
2420 | 2420 | } |
2421 | - foreach($this->unique_indexes() as $unique_index_name=>$unique_index){ |
|
2421 | + foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) { |
|
2422 | 2422 | $uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields()); |
2423 | 2423 | $query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params; |
2424 | 2424 | } |
2425 | 2425 | //if there is nothing to base this search on, then we shouldn't find anything |
2426 | - if( empty( $query_params ) ){ |
|
2426 | + if (empty($query_params)) { |
|
2427 | 2427 | return array(); |
2428 | - }else{ |
|
2428 | + } else { |
|
2429 | 2429 | return $this->get_one($query_params); |
2430 | 2430 | } |
2431 | 2431 | } |
@@ -2439,7 +2439,7 @@ discard block |
||
2439 | 2439 | * @return boolean |
2440 | 2440 | * @throws \EE_Error |
2441 | 2441 | */ |
2442 | - public function exists($query_params){ |
|
2442 | + public function exists($query_params) { |
|
2443 | 2443 | $query_params['limit'] = 1; |
2444 | 2444 | return $this->count($query_params) > 0; |
2445 | 2445 | } |
@@ -2453,7 +2453,7 @@ discard block |
||
2453 | 2453 | * @return boolean |
2454 | 2454 | * @throws \EE_Error |
2455 | 2455 | */ |
2456 | - public function exists_by_ID($id){ |
|
2456 | + public function exists_by_ID($id) { |
|
2457 | 2457 | return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id))); |
2458 | 2458 | } |
2459 | 2459 | |
@@ -2473,45 +2473,45 @@ discard block |
||
2473 | 2473 | * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert |
2474 | 2474 | * @return int ID of new row inserted, or FALSE on failure |
2475 | 2475 | */ |
2476 | - protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){ |
|
2476 | + protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) { |
|
2477 | 2477 | global $wpdb; |
2478 | 2478 | $insertion_col_n_values = array(); |
2479 | 2479 | $format_for_insertion = array(); |
2480 | 2480 | $fields_on_table = $this->_get_fields_for_table($table->get_table_alias()); |
2481 | - foreach($fields_on_table as $field_name => $field_obj){ |
|
2481 | + foreach ($fields_on_table as $field_name => $field_obj) { |
|
2482 | 2482 | //check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing |
2483 | - if($field_obj->is_auto_increment()){ |
|
2483 | + if ($field_obj->is_auto_increment()) { |
|
2484 | 2484 | continue; |
2485 | 2485 | } |
2486 | 2486 | $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
2487 | 2487 | //if the value we want to assign it to is NULL, just don't mention it for the insertion |
2488 | - if( $prepared_value !== NULL ){ |
|
2489 | - $insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value; |
|
2488 | + if ($prepared_value !== NULL) { |
|
2489 | + $insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value; |
|
2490 | 2490 | $format_for_insertion[] = $field_obj->get_wpdb_data_type(); |
2491 | 2491 | } |
2492 | 2492 | } |
2493 | 2493 | |
2494 | - if($table instanceof EE_Secondary_Table && $new_id){ |
|
2494 | + if ($table instanceof EE_Secondary_Table && $new_id) { |
|
2495 | 2495 | //its not the main table, so we should have already saved the main table's PK which we just inserted |
2496 | 2496 | //so add the fk to the main table as a column |
2497 | 2497 | $insertion_col_n_values[$table->get_fk_on_table()] = $new_id; |
2498 | - $format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs |
|
2498 | + $format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs |
|
2499 | 2499 | } |
2500 | 2500 | //insert the new entry |
2501 | - $result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) ); |
|
2502 | - if( $result === false ) { |
|
2501 | + $result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion)); |
|
2502 | + if ($result === false) { |
|
2503 | 2503 | return false; |
2504 | 2504 | } |
2505 | 2505 | //ok, now what do we return for the ID of the newly-inserted thing? |
2506 | - if($this->has_primary_key_field()){ |
|
2507 | - if($this->get_primary_key_field()->is_auto_increment()){ |
|
2506 | + if ($this->has_primary_key_field()) { |
|
2507 | + if ($this->get_primary_key_field()->is_auto_increment()) { |
|
2508 | 2508 | return $wpdb->insert_id; |
2509 | - }else{ |
|
2509 | + } else { |
|
2510 | 2510 | //it's not an auto-increment primary key, so |
2511 | 2511 | //it must have been supplied |
2512 | 2512 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
2513 | 2513 | } |
2514 | - }else{ |
|
2514 | + } else { |
|
2515 | 2515 | //we can't return a primary key because there is none. instead return |
2516 | 2516 | //a unique string indicating this model |
2517 | 2517 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2530,15 +2530,15 @@ discard block |
||
2530 | 2530 | * @return mixed string|int|float depending on what the table column will be expecting |
2531 | 2531 | * @throws \EE_Error |
2532 | 2532 | */ |
2533 | - protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){ |
|
2533 | + protected function _prepare_value_or_use_default($field_obj, $fields_n_values) { |
|
2534 | 2534 | //if this field doesn't allow nullable, don't allow it |
2535 | - if( ! $field_obj->is_nullable() && ( |
|
2536 | - ! isset( $fields_n_values[ $field_obj->get_name() ] ) || |
|
2537 | - $fields_n_values[ $field_obj->get_name() ] === NULL ) ){ |
|
2538 | - $fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value(); |
|
2535 | + if ( ! $field_obj->is_nullable() && ( |
|
2536 | + ! isset($fields_n_values[$field_obj->get_name()]) || |
|
2537 | + $fields_n_values[$field_obj->get_name()] === NULL )) { |
|
2538 | + $fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value(); |
|
2539 | 2539 | } |
2540 | - $unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL; |
|
2541 | - return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj); |
|
2540 | + $unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL; |
|
2541 | + return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj); |
|
2542 | 2542 | } |
2543 | 2543 | |
2544 | 2544 | |
@@ -2550,9 +2550,9 @@ discard block |
||
2550 | 2550 | * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection |
2551 | 2551 | * @return mixed a value ready for use in the database for insertions, updating, or in a where clause |
2552 | 2552 | */ |
2553 | - private function _prepare_value_for_use_in_db($value, $field){ |
|
2554 | - if($field && $field instanceof EE_Model_Field_Base){ |
|
2555 | - switch( $this->_values_already_prepared_by_model_object ){ |
|
2553 | + private function _prepare_value_for_use_in_db($value, $field) { |
|
2554 | + if ($field && $field instanceof EE_Model_Field_Base) { |
|
2555 | + switch ($this->_values_already_prepared_by_model_object) { |
|
2556 | 2556 | /** @noinspection PhpMissingBreakStatementInspection */ |
2557 | 2557 | case self::not_prepared_by_model_object: |
2558 | 2558 | $value = $field->prepare_for_set($value); |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | //leave the value alone |
2564 | 2564 | } |
2565 | 2565 | return $value; |
2566 | - }else{ |
|
2566 | + } else { |
|
2567 | 2567 | return $value; |
2568 | 2568 | } |
2569 | 2569 | } |
@@ -2573,13 +2573,13 @@ discard block |
||
2573 | 2573 | * @return EE_Primary_Table |
2574 | 2574 | * @throws EE_Error |
2575 | 2575 | */ |
2576 | - protected function _get_main_table(){ |
|
2577 | - foreach($this->_tables as $table){ |
|
2578 | - if($table instanceof EE_Primary_Table){ |
|
2576 | + protected function _get_main_table() { |
|
2577 | + foreach ($this->_tables as $table) { |
|
2578 | + if ($table instanceof EE_Primary_Table) { |
|
2579 | 2579 | return $table; |
2580 | 2580 | } |
2581 | 2581 | } |
2582 | - throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this))); |
|
2582 | + throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this))); |
|
2583 | 2583 | } |
2584 | 2584 | |
2585 | 2585 | |
@@ -2602,7 +2602,7 @@ discard block |
||
2602 | 2602 | */ |
2603 | 2603 | public function second_table() { |
2604 | 2604 | // grab second table from tables array |
2605 | - $second_table = end( $this->_tables ); |
|
2605 | + $second_table = end($this->_tables); |
|
2606 | 2606 | return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL; |
2607 | 2607 | } |
2608 | 2608 | |
@@ -2615,8 +2615,8 @@ discard block |
||
2615 | 2615 | * @param string $table_alias |
2616 | 2616 | * @return EE_Primary_Table | EE_Secondary_Table |
2617 | 2617 | */ |
2618 | - public function get_table_obj_by_alias( $table_alias = '' ) { |
|
2619 | - return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL; |
|
2618 | + public function get_table_obj_by_alias($table_alias = '') { |
|
2619 | + return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL; |
|
2620 | 2620 | } |
2621 | 2621 | |
2622 | 2622 | |
@@ -2625,10 +2625,10 @@ discard block |
||
2625 | 2625 | * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables |
2626 | 2626 | * @return EE_Secondary_Table[] |
2627 | 2627 | */ |
2628 | - protected function _get_other_tables(){ |
|
2629 | - $other_tables =array(); |
|
2630 | - foreach($this->_tables as $table_alias => $table){ |
|
2631 | - if($table instanceof EE_Secondary_Table){ |
|
2628 | + protected function _get_other_tables() { |
|
2629 | + $other_tables = array(); |
|
2630 | + foreach ($this->_tables as $table_alias => $table) { |
|
2631 | + if ($table instanceof EE_Secondary_Table) { |
|
2632 | 2632 | $other_tables[$table_alias] = $table; |
2633 | 2633 | } |
2634 | 2634 | } |
@@ -2640,7 +2640,7 @@ discard block |
||
2640 | 2640 | * @param string $table_alias, array key in EEM_Base::_tables |
2641 | 2641 | * @return EE_Model_Field_Base[] |
2642 | 2642 | */ |
2643 | - public function _get_fields_for_table($table_alias){ |
|
2643 | + public function _get_fields_for_table($table_alias) { |
|
2644 | 2644 | return $this->_fields[$table_alias]; |
2645 | 2645 | } |
2646 | 2646 | |
@@ -2656,19 +2656,19 @@ discard block |
||
2656 | 2656 | * @return EE_Model_Query_Info_Carrier |
2657 | 2657 | * @throws \EE_Error |
2658 | 2658 | */ |
2659 | - public function _extract_related_models_from_query($query_params){ |
|
2659 | + public function _extract_related_models_from_query($query_params) { |
|
2660 | 2660 | $query_info_carrier = new EE_Model_Query_Info_Carrier(); |
2661 | - if ( array_key_exists( 0, $query_params ) ) { |
|
2662 | - $this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 ); |
|
2661 | + if (array_key_exists(0, $query_params)) { |
|
2662 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0); |
|
2663 | 2663 | } |
2664 | - if ( array_key_exists( 'group_by', $query_params ) ) { |
|
2665 | - if ( is_array( $query_params['group_by'] ) ) { |
|
2664 | + if (array_key_exists('group_by', $query_params)) { |
|
2665 | + if (is_array($query_params['group_by'])) { |
|
2666 | 2666 | $this->_extract_related_models_from_sub_params_array_values( |
2667 | 2667 | $query_params['group_by'], |
2668 | 2668 | $query_info_carrier, |
2669 | 2669 | 'group_by' |
2670 | 2670 | ); |
2671 | - } elseif ( ! empty ( $query_params['group_by'] ) ) { |
|
2671 | + } elseif ( ! empty ($query_params['group_by'])) { |
|
2672 | 2672 | $this->_extract_related_model_info_from_query_param( |
2673 | 2673 | $query_params['group_by'], |
2674 | 2674 | $query_info_carrier, |
@@ -2676,21 +2676,21 @@ discard block |
||
2676 | 2676 | ); |
2677 | 2677 | } |
2678 | 2678 | } |
2679 | - if ( array_key_exists( 'having', $query_params ) ) { |
|
2679 | + if (array_key_exists('having', $query_params)) { |
|
2680 | 2680 | $this->_extract_related_models_from_sub_params_array_keys( |
2681 | 2681 | $query_params[0], |
2682 | 2682 | $query_info_carrier, |
2683 | 2683 | 'having' |
2684 | 2684 | ); |
2685 | 2685 | } |
2686 | - if ( array_key_exists( 'order_by', $query_params ) ) { |
|
2687 | - if ( is_array( $query_params['order_by'] ) ) { |
|
2686 | + if (array_key_exists('order_by', $query_params)) { |
|
2687 | + if (is_array($query_params['order_by'])) { |
|
2688 | 2688 | $this->_extract_related_models_from_sub_params_array_keys( |
2689 | 2689 | $query_params['order_by'], |
2690 | 2690 | $query_info_carrier, |
2691 | 2691 | 'order_by' |
2692 | 2692 | ); |
2693 | - } elseif ( ! empty( $query_params['order_by'] ) ) { |
|
2693 | + } elseif ( ! empty($query_params['order_by'])) { |
|
2694 | 2694 | $this->_extract_related_model_info_from_query_param( |
2695 | 2695 | $query_params['order_by'], |
2696 | 2696 | $query_info_carrier, |
@@ -2698,7 +2698,7 @@ discard block |
||
2698 | 2698 | ); |
2699 | 2699 | } |
2700 | 2700 | } |
2701 | - if ( array_key_exists( 'force_join', $query_params ) ) { |
|
2701 | + if (array_key_exists('force_join', $query_params)) { |
|
2702 | 2702 | $this->_extract_related_models_from_sub_params_array_values( |
2703 | 2703 | $query_params['force_join'], |
2704 | 2704 | $query_info_carrier, |
@@ -2716,34 +2716,34 @@ discard block |
||
2716 | 2716 | * @throws EE_Error |
2717 | 2717 | * @return \EE_Model_Query_Info_Carrier |
2718 | 2718 | */ |
2719 | - private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2720 | - if (!empty($sub_query_params)){ |
|
2719 | + private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2720 | + if ( ! empty($sub_query_params)) { |
|
2721 | 2721 | $sub_query_params = (array) $sub_query_params; |
2722 | - foreach($sub_query_params as $param => $possibly_array_of_params){ |
|
2722 | + foreach ($sub_query_params as $param => $possibly_array_of_params) { |
|
2723 | 2723 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2724 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type); |
|
2724 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2725 | 2725 | |
2726 | 2726 | //if $possibly_array_of_params is an array, try recursing into it, searching for keys which |
2727 | 2727 | //indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried |
2728 | 2728 | //extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value |
2729 | 2729 | //of array('Registration.TXN_ID'=>23) |
2730 | 2730 | $query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param); |
2731 | - if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){ |
|
2732 | - if (! is_array($possibly_array_of_params)){ |
|
2731 | + if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) { |
|
2732 | + if ( ! is_array($possibly_array_of_params)) { |
|
2733 | 2733 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
2734 | - $param,$possibly_array_of_params)); |
|
2735 | - }else{ |
|
2736 | - $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
|
2734 | + $param, $possibly_array_of_params)); |
|
2735 | + } else { |
|
2736 | + $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type); |
|
2737 | 2737 | } |
2738 | - }elseif($query_param_type === 0 //ie WHERE |
|
2738 | + }elseif ($query_param_type === 0 //ie WHERE |
|
2739 | 2739 | && is_array($possibly_array_of_params) |
2740 | 2740 | && isset($possibly_array_of_params[2]) |
2741 | - && $possibly_array_of_params[2] == true){ |
|
2741 | + && $possibly_array_of_params[2] == true) { |
|
2742 | 2742 | //then $possible_array_of_params looks something like array('<','DTT_sold',true) |
2743 | 2743 | //indicating that $possible_array_of_params[1] is actually a field name, |
2744 | 2744 | //from which we should extract query parameters! |
2745 | - if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) { |
|
2746 | - throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params))); |
|
2745 | + if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) { |
|
2746 | + throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params))); |
|
2747 | 2747 | } |
2748 | 2748 | $this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type); |
2749 | 2749 | } |
@@ -2762,14 +2762,14 @@ discard block |
||
2762 | 2762 | * @throws EE_Error |
2763 | 2763 | * @return \EE_Model_Query_Info_Carrier |
2764 | 2764 | */ |
2765 | - private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2766 | - if (!empty($sub_query_params)){ |
|
2767 | - if(!is_array($sub_query_params)){ |
|
2768 | - throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params)); |
|
2765 | + private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2766 | + if ( ! empty($sub_query_params)) { |
|
2767 | + if ( ! is_array($sub_query_params)) { |
|
2768 | + throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params)); |
|
2769 | 2769 | } |
2770 | - foreach($sub_query_params as $param){ |
|
2770 | + foreach ($sub_query_params as $param) { |
|
2771 | 2771 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2772 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type); |
|
2772 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2773 | 2773 | } |
2774 | 2774 | } |
2775 | 2775 | return $model_query_info_carrier; |
@@ -2788,8 +2788,8 @@ discard block |
||
2788 | 2788 | * @throws EE_Error |
2789 | 2789 | * @return EE_Model_Query_Info_Carrier |
2790 | 2790 | */ |
2791 | - public function _create_model_query_info_carrier($query_params){ |
|
2792 | - if ( ! is_array( $query_params ) ) { |
|
2791 | + public function _create_model_query_info_carrier($query_params) { |
|
2792 | + if ( ! is_array($query_params)) { |
|
2793 | 2793 | EE_Error::doing_it_wrong( |
2794 | 2794 | 'EEM_Base::_create_model_query_info_carrier', |
2795 | 2795 | sprintf( |
@@ -2797,16 +2797,16 @@ discard block |
||
2797 | 2797 | '$query_params should be an array, you passed a variable of type %s', |
2798 | 2798 | 'event_espresso' |
2799 | 2799 | ), |
2800 | - gettype( $query_params ) |
|
2800 | + gettype($query_params) |
|
2801 | 2801 | ), |
2802 | 2802 | '4.6.0' |
2803 | 2803 | ); |
2804 | 2804 | $query_params = array(); |
2805 | 2805 | } |
2806 | - $where_query_params = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
2806 | + $where_query_params = isset($query_params[0]) ? $query_params[0] : array(); |
|
2807 | 2807 | //first check if we should alter the query to account for caps or not |
2808 | 2808 | //because the caps might require us to do extra joins |
2809 | - if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) { |
|
2809 | + if (isset($query_params['caps']) && $query_params['caps'] !== 'none') { |
|
2810 | 2810 | $query_params[0] = $where_query_params = array_replace_recursive( |
2811 | 2811 | $where_query_params, |
2812 | 2812 | $this->caps_where_conditions( |
@@ -2814,10 +2814,10 @@ discard block |
||
2814 | 2814 | ) |
2815 | 2815 | ); |
2816 | 2816 | } |
2817 | - $query_object = $this->_extract_related_models_from_query( $query_params ); |
|
2817 | + $query_object = $this->_extract_related_models_from_query($query_params); |
|
2818 | 2818 | //verify where_query_params has NO numeric indexes.... that's simply not how you use it! |
2819 | - foreach ( $where_query_params as $key => $value ) { |
|
2820 | - if ( is_int( $key ) ) { |
|
2819 | + foreach ($where_query_params as $key => $value) { |
|
2820 | + if (is_int($key)) { |
|
2821 | 2821 | throw new EE_Error( |
2822 | 2822 | sprintf( |
2823 | 2823 | __( |
@@ -2825,16 +2825,16 @@ discard block |
||
2825 | 2825 | "event_espresso" |
2826 | 2826 | ), |
2827 | 2827 | $key, |
2828 | - var_export( $value, true ), |
|
2829 | - var_export( $query_params, true ), |
|
2830 | - get_class( $this ) |
|
2828 | + var_export($value, true), |
|
2829 | + var_export($query_params, true), |
|
2830 | + get_class($this) |
|
2831 | 2831 | ) |
2832 | 2832 | ); |
2833 | 2833 | } |
2834 | 2834 | } |
2835 | 2835 | if ( |
2836 | - array_key_exists( 'default_where_conditions', $query_params ) |
|
2837 | - && ! empty( $query_params['default_where_conditions'] ) |
|
2836 | + array_key_exists('default_where_conditions', $query_params) |
|
2837 | + && ! empty($query_params['default_where_conditions']) |
|
2838 | 2838 | ) { |
2839 | 2839 | $use_default_where_conditions = $query_params['default_where_conditions']; |
2840 | 2840 | } else { |
@@ -2848,13 +2848,13 @@ discard block |
||
2848 | 2848 | ), |
2849 | 2849 | $where_query_params |
2850 | 2850 | ); |
2851 | - $query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) ); |
|
2851 | + $query_object->set_where_sql($this->_construct_where_clause($where_query_params)); |
|
2852 | 2852 | // if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join. |
2853 | 2853 | // So we need to setup a subquery and use that for the main join. |
2854 | 2854 | // Note for now this only works on the primary table for the model. |
2855 | 2855 | // So for instance, you could set the limit array like this: |
2856 | 2856 | // array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) ) |
2857 | - if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) { |
|
2857 | + if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) { |
|
2858 | 2858 | $query_object->set_main_model_join_sql( |
2859 | 2859 | $this->_construct_limit_join_select( |
2860 | 2860 | $query_params['on_join_limit'][0], |
@@ -2863,40 +2863,40 @@ discard block |
||
2863 | 2863 | ); |
2864 | 2864 | } |
2865 | 2865 | //set limit |
2866 | - if ( array_key_exists( 'limit', $query_params ) ) { |
|
2867 | - if ( is_array( $query_params['limit'] ) ) { |
|
2868 | - if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) { |
|
2866 | + if (array_key_exists('limit', $query_params)) { |
|
2867 | + if (is_array($query_params['limit'])) { |
|
2868 | + if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) { |
|
2869 | 2869 | $e = sprintf( |
2870 | 2870 | __( |
2871 | 2871 | "Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", |
2872 | 2872 | "event_espresso" |
2873 | 2873 | ), |
2874 | - http_build_query( $query_params['limit'] ) |
|
2874 | + http_build_query($query_params['limit']) |
|
2875 | 2875 | ); |
2876 | - throw new EE_Error( $e . "|" . $e ); |
|
2876 | + throw new EE_Error($e."|".$e); |
|
2877 | 2877 | } |
2878 | 2878 | //they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25 |
2879 | - $query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] ); |
|
2880 | - } elseif ( ! empty ( $query_params['limit'] ) ) { |
|
2881 | - $query_object->set_limit_sql( " LIMIT " . $query_params['limit'] ); |
|
2879 | + $query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]); |
|
2880 | + } elseif ( ! empty ($query_params['limit'])) { |
|
2881 | + $query_object->set_limit_sql(" LIMIT ".$query_params['limit']); |
|
2882 | 2882 | } |
2883 | 2883 | } |
2884 | 2884 | //set order by |
2885 | - if ( array_key_exists( 'order_by', $query_params ) ) { |
|
2886 | - if ( is_array( $query_params['order_by'] ) ) { |
|
2885 | + if (array_key_exists('order_by', $query_params)) { |
|
2886 | + if (is_array($query_params['order_by'])) { |
|
2887 | 2887 | //if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must |
2888 | 2888 | //specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So |
2889 | 2889 | //including 'order' wouldn't make any sense if 'order_by' has already specified which way to order! |
2890 | - if ( array_key_exists( 'order', $query_params ) ) { |
|
2890 | + if (array_key_exists('order', $query_params)) { |
|
2891 | 2891 | throw new EE_Error( |
2892 | 2892 | sprintf( |
2893 | 2893 | __( |
2894 | 2894 | "In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", |
2895 | 2895 | "event_espresso" |
2896 | 2896 | ), |
2897 | - get_class( $this ), |
|
2898 | - implode( ", ", array_keys( $query_params['order_by'] ) ), |
|
2899 | - implode( ", ", $query_params['order_by'] ), |
|
2897 | + get_class($this), |
|
2898 | + implode(", ", array_keys($query_params['order_by'])), |
|
2899 | + implode(", ", $query_params['order_by']), |
|
2900 | 2900 | $query_params['order'] |
2901 | 2901 | ) |
2902 | 2902 | ); |
@@ -2908,57 +2908,57 @@ discard block |
||
2908 | 2908 | ); |
2909 | 2909 | //assume it's an array of fields to order by |
2910 | 2910 | $order_array = array(); |
2911 | - foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) { |
|
2912 | - $order = $this->_extract_order( $order ); |
|
2913 | - $order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order; |
|
2911 | + foreach ($query_params['order_by'] as $field_name_to_order_by => $order) { |
|
2912 | + $order = $this->_extract_order($order); |
|
2913 | + $order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order; |
|
2914 | 2914 | } |
2915 | - $query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) ); |
|
2916 | - } elseif ( ! empty ( $query_params['order_by'] ) ) { |
|
2915 | + $query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array)); |
|
2916 | + } elseif ( ! empty ($query_params['order_by'])) { |
|
2917 | 2917 | $this->_extract_related_model_info_from_query_param( |
2918 | 2918 | $query_params['order_by'], |
2919 | 2919 | $query_object, |
2920 | 2920 | 'order', |
2921 | 2921 | $query_params['order_by'] |
2922 | 2922 | ); |
2923 | - $order = isset( $query_params['order'] ) |
|
2924 | - ? $this->_extract_order( $query_params['order'] ) |
|
2923 | + $order = isset($query_params['order']) |
|
2924 | + ? $this->_extract_order($query_params['order']) |
|
2925 | 2925 | : 'DESC'; |
2926 | 2926 | $query_object->set_order_by_sql( |
2927 | - " ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order |
|
2927 | + " ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order |
|
2928 | 2928 | ); |
2929 | 2929 | } |
2930 | 2930 | } |
2931 | 2931 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
2932 | - if ( ! array_key_exists( 'order_by', $query_params ) |
|
2933 | - && array_key_exists( 'order', $query_params ) |
|
2934 | - && ! empty( $query_params['order'] ) |
|
2932 | + if ( ! array_key_exists('order_by', $query_params) |
|
2933 | + && array_key_exists('order', $query_params) |
|
2934 | + && ! empty($query_params['order']) |
|
2935 | 2935 | ) { |
2936 | 2936 | $pk_field = $this->get_primary_key_field(); |
2937 | - $order = $this->_extract_order( $query_params['order'] ); |
|
2938 | - $query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order ); |
|
2937 | + $order = $this->_extract_order($query_params['order']); |
|
2938 | + $query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order); |
|
2939 | 2939 | } |
2940 | 2940 | //set group by |
2941 | - if ( array_key_exists( 'group_by', $query_params ) ) { |
|
2942 | - if ( is_array( $query_params['group_by'] ) ) { |
|
2941 | + if (array_key_exists('group_by', $query_params)) { |
|
2942 | + if (is_array($query_params['group_by'])) { |
|
2943 | 2943 | //it's an array, so assume we'll be grouping by a bunch of stuff |
2944 | 2944 | $group_by_array = array(); |
2945 | - foreach ( $query_params['group_by'] as $field_name_to_group_by ) { |
|
2946 | - $group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by ); |
|
2945 | + foreach ($query_params['group_by'] as $field_name_to_group_by) { |
|
2946 | + $group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by); |
|
2947 | 2947 | } |
2948 | - $query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) ); |
|
2949 | - } elseif ( ! empty ( $query_params['group_by'] ) ) { |
|
2948 | + $query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array)); |
|
2949 | + } elseif ( ! empty ($query_params['group_by'])) { |
|
2950 | 2950 | $query_object->set_group_by_sql( |
2951 | - " GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] ) |
|
2951 | + " GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']) |
|
2952 | 2952 | ); |
2953 | 2953 | } |
2954 | 2954 | } |
2955 | 2955 | //set having |
2956 | - if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) { |
|
2957 | - $query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) ); |
|
2956 | + if (array_key_exists('having', $query_params) && $query_params['having']) { |
|
2957 | + $query_object->set_having_sql($this->_construct_having_clause($query_params['having'])); |
|
2958 | 2958 | } |
2959 | 2959 | //now, just verify they didn't pass anything wack |
2960 | - foreach ( $query_params as $query_key => $query_value ) { |
|
2961 | - if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) { |
|
2960 | + foreach ($query_params as $query_key => $query_value) { |
|
2961 | + if ( ! in_array($query_key, $this->_allowed_query_params, true)) { |
|
2962 | 2962 | throw new EE_Error( |
2963 | 2963 | sprintf( |
2964 | 2964 | __( |
@@ -2966,16 +2966,16 @@ discard block |
||
2966 | 2966 | 'event_espresso' |
2967 | 2967 | ), |
2968 | 2968 | $query_key, |
2969 | - get_class( $this ), |
|
2969 | + get_class($this), |
|
2970 | 2970 | // print_r( $this->_allowed_query_params, TRUE ) |
2971 | - implode( ',', $this->_allowed_query_params ) |
|
2971 | + implode(',', $this->_allowed_query_params) |
|
2972 | 2972 | ) |
2973 | 2973 | ); |
2974 | 2974 | } |
2975 | 2975 | } |
2976 | 2976 | $main_model_join_sql = $query_object->get_main_model_join_sql(); |
2977 | - if ( empty( $main_model_join_sql ) ) { |
|
2978 | - $query_object->set_main_model_join_sql( $this->_construct_internal_join() ); |
|
2977 | + if (empty($main_model_join_sql)) { |
|
2978 | + $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
|
2979 | 2979 | } |
2980 | 2980 | return $query_object; |
2981 | 2981 | } |
@@ -2990,17 +2990,17 @@ discard block |
||
2990 | 2990 | * @return array like EEM_Base::get_all() 's $query_params[0] |
2991 | 2991 | * @throws \EE_Error |
2992 | 2992 | */ |
2993 | - public function caps_where_conditions( $context = self::caps_read ) { |
|
2994 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
2993 | + public function caps_where_conditions($context = self::caps_read) { |
|
2994 | + EEM_Base::verify_is_valid_cap_context($context); |
|
2995 | 2995 | $cap_where_conditions = array(); |
2996 | - $cap_restrictions = $this->caps_missing( $context ); |
|
2996 | + $cap_restrictions = $this->caps_missing($context); |
|
2997 | 2997 | /** |
2998 | 2998 | * @var $cap_restrictions EE_Default_Where_Conditions[] |
2999 | 2999 | */ |
3000 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
3001 | - $cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() ); |
|
3000 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
3001 | + $cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions()); |
|
3002 | 3002 | } |
3003 | - return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions ); |
|
3003 | + return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions); |
|
3004 | 3004 | } |
3005 | 3005 | |
3006 | 3006 | /** |
@@ -3010,11 +3010,11 @@ discard block |
||
3010 | 3010 | * @return string either ASC, asc, DESC or desc |
3011 | 3011 | * @throws EE_Error |
3012 | 3012 | */ |
3013 | - private function _extract_order($should_be_order_string){ |
|
3014 | - if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
|
3013 | + private function _extract_order($should_be_order_string) { |
|
3014 | + if (in_array($should_be_order_string, $this->_allowed_order_values)) { |
|
3015 | 3015 | return $should_be_order_string; |
3016 | - }else{ |
|
3017 | - throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
|
3016 | + } else { |
|
3017 | + throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string)); |
|
3018 | 3018 | } |
3019 | 3019 | } |
3020 | 3020 | |
@@ -3032,7 +3032,7 @@ discard block |
||
3032 | 3032 | * @throws EE_Error |
3033 | 3033 | * @return array like $query_params[0], see EEM_Base::get_all for documentation |
3034 | 3034 | */ |
3035 | - private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){ |
|
3035 | + private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) { |
|
3036 | 3036 | $allowed_used_default_where_conditions_values = array( |
3037 | 3037 | 'all', |
3038 | 3038 | 'this_model_only', |
@@ -3040,17 +3040,17 @@ discard block |
||
3040 | 3040 | 'minimum', |
3041 | 3041 | 'none' |
3042 | 3042 | ); |
3043 | - if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){ |
|
3044 | - throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values))); |
|
3043 | + if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) { |
|
3044 | + throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values))); |
|
3045 | 3045 | } |
3046 | 3046 | $universal_query_params = array(); |
3047 | - if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){ |
|
3047 | + if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') { |
|
3048 | 3048 | $universal_query_params = $this->_get_default_where_conditions(); |
3049 | - } else if( $use_default_where_conditions === 'minimum' ) { |
|
3049 | + } else if ($use_default_where_conditions === 'minimum') { |
|
3050 | 3050 | $universal_query_params = $this->_get_minimum_where_conditions(); |
3051 | 3051 | } |
3052 | - if(in_array($use_default_where_conditions,array('all','other_models_only'))){ |
|
3053 | - foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){ |
|
3052 | + if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) { |
|
3053 | + foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) { |
|
3054 | 3054 | $related_model = $this->get_related_model_obj($model_name); |
3055 | 3055 | $related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path); |
3056 | 3056 | $overrides = $this->_override_defaults_or_make_null_friendly( |
@@ -3083,20 +3083,20 @@ discard block |
||
3083 | 3083 | * @return array like EEM_Base::get_all's $query_params[0] |
3084 | 3084 | * @throws \EE_Error |
3085 | 3085 | */ |
3086 | - private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){ |
|
3086 | + private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) { |
|
3087 | 3087 | $null_friendly_where_conditions = array(); |
3088 | 3088 | $none_overridden = true; |
3089 | 3089 | $or_condition_key_for_defaults = 'OR*'.get_class($model); |
3090 | 3090 | |
3091 | - foreach($default_where_conditions as $key => $val){ |
|
3092 | - if( isset($provided_where_conditions[$key])){ |
|
3091 | + foreach ($default_where_conditions as $key => $val) { |
|
3092 | + if (isset($provided_where_conditions[$key])) { |
|
3093 | 3093 | $none_overridden = false; |
3094 | - }else{ |
|
3094 | + } else { |
|
3095 | 3095 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
3096 | 3096 | } |
3097 | 3097 | } |
3098 | - if( $none_overridden && $default_where_conditions){ |
|
3099 | - if($model->has_primary_key_field()){ |
|
3098 | + if ($none_overridden && $default_where_conditions) { |
|
3099 | + if ($model->has_primary_key_field()) { |
|
3100 | 3100 | $null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL'); |
3101 | 3101 | }/*else{ |
3102 | 3102 | //@todo NO PK, use other defaults |
@@ -3113,8 +3113,8 @@ discard block |
||
3113 | 3113 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
3114 | 3114 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
3115 | 3115 | */ |
3116 | - private function _get_default_where_conditions($model_relation_path = null){ |
|
3117 | - if ( $this->_ignore_where_strategy ){ |
|
3116 | + private function _get_default_where_conditions($model_relation_path = null) { |
|
3117 | + if ($this->_ignore_where_strategy) { |
|
3118 | 3118 | return array(); |
3119 | 3119 | } |
3120 | 3120 | return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -3128,8 +3128,8 @@ discard block |
||
3128 | 3128 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
3129 | 3129 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
3130 | 3130 | */ |
3131 | - protected function _get_minimum_where_conditions($model_relation_path = null){ |
|
3132 | - if ( $this->_ignore_where_strategy ){ |
|
3131 | + protected function _get_minimum_where_conditions($model_relation_path = null) { |
|
3132 | + if ($this->_ignore_where_strategy) { |
|
3133 | 3133 | return array(); |
3134 | 3134 | } |
3135 | 3135 | return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -3145,16 +3145,16 @@ discard block |
||
3145 | 3145 | * @return string |
3146 | 3146 | * @throws \EE_Error |
3147 | 3147 | */ |
3148 | - private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){ |
|
3148 | + private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) { |
|
3149 | 3149 | $selects = $this->_get_columns_to_select_for_this_model(); |
3150 | - foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){ |
|
3150 | + foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) { |
|
3151 | 3151 | $other_model_included = $this->get_related_model_obj($name_of_other_model_included); |
3152 | - $other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain ); |
|
3153 | - foreach ( $other_model_selects as $key => $value ) { |
|
3152 | + $other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain); |
|
3153 | + foreach ($other_model_selects as $key => $value) { |
|
3154 | 3154 | $selects[] = $value; |
3155 | 3155 | } |
3156 | 3156 | } |
3157 | - return implode(", ",$selects); |
|
3157 | + return implode(", ", $selects); |
|
3158 | 3158 | } |
3159 | 3159 | |
3160 | 3160 | /** |
@@ -3163,19 +3163,19 @@ discard block |
||
3163 | 3163 | * @param string $model_relation_chain like 'Question.Question_Group.Event' |
3164 | 3164 | * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'" |
3165 | 3165 | */ |
3166 | - public function _get_columns_to_select_for_this_model($model_relation_chain = ''){ |
|
3166 | + public function _get_columns_to_select_for_this_model($model_relation_chain = '') { |
|
3167 | 3167 | $fields = $this->field_settings(); |
3168 | 3168 | $selects = array(); |
3169 | 3169 | $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name()); |
3170 | - foreach($fields as $field_obj){ |
|
3171 | - $selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
3170 | + foreach ($fields as $field_obj) { |
|
3171 | + $selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
3172 | 3172 | } |
3173 | 3173 | //make sure we are also getting the PKs of each table |
3174 | 3174 | $tables = $this->get_tables(); |
3175 | - if(count($tables) > 1){ |
|
3176 | - foreach($tables as $table_obj){ |
|
3177 | - $qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column(); |
|
3178 | - if( ! in_array($qualified_pk_column,$selects)){ |
|
3175 | + if (count($tables) > 1) { |
|
3176 | + foreach ($tables as $table_obj) { |
|
3177 | + $qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column(); |
|
3178 | + if ( ! in_array($qualified_pk_column, $selects)) { |
|
3179 | 3179 | $selects[] = "$qualified_pk_column AS '$qualified_pk_column'"; |
3180 | 3180 | } |
3181 | 3181 | } |
@@ -3205,65 +3205,65 @@ discard block |
||
3205 | 3205 | $query_param_type, |
3206 | 3206 | $original_query_param = null |
3207 | 3207 | ) { |
3208 | - if( $original_query_param === null ){ |
|
3208 | + if ($original_query_param === null) { |
|
3209 | 3209 | $original_query_param = $query_param; |
3210 | 3210 | } |
3211 | 3211 | $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); |
3212 | 3212 | /** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */ |
3213 | - $allow_logic_query_params = in_array($query_param_type,array('where','having')); |
|
3214 | - $allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order')); |
|
3213 | + $allow_logic_query_params = in_array($query_param_type, array('where', 'having')); |
|
3214 | + $allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order')); |
|
3215 | 3215 | //check to see if we have a field on this model |
3216 | 3216 | $this_model_fields = $this->field_settings(true); |
3217 | - if(array_key_exists($query_param,$this_model_fields)){ |
|
3218 | - if($allow_fields){ |
|
3217 | + if (array_key_exists($query_param, $this_model_fields)) { |
|
3218 | + if ($allow_fields) { |
|
3219 | 3219 | return; |
3220 | - }else{ |
|
3220 | + } else { |
|
3221 | 3221 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
3222 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
3222 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
3223 | 3223 | } |
3224 | 3224 | } |
3225 | 3225 | //check if this is a special logic query param |
3226 | - elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
|
3227 | - if($allow_logic_query_params){ |
|
3226 | + elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) { |
|
3227 | + if ($allow_logic_query_params) { |
|
3228 | 3228 | return; |
3229 | - }else{ |
|
3229 | + } else { |
|
3230 | 3230 | throw new EE_Error( |
3231 | 3231 | sprintf( |
3232 | - __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
|
3233 | - implode( '", "', $this->_logic_query_param_keys ), |
|
3234 | - $query_param , |
|
3235 | - get_class( $this ), |
|
3232 | + __('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'), |
|
3233 | + implode('", "', $this->_logic_query_param_keys), |
|
3234 | + $query_param, |
|
3235 | + get_class($this), |
|
3236 | 3236 | '<br />', |
3237 | - "\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param |
|
3237 | + "\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param |
|
3238 | 3238 | ) |
3239 | 3239 | ); |
3240 | 3240 | } |
3241 | 3241 | } |
3242 | 3242 | |
3243 | 3243 | //check if it's a custom selection |
3244 | - elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3244 | + elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
3245 | 3245 | return; |
3246 | 3246 | } |
3247 | 3247 | |
3248 | 3248 | //check if has a model name at the beginning |
3249 | 3249 | //and |
3250 | 3250 | //check if it's a field on a related model |
3251 | - foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){ |
|
3252 | - if(strpos($query_param, $valid_related_model_name.".") === 0){ |
|
3253 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
3251 | + foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) { |
|
3252 | + if (strpos($query_param, $valid_related_model_name.".") === 0) { |
|
3253 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
3254 | 3254 | $query_param = substr($query_param, strlen($valid_related_model_name.".")); |
3255 | - if($query_param === ''){ |
|
3255 | + if ($query_param === '') { |
|
3256 | 3256 | //nothing left to $query_param |
3257 | 3257 | //we should actually end in a field name, not a model like this! |
3258 | 3258 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
3259 | - $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
|
3260 | - }else{ |
|
3259 | + $query_param, $query_param_type, get_class($this), $valid_related_model_name)); |
|
3260 | + } else { |
|
3261 | 3261 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
3262 | 3262 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
3263 | 3263 | return; |
3264 | 3264 | } |
3265 | - }elseif($query_param === $valid_related_model_name){ |
|
3266 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
3265 | + }elseif ($query_param === $valid_related_model_name) { |
|
3266 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
3267 | 3267 | return; |
3268 | 3268 | } |
3269 | 3269 | } |
@@ -3273,7 +3273,7 @@ discard block |
||
3273 | 3273 | //and we previously confirmed it wasn't a logic query param or field on the current model |
3274 | 3274 | //it's wack, that's what it is |
3275 | 3275 | throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"), |
3276 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
3276 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
3277 | 3277 | |
3278 | 3278 | } |
3279 | 3279 | |
@@ -3292,26 +3292,26 @@ discard block |
||
3292 | 3292 | * @return void |
3293 | 3293 | * @throws \EE_Error |
3294 | 3294 | */ |
3295 | - private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){ |
|
3295 | + private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) { |
|
3296 | 3296 | $relation_obj = $this->related_settings_for($model_name); |
3297 | 3297 | |
3298 | 3298 | $model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param); |
3299 | 3299 | //check if the relation is HABTM, because then we're essentially doing two joins |
3300 | 3300 | //If so, join first to the JOIN table, and add its data types, and then continue as normal |
3301 | - if($relation_obj instanceof EE_HABTM_Relation){ |
|
3301 | + if ($relation_obj instanceof EE_HABTM_Relation) { |
|
3302 | 3302 | $join_model_obj = $relation_obj->get_join_model(); |
3303 | 3303 | //replace the model specified with the join model for this relation chain, whi |
3304 | 3304 | $relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain); |
3305 | 3305 | $new_query_info = new EE_Model_Query_Info_Carrier( |
3306 | 3306 | array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()), |
3307 | 3307 | $relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model)); |
3308 | - $passed_in_query_info->merge( $new_query_info ); |
|
3308 | + $passed_in_query_info->merge($new_query_info); |
|
3309 | 3309 | } |
3310 | 3310 | //now just join to the other table pointed to by the relation object, and add its data types |
3311 | 3311 | $new_query_info = new EE_Model_Query_Info_Carrier( |
3312 | 3312 | array($model_relation_chain=>$model_name), |
3313 | 3313 | $relation_obj->get_join_statement($model_relation_chain)); |
3314 | - $passed_in_query_info->merge( $new_query_info ); |
|
3314 | + $passed_in_query_info->merge($new_query_info); |
|
3315 | 3315 | } |
3316 | 3316 | |
3317 | 3317 | |
@@ -3323,11 +3323,11 @@ discard block |
||
3323 | 3323 | * @return string of SQL |
3324 | 3324 | * @throws \EE_Error |
3325 | 3325 | */ |
3326 | - private function _construct_where_clause($where_params){ |
|
3326 | + private function _construct_where_clause($where_params) { |
|
3327 | 3327 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
3328 | - if($SQL){ |
|
3329 | - return " WHERE ". $SQL; |
|
3330 | - }else{ |
|
3328 | + if ($SQL) { |
|
3329 | + return " WHERE ".$SQL; |
|
3330 | + } else { |
|
3331 | 3331 | return ''; |
3332 | 3332 | } |
3333 | 3333 | } |
@@ -3342,11 +3342,11 @@ discard block |
||
3342 | 3342 | * @return string |
3343 | 3343 | * @throws \EE_Error |
3344 | 3344 | */ |
3345 | - private function _construct_having_clause($having_params){ |
|
3345 | + private function _construct_having_clause($having_params) { |
|
3346 | 3346 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
3347 | - if($SQL){ |
|
3348 | - return " HAVING ". $SQL; |
|
3349 | - }else{ |
|
3347 | + if ($SQL) { |
|
3348 | + return " HAVING ".$SQL; |
|
3349 | + } else { |
|
3350 | 3350 | return ''; |
3351 | 3351 | } |
3352 | 3352 | |
@@ -3360,16 +3360,16 @@ discard block |
||
3360 | 3360 | * @return EE_Model_Field_Base |
3361 | 3361 | * @throws EE_Error |
3362 | 3362 | */ |
3363 | - protected function _get_field_on_model($field_name,$model_name){ |
|
3363 | + protected function _get_field_on_model($field_name, $model_name) { |
|
3364 | 3364 | $model_class = 'EEM_'.$model_name; |
3365 | 3365 | $model_filepath = $model_class.".model.php"; |
3366 | - if ( is_readable($model_filepath)){ |
|
3366 | + if (is_readable($model_filepath)) { |
|
3367 | 3367 | require_once($model_filepath); |
3368 | - $model_instance=call_user_func($model_name."::instance"); |
|
3368 | + $model_instance = call_user_func($model_name."::instance"); |
|
3369 | 3369 | /* @var $model_instance EEM_Base */ |
3370 | 3370 | return $model_instance->field_settings_for($field_name); |
3371 | - }else{ |
|
3372 | - throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
|
3371 | + } else { |
|
3372 | + throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath)); |
|
3373 | 3373 | } |
3374 | 3374 | } |
3375 | 3375 | |
@@ -3382,41 +3382,41 @@ discard block |
||
3382 | 3382 | * @throws EE_Error |
3383 | 3383 | * @return string of SQL |
3384 | 3384 | */ |
3385 | - private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){ |
|
3386 | - $where_clauses=array(); |
|
3387 | - foreach($where_params as $query_param => $op_and_value_or_sub_condition){ |
|
3388 | - $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param); |
|
3389 | - if(in_array($query_param,$this->_logic_query_param_keys)){ |
|
3390 | - switch($query_param){ |
|
3385 | + private function _construct_condition_clause_recursive($where_params, $glue = ' AND') { |
|
3386 | + $where_clauses = array(); |
|
3387 | + foreach ($where_params as $query_param => $op_and_value_or_sub_condition) { |
|
3388 | + $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param); |
|
3389 | + if (in_array($query_param, $this->_logic_query_param_keys)) { |
|
3390 | + switch ($query_param) { |
|
3391 | 3391 | case 'not': |
3392 | 3392 | case 'NOT': |
3393 | - $where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
3393 | + $where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
3394 | 3394 | break; |
3395 | 3395 | case 'and': |
3396 | 3396 | case 'AND': |
3397 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")"; |
|
3397 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")"; |
|
3398 | 3398 | break; |
3399 | 3399 | case 'or': |
3400 | 3400 | case 'OR': |
3401 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
|
3401 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")"; |
|
3402 | 3402 | break; |
3403 | 3403 | } |
3404 | - }else{ |
|
3404 | + } else { |
|
3405 | 3405 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
3406 | 3406 | |
3407 | 3407 | //if it's not a normal field, maybe it's a custom selection? |
3408 | - if( ! $field_obj){ |
|
3409 | - if(isset( $this->_custom_selections[$query_param][1])){ |
|
3408 | + if ( ! $field_obj) { |
|
3409 | + if (isset($this->_custom_selections[$query_param][1])) { |
|
3410 | 3410 | $field_obj = $this->_custom_selections[$query_param][1]; |
3411 | - }else{ |
|
3412 | - throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
|
3411 | + } else { |
|
3412 | + throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param)); |
|
3413 | 3413 | } |
3414 | 3414 | } |
3415 | 3415 | $op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj); |
3416 | - $where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3416 | + $where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3417 | 3417 | } |
3418 | 3418 | } |
3419 | - return $where_clauses ? implode( $glue, $where_clauses ) : ''; |
|
3419 | + return $where_clauses ? implode($glue, $where_clauses) : ''; |
|
3420 | 3420 | } |
3421 | 3421 | |
3422 | 3422 | |
@@ -3427,18 +3427,18 @@ discard block |
||
3427 | 3427 | * @throws EE_Error |
3428 | 3428 | * @return string table alias and column name for SQL, eg "Transaction.TXN_ID" |
3429 | 3429 | */ |
3430 | - private function _deduce_column_name_from_query_param($query_param){ |
|
3430 | + private function _deduce_column_name_from_query_param($query_param) { |
|
3431 | 3431 | $field = $this->_deduce_field_from_query_param($query_param); |
3432 | 3432 | |
3433 | - if( $field ){ |
|
3434 | - $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
|
3435 | - return $table_alias_prefix . $field->get_qualified_column(); |
|
3436 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3433 | + if ($field) { |
|
3434 | + $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param); |
|
3435 | + return $table_alias_prefix.$field->get_qualified_column(); |
|
3436 | + }elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
3437 | 3437 | //maybe it's custom selection item? |
3438 | 3438 | //if so, just use it as the "column name" |
3439 | 3439 | return $query_param; |
3440 | - }else{ |
|
3441 | - throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
|
3440 | + } else { |
|
3441 | + throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections))); |
|
3442 | 3442 | } |
3443 | 3443 | } |
3444 | 3444 | |
@@ -3450,11 +3450,11 @@ discard block |
||
3450 | 3450 | * @param string $condition_query_param_key |
3451 | 3451 | * @return string |
3452 | 3452 | */ |
3453 | - private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){ |
|
3453 | + private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
3454 | 3454 | $pos_of_star = strpos($condition_query_param_key, '*'); |
3455 | - if($pos_of_star === FALSE){ |
|
3455 | + if ($pos_of_star === FALSE) { |
|
3456 | 3456 | return $condition_query_param_key; |
3457 | - }else{ |
|
3457 | + } else { |
|
3458 | 3458 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
3459 | 3459 | return $condition_query_param_sans_star; |
3460 | 3460 | } |
@@ -3469,12 +3469,12 @@ discard block |
||
3469 | 3469 | * @throws EE_Error |
3470 | 3470 | * @return string |
3471 | 3471 | */ |
3472 | - private function _construct_op_and_value($op_and_value, $field_obj){ |
|
3473 | - if ( is_array( $op_and_value ) ) { |
|
3474 | - $operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null; |
|
3475 | - if ( ! $operator ) { |
|
3472 | + private function _construct_op_and_value($op_and_value, $field_obj) { |
|
3473 | + if (is_array($op_and_value)) { |
|
3474 | + $operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null; |
|
3475 | + if ( ! $operator) { |
|
3476 | 3476 | $php_array_like_string = array(); |
3477 | - foreach ( $op_and_value as $key => $value ) { |
|
3477 | + foreach ($op_and_value as $key => $value) { |
|
3478 | 3478 | $php_array_like_string[] = "$key=>$value"; |
3479 | 3479 | } |
3480 | 3480 | throw new EE_Error( |
@@ -3483,27 +3483,27 @@ discard block |
||
3483 | 3483 | "You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", |
3484 | 3484 | "event_espresso" |
3485 | 3485 | ), |
3486 | - implode( ",", $php_array_like_string ) |
|
3486 | + implode(",", $php_array_like_string) |
|
3487 | 3487 | ) |
3488 | 3488 | ); |
3489 | 3489 | } |
3490 | - $value = isset( $op_and_value[1] ) ? $op_and_value[1] : null; |
|
3490 | + $value = isset($op_and_value[1]) ? $op_and_value[1] : null; |
|
3491 | 3491 | } else { |
3492 | 3492 | $operator = '='; |
3493 | 3493 | $value = $op_and_value; |
3494 | 3494 | } |
3495 | 3495 | //check to see if the value is actually another field |
3496 | - if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) { |
|
3497 | - return $operator . SP . $this->_deduce_column_name_from_query_param( $value ); |
|
3498 | - } elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) { |
|
3496 | + if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) { |
|
3497 | + return $operator.SP.$this->_deduce_column_name_from_query_param($value); |
|
3498 | + } elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3499 | 3499 | //in this case, the value should be an array, or at least a comma-separated list |
3500 | 3500 | //it will need to handle a little differently |
3501 | - $cleaned_value = $this->_construct_in_value( $value, $field_obj ); |
|
3501 | + $cleaned_value = $this->_construct_in_value($value, $field_obj); |
|
3502 | 3502 | //note: $cleaned_value has already been run through $wpdb->prepare() |
3503 | - return $operator . SP . $cleaned_value; |
|
3504 | - } elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) { |
|
3503 | + return $operator.SP.$cleaned_value; |
|
3504 | + } elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) { |
|
3505 | 3505 | //the value should be an array with count of two. |
3506 | - if ( count( $value ) !== 2 ) { |
|
3506 | + if (count($value) !== 2) { |
|
3507 | 3507 | throw new EE_Error( |
3508 | 3508 | sprintf( |
3509 | 3509 | __( |
@@ -3514,10 +3514,10 @@ discard block |
||
3514 | 3514 | ) |
3515 | 3515 | ); |
3516 | 3516 | } |
3517 | - $cleaned_value = $this->_construct_between_value( $value, $field_obj ); |
|
3518 | - return $operator . SP . $cleaned_value; |
|
3519 | - } elseif ( in_array( $operator, $this->_null_style_operators ) ) { |
|
3520 | - if ( $value !== null ) { |
|
3517 | + $cleaned_value = $this->_construct_between_value($value, $field_obj); |
|
3518 | + return $operator.SP.$cleaned_value; |
|
3519 | + } elseif (in_array($operator, $this->_null_style_operators)) { |
|
3520 | + if ($value !== null) { |
|
3521 | 3521 | throw new EE_Error( |
3522 | 3522 | sprintf( |
3523 | 3523 | __( |
@@ -3530,13 +3530,13 @@ discard block |
||
3530 | 3530 | ); |
3531 | 3531 | } |
3532 | 3532 | return $operator; |
3533 | - } elseif ( $operator === 'LIKE' && ! is_array( $value ) ) { |
|
3533 | + } elseif ($operator === 'LIKE' && ! is_array($value)) { |
|
3534 | 3534 | //if the operator is 'LIKE', we want to allow percent signs (%) and not |
3535 | 3535 | //remove other junk. So just treat it as a string. |
3536 | - return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' ); |
|
3537 | - } elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) { |
|
3538 | - return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj ); |
|
3539 | - } elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) { |
|
3536 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s'); |
|
3537 | + } elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3538 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj); |
|
3539 | + } elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3540 | 3540 | throw new EE_Error( |
3541 | 3541 | sprintf( |
3542 | 3542 | __( |
@@ -3547,7 +3547,7 @@ discard block |
||
3547 | 3547 | $operator |
3548 | 3548 | ) |
3549 | 3549 | ); |
3550 | - } elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) { |
|
3550 | + } elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3551 | 3551 | throw new EE_Error( |
3552 | 3552 | sprintf( |
3553 | 3553 | __( |
@@ -3565,7 +3565,7 @@ discard block |
||
3565 | 3565 | "It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", |
3566 | 3566 | "event_espresso" |
3567 | 3567 | ), |
3568 | - http_build_query( $op_and_value ) |
|
3568 | + http_build_query($op_and_value) |
|
3569 | 3569 | ) |
3570 | 3570 | ); |
3571 | 3571 | } |
@@ -3581,12 +3581,12 @@ discard block |
||
3581 | 3581 | * @return string |
3582 | 3582 | * @throws \EE_Error |
3583 | 3583 | */ |
3584 | - public function _construct_between_value( $values, $field_obj ) { |
|
3584 | + public function _construct_between_value($values, $field_obj) { |
|
3585 | 3585 | $cleaned_values = array(); |
3586 | - foreach ( $values as $value ) { |
|
3587 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3586 | + foreach ($values as $value) { |
|
3587 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3588 | 3588 | } |
3589 | - return $cleaned_values[0] . " AND " . $cleaned_values[1]; |
|
3589 | + return $cleaned_values[0]." AND ".$cleaned_values[1]; |
|
3590 | 3590 | } |
3591 | 3591 | |
3592 | 3592 | |
@@ -3603,26 +3603,26 @@ discard block |
||
3603 | 3603 | * @return string of SQL to follow an 'IN' or 'NOT IN' operator |
3604 | 3604 | * @throws \EE_Error |
3605 | 3605 | */ |
3606 | - public function _construct_in_value($values, $field_obj){ |
|
3606 | + public function _construct_in_value($values, $field_obj) { |
|
3607 | 3607 | //check if the value is a CSV list |
3608 | - if(is_string($values)){ |
|
3608 | + if (is_string($values)) { |
|
3609 | 3609 | //in which case, turn it into an array |
3610 | - $values = explode(",",$values); |
|
3610 | + $values = explode(",", $values); |
|
3611 | 3611 | } |
3612 | 3612 | $cleaned_values = array(); |
3613 | - foreach($values as $value){ |
|
3614 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3613 | + foreach ($values as $value) { |
|
3614 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3615 | 3615 | } |
3616 | 3616 | //we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()", |
3617 | 3617 | //but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set |
3618 | 3618 | //which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns |
3619 | - if(empty($cleaned_values)){ |
|
3619 | + if (empty($cleaned_values)) { |
|
3620 | 3620 | $all_fields = $this->field_settings(); |
3621 | 3621 | $a_field = array_shift($all_fields); |
3622 | 3622 | $main_table = $this->_get_main_table(); |
3623 | 3623 | $cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE"; |
3624 | 3624 | } |
3625 | - return "(".implode(",",$cleaned_values).")"; |
|
3625 | + return "(".implode(",", $cleaned_values).")"; |
|
3626 | 3626 | } |
3627 | 3627 | |
3628 | 3628 | |
@@ -3634,16 +3634,16 @@ discard block |
||
3634 | 3634 | * @throws EE_Error |
3635 | 3635 | * @return false|null|string |
3636 | 3636 | */ |
3637 | - private function _wpdb_prepare_using_field($value,$field_obj){ |
|
3637 | + private function _wpdb_prepare_using_field($value, $field_obj) { |
|
3638 | 3638 | /** @type WPDB $wpdb */ |
3639 | 3639 | global $wpdb; |
3640 | - if($field_obj instanceof EE_Model_Field_Base){ |
|
3641 | - return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3642 | - }else{//$field_obj should really just be a data type |
|
3643 | - if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
|
3644 | - throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
|
3640 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
3641 | + return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3642 | + } else {//$field_obj should really just be a data type |
|
3643 | + if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) { |
|
3644 | + throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types))); |
|
3645 | 3645 | } |
3646 | - return $wpdb->prepare($field_obj,$value); |
|
3646 | + return $wpdb->prepare($field_obj, $value); |
|
3647 | 3647 | } |
3648 | 3648 | } |
3649 | 3649 | |
@@ -3655,27 +3655,27 @@ discard block |
||
3655 | 3655 | * @throws EE_Error |
3656 | 3656 | * @return EE_Model_Field_Base |
3657 | 3657 | */ |
3658 | - protected function _deduce_field_from_query_param($query_param_name){ |
|
3658 | + protected function _deduce_field_from_query_param($query_param_name) { |
|
3659 | 3659 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
3660 | 3660 | //which will help us find the database table and column |
3661 | 3661 | |
3662 | - $query_param_parts = explode(".",$query_param_name); |
|
3663 | - if(empty($query_param_parts)){ |
|
3664 | - throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
3662 | + $query_param_parts = explode(".", $query_param_name); |
|
3663 | + if (empty($query_param_parts)) { |
|
3664 | + throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
3665 | 3665 | } |
3666 | 3666 | $number_of_parts = count($query_param_parts); |
3667 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
3668 | - if($number_of_parts === 1){ |
|
3667 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
3668 | + if ($number_of_parts === 1) { |
|
3669 | 3669 | $field_name = $last_query_param_part; |
3670 | 3670 | $model_obj = $this; |
3671 | - }else{// $number_of_parts >= 2 |
|
3671 | + } else {// $number_of_parts >= 2 |
|
3672 | 3672 | //the last part is the column name, and there are only 2parts. therefore... |
3673 | 3673 | $field_name = $last_query_param_part; |
3674 | - $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
|
3674 | + $model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]); |
|
3675 | 3675 | } |
3676 | - try{ |
|
3676 | + try { |
|
3677 | 3677 | return $model_obj->field_settings_for($field_name); |
3678 | - }catch(EE_Error $e){ |
|
3678 | + } catch (EE_Error $e) { |
|
3679 | 3679 | return null; |
3680 | 3680 | } |
3681 | 3681 | } |
@@ -3689,13 +3689,13 @@ discard block |
||
3689 | 3689 | * @throws EE_Error |
3690 | 3690 | * @return string |
3691 | 3691 | */ |
3692 | - public function _get_qualified_column_for_field($field_name){ |
|
3692 | + public function _get_qualified_column_for_field($field_name) { |
|
3693 | 3693 | $all_fields = $this->field_settings(); |
3694 | 3694 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
3695 | - if($field){ |
|
3695 | + if ($field) { |
|
3696 | 3696 | return $field->get_qualified_column(); |
3697 | - }else{ |
|
3698 | - throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
|
3697 | + } else { |
|
3698 | + throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this))); |
|
3699 | 3699 | } |
3700 | 3700 | } |
3701 | 3701 | |
@@ -3709,17 +3709,17 @@ discard block |
||
3709 | 3709 | * @param mixed|string $limit The limit for this select |
3710 | 3710 | * @return string The final select join element for the query. |
3711 | 3711 | */ |
3712 | - public function _construct_limit_join_select( $table_alias, $limit ) { |
|
3712 | + public function _construct_limit_join_select($table_alias, $limit) { |
|
3713 | 3713 | $SQL = ''; |
3714 | - foreach ( $this->_tables as $table_obj ) { |
|
3715 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
3714 | + foreach ($this->_tables as $table_obj) { |
|
3715 | + if ($table_obj instanceof EE_Primary_Table) { |
|
3716 | 3716 | $SQL .= $table_alias === $table_obj->get_table_alias() |
3717 | - ? $table_obj->get_select_join_limit( $limit ) |
|
3718 | - : SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP; |
|
3719 | - } elseif ( $table_obj instanceof EE_Secondary_Table ) { |
|
3717 | + ? $table_obj->get_select_join_limit($limit) |
|
3718 | + : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
3719 | + } elseif ($table_obj instanceof EE_Secondary_Table) { |
|
3720 | 3720 | $SQL .= $table_alias === $table_obj->get_table_alias() |
3721 | - ? $table_obj->get_select_join_limit_join( $limit ) |
|
3722 | - : SP . $table_obj->get_join_sql( $table_alias ) . SP; |
|
3721 | + ? $table_obj->get_select_join_limit_join($limit) |
|
3722 | + : SP.$table_obj->get_join_sql($table_alias).SP; |
|
3723 | 3723 | } |
3724 | 3724 | } |
3725 | 3725 | return $SQL; |
@@ -3734,7 +3734,7 @@ discard block |
||
3734 | 3734 | * @return string SQL |
3735 | 3735 | * @throws \EE_Error |
3736 | 3736 | */ |
3737 | - public function _construct_internal_join(){ |
|
3737 | + public function _construct_internal_join() { |
|
3738 | 3738 | $SQL = $this->_get_main_table()->get_table_sql(); |
3739 | 3739 | $SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias()); |
3740 | 3740 | return $SQL; |
@@ -3755,17 +3755,17 @@ discard block |
||
3755 | 3755 | * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause) |
3756 | 3756 | * @return string |
3757 | 3757 | */ |
3758 | - public function _construct_internal_join_to_table_with_alias($alias_prefixed){ |
|
3758 | + public function _construct_internal_join_to_table_with_alias($alias_prefixed) { |
|
3759 | 3759 | $SQL = ''; |
3760 | 3760 | $alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed); |
3761 | - foreach($this->_tables as $table_obj){ |
|
3762 | - if($table_obj instanceof EE_Secondary_Table){//table is secondary table |
|
3763 | - if($alias_sans_prefix === $table_obj->get_table_alias()){ |
|
3761 | + foreach ($this->_tables as $table_obj) { |
|
3762 | + if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table |
|
3763 | + if ($alias_sans_prefix === $table_obj->get_table_alias()) { |
|
3764 | 3764 | //so we're joining to this table, meaning the table is already in |
3765 | 3765 | //the FROM statement, BUT the primary table isn't. So we want |
3766 | 3766 | //to add the inverse join sql |
3767 | 3767 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
3768 | - }else{ |
|
3768 | + } else { |
|
3769 | 3769 | //just add a regular JOIN to this table from the primary table |
3770 | 3770 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
3771 | 3771 | } |
@@ -3779,9 +3779,9 @@ discard block |
||
3779 | 3779 | * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc) |
3780 | 3780 | * @return array |
3781 | 3781 | */ |
3782 | - public function _get_data_types(){ |
|
3782 | + public function _get_data_types() { |
|
3783 | 3783 | $data_types = array(); |
3784 | - foreach( $this->field_settings() as $field_obj){ |
|
3784 | + foreach ($this->field_settings() as $field_obj) { |
|
3785 | 3785 | //$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type(); |
3786 | 3786 | /** @var $field_obj EE_Model_Field_Base */ |
3787 | 3787 | $data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type(); |
@@ -3797,10 +3797,10 @@ discard block |
||
3797 | 3797 | * @throws EE_Error |
3798 | 3798 | * @return EEM_Base |
3799 | 3799 | */ |
3800 | - public function get_related_model_obj($model_name){ |
|
3800 | + public function get_related_model_obj($model_name) { |
|
3801 | 3801 | $model_classname = "EEM_".$model_name; |
3802 | - if(!class_exists($model_classname)){ |
|
3803 | - throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname)); |
|
3802 | + if ( ! class_exists($model_classname)) { |
|
3803 | + throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname)); |
|
3804 | 3804 | } |
3805 | 3805 | return call_user_func($model_classname."::instance"); |
3806 | 3806 | } |
@@ -3810,7 +3810,7 @@ discard block |
||
3810 | 3810 | * Returns the array of EE_ModelRelations for this model. |
3811 | 3811 | * @return EE_Model_Relation_Base[] |
3812 | 3812 | */ |
3813 | - public function relation_settings(){ |
|
3813 | + public function relation_settings() { |
|
3814 | 3814 | return $this->_model_relations; |
3815 | 3815 | } |
3816 | 3816 | |
@@ -3820,10 +3820,10 @@ discard block |
||
3820 | 3820 | * (Eg, without an event, datetimes have little purpose.) |
3821 | 3821 | * @return EE_Belongs_To_Relation[] |
3822 | 3822 | */ |
3823 | - public function belongs_to_relations(){ |
|
3823 | + public function belongs_to_relations() { |
|
3824 | 3824 | $belongs_to_relations = array(); |
3825 | - foreach($this->relation_settings() as $model_name => $relation_obj){ |
|
3826 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
3825 | + foreach ($this->relation_settings() as $model_name => $relation_obj) { |
|
3826 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
3827 | 3827 | $belongs_to_relations[$model_name] = $relation_obj; |
3828 | 3828 | } |
3829 | 3829 | } |
@@ -3838,15 +3838,15 @@ discard block |
||
3838 | 3838 | * @throws EE_Error |
3839 | 3839 | * @return EE_Model_Relation_Base |
3840 | 3840 | */ |
3841 | - public function related_settings_for($relation_name){ |
|
3842 | - $relatedModels=$this->relation_settings(); |
|
3843 | - if(!array_key_exists($relation_name,$relatedModels)){ |
|
3841 | + public function related_settings_for($relation_name) { |
|
3842 | + $relatedModels = $this->relation_settings(); |
|
3843 | + if ( ! array_key_exists($relation_name, $relatedModels)) { |
|
3844 | 3844 | throw new EE_Error( |
3845 | 3845 | sprintf( |
3846 | - __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'), |
|
3846 | + __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'), |
|
3847 | 3847 | $relation_name, |
3848 | 3848 | $this->_get_class_name(), |
3849 | - implode( ', ', array_keys( $relatedModels )) |
|
3849 | + implode(', ', array_keys($relatedModels)) |
|
3850 | 3850 | ) |
3851 | 3851 | ); |
3852 | 3852 | } |
@@ -3861,10 +3861,10 @@ discard block |
||
3861 | 3861 | * @throws EE_Error |
3862 | 3862 | * @return EE_Model_Field_Base |
3863 | 3863 | */ |
3864 | - public function field_settings_for($fieldName){ |
|
3865 | - $fieldSettings=$this->field_settings(true); |
|
3866 | - if( ! array_key_exists($fieldName,$fieldSettings)){ |
|
3867 | - throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this))); |
|
3864 | + public function field_settings_for($fieldName) { |
|
3865 | + $fieldSettings = $this->field_settings(true); |
|
3866 | + if ( ! array_key_exists($fieldName, $fieldSettings)) { |
|
3867 | + throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this))); |
|
3868 | 3868 | } |
3869 | 3869 | return $fieldSettings[$fieldName]; |
3870 | 3870 | } |
@@ -3874,11 +3874,11 @@ discard block |
||
3874 | 3874 | * @param string $fieldName a key in the model's _field_settings array |
3875 | 3875 | * @return boolean |
3876 | 3876 | */ |
3877 | - public function has_field($fieldName){ |
|
3877 | + public function has_field($fieldName) { |
|
3878 | 3878 | $fieldSettings = $this->field_settings(true); |
3879 | - if( isset($fieldSettings[$fieldName])){ |
|
3879 | + if (isset($fieldSettings[$fieldName])) { |
|
3880 | 3880 | return true; |
3881 | - }else{ |
|
3881 | + } else { |
|
3882 | 3882 | return false; |
3883 | 3883 | } |
3884 | 3884 | } |
@@ -3888,11 +3888,11 @@ discard block |
||
3888 | 3888 | * @param string $relation_name possibly one of the keys in the relation_settings array |
3889 | 3889 | * @return boolean |
3890 | 3890 | */ |
3891 | - public function has_relation($relation_name){ |
|
3891 | + public function has_relation($relation_name) { |
|
3892 | 3892 | $relations = $this->relation_settings(); |
3893 | - if(isset($relations[$relation_name])){ |
|
3893 | + if (isset($relations[$relation_name])) { |
|
3894 | 3894 | return true; |
3895 | - }else{ |
|
3895 | + } else { |
|
3896 | 3896 | return false; |
3897 | 3897 | } |
3898 | 3898 | } |
@@ -3904,7 +3904,7 @@ discard block |
||
3904 | 3904 | * @param $field_obj |
3905 | 3905 | * @return boolean |
3906 | 3906 | */ |
3907 | - public function is_primary_key_field( $field_obj ){ |
|
3907 | + public function is_primary_key_field($field_obj) { |
|
3908 | 3908 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
3909 | 3909 | } |
3910 | 3910 | |
@@ -3916,16 +3916,16 @@ discard block |
||
3916 | 3916 | * @return EE_Model_Field_Base |
3917 | 3917 | * @throws EE_Error |
3918 | 3918 | */ |
3919 | - public function get_primary_key_field(){ |
|
3920 | - if( $this->_primary_key_field === NULL ){ |
|
3921 | - foreach( $this->field_settings( TRUE ) as $field_obj ){ |
|
3922 | - if( $this->is_primary_key_field( $field_obj )){ |
|
3919 | + public function get_primary_key_field() { |
|
3920 | + if ($this->_primary_key_field === NULL) { |
|
3921 | + foreach ($this->field_settings(TRUE) as $field_obj) { |
|
3922 | + if ($this->is_primary_key_field($field_obj)) { |
|
3923 | 3923 | $this->_primary_key_field = $field_obj; |
3924 | 3924 | break; |
3925 | 3925 | } |
3926 | 3926 | } |
3927 | - if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){ |
|
3928 | - throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this))); |
|
3927 | + if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) { |
|
3928 | + throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this))); |
|
3929 | 3929 | } |
3930 | 3930 | } |
3931 | 3931 | return $this->_primary_key_field; |
@@ -3938,12 +3938,12 @@ discard block |
||
3938 | 3938 | * Internally does some caching. |
3939 | 3939 | * @return boolean |
3940 | 3940 | */ |
3941 | - public function has_primary_key_field(){ |
|
3942 | - if($this->_has_primary_key_field === null){ |
|
3943 | - try{ |
|
3941 | + public function has_primary_key_field() { |
|
3942 | + if ($this->_has_primary_key_field === null) { |
|
3943 | + try { |
|
3944 | 3944 | $this->get_primary_key_field(); |
3945 | 3945 | $this->_has_primary_key_field = true; |
3946 | - }catch(EE_Error $e){ |
|
3946 | + } catch (EE_Error $e) { |
|
3947 | 3947 | $this->_has_primary_key_field = false; |
3948 | 3948 | } |
3949 | 3949 | } |
@@ -3957,9 +3957,9 @@ discard block |
||
3957 | 3957 | * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc |
3958 | 3958 | * @return EE_Model_Field_Base or null if none is found |
3959 | 3959 | */ |
3960 | - public function get_a_field_of_type($field_class_name){ |
|
3961 | - foreach($this->field_settings() as $field){ |
|
3962 | - if( $field instanceof $field_class_name ){ |
|
3960 | + public function get_a_field_of_type($field_class_name) { |
|
3961 | + foreach ($this->field_settings() as $field) { |
|
3962 | + if ($field instanceof $field_class_name) { |
|
3963 | 3963 | return $field; |
3964 | 3964 | } |
3965 | 3965 | } |
@@ -3973,22 +3973,22 @@ discard block |
||
3973 | 3973 | * @return EE_Foreign_Key_Field_Base |
3974 | 3974 | * @throws EE_Error |
3975 | 3975 | */ |
3976 | - public function get_foreign_key_to($model_name){ |
|
3977 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3978 | - foreach($this->field_settings() as $field){ |
|
3979 | - if( |
|
3976 | + public function get_foreign_key_to($model_name) { |
|
3977 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3978 | + foreach ($this->field_settings() as $field) { |
|
3979 | + if ( |
|
3980 | 3980 | $field instanceof EE_Foreign_Key_Field_Base |
3981 | - && in_array($model_name,$field->get_model_names_pointed_to() ) |
|
3981 | + && in_array($model_name, $field->get_model_names_pointed_to()) |
|
3982 | 3982 | ) { |
3983 | - $this->_cache_foreign_key_to_fields[ $model_name ] = $field; |
|
3983 | + $this->_cache_foreign_key_to_fields[$model_name] = $field; |
|
3984 | 3984 | break; |
3985 | 3985 | } |
3986 | 3986 | } |
3987 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3988 | - throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this))); |
|
3987 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3988 | + throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this))); |
|
3989 | 3989 | } |
3990 | 3990 | } |
3991 | - return $this->_cache_foreign_key_to_fields[ $model_name ]; |
|
3991 | + return $this->_cache_foreign_key_to_fields[$model_name]; |
|
3992 | 3992 | } |
3993 | 3993 | |
3994 | 3994 | |
@@ -3999,7 +3999,7 @@ discard block |
||
3999 | 3999 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
4000 | 4000 | * @return EE_Table_Base |
4001 | 4001 | */ |
4002 | - public function get_table_for_alias($table_alias){ |
|
4002 | + public function get_table_for_alias($table_alias) { |
|
4003 | 4003 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
4004 | 4004 | return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name(); |
4005 | 4005 | } |
@@ -4012,25 +4012,25 @@ discard block |
||
4012 | 4012 | * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields |
4013 | 4013 | * @return EE_Model_Field_Base[] where the keys are the field's name |
4014 | 4014 | */ |
4015 | - public function field_settings($include_db_only_fields = false){ |
|
4016 | - if( $include_db_only_fields ){ |
|
4017 | - if( $this->_cached_fields === NULL ){ |
|
4015 | + public function field_settings($include_db_only_fields = false) { |
|
4016 | + if ($include_db_only_fields) { |
|
4017 | + if ($this->_cached_fields === NULL) { |
|
4018 | 4018 | $this->_cached_fields = array(); |
4019 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
4020 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
4021 | - $this->_cached_fields[$field_name]=$field_obj; |
|
4019 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
4020 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
4021 | + $this->_cached_fields[$field_name] = $field_obj; |
|
4022 | 4022 | } |
4023 | 4023 | } |
4024 | 4024 | } |
4025 | 4025 | return $this->_cached_fields; |
4026 | - }else{ |
|
4027 | - if( $this->_cached_fields_non_db_only === NULL ){ |
|
4026 | + } else { |
|
4027 | + if ($this->_cached_fields_non_db_only === NULL) { |
|
4028 | 4028 | $this->_cached_fields_non_db_only = array(); |
4029 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
4030 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
4029 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
4030 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
4031 | 4031 | /** @var $field_obj EE_Model_Field_Base */ |
4032 | - if( ! $field_obj->is_db_only_field() ){ |
|
4033 | - $this->_cached_fields_non_db_only[$field_name]=$field_obj; |
|
4032 | + if ( ! $field_obj->is_db_only_field()) { |
|
4033 | + $this->_cached_fields_non_db_only[$field_name] = $field_obj; |
|
4034 | 4034 | } |
4035 | 4035 | } |
4036 | 4036 | } |
@@ -4049,60 +4049,60 @@ discard block |
||
4049 | 4049 | * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed) |
4050 | 4050 | * @throws \EE_Error |
4051 | 4051 | */ |
4052 | - protected function _create_objects( $rows = array() ) { |
|
4053 | - $array_of_objects=array(); |
|
4054 | - if(empty($rows)){ |
|
4052 | + protected function _create_objects($rows = array()) { |
|
4053 | + $array_of_objects = array(); |
|
4054 | + if (empty($rows)) { |
|
4055 | 4055 | return array(); |
4056 | 4056 | } |
4057 | 4057 | $count_if_model_has_no_primary_key = 0; |
4058 | 4058 | $has_primary_key = $this->has_primary_key_field(); |
4059 | 4059 | $primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null; |
4060 | - foreach ( (array)$rows as $row ) { |
|
4061 | - if(empty($row)){ |
|
4060 | + foreach ((array) $rows as $row) { |
|
4061 | + if (empty($row)) { |
|
4062 | 4062 | //wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful... |
4063 | 4063 | return array(); |
4064 | 4064 | } |
4065 | 4065 | //check if we've already set this object in the results array, |
4066 | 4066 | //in which case there's no need to process it further (again) |
4067 | - if( $has_primary_key ) { |
|
4067 | + if ($has_primary_key) { |
|
4068 | 4068 | $table_pk_value = $this->_get_column_value_with_table_alias_or_not( |
4069 | 4069 | $row, |
4070 | 4070 | $primary_key_field->get_qualified_column(), |
4071 | 4071 | $primary_key_field->get_table_column() |
4072 | 4072 | ); |
4073 | - if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) { |
|
4073 | + if ($table_pk_value && isset($array_of_objects[$table_pk_value])) { |
|
4074 | 4074 | continue; |
4075 | 4075 | } |
4076 | 4076 | } |
4077 | 4077 | $classInstance = $this->instantiate_class_from_array_or_object($row); |
4078 | - if( ! $classInstance ) { |
|
4078 | + if ( ! $classInstance) { |
|
4079 | 4079 | throw new EE_Error( |
4080 | 4080 | sprintf( |
4081 | - __( 'Could not create instance of class %s from row %s', 'event_espresso' ), |
|
4081 | + __('Could not create instance of class %s from row %s', 'event_espresso'), |
|
4082 | 4082 | $this->get_this_model_name(), |
4083 | - http_build_query( $row ) |
|
4083 | + http_build_query($row) |
|
4084 | 4084 | ) |
4085 | 4085 | ); |
4086 | 4086 | } |
4087 | 4087 | //set the timezone on the instantiated objects |
4088 | - $classInstance->set_timezone( $this->_timezone ); |
|
4088 | + $classInstance->set_timezone($this->_timezone); |
|
4089 | 4089 | //make sure if there is any timezone setting present that we set the timezone for the object |
4090 | 4090 | $key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++; |
4091 | - $array_of_objects[ $key ] = $classInstance; |
|
4091 | + $array_of_objects[$key] = $classInstance; |
|
4092 | 4092 | //also, for all the relations of type BelongsTo, see if we can cache |
4093 | 4093 | //those related models |
4094 | 4094 | //(we could do this for other relations too, but if there are conditions |
4095 | 4095 | //that filtered out some fo the results, then we'd be caching an incomplete set |
4096 | 4096 | //so it requires a little more thought than just caching them immediately...) |
4097 | - foreach($this->_model_relations as $modelName => $relation_obj){ |
|
4098 | - if( $relation_obj instanceof EE_Belongs_To_Relation){ |
|
4097 | + foreach ($this->_model_relations as $modelName => $relation_obj) { |
|
4098 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
4099 | 4099 | //check if this model's INFO is present. If so, cache it on the model |
4100 | 4100 | $other_model = $relation_obj->get_other_model(); |
4101 | 4101 | $other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row); |
4102 | 4102 | //if we managed to make a model object from the results, cache it on the main model object |
4103 | - if( $other_model_obj_maybe ){ |
|
4103 | + if ($other_model_obj_maybe) { |
|
4104 | 4104 | //set timezone on these other model objects if they are present |
4105 | - $other_model_obj_maybe->set_timezone( $this->_timezone ); |
|
4105 | + $other_model_obj_maybe->set_timezone($this->_timezone); |
|
4106 | 4106 | $classInstance->cache($modelName, $other_model_obj_maybe); |
4107 | 4107 | } |
4108 | 4108 | } |
@@ -4123,12 +4123,12 @@ discard block |
||
4123 | 4123 | |
4124 | 4124 | $this_model_fields_and_values = array(); |
4125 | 4125 | //setup the row using default values; |
4126 | - foreach ( $this->field_settings() as $field_name => $field_obj ) { |
|
4126 | + foreach ($this->field_settings() as $field_name => $field_obj) { |
|
4127 | 4127 | $this_model_fields_and_values[$field_name] = $field_obj->get_default_value(); |
4128 | 4128 | } |
4129 | 4129 | |
4130 | 4130 | $className = $this->_get_class_name(); |
4131 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE ); |
|
4131 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE); |
|
4132 | 4132 | |
4133 | 4133 | return $classInstance; |
4134 | 4134 | } |
@@ -4141,45 +4141,45 @@ discard block |
||
4141 | 4141 | * @return EE_Base_Class |
4142 | 4142 | * @throws \EE_Error |
4143 | 4143 | */ |
4144 | - public function instantiate_class_from_array_or_object($cols_n_values){ |
|
4145 | - if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) { |
|
4146 | - $cols_n_values = get_object_vars( $cols_n_values ); |
|
4144 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
4145 | + if ( ! is_array($cols_n_values) && is_object($cols_n_values)) { |
|
4146 | + $cols_n_values = get_object_vars($cols_n_values); |
|
4147 | 4147 | } |
4148 | 4148 | $primary_key = NULL; |
4149 | 4149 | //make sure the array only has keys that are fields/columns on this model |
4150 | - $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
4151 | - if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){ |
|
4152 | - $primary_key = $this_model_fields_n_values[ $this->primary_key_name() ]; |
|
4150 | + $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
4151 | + if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) { |
|
4152 | + $primary_key = $this_model_fields_n_values[$this->primary_key_name()]; |
|
4153 | 4153 | } |
4154 | - $className=$this->_get_class_name(); |
|
4154 | + $className = $this->_get_class_name(); |
|
4155 | 4155 | |
4156 | 4156 | //check we actually found results that we can use to build our model object |
4157 | 4157 | //if not, return null |
4158 | - if( $this->has_primary_key_field()){ |
|
4159 | - if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
|
4158 | + if ($this->has_primary_key_field()) { |
|
4159 | + if (empty($this_model_fields_n_values[$this->primary_key_name()])) { |
|
4160 | 4160 | return NULL; |
4161 | 4161 | } |
4162 | - }else if($this->unique_indexes()){ |
|
4162 | + } else if ($this->unique_indexes()) { |
|
4163 | 4163 | $first_column = reset($this_model_fields_n_values); |
4164 | - if(empty($first_column)){ |
|
4164 | + if (empty($first_column)) { |
|
4165 | 4165 | return NULL; |
4166 | 4166 | } |
4167 | 4167 | } |
4168 | 4168 | |
4169 | 4169 | // if there is no primary key or the object doesn't already exist in the entity map, then create a new instance |
4170 | - if ( $primary_key){ |
|
4171 | - $classInstance = $this->get_from_entity_map( $primary_key ); |
|
4172 | - if( ! $classInstance) { |
|
4173 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
4170 | + if ($primary_key) { |
|
4171 | + $classInstance = $this->get_from_entity_map($primary_key); |
|
4172 | + if ( ! $classInstance) { |
|
4173 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
4174 | 4174 | // add this new object to the entity map |
4175 | - $classInstance = $this->add_to_entity_map( $classInstance ); |
|
4175 | + $classInstance = $this->add_to_entity_map($classInstance); |
|
4176 | 4176 | } |
4177 | - }else{ |
|
4178 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
4177 | + } else { |
|
4178 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
4179 | 4179 | } |
4180 | 4180 | |
4181 | 4181 | //it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example). In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property. |
4182 | - $this->set_timezone( $classInstance->get_timezone() ); |
|
4182 | + $this->set_timezone($classInstance->get_timezone()); |
|
4183 | 4183 | return $classInstance; |
4184 | 4184 | } |
4185 | 4185 | /** |
@@ -4187,8 +4187,8 @@ discard block |
||
4187 | 4187 | * @param int|string $id the ID of the model object |
4188 | 4188 | * @return EE_Base_Class |
4189 | 4189 | */ |
4190 | - public function get_from_entity_map( $id ){ |
|
4191 | - return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL; |
|
4190 | + public function get_from_entity_map($id) { |
|
4191 | + return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL; |
|
4192 | 4192 | } |
4193 | 4193 | |
4194 | 4194 | |
@@ -4210,21 +4210,21 @@ discard block |
||
4210 | 4210 | * @throws EE_Error |
4211 | 4211 | * @return \EE_Base_Class |
4212 | 4212 | */ |
4213 | - public function add_to_entity_map( EE_Base_Class $object) { |
|
4213 | + public function add_to_entity_map(EE_Base_Class $object) { |
|
4214 | 4214 | $className = $this->_get_class_name(); |
4215 | - if( ! $object instanceof $className ){ |
|
4216 | - throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) ); |
|
4215 | + if ( ! $object instanceof $className) { |
|
4216 | + throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className)); |
|
4217 | 4217 | } |
4218 | 4218 | /** @var $object EE_Base_Class */ |
4219 | - if ( ! $object->ID() ){ |
|
4220 | - throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this))); |
|
4219 | + if ( ! $object->ID()) { |
|
4220 | + throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this))); |
|
4221 | 4221 | } |
4222 | 4222 | // double check it's not already there |
4223 | - $classInstance = $this->get_from_entity_map( $object->ID() ); |
|
4224 | - if ( $classInstance ) { |
|
4223 | + $classInstance = $this->get_from_entity_map($object->ID()); |
|
4224 | + if ($classInstance) { |
|
4225 | 4225 | return $classInstance; |
4226 | 4226 | } else { |
4227 | - $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object; |
|
4227 | + $this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object; |
|
4228 | 4228 | return $object; |
4229 | 4229 | } |
4230 | 4230 | } |
@@ -4238,13 +4238,13 @@ discard block |
||
4238 | 4238 | * @param int|string $id the ID of the model object |
4239 | 4239 | * @return boolean |
4240 | 4240 | */ |
4241 | - public function clear_entity_map( $id = null ) { |
|
4242 | - if ( empty( $id ) ) { |
|
4243 | - $this->_entity_map[ EEM_Base::$_model_query_blog_id ] = array(); |
|
4241 | + public function clear_entity_map($id = null) { |
|
4242 | + if (empty($id)) { |
|
4243 | + $this->_entity_map[EEM_Base::$_model_query_blog_id] = array(); |
|
4244 | 4244 | return true; |
4245 | 4245 | } |
4246 | - if ( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ) { |
|
4247 | - unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ); |
|
4246 | + if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id])) { |
|
4247 | + unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]); |
|
4248 | 4248 | return true; |
4249 | 4249 | } |
4250 | 4250 | return false; |
@@ -4260,8 +4260,8 @@ discard block |
||
4260 | 4260 | * @param array $cols_n_values |
4261 | 4261 | * @return array |
4262 | 4262 | */ |
4263 | - public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) { |
|
4264 | - return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
4263 | + public function deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
4264 | + return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
4265 | 4265 | } |
4266 | 4266 | |
4267 | 4267 | |
@@ -4274,23 +4274,23 @@ discard block |
||
4274 | 4274 | * @param string $cols_n_values |
4275 | 4275 | * @return array |
4276 | 4276 | */ |
4277 | - protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){ |
|
4277 | + protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
4278 | 4278 | $this_model_fields_n_values = array(); |
4279 | - foreach( $this->get_tables() as $table_alias => $table_obj ) { |
|
4280 | - $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() ); |
|
4279 | + foreach ($this->get_tables() as $table_alias => $table_obj) { |
|
4280 | + $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column()); |
|
4281 | 4281 | //there is a primary key on this table and its not set. Use defaults for all its columns |
4282 | - if( $table_pk_value === null && $table_obj->get_pk_column() ){ |
|
4283 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
4284 | - if( ! $field_obj->is_db_only_field() ){ |
|
4282 | + if ($table_pk_value === null && $table_obj->get_pk_column()) { |
|
4283 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
4284 | + if ( ! $field_obj->is_db_only_field()) { |
|
4285 | 4285 | //prepare field as if its coming from db |
4286 | - $prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() ); |
|
4287 | - $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
|
4286 | + $prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value()); |
|
4287 | + $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value); |
|
4288 | 4288 | } |
4289 | 4289 | } |
4290 | - }else{ |
|
4290 | + } else { |
|
4291 | 4291 | //the table's rows existed. Use their values |
4292 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
4293 | - if( ! $field_obj->is_db_only_field() ){ |
|
4292 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
4293 | + if ( ! $field_obj->is_db_only_field()) { |
|
4294 | 4294 | $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not( |
4295 | 4295 | $cols_n_values, $field_obj->get_qualified_column(), |
4296 | 4296 | $field_obj->get_table_column() |
@@ -4310,15 +4310,15 @@ discard block |
||
4310 | 4310 | * @param $regular_column |
4311 | 4311 | * @return null |
4312 | 4312 | */ |
4313 | - protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){ |
|
4313 | + protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) { |
|
4314 | 4314 | $value = null; |
4315 | 4315 | //ask the field what it think it's table_name.column_name should be, and call it the "qualified column" |
4316 | 4316 | //does the field on the model relate to this column retrieved from the db? |
4317 | 4317 | //or is it a db-only field? (not relating to the model) |
4318 | - if( isset( $cols_n_values[ $qualified_column ] ) ){ |
|
4319 | - $value = $cols_n_values[ $qualified_column ]; |
|
4320 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4321 | - $value = $cols_n_values[ $regular_column ]; |
|
4318 | + if (isset($cols_n_values[$qualified_column])) { |
|
4319 | + $value = $cols_n_values[$qualified_column]; |
|
4320 | + }elseif (isset($cols_n_values[$regular_column])) { |
|
4321 | + $value = $cols_n_values[$regular_column]; |
|
4322 | 4322 | } |
4323 | 4323 | return $value; |
4324 | 4324 | } |
@@ -4334,25 +4334,25 @@ discard block |
||
4334 | 4334 | * @return EE_Base_Class |
4335 | 4335 | * @throws \EE_Error |
4336 | 4336 | */ |
4337 | - public function refresh_entity_map_from_db( $id ){ |
|
4338 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
4339 | - if( $obj_in_map ){ |
|
4337 | + public function refresh_entity_map_from_db($id) { |
|
4338 | + $obj_in_map = $this->get_from_entity_map($id); |
|
4339 | + if ($obj_in_map) { |
|
4340 | 4340 | $wpdb_results = $this->_get_all_wpdb_results( |
4341 | - array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) |
|
4341 | + array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1) |
|
4342 | 4342 | ); |
4343 | - if( $wpdb_results && is_array( $wpdb_results ) ){ |
|
4344 | - $one_row = reset( $wpdb_results ); |
|
4345 | - foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) { |
|
4346 | - $obj_in_map->set_from_db( $field_name, $db_value ); |
|
4343 | + if ($wpdb_results && is_array($wpdb_results)) { |
|
4344 | + $one_row = reset($wpdb_results); |
|
4345 | + foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) { |
|
4346 | + $obj_in_map->set_from_db($field_name, $db_value); |
|
4347 | 4347 | } |
4348 | 4348 | //clear the cache of related model objects |
4349 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
4350 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
4349 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
4350 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
4351 | 4351 | } |
4352 | 4352 | } |
4353 | 4353 | return $obj_in_map; |
4354 | - }else{ |
|
4355 | - return $this->get_one_by_ID( $id ); |
|
4354 | + } else { |
|
4355 | + return $this->get_one_by_ID($id); |
|
4356 | 4356 | } |
4357 | 4357 | } |
4358 | 4358 | |
@@ -4370,24 +4370,24 @@ discard block |
||
4370 | 4370 | * @return \EE_Base_Class |
4371 | 4371 | * @throws \EE_Error |
4372 | 4372 | */ |
4373 | - public function refresh_entity_map_with( $id, $replacing_model_obj ) { |
|
4374 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
4375 | - if( $obj_in_map ){ |
|
4376 | - if( $replacing_model_obj instanceof EE_Base_Class ){ |
|
4377 | - foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) { |
|
4378 | - $obj_in_map->set( $field_name, $value ); |
|
4373 | + public function refresh_entity_map_with($id, $replacing_model_obj) { |
|
4374 | + $obj_in_map = $this->get_from_entity_map($id); |
|
4375 | + if ($obj_in_map) { |
|
4376 | + if ($replacing_model_obj instanceof EE_Base_Class) { |
|
4377 | + foreach ($replacing_model_obj->model_field_array() as $field_name => $value) { |
|
4378 | + $obj_in_map->set($field_name, $value); |
|
4379 | 4379 | } |
4380 | 4380 | //make the model object in the entity map's cache match the $replacing_model_obj |
4381 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
4382 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
4383 | - foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) { |
|
4384 | - $obj_in_map->cache( $relation_name, $cached_obj, $cache_id ); |
|
4381 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
4382 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
4383 | + foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) { |
|
4384 | + $obj_in_map->cache($relation_name, $cached_obj, $cache_id); |
|
4385 | 4385 | } |
4386 | 4386 | } |
4387 | 4387 | } |
4388 | 4388 | return $obj_in_map; |
4389 | - }else{ |
|
4390 | - $this->add_to_entity_map( $replacing_model_obj ); |
|
4389 | + } else { |
|
4390 | + $this->add_to_entity_map($replacing_model_obj); |
|
4391 | 4391 | return $replacing_model_obj; |
4392 | 4392 | } |
4393 | 4393 | } |
@@ -4400,7 +4400,7 @@ discard block |
||
4400 | 4400 | * require_once($this->_getClassName().".class.php"); |
4401 | 4401 | * @return string |
4402 | 4402 | */ |
4403 | - private function _get_class_name(){ |
|
4403 | + private function _get_class_name() { |
|
4404 | 4404 | return "EE_".$this->get_this_model_name(); |
4405 | 4405 | } |
4406 | 4406 | |
@@ -4413,8 +4413,8 @@ discard block |
||
4413 | 4413 | * @param int $quantity |
4414 | 4414 | * @return string |
4415 | 4415 | */ |
4416 | - public function item_name($quantity = 1){ |
|
4417 | - return (int)$quantity === 1 ? $this->singular_item : $this->plural_item; |
|
4416 | + public function item_name($quantity = 1) { |
|
4417 | + return (int) $quantity === 1 ? $this->singular_item : $this->plural_item; |
|
4418 | 4418 | } |
4419 | 4419 | |
4420 | 4420 | |
@@ -4441,13 +4441,13 @@ discard block |
||
4441 | 4441 | * @throws EE_Error |
4442 | 4442 | * @return mixed whatever the plugin which calls add_filter decides |
4443 | 4443 | */ |
4444 | - public function __call($methodName,$args){ |
|
4445 | - $className=get_class($this); |
|
4446 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
4447 | - if(!has_filter($tagName)){ |
|
4444 | + public function __call($methodName, $args) { |
|
4445 | + $className = get_class($this); |
|
4446 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
4447 | + if ( ! has_filter($tagName)) { |
|
4448 | 4448 | throw new EE_Error( |
4449 | 4449 | sprintf( |
4450 | - __( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ), |
|
4450 | + __('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'), |
|
4451 | 4451 | $methodName, |
4452 | 4452 | $className, |
4453 | 4453 | $tagName, |
@@ -4456,7 +4456,7 @@ discard block |
||
4456 | 4456 | ); |
4457 | 4457 | } |
4458 | 4458 | |
4459 | - return apply_filters($tagName,null,$this,$args); |
|
4459 | + return apply_filters($tagName, null, $this, $args); |
|
4460 | 4460 | } |
4461 | 4461 | |
4462 | 4462 | |
@@ -4474,28 +4474,28 @@ discard block |
||
4474 | 4474 | * @throws EE_Error |
4475 | 4475 | * @return EE_Base_Class |
4476 | 4476 | */ |
4477 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){ |
|
4477 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
4478 | 4478 | $className = $this->_get_class_name(); |
4479 | - if ( $base_class_obj_or_id instanceof $className ) { |
|
4479 | + if ($base_class_obj_or_id instanceof $className) { |
|
4480 | 4480 | $model_object = $base_class_obj_or_id; |
4481 | 4481 | } else { |
4482 | 4482 | $primary_key_field = $this->get_primary_key_field(); |
4483 | 4483 | if ( |
4484 | 4484 | $primary_key_field instanceof EE_Primary_Key_Int_Field |
4485 | 4485 | && ( |
4486 | - is_int( $base_class_obj_or_id ) |
|
4487 | - || is_string( $base_class_obj_or_id ) |
|
4486 | + is_int($base_class_obj_or_id) |
|
4487 | + || is_string($base_class_obj_or_id) |
|
4488 | 4488 | ) |
4489 | 4489 | ) { |
4490 | 4490 | // assume it's an ID. |
4491 | 4491 | // either a proper integer or a string representing an integer (eg "101" instead of 101) |
4492 | - $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
|
4492 | + $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
|
4493 | 4493 | } else if ( |
4494 | 4494 | $primary_key_field instanceof EE_Primary_Key_String_Field |
4495 | - && is_string( $base_class_obj_or_id ) |
|
4495 | + && is_string($base_class_obj_or_id) |
|
4496 | 4496 | ) { |
4497 | 4497 | // assume its a string representation of the object |
4498 | - $model_object = $this->get_one_by_ID( $base_class_obj_or_id ); |
|
4498 | + $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
|
4499 | 4499 | } else { |
4500 | 4500 | throw new EE_Error( |
4501 | 4501 | sprintf( |
@@ -4505,12 +4505,12 @@ discard block |
||
4505 | 4505 | ), |
4506 | 4506 | $base_class_obj_or_id, |
4507 | 4507 | $this->_get_class_name(), |
4508 | - print_r( $base_class_obj_or_id, true ) |
|
4508 | + print_r($base_class_obj_or_id, true) |
|
4509 | 4509 | ) |
4510 | 4510 | ); |
4511 | 4511 | } |
4512 | 4512 | } |
4513 | - if ( $ensure_is_in_db && $model_object->ID() !== null ) { |
|
4513 | + if ($ensure_is_in_db && $model_object->ID() !== null) { |
|
4514 | 4514 | $model_object->save(); |
4515 | 4515 | } |
4516 | 4516 | return $model_object; |
@@ -4526,19 +4526,19 @@ discard block |
||
4526 | 4526 | * @return int|string depending on the type of this model object's ID |
4527 | 4527 | * @throws EE_Error |
4528 | 4528 | */ |
4529 | - public function ensure_is_ID($base_class_obj_or_id){ |
|
4529 | + public function ensure_is_ID($base_class_obj_or_id) { |
|
4530 | 4530 | $className = $this->_get_class_name(); |
4531 | - if( $base_class_obj_or_id instanceof $className ){ |
|
4531 | + if ($base_class_obj_or_id instanceof $className) { |
|
4532 | 4532 | /** @var $base_class_obj_or_id EE_Base_Class */ |
4533 | 4533 | $id = $base_class_obj_or_id->ID(); |
4534 | - }elseif(is_int($base_class_obj_or_id)){ |
|
4534 | + }elseif (is_int($base_class_obj_or_id)) { |
|
4535 | 4535 | //assume it's an ID |
4536 | 4536 | $id = $base_class_obj_or_id; |
4537 | - }elseif(is_string($base_class_obj_or_id)){ |
|
4537 | + }elseif (is_string($base_class_obj_or_id)) { |
|
4538 | 4538 | //assume its a string representation of the object |
4539 | 4539 | $id = $base_class_obj_or_id; |
4540 | - }else{ |
|
4541 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
4540 | + } else { |
|
4541 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
4542 | 4542 | } |
4543 | 4543 | return $id; |
4544 | 4544 | } |
@@ -4561,14 +4561,14 @@ discard block |
||
4561 | 4561 | * @param int $values_already_prepared like one of the constants on EEM_Base |
4562 | 4562 | * @return void |
4563 | 4563 | */ |
4564 | - public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){ |
|
4564 | + public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) { |
|
4565 | 4565 | $this->_values_already_prepared_by_model_object = $values_already_prepared; |
4566 | 4566 | } |
4567 | 4567 | /** |
4568 | 4568 | * Read comments for assume_values_already_prepared_by_model_object() |
4569 | 4569 | * @return int |
4570 | 4570 | */ |
4571 | - public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
|
4571 | + public function get_assumption_concerning_values_already_prepared_by_model_object() { |
|
4572 | 4572 | return $this->_values_already_prepared_by_model_object; |
4573 | 4573 | } |
4574 | 4574 | |
@@ -4576,17 +4576,17 @@ discard block |
||
4576 | 4576 | * Gets all the indexes on this model |
4577 | 4577 | * @return EE_Index[] |
4578 | 4578 | */ |
4579 | - public function indexes(){ |
|
4579 | + public function indexes() { |
|
4580 | 4580 | return $this->_indexes; |
4581 | 4581 | } |
4582 | 4582 | /** |
4583 | 4583 | * Gets all the Unique Indexes on this model |
4584 | 4584 | * @return EE_Unique_Index[] |
4585 | 4585 | */ |
4586 | - public function unique_indexes(){ |
|
4586 | + public function unique_indexes() { |
|
4587 | 4587 | $unique_indexes = array(); |
4588 | - foreach($this->_indexes as $name => $index){ |
|
4589 | - if($index instanceof EE_Unique_Index){ |
|
4588 | + foreach ($this->_indexes as $name => $index) { |
|
4589 | + if ($index instanceof EE_Unique_Index) { |
|
4590 | 4590 | $unique_indexes [$name] = $index; |
4591 | 4591 | } |
4592 | 4592 | } |
@@ -4604,13 +4604,13 @@ discard block |
||
4604 | 4604 | * @return EE_Model_Field_Base[] indexed by the field's name |
4605 | 4605 | * @throws \EE_Error |
4606 | 4606 | */ |
4607 | - public function get_combined_primary_key_fields(){ |
|
4608 | - foreach($this->indexes() as $index){ |
|
4609 | - if($index instanceof EE_Primary_Key_Index){ |
|
4607 | + public function get_combined_primary_key_fields() { |
|
4608 | + foreach ($this->indexes() as $index) { |
|
4609 | + if ($index instanceof EE_Primary_Key_Index) { |
|
4610 | 4610 | return $index->fields(); |
4611 | 4611 | } |
4612 | 4612 | } |
4613 | - return array( $this->primary_key_name() => $this->get_primary_key_field()); |
|
4613 | + return array($this->primary_key_name() => $this->get_primary_key_field()); |
|
4614 | 4614 | } |
4615 | 4615 | |
4616 | 4616 | |
@@ -4624,7 +4624,7 @@ discard block |
||
4624 | 4624 | * @return string |
4625 | 4625 | * @throws \EE_Error |
4626 | 4626 | */ |
4627 | - public function get_index_primary_key_string($cols_n_values){ |
|
4627 | + public function get_index_primary_key_string($cols_n_values) { |
|
4628 | 4628 | $cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields()); |
4629 | 4629 | return http_build_query($cols_n_values_for_primary_key_index); |
4630 | 4630 | } |
@@ -4639,13 +4639,13 @@ discard block |
||
4639 | 4639 | * @return null|array |
4640 | 4640 | * @throws \EE_Error |
4641 | 4641 | */ |
4642 | - public function parse_index_primary_key_string( $index_primary_key_string) { |
|
4642 | + public function parse_index_primary_key_string($index_primary_key_string) { |
|
4643 | 4643 | $key_fields = $this->get_combined_primary_key_fields(); |
4644 | 4644 | //check all of them are in the $id |
4645 | 4645 | $key_vals_in_combined_pk = array(); |
4646 | - parse_str( $index_primary_key_string, $key_vals_in_combined_pk ); |
|
4647 | - foreach( $key_fields as $key_field_name => $field_obj ) { |
|
4648 | - if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){ |
|
4646 | + parse_str($index_primary_key_string, $key_vals_in_combined_pk); |
|
4647 | + foreach ($key_fields as $key_field_name => $field_obj) { |
|
4648 | + if ( ! isset($key_vals_in_combined_pk[$key_field_name])) { |
|
4649 | 4649 | return NULL; |
4650 | 4650 | } |
4651 | 4651 | } |
@@ -4662,10 +4662,10 @@ discard block |
||
4662 | 4662 | * @return boolean |
4663 | 4663 | * @throws \EE_Error |
4664 | 4664 | */ |
4665 | - public function has_all_combined_primary_key_fields( $key_vals ) { |
|
4666 | - $keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() ); |
|
4667 | - foreach( $keys_it_should_have as $key ){ |
|
4668 | - if( ! isset( $key_vals[ $key ] ) ){ |
|
4665 | + public function has_all_combined_primary_key_fields($key_vals) { |
|
4666 | + $keys_it_should_have = array_keys($this->get_combined_primary_key_fields()); |
|
4667 | + foreach ($keys_it_should_have as $key) { |
|
4668 | + if ( ! isset($key_vals[$key])) { |
|
4669 | 4669 | return false; |
4670 | 4670 | } |
4671 | 4671 | } |
@@ -4681,23 +4681,23 @@ discard block |
||
4681 | 4681 | * @throws EE_Error |
4682 | 4682 | * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed) |
4683 | 4683 | */ |
4684 | - public function get_all_copies($model_object_or_attributes_array, $query_params = array()){ |
|
4684 | + public function get_all_copies($model_object_or_attributes_array, $query_params = array()) { |
|
4685 | 4685 | |
4686 | - if($model_object_or_attributes_array instanceof EE_Base_Class){ |
|
4686 | + if ($model_object_or_attributes_array instanceof EE_Base_Class) { |
|
4687 | 4687 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
4688 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
4688 | + }elseif (is_array($model_object_or_attributes_array)) { |
|
4689 | 4689 | $attributes_array = $model_object_or_attributes_array; |
4690 | - }else{ |
|
4691 | - throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
|
4690 | + } else { |
|
4691 | + throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array)); |
|
4692 | 4692 | } |
4693 | 4693 | //even copies obviously won't have the same ID, so remove the primary key |
4694 | 4694 | //from the WHERE conditions for finding copies (if there is a primary key, of course) |
4695 | - if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){ |
|
4695 | + if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) { |
|
4696 | 4696 | unset($attributes_array[$this->primary_key_name()]); |
4697 | 4697 | } |
4698 | - if(isset($query_params[0])){ |
|
4699 | - $query_params[0] = array_merge($attributes_array,$query_params); |
|
4700 | - }else{ |
|
4698 | + if (isset($query_params[0])) { |
|
4699 | + $query_params[0] = array_merge($attributes_array, $query_params); |
|
4700 | + } else { |
|
4701 | 4701 | $query_params[0] = $attributes_array; |
4702 | 4702 | } |
4703 | 4703 | return $this->get_all($query_params); |
@@ -4713,16 +4713,16 @@ discard block |
||
4713 | 4713 | * @return EE_Base_Class |
4714 | 4714 | * @throws \EE_Error |
4715 | 4715 | */ |
4716 | - public function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
4717 | - if( ! is_array( $query_params ) ){ |
|
4718 | - EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
4716 | + public function get_one_copy($model_object_or_attributes_array, $query_params = array()) { |
|
4717 | + if ( ! is_array($query_params)) { |
|
4718 | + EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
4719 | 4719 | $query_params = array(); |
4720 | 4720 | } |
4721 | 4721 | $query_params['limit'] = 1; |
4722 | - $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
4723 | - if(is_array($copies)){ |
|
4722 | + $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
4723 | + if (is_array($copies)) { |
|
4724 | 4724 | return array_shift($copies); |
4725 | - }else{ |
|
4725 | + } else { |
|
4726 | 4726 | return null; |
4727 | 4727 | } |
4728 | 4728 | } |
@@ -4738,10 +4738,10 @@ discard block |
||
4738 | 4738 | * @return int number of rows updated |
4739 | 4739 | * @throws \EE_Error |
4740 | 4740 | */ |
4741 | - public function update_by_ID($fields_n_values,$id){ |
|
4741 | + public function update_by_ID($fields_n_values, $id) { |
|
4742 | 4742 | $query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id), |
4743 | 4743 | 'default_where_conditions'=>'other_models_only',); |
4744 | - return $this->update($fields_n_values,$query_params); |
|
4744 | + return $this->update($fields_n_values, $query_params); |
|
4745 | 4745 | } |
4746 | 4746 | |
4747 | 4747 | |
@@ -4752,12 +4752,12 @@ discard block |
||
4752 | 4752 | * @return string an operator which can be used in SQL |
4753 | 4753 | * @throws EE_Error |
4754 | 4754 | */ |
4755 | - private function _prepare_operator_for_sql($operator_supplied){ |
|
4755 | + private function _prepare_operator_for_sql($operator_supplied) { |
|
4756 | 4756 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
4757 | - if($sql_operator){ |
|
4757 | + if ($sql_operator) { |
|
4758 | 4758 | return $sql_operator; |
4759 | - }else{ |
|
4760 | - throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
|
4759 | + } else { |
|
4760 | + throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators)))); |
|
4761 | 4761 | } |
4762 | 4762 | } |
4763 | 4763 | |
@@ -4771,10 +4771,10 @@ discard block |
||
4771 | 4771 | * @return string[] |
4772 | 4772 | * @throws \EE_Error |
4773 | 4773 | */ |
4774 | - public function get_all_names($query_params = array()){ |
|
4774 | + public function get_all_names($query_params = array()) { |
|
4775 | 4775 | $objs = $this->get_all($query_params); |
4776 | 4776 | $names = array(); |
4777 | - foreach($objs as $obj){ |
|
4777 | + foreach ($objs as $obj) { |
|
4778 | 4778 | $names[$obj->ID()] = $obj->name(); |
4779 | 4779 | } |
4780 | 4780 | return $names; |
@@ -4793,11 +4793,11 @@ discard block |
||
4793 | 4793 | * @return array |
4794 | 4794 | * @throws \EE_Error |
4795 | 4795 | */ |
4796 | - public function get_IDs( $model_objects, $filter_out_empty_ids = false) { |
|
4797 | - if( ! $this->has_primary_key_field() ) { |
|
4798 | - if( WP_DEBUG ) { |
|
4796 | + public function get_IDs($model_objects, $filter_out_empty_ids = false) { |
|
4797 | + if ( ! $this->has_primary_key_field()) { |
|
4798 | + if (WP_DEBUG) { |
|
4799 | 4799 | EE_Error::add_error( |
4800 | - __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), |
|
4800 | + __('Trying to get IDs from a model than has no primary key', 'event_espresso'), |
|
4801 | 4801 | __FILE__, |
4802 | 4802 | __FUNCTION__, |
4803 | 4803 | __LINE__ |
@@ -4805,13 +4805,13 @@ discard block |
||
4805 | 4805 | } |
4806 | 4806 | } |
4807 | 4807 | $IDs = array(); |
4808 | - foreach( $model_objects as $model_object ) { |
|
4808 | + foreach ($model_objects as $model_object) { |
|
4809 | 4809 | $id = $model_object->ID(); |
4810 | - if( ! $id ) { |
|
4811 | - if( $filter_out_empty_ids ) { |
|
4810 | + if ( ! $id) { |
|
4811 | + if ($filter_out_empty_ids) { |
|
4812 | 4812 | continue; |
4813 | 4813 | } |
4814 | - if ( WP_DEBUG ) { |
|
4814 | + if (WP_DEBUG) { |
|
4815 | 4815 | EE_Error::add_error( |
4816 | 4816 | __( |
4817 | 4817 | 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', |
@@ -4833,8 +4833,8 @@ discard block |
||
4833 | 4833 | * are no capabilities that relate to this model returns false |
4834 | 4834 | * @return string|false |
4835 | 4835 | */ |
4836 | - public function cap_slug(){ |
|
4837 | - return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4836 | + public function cap_slug() { |
|
4837 | + return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4838 | 4838 | } |
4839 | 4839 | |
4840 | 4840 | |
@@ -4849,34 +4849,34 @@ discard block |
||
4849 | 4849 | * @return EE_Default_Where_Conditions[] indexed by associated capability |
4850 | 4850 | * @throws \EE_Error |
4851 | 4851 | */ |
4852 | - public function cap_restrictions( $context = EEM_Base::caps_read ) { |
|
4853 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
4852 | + public function cap_restrictions($context = EEM_Base::caps_read) { |
|
4853 | + EEM_Base::verify_is_valid_cap_context($context); |
|
4854 | 4854 | //check if we ought to run the restriction generator first |
4855 | - if( |
|
4856 | - isset( $this->_cap_restriction_generators[ $context ] ) |
|
4857 | - && $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base |
|
4858 | - && ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() |
|
4855 | + if ( |
|
4856 | + isset($this->_cap_restriction_generators[$context]) |
|
4857 | + && $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base |
|
4858 | + && ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions() |
|
4859 | 4859 | ) { |
4860 | - $this->_cap_restrictions[ $context ] = array_merge( |
|
4861 | - $this->_cap_restrictions[ $context ], |
|
4862 | - $this->_cap_restriction_generators[ $context ]->generate_restrictions() |
|
4860 | + $this->_cap_restrictions[$context] = array_merge( |
|
4861 | + $this->_cap_restrictions[$context], |
|
4862 | + $this->_cap_restriction_generators[$context]->generate_restrictions() |
|
4863 | 4863 | ); |
4864 | 4864 | } |
4865 | 4865 | //and make sure we've finalized the construction of each restriction |
4866 | - foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) { |
|
4867 | - if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) { |
|
4868 | - $where_conditions_obj->_finalize_construct( $this ); |
|
4866 | + foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) { |
|
4867 | + if ($where_conditions_obj instanceof EE_Default_Where_Conditions) { |
|
4868 | + $where_conditions_obj->_finalize_construct($this); |
|
4869 | 4869 | } |
4870 | 4870 | } |
4871 | 4871 | |
4872 | - return $this->_cap_restrictions[ $context ]; |
|
4872 | + return $this->_cap_restrictions[$context]; |
|
4873 | 4873 | } |
4874 | 4874 | |
4875 | 4875 | /** |
4876 | 4876 | * Indicating whether or not this model thinks its a wp core model |
4877 | 4877 | * @return boolean |
4878 | 4878 | */ |
4879 | - public function is_wp_core_model(){ |
|
4879 | + public function is_wp_core_model() { |
|
4880 | 4880 | return $this->_wp_core_model; |
4881 | 4881 | } |
4882 | 4882 | |
@@ -4890,12 +4890,12 @@ discard block |
||
4890 | 4890 | * @return EE_Default_Where_Conditions[] indexed by capability name |
4891 | 4891 | * @throws \EE_Error |
4892 | 4892 | */ |
4893 | - public function caps_missing( $context = EEM_Base::caps_read ) { |
|
4893 | + public function caps_missing($context = EEM_Base::caps_read) { |
|
4894 | 4894 | $missing_caps = array(); |
4895 | - $cap_restrictions = $this->cap_restrictions( $context ); |
|
4896 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
4897 | - if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) { |
|
4898 | - $missing_caps[ $cap ] = $restriction_if_no_cap; |
|
4895 | + $cap_restrictions = $this->cap_restrictions($context); |
|
4896 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
4897 | + if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) { |
|
4898 | + $missing_caps[$cap] = $restriction_if_no_cap; |
|
4899 | 4899 | } |
4900 | 4900 | } |
4901 | 4901 | return $missing_caps; |
@@ -4907,7 +4907,7 @@ discard block |
||
4907 | 4907 | * one of 'read', 'edit', or 'delete' |
4908 | 4908 | */ |
4909 | 4909 | public function cap_contexts_to_cap_action_map() { |
4910 | - return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this ); |
|
4910 | + return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this); |
|
4911 | 4911 | } |
4912 | 4912 | |
4913 | 4913 | |
@@ -4918,19 +4918,19 @@ discard block |
||
4918 | 4918 | * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values |
4919 | 4919 | * @throws \EE_Error |
4920 | 4920 | */ |
4921 | - public function cap_action_for_context( $context ) { |
|
4921 | + public function cap_action_for_context($context) { |
|
4922 | 4922 | $mapping = $this->cap_contexts_to_cap_action_map(); |
4923 | - if( isset( $mapping[ $context ] ) ) { |
|
4924 | - return $mapping[ $context ]; |
|
4923 | + if (isset($mapping[$context])) { |
|
4924 | + return $mapping[$context]; |
|
4925 | 4925 | } |
4926 | - if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) { |
|
4926 | + if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) { |
|
4927 | 4927 | return $action; |
4928 | 4928 | } |
4929 | 4929 | throw new EE_Error( |
4930 | 4930 | sprintf( |
4931 | - __( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ), |
|
4931 | + __('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'), |
|
4932 | 4932 | $context, |
4933 | - implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) ) |
|
4933 | + implode(',', array_keys($this->cap_contexts_to_cap_action_map())) |
|
4934 | 4934 | ) |
4935 | 4935 | ); |
4936 | 4936 | |
@@ -4941,7 +4941,7 @@ discard block |
||
4941 | 4941 | * @return array |
4942 | 4942 | */ |
4943 | 4943 | static public function valid_cap_contexts() { |
4944 | - return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array( |
|
4944 | + return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array( |
|
4945 | 4945 | self::caps_read, |
4946 | 4946 | self::caps_read_admin, |
4947 | 4947 | self::caps_edit, |
@@ -4957,17 +4957,17 @@ discard block |
||
4957 | 4957 | * @return bool |
4958 | 4958 | * @throws \EE_Error |
4959 | 4959 | */ |
4960 | - static public function verify_is_valid_cap_context( $context ) { |
|
4960 | + static public function verify_is_valid_cap_context($context) { |
|
4961 | 4961 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
4962 | - if( in_array( $context, $valid_cap_contexts ) ) { |
|
4962 | + if (in_array($context, $valid_cap_contexts)) { |
|
4963 | 4963 | return true; |
4964 | - }else{ |
|
4964 | + } else { |
|
4965 | 4965 | throw new EE_Error( |
4966 | 4966 | sprintf( |
4967 | - __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
|
4967 | + __('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'), |
|
4968 | 4968 | $context, |
4969 | - 'EEM_Base' , |
|
4970 | - implode(',', $valid_cap_contexts ) |
|
4969 | + 'EEM_Base', |
|
4970 | + implode(',', $valid_cap_contexts) |
|
4971 | 4971 | ) |
4972 | 4972 | ); |
4973 | 4973 | } |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | if( isset( $this->_cap_restriction_generators[ $context ] ) && |
555 | 555 | $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
556 | 556 | return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
557 | - }else{ |
|
557 | + } else{ |
|
558 | 558 | return array(); |
559 | 559 | } |
560 | 560 | } |
@@ -812,13 +812,13 @@ discard block |
||
812 | 812 | $last_model_name = end( $models_to_follow_to_wp_users ); |
813 | 813 | $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
814 | 814 | $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
815 | - }else{ |
|
815 | + } else{ |
|
816 | 816 | $model_with_fk_to_wp_users = $this; |
817 | 817 | $model_chain_to_wp_user = ''; |
818 | 818 | } |
819 | 819 | $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
820 | 820 | return $model_chain_to_wp_user . $wp_user_field->get_name(); |
821 | - }catch( EE_Error $e ) { |
|
821 | + } catch( EE_Error $e ) { |
|
822 | 822 | return false; |
823 | 823 | } |
824 | 824 | } |
@@ -846,11 +846,11 @@ discard block |
||
846 | 846 | public function is_owned() { |
847 | 847 | if( $this->model_chain_to_wp_user() ){ |
848 | 848 | return true; |
849 | - }else{ |
|
849 | + } else{ |
|
850 | 850 | try{ |
851 | 851 | $this->get_foreign_key_to( 'WP_User' ); |
852 | 852 | return true; |
853 | - }catch( EE_Error $e ){ |
|
853 | + } catch( EE_Error $e ){ |
|
854 | 854 | return false; |
855 | 855 | } |
856 | 856 | } |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
947 | 947 | } |
948 | 948 | $columns_to_select_string = implode(", ",$select_sql_array); |
949 | - }else{ |
|
949 | + } else{ |
|
950 | 950 | $columns_to_select_string = $columns_to_select; |
951 | 951 | } |
952 | 952 | return $columns_to_select_string; |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | } |
1003 | 1003 | if( $this->has_primary_key_field ( ) ) { |
1004 | 1004 | $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
1005 | - }else{ |
|
1005 | + } else{ |
|
1006 | 1006 | //no primary key, so the $id must be from the get_index_primary_key_string() |
1007 | 1007 | $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
1008 | 1008 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $items = $this->get_all($query_params); |
1030 | 1030 | if(empty($items)){ |
1031 | 1031 | return null; |
1032 | - }else{ |
|
1032 | + } else{ |
|
1033 | 1033 | return array_shift($items); |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
1416 | 1416 | if( $this->has_primary_key_field() ){ |
1417 | 1417 | $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
1418 | - }else{ |
|
1418 | + } else{ |
|
1419 | 1419 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
1420 | 1420 | $main_table_pk_value = null; |
1421 | 1421 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
1455 | 1455 | if( $this->has_primary_key_field() ){ |
1456 | 1456 | $model_objs_affected_ids = $this->get_col( $query_params ); |
1457 | - }else{ |
|
1457 | + } else{ |
|
1458 | 1458 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
1459 | 1459 | $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
1460 | 1460 | $model_objs_affected_ids = array(); |
@@ -1518,9 +1518,9 @@ discard block |
||
1518 | 1518 | |
1519 | 1519 | if( $field_to_select ){ |
1520 | 1520 | $field = $this->field_settings_for( $field_to_select ); |
1521 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
1521 | + } elseif( $this->has_primary_key_field ( ) ){ |
|
1522 | 1522 | $field = $this->get_primary_key_field(); |
1523 | - }else{ |
|
1523 | + } else{ |
|
1524 | 1524 | //no primary key, just grab the first column |
1525 | 1525 | $field = reset( $this->field_settings()); |
1526 | 1526 | } |
@@ -1547,7 +1547,7 @@ discard block |
||
1547 | 1547 | $col = $this->get_col( $query_params, $field_to_select ); |
1548 | 1548 | if( ! empty( $col ) ) { |
1549 | 1549 | return reset( $col ); |
1550 | - }else{ |
|
1550 | + } else{ |
|
1551 | 1551 | return NULL; |
1552 | 1552 | } |
1553 | 1553 | } |
@@ -1674,7 +1674,7 @@ discard block |
||
1674 | 1674 | |
1675 | 1675 | // /echo "delete sql:$SQL"; |
1676 | 1676 | $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
1677 | - }else{ |
|
1677 | + } else{ |
|
1678 | 1678 | $rows_deleted = 0; |
1679 | 1679 | } |
1680 | 1680 | |
@@ -1718,7 +1718,7 @@ discard block |
||
1718 | 1718 | //first, if $ignore_this_model_obj was supplied, get its model |
1719 | 1719 | if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
1720 | 1720 | $ignored_model = $ignore_this_model_obj->get_model(); |
1721 | - }else{ |
|
1721 | + } else{ |
|
1722 | 1722 | $ignored_model = null; |
1723 | 1723 | } |
1724 | 1724 | //now check all the relations of $this_model_obj_or_id and see if there |
@@ -1731,7 +1731,7 @@ discard block |
||
1731 | 1731 | if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){ |
1732 | 1732 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
1733 | 1733 | array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
1734 | - }else{ |
|
1734 | + } else{ |
|
1735 | 1735 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
1736 | 1736 | } |
1737 | 1737 | |
@@ -1804,7 +1804,7 @@ discard block |
||
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | return !empty($query) ? implode(' AND ', $query ) : ''; |
1807 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1807 | + } elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1808 | 1808 | $ways_to_identify_a_row = array(); |
1809 | 1809 | $fields = $this->get_combined_primary_key_fields(); |
1810 | 1810 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
@@ -1820,7 +1820,7 @@ discard block |
||
1820 | 1820 | $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
1821 | 1821 | } |
1822 | 1822 | return implode(" OR ",$ways_to_identify_a_row); |
1823 | - }else{ |
|
1823 | + } else{ |
|
1824 | 1824 | //so there's no primary key and no combined key... |
1825 | 1825 | //sorry, can't help you |
1826 | 1826 | throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
@@ -1844,10 +1844,10 @@ discard block |
||
1844 | 1844 | if($field_to_count){ |
1845 | 1845 | $field_obj = $this->field_settings_for($field_to_count); |
1846 | 1846 | $column_to_count = $field_obj->get_qualified_column(); |
1847 | - }elseif($this->has_primary_key_field ()){ |
|
1847 | + } elseif($this->has_primary_key_field ()){ |
|
1848 | 1848 | $pk_field_obj = $this->get_primary_key_field(); |
1849 | 1849 | $column_to_count = $pk_field_obj->get_qualified_column(); |
1850 | - }else{//there's no primary key |
|
1850 | + } else{//there's no primary key |
|
1851 | 1851 | $column_to_count = '*'; |
1852 | 1852 | } |
1853 | 1853 | |
@@ -1872,7 +1872,7 @@ discard block |
||
1872 | 1872 | if($field_to_sum){ |
1873 | 1873 | $field_obj = $this->field_settings_for($field_to_sum); |
1874 | 1874 | |
1875 | - }else{ |
|
1875 | + } else{ |
|
1876 | 1876 | $field_obj = $this->get_primary_key_field(); |
1877 | 1877 | } |
1878 | 1878 | $column_to_count = $field_obj->get_qualified_column(); |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | $data_type = $field_obj->get_wpdb_data_type(); |
1883 | 1883 | if( $data_type === '%d' || $data_type === '%s' ){ |
1884 | 1884 | return (float)$return_value; |
1885 | - }else{//must be %f |
|
1885 | + } else{//must be %f |
|
1886 | 1886 | return (float)$return_value; |
1887 | 1887 | } |
1888 | 1888 | } |
@@ -1920,10 +1920,10 @@ discard block |
||
1920 | 1920 | $wpdb->show_errors( $old_show_errors_value ); |
1921 | 1921 | if( ! empty( $wpdb->last_error ) ){ |
1922 | 1922 | throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
1923 | - }elseif( $result === false ){ |
|
1923 | + } elseif( $result === false ){ |
|
1924 | 1924 | throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
1925 | 1925 | } |
1926 | - }elseif( $result === false ) { |
|
1926 | + } elseif( $result === false ) { |
|
1927 | 1927 | EE_Error::add_error( |
1928 | 1928 | sprintf( |
1929 | 1929 | __( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ), |
@@ -2265,7 +2265,7 @@ discard block |
||
2265 | 2265 | $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
2266 | 2266 | if( $results ){ |
2267 | 2267 | return array_shift($results); |
2268 | - }else{ |
|
2268 | + } else{ |
|
2269 | 2269 | return null; |
2270 | 2270 | } |
2271 | 2271 | |
@@ -2336,7 +2336,7 @@ discard block |
||
2336 | 2336 | */ |
2337 | 2337 | do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
2338 | 2338 | return $new_id; |
2339 | - }else{ |
|
2339 | + } else{ |
|
2340 | 2340 | return FALSE; |
2341 | 2341 | } |
2342 | 2342 | } |
@@ -2398,9 +2398,9 @@ discard block |
||
2398 | 2398 | public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
2399 | 2399 | if($obj_or_fields_array instanceof EE_Base_Class){ |
2400 | 2400 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
2401 | - }elseif( is_array($obj_or_fields_array)){ |
|
2401 | + } elseif( is_array($obj_or_fields_array)){ |
|
2402 | 2402 | $fields_n_values = $obj_or_fields_array; |
2403 | - }else{ |
|
2403 | + } else{ |
|
2404 | 2404 | throw new EE_Error( |
2405 | 2405 | sprintf( |
2406 | 2406 | __( |
@@ -2425,7 +2425,7 @@ discard block |
||
2425 | 2425 | //if there is nothing to base this search on, then we shouldn't find anything |
2426 | 2426 | if( empty( $query_params ) ){ |
2427 | 2427 | return array(); |
2428 | - }else{ |
|
2428 | + } else{ |
|
2429 | 2429 | return $this->get_one($query_params); |
2430 | 2430 | } |
2431 | 2431 | } |
@@ -2506,12 +2506,12 @@ discard block |
||
2506 | 2506 | if($this->has_primary_key_field()){ |
2507 | 2507 | if($this->get_primary_key_field()->is_auto_increment()){ |
2508 | 2508 | return $wpdb->insert_id; |
2509 | - }else{ |
|
2509 | + } else{ |
|
2510 | 2510 | //it's not an auto-increment primary key, so |
2511 | 2511 | //it must have been supplied |
2512 | 2512 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
2513 | 2513 | } |
2514 | - }else{ |
|
2514 | + } else{ |
|
2515 | 2515 | //we can't return a primary key because there is none. instead return |
2516 | 2516 | //a unique string indicating this model |
2517 | 2517 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2563,7 +2563,7 @@ discard block |
||
2563 | 2563 | //leave the value alone |
2564 | 2564 | } |
2565 | 2565 | return $value; |
2566 | - }else{ |
|
2566 | + } else{ |
|
2567 | 2567 | return $value; |
2568 | 2568 | } |
2569 | 2569 | } |
@@ -2732,10 +2732,10 @@ discard block |
||
2732 | 2732 | if (! is_array($possibly_array_of_params)){ |
2733 | 2733 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
2734 | 2734 | $param,$possibly_array_of_params)); |
2735 | - }else{ |
|
2735 | + } else{ |
|
2736 | 2736 | $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
2737 | 2737 | } |
2738 | - }elseif($query_param_type === 0 //ie WHERE |
|
2738 | + } elseif($query_param_type === 0 //ie WHERE |
|
2739 | 2739 | && is_array($possibly_array_of_params) |
2740 | 2740 | && isset($possibly_array_of_params[2]) |
2741 | 2741 | && $possibly_array_of_params[2] == true){ |
@@ -3013,7 +3013,7 @@ discard block |
||
3013 | 3013 | private function _extract_order($should_be_order_string){ |
3014 | 3014 | if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
3015 | 3015 | return $should_be_order_string; |
3016 | - }else{ |
|
3016 | + } else{ |
|
3017 | 3017 | throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
3018 | 3018 | } |
3019 | 3019 | } |
@@ -3091,7 +3091,7 @@ discard block |
||
3091 | 3091 | foreach($default_where_conditions as $key => $val){ |
3092 | 3092 | if( isset($provided_where_conditions[$key])){ |
3093 | 3093 | $none_overridden = false; |
3094 | - }else{ |
|
3094 | + } else{ |
|
3095 | 3095 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
3096 | 3096 | } |
3097 | 3097 | } |
@@ -3217,7 +3217,7 @@ discard block |
||
3217 | 3217 | if(array_key_exists($query_param,$this_model_fields)){ |
3218 | 3218 | if($allow_fields){ |
3219 | 3219 | return; |
3220 | - }else{ |
|
3220 | + } else{ |
|
3221 | 3221 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
3222 | 3222 | $query_param,get_class($this),$query_param_type,$original_query_param)); |
3223 | 3223 | } |
@@ -3226,7 +3226,7 @@ discard block |
||
3226 | 3226 | elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
3227 | 3227 | if($allow_logic_query_params){ |
3228 | 3228 | return; |
3229 | - }else{ |
|
3229 | + } else{ |
|
3230 | 3230 | throw new EE_Error( |
3231 | 3231 | sprintf( |
3232 | 3232 | __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
@@ -3257,12 +3257,12 @@ discard block |
||
3257 | 3257 | //we should actually end in a field name, not a model like this! |
3258 | 3258 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
3259 | 3259 | $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
3260 | - }else{ |
|
3260 | + } else{ |
|
3261 | 3261 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
3262 | 3262 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
3263 | 3263 | return; |
3264 | 3264 | } |
3265 | - }elseif($query_param === $valid_related_model_name){ |
|
3265 | + } elseif($query_param === $valid_related_model_name){ |
|
3266 | 3266 | $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
3267 | 3267 | return; |
3268 | 3268 | } |
@@ -3327,7 +3327,7 @@ discard block |
||
3327 | 3327 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
3328 | 3328 | if($SQL){ |
3329 | 3329 | return " WHERE ". $SQL; |
3330 | - }else{ |
|
3330 | + } else{ |
|
3331 | 3331 | return ''; |
3332 | 3332 | } |
3333 | 3333 | } |
@@ -3346,7 +3346,7 @@ discard block |
||
3346 | 3346 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
3347 | 3347 | if($SQL){ |
3348 | 3348 | return " HAVING ". $SQL; |
3349 | - }else{ |
|
3349 | + } else{ |
|
3350 | 3350 | return ''; |
3351 | 3351 | } |
3352 | 3352 | |
@@ -3368,7 +3368,7 @@ discard block |
||
3368 | 3368 | $model_instance=call_user_func($model_name."::instance"); |
3369 | 3369 | /* @var $model_instance EEM_Base */ |
3370 | 3370 | return $model_instance->field_settings_for($field_name); |
3371 | - }else{ |
|
3371 | + } else{ |
|
3372 | 3372 | throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
3373 | 3373 | } |
3374 | 3374 | } |
@@ -3401,14 +3401,14 @@ discard block |
||
3401 | 3401 | $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
3402 | 3402 | break; |
3403 | 3403 | } |
3404 | - }else{ |
|
3404 | + } else{ |
|
3405 | 3405 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
3406 | 3406 | |
3407 | 3407 | //if it's not a normal field, maybe it's a custom selection? |
3408 | 3408 | if( ! $field_obj){ |
3409 | 3409 | if(isset( $this->_custom_selections[$query_param][1])){ |
3410 | 3410 | $field_obj = $this->_custom_selections[$query_param][1]; |
3411 | - }else{ |
|
3411 | + } else{ |
|
3412 | 3412 | throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
3413 | 3413 | } |
3414 | 3414 | } |
@@ -3433,11 +3433,11 @@ discard block |
||
3433 | 3433 | if( $field ){ |
3434 | 3434 | $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
3435 | 3435 | return $table_alias_prefix . $field->get_qualified_column(); |
3436 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3436 | + } elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3437 | 3437 | //maybe it's custom selection item? |
3438 | 3438 | //if so, just use it as the "column name" |
3439 | 3439 | return $query_param; |
3440 | - }else{ |
|
3440 | + } else{ |
|
3441 | 3441 | throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
3442 | 3442 | } |
3443 | 3443 | } |
@@ -3454,7 +3454,7 @@ discard block |
||
3454 | 3454 | $pos_of_star = strpos($condition_query_param_key, '*'); |
3455 | 3455 | if($pos_of_star === FALSE){ |
3456 | 3456 | return $condition_query_param_key; |
3457 | - }else{ |
|
3457 | + } else{ |
|
3458 | 3458 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
3459 | 3459 | return $condition_query_param_sans_star; |
3460 | 3460 | } |
@@ -3639,7 +3639,7 @@ discard block |
||
3639 | 3639 | global $wpdb; |
3640 | 3640 | if($field_obj instanceof EE_Model_Field_Base){ |
3641 | 3641 | return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
3642 | - }else{//$field_obj should really just be a data type |
|
3642 | + } else{//$field_obj should really just be a data type |
|
3643 | 3643 | if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
3644 | 3644 | throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
3645 | 3645 | } |
@@ -3668,14 +3668,14 @@ discard block |
||
3668 | 3668 | if($number_of_parts === 1){ |
3669 | 3669 | $field_name = $last_query_param_part; |
3670 | 3670 | $model_obj = $this; |
3671 | - }else{// $number_of_parts >= 2 |
|
3671 | + } else{// $number_of_parts >= 2 |
|
3672 | 3672 | //the last part is the column name, and there are only 2parts. therefore... |
3673 | 3673 | $field_name = $last_query_param_part; |
3674 | 3674 | $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
3675 | 3675 | } |
3676 | 3676 | try{ |
3677 | 3677 | return $model_obj->field_settings_for($field_name); |
3678 | - }catch(EE_Error $e){ |
|
3678 | + } catch(EE_Error $e){ |
|
3679 | 3679 | return null; |
3680 | 3680 | } |
3681 | 3681 | } |
@@ -3694,7 +3694,7 @@ discard block |
||
3694 | 3694 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
3695 | 3695 | if($field){ |
3696 | 3696 | return $field->get_qualified_column(); |
3697 | - }else{ |
|
3697 | + } else{ |
|
3698 | 3698 | throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
3699 | 3699 | } |
3700 | 3700 | } |
@@ -3765,7 +3765,7 @@ discard block |
||
3765 | 3765 | //the FROM statement, BUT the primary table isn't. So we want |
3766 | 3766 | //to add the inverse join sql |
3767 | 3767 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
3768 | - }else{ |
|
3768 | + } else{ |
|
3769 | 3769 | //just add a regular JOIN to this table from the primary table |
3770 | 3770 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
3771 | 3771 | } |
@@ -3878,7 +3878,7 @@ discard block |
||
3878 | 3878 | $fieldSettings = $this->field_settings(true); |
3879 | 3879 | if( isset($fieldSettings[$fieldName])){ |
3880 | 3880 | return true; |
3881 | - }else{ |
|
3881 | + } else{ |
|
3882 | 3882 | return false; |
3883 | 3883 | } |
3884 | 3884 | } |
@@ -3892,7 +3892,7 @@ discard block |
||
3892 | 3892 | $relations = $this->relation_settings(); |
3893 | 3893 | if(isset($relations[$relation_name])){ |
3894 | 3894 | return true; |
3895 | - }else{ |
|
3895 | + } else{ |
|
3896 | 3896 | return false; |
3897 | 3897 | } |
3898 | 3898 | } |
@@ -3943,7 +3943,7 @@ discard block |
||
3943 | 3943 | try{ |
3944 | 3944 | $this->get_primary_key_field(); |
3945 | 3945 | $this->_has_primary_key_field = true; |
3946 | - }catch(EE_Error $e){ |
|
3946 | + } catch(EE_Error $e){ |
|
3947 | 3947 | $this->_has_primary_key_field = false; |
3948 | 3948 | } |
3949 | 3949 | } |
@@ -4023,7 +4023,7 @@ discard block |
||
4023 | 4023 | } |
4024 | 4024 | } |
4025 | 4025 | return $this->_cached_fields; |
4026 | - }else{ |
|
4026 | + } else{ |
|
4027 | 4027 | if( $this->_cached_fields_non_db_only === NULL ){ |
4028 | 4028 | $this->_cached_fields_non_db_only = array(); |
4029 | 4029 | foreach($this->_fields as $fields_corresponding_to_table){ |
@@ -4159,7 +4159,7 @@ discard block |
||
4159 | 4159 | if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
4160 | 4160 | return NULL; |
4161 | 4161 | } |
4162 | - }else if($this->unique_indexes()){ |
|
4162 | + } else if($this->unique_indexes()){ |
|
4163 | 4163 | $first_column = reset($this_model_fields_n_values); |
4164 | 4164 | if(empty($first_column)){ |
4165 | 4165 | return NULL; |
@@ -4174,7 +4174,7 @@ discard block |
||
4174 | 4174 | // add this new object to the entity map |
4175 | 4175 | $classInstance = $this->add_to_entity_map( $classInstance ); |
4176 | 4176 | } |
4177 | - }else{ |
|
4177 | + } else{ |
|
4178 | 4178 | $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
4179 | 4179 | } |
4180 | 4180 | |
@@ -4287,7 +4287,7 @@ discard block |
||
4287 | 4287 | $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
4288 | 4288 | } |
4289 | 4289 | } |
4290 | - }else{ |
|
4290 | + } else{ |
|
4291 | 4291 | //the table's rows existed. Use their values |
4292 | 4292 | foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
4293 | 4293 | if( ! $field_obj->is_db_only_field() ){ |
@@ -4317,7 +4317,7 @@ discard block |
||
4317 | 4317 | //or is it a db-only field? (not relating to the model) |
4318 | 4318 | if( isset( $cols_n_values[ $qualified_column ] ) ){ |
4319 | 4319 | $value = $cols_n_values[ $qualified_column ]; |
4320 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4320 | + } elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4321 | 4321 | $value = $cols_n_values[ $regular_column ]; |
4322 | 4322 | } |
4323 | 4323 | return $value; |
@@ -4351,7 +4351,7 @@ discard block |
||
4351 | 4351 | } |
4352 | 4352 | } |
4353 | 4353 | return $obj_in_map; |
4354 | - }else{ |
|
4354 | + } else{ |
|
4355 | 4355 | return $this->get_one_by_ID( $id ); |
4356 | 4356 | } |
4357 | 4357 | } |
@@ -4386,7 +4386,7 @@ discard block |
||
4386 | 4386 | } |
4387 | 4387 | } |
4388 | 4388 | return $obj_in_map; |
4389 | - }else{ |
|
4389 | + } else{ |
|
4390 | 4390 | $this->add_to_entity_map( $replacing_model_obj ); |
4391 | 4391 | return $replacing_model_obj; |
4392 | 4392 | } |
@@ -4531,13 +4531,13 @@ discard block |
||
4531 | 4531 | if( $base_class_obj_or_id instanceof $className ){ |
4532 | 4532 | /** @var $base_class_obj_or_id EE_Base_Class */ |
4533 | 4533 | $id = $base_class_obj_or_id->ID(); |
4534 | - }elseif(is_int($base_class_obj_or_id)){ |
|
4534 | + } elseif(is_int($base_class_obj_or_id)){ |
|
4535 | 4535 | //assume it's an ID |
4536 | 4536 | $id = $base_class_obj_or_id; |
4537 | - }elseif(is_string($base_class_obj_or_id)){ |
|
4537 | + } elseif(is_string($base_class_obj_or_id)){ |
|
4538 | 4538 | //assume its a string representation of the object |
4539 | 4539 | $id = $base_class_obj_or_id; |
4540 | - }else{ |
|
4540 | + } else{ |
|
4541 | 4541 | throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
4542 | 4542 | } |
4543 | 4543 | return $id; |
@@ -4685,9 +4685,9 @@ discard block |
||
4685 | 4685 | |
4686 | 4686 | if($model_object_or_attributes_array instanceof EE_Base_Class){ |
4687 | 4687 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
4688 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
4688 | + } elseif(is_array($model_object_or_attributes_array)){ |
|
4689 | 4689 | $attributes_array = $model_object_or_attributes_array; |
4690 | - }else{ |
|
4690 | + } else{ |
|
4691 | 4691 | throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
4692 | 4692 | } |
4693 | 4693 | //even copies obviously won't have the same ID, so remove the primary key |
@@ -4697,7 +4697,7 @@ discard block |
||
4697 | 4697 | } |
4698 | 4698 | if(isset($query_params[0])){ |
4699 | 4699 | $query_params[0] = array_merge($attributes_array,$query_params); |
4700 | - }else{ |
|
4700 | + } else{ |
|
4701 | 4701 | $query_params[0] = $attributes_array; |
4702 | 4702 | } |
4703 | 4703 | return $this->get_all($query_params); |
@@ -4722,7 +4722,7 @@ discard block |
||
4722 | 4722 | $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
4723 | 4723 | if(is_array($copies)){ |
4724 | 4724 | return array_shift($copies); |
4725 | - }else{ |
|
4725 | + } else{ |
|
4726 | 4726 | return null; |
4727 | 4727 | } |
4728 | 4728 | } |
@@ -4756,7 +4756,7 @@ discard block |
||
4756 | 4756 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
4757 | 4757 | if($sql_operator){ |
4758 | 4758 | return $sql_operator; |
4759 | - }else{ |
|
4759 | + } else{ |
|
4760 | 4760 | throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
4761 | 4761 | } |
4762 | 4762 | } |
@@ -4961,7 +4961,7 @@ discard block |
||
4961 | 4961 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
4962 | 4962 | if( in_array( $context, $valid_cap_contexts ) ) { |
4963 | 4963 | return true; |
4964 | - }else{ |
|
4964 | + } else{ |
|
4965 | 4965 | throw new EE_Error( |
4966 | 4966 | sprintf( |
4967 | 4967 | __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
@@ -328,7 +328,7 @@ |
||
328 | 328 | * @param int $TXN_ID |
329 | 329 | * @param int $ATT_ID |
330 | 330 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
331 | - * @return mixed array on success, FALSE on fail |
|
331 | + * @return null|EE_Base_Class array on success, FALSE on fail |
|
332 | 332 | */ |
333 | 333 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
334 | 334 | return $this->get_one(array( |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). |
107 | 107 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
108 | 108 | */ |
109 | - protected function __construct( $timezone = null ) { |
|
110 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
111 | - $this->singular_item = __('Registration','event_espresso'); |
|
112 | - $this->plural_item = __('Registrations','event_espresso'); |
|
109 | + protected function __construct($timezone = null) { |
|
110 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
111 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
112 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
113 | 113 | |
114 | 114 | $this->_tables = array( |
115 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
115 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
116 | 116 | ); |
117 | 117 | $this->_fields = array( |
118 | 118 | 'Registration'=>array( |
119 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
120 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
121 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
122 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
123 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
124 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
125 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
126 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
127 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
128 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
129 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
130 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
131 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
132 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
133 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
134 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
119 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
120 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
121 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
122 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
123 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
124 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
125 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
126 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
127 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
128 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
129 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
130 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
131 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
132 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
133 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
134 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | $this->_model_relations = array( |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | 'Answer'=>new EE_Has_Many_Relation(), |
144 | 144 | 'Checkin'=>new EE_Has_Many_Relation(), |
145 | 145 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
146 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
147 | - 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related |
|
146 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
147 | + 'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related |
|
148 | 148 | ); |
149 | 149 | $this->_model_chain_to_wp_user = 'Event'; |
150 | 150 | |
151 | - parent::__construct( $timezone ); |
|
151 | + parent::__construct($timezone); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * @param bool $translated If true will return the values as singular localized strings |
244 | 244 | * @return array |
245 | 245 | */ |
246 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
247 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
248 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
246 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
247 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
248 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | * @param array $exclude |
257 | 257 | * @return array |
258 | 258 | */ |
259 | - private function _get_registration_status_array( $exclude = array() ) { |
|
259 | + private function _get_registration_status_array($exclude = array()) { |
|
260 | 260 | //in the very rare circumstance that we are deleting a model's table's data |
261 | 261 | //and the table hasn't actually been created, this could have an error |
262 | 262 | /** @type WPDB $wpdb */ |
263 | 263 | global $wpdb; |
264 | - if( $this->_get_table_analysis()->tableExists( $wpdb->prefix . 'esp_status' ) ){ |
|
265 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
266 | - $results = $wpdb->get_results( $SQL ); |
|
264 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
265 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
266 | + $results = $wpdb->get_results($SQL); |
|
267 | 267 | self::$_reg_status = array(); |
268 | - foreach ( $results as $status ) { |
|
269 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
270 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
268 | + foreach ($results as $status) { |
|
269 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
270 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | * @throws \EE_Error |
281 | 281 | */ |
282 | 282 | protected function _get_table_analysis() { |
283 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
283 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
284 | 284 | return $this->_table_analysis; |
285 | 285 | } else { |
286 | 286 | throw new \EE_Error( |
287 | 287 | sprintf( |
288 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
289 | - get_class( $this ) |
|
288 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
289 | + get_class($this) |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | } |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | * @return array |
302 | 302 | * @throws \EE_Error |
303 | 303 | */ |
304 | - public function get_reg_months_and_years( $where_params ) { |
|
304 | + public function get_reg_months_and_years($where_params) { |
|
305 | 305 | $query_params[0] = $where_params; |
306 | 306 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
307 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
307 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
308 | 308 | $columns_to_select = array( |
309 | 309 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
310 | 310 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
311 | 311 | ); |
312 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
312 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * @param int $ATT_ID |
322 | 322 | * @return EE_Registration[] |
323 | 323 | */ |
324 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
325 | - if ( ! $ATT_ID ) { |
|
324 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
325 | + if ( ! $ATT_ID) { |
|
326 | 326 | return FALSE; |
327 | 327 | } |
328 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
328 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param string $REG_url_link |
337 | 337 | * @return EE_Registration |
338 | 338 | */ |
339 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
340 | - if(!$REG_url_link){ |
|
339 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
340 | + if ( ! $REG_url_link) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
356 | 356 | * @return mixed array on success, FALSE on fail |
357 | 357 | */ |
358 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
358 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
359 | 359 | return $this->get_one(array( |
360 | 360 | array( |
361 | 361 | 'TXN_ID'=>$TXN_ID, |
362 | 362 | 'ATT_ID'=>$ATT_ID |
363 | 363 | ), |
364 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
364 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
365 | 365 | )); |
366 | 366 | } |
367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
374 | 374 | * @return stdClass[] with properties regDate and total |
375 | 375 | */ |
376 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
376 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
377 | 377 | |
378 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
379 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
378 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
379 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
380 | 380 | |
381 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
381 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
382 | 382 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
383 | 383 | } |
384 | 384 | |
385 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
385 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
386 | 386 | |
387 | 387 | $results = $this->_get_all_wpdb_results( |
388 | 388 | array( |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | ), |
393 | 393 | OBJECT, |
394 | 394 | array( |
395 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
396 | - 'total'=>array('count(REG_ID)','%d') |
|
395 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
396 | + 'total'=>array('count(REG_ID)', '%d') |
|
397 | 397 | )); |
398 | 398 | return $results; |
399 | 399 | } |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
409 | 409 | * (i.e. RAP) |
410 | 410 | */ |
411 | - public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) { |
|
411 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') { |
|
412 | 412 | global $wpdb; |
413 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
413 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
414 | 414 | $event_table = $wpdb->posts; |
415 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
415 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
416 | 416 | |
417 | 417 | //prepare the query interval for displaying offset |
418 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' ); |
|
418 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
419 | 419 | |
420 | 420 | //inner date query |
421 | 421 | $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
422 | 422 | $inner_where = " WHERE"; |
423 | 423 | //exclude events not authored by user if permissions in effect |
424 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
424 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
425 | 425 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
426 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
426 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
427 | 427 | } |
428 | 428 | $inner_where .= " REG_date >= '$sql_date'"; |
429 | 429 | $inner_date_query .= $inner_where; |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | $select_parts = array(); |
436 | 436 | |
437 | 437 | //loop through registration stati to do parts for each status. |
438 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
439 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
438 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
439 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -444,14 +444,14 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | //setup the selects |
447 | - $select .= implode(', ', $select_parts ); |
|
447 | + $select .= implode(', ', $select_parts); |
|
448 | 448 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
449 | 449 | |
450 | 450 | //setup the joins |
451 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
451 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
452 | 452 | |
453 | 453 | //now let's put it all together |
454 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
454 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
455 | 455 | |
456 | 456 | //and execute it |
457 | 457 | $results = $wpdb->get_results( |
@@ -472,23 +472,23 @@ discard block |
||
472 | 472 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
473 | 473 | * @return stdClass[] each with properties event_name, reg_limit, and total |
474 | 474 | */ |
475 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
475 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
476 | 476 | |
477 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
478 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
477 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
478 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
479 | 479 | |
480 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
480 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
481 | 481 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
482 | 482 | } |
483 | 483 | $results = $this->_get_all_wpdb_results(array( |
484 | 484 | $where, |
485 | 485 | 'group_by'=>'Event.EVT_name', |
486 | 486 | 'order_by'=>'Event.EVT_name', |
487 | - 'limit'=>array(0,24)), |
|
487 | + 'limit'=>array(0, 24)), |
|
488 | 488 | OBJECT, |
489 | 489 | array( |
490 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
491 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
490 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
491 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
492 | 492 | ) |
493 | 493 | ); |
494 | 494 | |
@@ -506,19 +506,19 @@ discard block |
||
506 | 506 | * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
507 | 507 | * (i.e. RAP) |
508 | 508 | */ |
509 | - public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) { |
|
509 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') { |
|
510 | 510 | global $wpdb; |
511 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
511 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
512 | 512 | $event_table = $wpdb->posts; |
513 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
513 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
514 | 514 | |
515 | 515 | //inner date query |
516 | 516 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
517 | 517 | $inner_where = " WHERE"; |
518 | 518 | //exclude events not authored by user if permissions in effect |
519 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
519 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
520 | 520 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
521 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
521 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
522 | 522 | } |
523 | 523 | $inner_where .= " REG_date >= '$sql_date'"; |
524 | 524 | $inner_date_query .= $inner_where; |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | $select_parts = array(); |
531 | 531 | |
532 | 532 | //loop through registration stati to do parts for each status. |
533 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
534 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
533 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
534 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
535 | 535 | continue; |
536 | 536 | } |
537 | 537 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | } |
540 | 540 | |
541 | 541 | //setup the selects |
542 | - $select .= implode( ', ', $select_parts ); |
|
542 | + $select .= implode(', ', $select_parts); |
|
543 | 543 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
544 | 544 | |
545 | 545 | //setup remaining joins |
546 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
546 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
547 | 547 | |
548 | 548 | //now put it all together |
549 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
549 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
550 | 550 | |
551 | 551 | //and execute |
552 | 552 | $results = $wpdb->get_results( |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param int $TXN_ID |
563 | 563 | * @return EE_Registration |
564 | 564 | */ |
565 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
566 | - if( ! $TXN_ID ){ |
|
565 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
566 | + if ( ! $TXN_ID) { |
|
567 | 567 | return false; |
568 | 568 | } |
569 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
569 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -578,11 +578,11 @@ discard block |
||
578 | 578 | * @param boolean $for_incomplete_payments |
579 | 579 | * @return int |
580 | 580 | */ |
581 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
581 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
582 | 582 | // we only count approved registrations towards registration limits |
583 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
584 | - if( $for_incomplete_payments ){ |
|
585 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
583 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
584 | + if ($for_incomplete_payments) { |
|
585 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | return $this->count($query_params); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | /** @type WPDB $wpdb */ |
599 | 599 | global $wpdb; |
600 | 600 | return $wpdb->query( |
601 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
601 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -608,17 +608,17 @@ discard block |
||
608 | 608 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
609 | 609 | * @return int |
610 | 610 | */ |
611 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
611 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
612 | 612 | global $wpdb; |
613 | 613 | //subquery to get latest checkin |
614 | 614 | $query = $wpdb->prepare( |
615 | 615 | 'SELECT ' |
616 | 616 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
617 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
617 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
618 | 618 | . '( SELECT ' |
619 | 619 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
620 | 620 | . 'REG_ID AS REG_ID ' |
621 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
621 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
622 | 622 | . 'WHERE DTT_ID=%d ' |
623 | 623 | . 'GROUP BY REG_ID' |
624 | 624 | . ') AS most_recent_checkin_per_reg ' |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $DTT_ID, |
630 | 630 | $checked_in |
631 | 631 | ); |
632 | - return (int)$wpdb->get_var( $query ); |
|
632 | + return (int) $wpdb->get_var($query); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
640 | 640 | * @return int |
641 | 641 | */ |
642 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
642 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
643 | 643 | global $wpdb; |
644 | 644 | //subquery to get latest checkin |
645 | 645 | $query = $wpdb->prepare( |
646 | 646 | 'SELECT ' |
647 | 647 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
648 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
648 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
649 | 649 | . '( SELECT ' |
650 | 650 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
651 | 651 | . 'REG_ID AS REG_ID ' |
652 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
653 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
652 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
653 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
654 | 654 | . 'ON c.DTT_ID=d.DTT_ID ' |
655 | 655 | . 'WHERE d.EVT_ID=%d ' |
656 | 656 | . 'GROUP BY REG_ID' |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | $EVT_ID, |
663 | 663 | $checked_in |
664 | 664 | ); |
665 | - return (int)$wpdb->get_var( $query ); |
|
665 | + return (int) $wpdb->get_var($query); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | |
@@ -677,15 +677,15 @@ discard block |
||
677 | 677 | * @param array $attendee_ids |
678 | 678 | * @return EE_Registration[] |
679 | 679 | */ |
680 | - public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) { |
|
680 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) { |
|
681 | 681 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
682 | 682 | global $wpdb; |
683 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
683 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
684 | 684 | $attendee_table = $wpdb->posts; |
685 | - $attendee_ids = is_array( $attendee_ids ) |
|
686 | - ? array_map( 'absint', $attendee_ids ) |
|
687 | - : array( (int) $attendee_ids ); |
|
688 | - $attendee_ids = implode( ',', $attendee_ids ); |
|
685 | + $attendee_ids = is_array($attendee_ids) |
|
686 | + ? array_map('absint', $attendee_ids) |
|
687 | + : array((int) $attendee_ids); |
|
688 | + $attendee_ids = implode(',', $attendee_ids); |
|
689 | 689 | |
690 | 690 | |
691 | 691 | //first we do a query to get the registration ids |
@@ -710,24 +710,24 @@ discard block |
||
710 | 710 | ARRAY_A |
711 | 711 | ); |
712 | 712 | |
713 | - if ( empty( $registration_ids ) ) { |
|
713 | + if (empty($registration_ids)) { |
|
714 | 714 | return array(); |
715 | 715 | } |
716 | 716 | |
717 | 717 | $ids_for_model_query = array(); |
718 | 718 | //let's flatten the ids so they can be used in the model query. |
719 | - foreach ( $registration_ids as $registration_id ) { |
|
720 | - if ( isset( $registration_id['registration_id'] ) ) { |
|
719 | + foreach ($registration_ids as $registration_id) { |
|
720 | + if (isset($registration_id['registration_id'])) { |
|
721 | 721 | $ids_for_model_query[] = $registration_id['registration_id']; |
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | //construct query |
726 | 726 | $_where = array( |
727 | - 'REG_ID' => array( 'IN', $ids_for_model_query ) |
|
727 | + 'REG_ID' => array('IN', $ids_for_model_query) |
|
728 | 728 | ); |
729 | 729 | |
730 | - return $this->get_all( array( $_where ) ); |
|
730 | + return $this->get_all(array($_where)); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | |
4 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | +} |
|
5 | 7 | /** |
6 | 8 | * |
7 | 9 | * Registration Model |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Sum all the deleted items. |
147 | 147 | * @param array $query_params like EEM_Base::get_all |
148 | 148 | * @param string $field_to_sum |
149 | - * @return int |
|
149 | + * @return double |
|
150 | 150 | */ |
151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | - * @return boolean success |
|
198 | + * @return integer success |
|
199 | 199 | */ |
200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
49 | + } else { |
|
50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $query_params |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
119 | 119 | } |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
129 | 129 | } |
130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
138 | 138 | * @return int |
139 | 139 | */ |
140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $field_to_sum |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
153 | 153 | return parent::sum($query_params, $field_to_sum); |
154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @return int |
161 | 161 | */ |
162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
164 | 164 | parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $query_params like EEM_Base::get_all |
170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
171 | 171 | */ |
172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
174 | 174 | return parent::get_all($query_params); |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $query_params like EEM_Base::get_all |
180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
181 | 181 | */ |
182 | - public function get_all_deleted($query_params = array()){ |
|
182 | + public function get_all_deleted($query_params = array()) { |
|
183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
184 | 184 | return parent::get_all($query_params); |
185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | 198 | * @return boolean success |
199 | 199 | */ |
200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function restore_by_ID($ID=FALSE){ |
|
212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
211 | + public function restore_by_ID($ID = FALSE) { |
|
212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
222 | - if ( ! $ID ) { |
|
221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
222 | + if ( ! $ID) { |
|
223 | 223 | return FALSE; |
224 | 224 | } |
225 | 225 | if ( |
226 | 226 | $this->delete_or_restore( |
227 | 227 | $delete, |
228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
229 | 229 | ) |
230 | 230 | ) { |
231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param bool $block_deletes |
246 | 246 | * @return boolean |
247 | 247 | */ |
248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
249 | 249 | //no matter what, we WON'T block soft deletes. |
250 | 250 | return $this->delete_or_restore(true, $query_params); |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $query_params like EEM_Base::get_all |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function restore($query_params = array()){ |
|
259 | + public function restore($query_params = array()) { |
|
260 | 260 | return $this->delete_or_restore(false, $query_params); |
261 | 261 | } |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @param array $query_params like EEM_Base::get_all |
266 | 266 | * @return boolean |
267 | 267 | */ |
268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
272 | 272 | return TRUE; |
273 | 273 | } else { |
274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
287 | 287 | * @return int number of items updated |
288 | 288 | */ |
289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
292 | 292 | } |
293 | 293 | } |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | * @ version 4.0 |
13 | 13 | * |
14 | 14 | */ |
15 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
16 | -require_once( EE_INTERFACES . 'EEI_Interfaces.php' ); |
|
15 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
16 | +require_once(EE_INTERFACES.'EEI_Interfaces.php'); |
|
17 | 17 | /** |
18 | 18 | * |
19 | 19 | * Class EEH_File |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | * @throws EE_Error if filesystem credentials are required |
53 | 53 | * @return WP_Filesystem_Base |
54 | 54 | */ |
55 | - private static function _get_wp_filesystem( $filepath = null) { |
|
56 | - if( apply_filters( |
|
55 | + private static function _get_wp_filesystem($filepath = null) { |
|
56 | + if (apply_filters( |
|
57 | 57 | 'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', |
58 | - $filepath && EEH_File::is_in_uploads_folder( $filepath ), |
|
59 | - $filepath ) ) { |
|
60 | - if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) { |
|
61 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
58 | + $filepath && EEH_File::is_in_uploads_folder($filepath), |
|
59 | + $filepath )) { |
|
60 | + if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) { |
|
61 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
62 | 62 | $method = 'direct'; |
63 | - $wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
63 | + $wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
64 | 64 | //check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem() |
65 | - if ( ! defined('FS_CHMOD_DIR') ) { |
|
66 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
65 | + if ( ! defined('FS_CHMOD_DIR')) { |
|
66 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
67 | 67 | } |
68 | - if ( ! defined('FS_CHMOD_FILE') ) { |
|
69 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
68 | + if ( ! defined('FS_CHMOD_FILE')) { |
|
69 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
70 | 70 | } |
71 | - require_once( $wp_filesystem_direct_file ); |
|
72 | - EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() ); |
|
71 | + require_once($wp_filesystem_direct_file); |
|
72 | + EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array()); |
|
73 | 73 | } |
74 | 74 | return EEH_File::$_wp_filesystem_direct; |
75 | 75 | } |
76 | 76 | global $wp_filesystem; |
77 | 77 | // no filesystem setup ??? |
78 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
78 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
79 | 79 | // if some eager beaver's just trying to get in there too early... |
80 | 80 | // let them do it, because we are one of those eager beavers! :P |
81 | 81 | /** |
@@ -88,34 +88,34 @@ discard block |
||
88 | 88 | * and there may be troubles if the WP files are owned by a different user |
89 | 89 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
90 | 90 | */ |
91 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
91 | + if (FALSE && ! did_action('wp_loaded')) { |
|
92 | 92 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
93 | - if ( WP_DEBUG ) { |
|
94 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
93 | + if (WP_DEBUG) { |
|
94 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
95 | 95 | } |
96 | - throw new EE_Error( $msg ); |
|
96 | + throw new EE_Error($msg); |
|
97 | 97 | } else { |
98 | 98 | // should be loaded if we are past the wp_loaded hook... |
99 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
100 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
101 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
99 | + if ( ! function_exists('WP_Filesystem')) { |
|
100 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
101 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
102 | 102 | } |
103 | 103 | // turn on output buffering so that we can capture the credentials form |
104 | 104 | ob_start(); |
105 | - $credentials = request_filesystem_credentials( '' ); |
|
105 | + $credentials = request_filesystem_credentials(''); |
|
106 | 106 | // store credentials form for the time being |
107 | 107 | EEH_File::$_credentials_form = ob_get_clean(); |
108 | 108 | // basically check for direct or previously configured access |
109 | - if ( ! WP_Filesystem( $credentials ) ) { |
|
109 | + if ( ! WP_Filesystem($credentials)) { |
|
110 | 110 | // if credentials do NOT exist |
111 | - if ( $credentials === FALSE ) { |
|
112 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
113 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
114 | - } elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) { |
|
115 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
111 | + if ($credentials === FALSE) { |
|
112 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
113 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
114 | + } elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
115 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
116 | 116 | throw new EE_Error( |
117 | 117 | sprintf( |
118 | - __( 'WP Filesystem Error: $1%s', 'event_espresso' ), |
|
118 | + __('WP Filesystem Error: $1%s', 'event_espresso'), |
|
119 | 119 | $wp_filesystem->errors->get_error_message() ) ); |
120 | 120 | } |
121 | 121 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * display_request_filesystem_credentials_form |
129 | 129 | */ |
130 | 130 | public static function display_request_filesystem_credentials_form() { |
131 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
132 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
131 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
132 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -147,29 +147,29 @@ discard block |
||
147 | 147 | * @throws EE_Error if filesystem credentials are required |
148 | 148 | * @return bool |
149 | 149 | */ |
150 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
150 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
151 | 151 | // load WP_Filesystem and set file permissions |
152 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
153 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
154 | - if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) { |
|
155 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
156 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
152 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
153 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
154 | + if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
155 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
156 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
157 | 157 | $msg = sprintf( |
158 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
158 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
159 | 159 | $file_name, |
160 | 160 | '<br />' |
161 | 161 | ); |
162 | - if ( EEH_File::exists( $full_file_path )) { |
|
163 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
162 | + if (EEH_File::exists($full_file_path)) { |
|
163 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
164 | 164 | } else { |
165 | 165 | // no file permissions means the file was not found |
166 | 166 | $msg .= sprintf( |
167 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
167 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
168 | 168 | $full_file_path |
169 | 169 | ); |
170 | 170 | } |
171 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
172 | - throw new EE_Error( $msg . '||' . $msg ); |
|
171 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
172 | + throw new EE_Error($msg.'||'.$msg); |
|
173 | 173 | } |
174 | 174 | return FALSE; |
175 | 175 | } |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | * @throws EE_Error if filesystem credentials are required |
188 | 188 | * @return string |
189 | 189 | */ |
190 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
190 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
191 | 191 | // load WP_Filesystem and set file permissions |
192 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
192 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
193 | 193 | // check file permissions |
194 | - $perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
195 | - if ( $perms ) { |
|
194 | + $perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
195 | + if ($perms) { |
|
196 | 196 | // file permissions exist, but way be set incorrectly |
197 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
198 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
197 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
198 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
199 | 199 | return sprintf( |
200 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
200 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
201 | 201 | $type_of_file, |
202 | 202 | $perms |
203 | 203 | ); |
204 | 204 | } else { |
205 | 205 | // file exists but file permissions could not be read ?!?! |
206 | 206 | return sprintf( |
207 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
207 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
208 | 208 | $full_file_path |
209 | 209 | ); |
210 | 210 | } |
@@ -222,35 +222,35 @@ discard block |
||
222 | 222 | * can't write to it |
223 | 223 | * @return bool false if folder isn't writable; true if it exists and is writeable, |
224 | 224 | */ |
225 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
226 | - if ( empty( $folder )) { |
|
225 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
226 | + if (empty($folder)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | // remove ending DS |
230 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
231 | - $parent_folder = EEH_File::get_parent_folder( $folder ); |
|
230 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
231 | + $parent_folder = EEH_File::get_parent_folder($folder); |
|
232 | 232 | // add DS to folder |
233 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
234 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $folder ); |
|
235 | - if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
233 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
234 | + $wp_filesystem = EEH_File::_get_wp_filesystem($folder); |
|
235 | + if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
236 | 236 | //ok so it doesn't exist. Does its parent? Can we write to it? |
237 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
237 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
238 | 238 | return false; |
239 | 239 | } |
240 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
240 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
241 | 241 | return false; |
242 | 242 | } else { |
243 | - if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) { |
|
244 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
245 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
246 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
247 | - throw new EE_Error( $msg ); |
|
243 | + if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) { |
|
244 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
245 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
246 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
247 | + throw new EE_Error($msg); |
|
248 | 248 | } |
249 | 249 | return false; |
250 | 250 | } |
251 | - EEH_File::add_index_file( $folder ); |
|
251 | + EEH_File::add_index_file($folder); |
|
252 | 252 | } |
253 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
253 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | return true; |
@@ -265,15 +265,15 @@ discard block |
||
265 | 265 | * @throws EE_Error if filesystem credentials are required |
266 | 266 | * @return bool |
267 | 267 | */ |
268 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
268 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
269 | 269 | // load WP_Filesystem and set file permissions |
270 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_path ); |
|
271 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
272 | - if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) { |
|
273 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
274 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
275 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
276 | - throw new EE_Error( $msg ); |
|
270 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_path); |
|
271 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
272 | + if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) { |
|
273 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
274 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
275 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
276 | + throw new EE_Error($msg); |
|
277 | 277 | } |
278 | 278 | return FALSE; |
279 | 279 | } |
@@ -290,25 +290,25 @@ discard block |
||
290 | 290 | * @throws EE_Error if filesystem credentials are required |
291 | 291 | * @return bool |
292 | 292 | */ |
293 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
293 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
294 | 294 | // load WP_Filesystem and set file permissions |
295 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
296 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
297 | - $parent_folder = EEH_File::get_parent_folder( $full_file_path ); |
|
298 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
299 | - if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) { |
|
295 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
296 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
297 | + $parent_folder = EEH_File::get_parent_folder($full_file_path); |
|
298 | + if ( ! EEH_File::exists($full_file_path)) { |
|
299 | + if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) { |
|
300 | 300 | return false; |
301 | 301 | } |
302 | - if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
303 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
304 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
305 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
306 | - throw new EE_Error( $msg ); |
|
302 | + if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
303 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
304 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
305 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
306 | + throw new EE_Error($msg); |
|
307 | 307 | } |
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | } |
311 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
311 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
312 | 312 | return false; |
313 | 313 | } |
314 | 314 | return true; |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | * @param string $file_or_folder_path |
321 | 321 | * @return string parent folder, ENDING with a directory separator |
322 | 322 | */ |
323 | - public static function get_parent_folder( $file_or_folder_path ) { |
|
323 | + public static function get_parent_folder($file_or_folder_path) { |
|
324 | 324 | //find the last DS, ignoring a DS on the very end |
325 | 325 | //eg if given "/var/something/somewhere/", we want to get "somewhere"'s |
326 | 326 | //parent folder, "/var/something/" |
327 | - $ds = strlen($file_or_folder_path) > 1 ? strrpos( $file_or_folder_path, DS, -2 ) : $file_or_folder_path; |
|
328 | - return substr( $file_or_folder_path, 0, $ds + 1 ); |
|
327 | + $ds = strlen($file_or_folder_path) > 1 ? strrpos($file_or_folder_path, DS, -2) : $file_or_folder_path; |
|
328 | + return substr($file_or_folder_path, 0, $ds + 1); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | // public static function ensure_folder_exists_recursively( $folder ) { |
@@ -340,12 +340,12 @@ discard block |
||
340 | 340 | * @throws EE_Error if filesystem credentials are required |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - public static function get_file_contents( $full_file_path = '' ){ |
|
344 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
345 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
343 | + public static function get_file_contents($full_file_path = '') { |
|
344 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
345 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
346 | 346 | // load WP_Filesystem and set file permissions |
347 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
348 | - return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ); |
|
347 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
348 | + return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)); |
|
349 | 349 | } |
350 | 350 | return ''; |
351 | 351 | } |
@@ -360,26 +360,26 @@ discard block |
||
360 | 360 | * @throws EE_Error if filesystem credentials are required |
361 | 361 | * @return bool |
362 | 362 | */ |
363 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
364 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
365 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
366 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
367 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
368 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
369 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
370 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
371 | - throw new EE_Error( $msg ); |
|
363 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
364 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
365 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
366 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
367 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
368 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
369 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
370 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
371 | + throw new EE_Error($msg); |
|
372 | 372 | } |
373 | 373 | return FALSE; |
374 | 374 | } |
375 | 375 | // load WP_Filesystem and set file permissions |
376 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
376 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
377 | 377 | // write the file |
378 | - if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) { |
|
379 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
380 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
381 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
382 | - throw new EE_Error( $msg ); |
|
378 | + if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) { |
|
379 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
380 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
381 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
382 | + throw new EE_Error($msg); |
|
383 | 383 | } |
384 | 384 | return FALSE; |
385 | 385 | } |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | * @throws EE_Error if filesystem credentials are required |
396 | 396 | * @return boolean |
397 | 397 | */ |
398 | - public static function delete( $filepath, $recursive = false, $type = false ) { |
|
398 | + public static function delete($filepath, $recursive = false, $type = false) { |
|
399 | 399 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
400 | - return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE; |
|
400 | + return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * @throws EE_Error if filesystem credentials are required |
410 | 410 | * @return bool |
411 | 411 | */ |
412 | - public static function exists( $full_file_path = '' ) { |
|
413 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
414 | - return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE; |
|
412 | + public static function exists($full_file_path = '') { |
|
413 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
414 | + return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -424,9 +424,9 @@ discard block |
||
424 | 424 | * @throws EE_Error if filesystem credentials are required |
425 | 425 | * @return bool |
426 | 426 | */ |
427 | - public static function is_readable( $full_file_path = '' ) { |
|
428 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path ); |
|
429 | - if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) { |
|
427 | + public static function is_readable($full_file_path = '') { |
|
428 | + $wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path); |
|
429 | + if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) { |
|
430 | 430 | return true; |
431 | 431 | } else { |
432 | 432 | return false; |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | * @param string $full_file_path |
443 | 443 | * @return string |
444 | 444 | */ |
445 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
446 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
445 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
446 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * @param string $full_file_path |
454 | 454 | * @return string |
455 | 455 | */ |
456 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
457 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
456 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
457 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | * @param string $full_file_path |
465 | 465 | * @return string |
466 | 466 | */ |
467 | - public static function get_file_extension( $full_file_path = '' ) { |
|
468 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
467 | + public static function get_file_extension($full_file_path = '') { |
|
468 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | * @throws EE_Error if filesystem credentials are required |
477 | 477 | * @return bool |
478 | 478 | */ |
479 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
480 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
481 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
482 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
479 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
480 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
481 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
482 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
483 | 483 | return FALSE; |
484 | 484 | } |
485 | 485 | } |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | * @throws EE_Error if filesystem credentials are required |
494 | 494 | * @return boolean |
495 | 495 | */ |
496 | - public static function add_index_file( $folder ) { |
|
497 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
498 | - if ( ! EEH_File::exists( $folder . 'index.php' ) ) { |
|
499 | - if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) { |
|
496 | + public static function add_index_file($folder) { |
|
497 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
498 | + if ( ! EEH_File::exists($folder.'index.php')) { |
|
499 | + if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) { |
|
500 | 500 | return false; |
501 | 501 | } |
502 | 502 | } |
@@ -511,11 +511,11 @@ discard block |
||
511 | 511 | * @param string $file_path |
512 | 512 | * @return string |
513 | 513 | */ |
514 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
514 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
515 | 515 | //extract file from path |
516 | - $filename = basename( $file_path ); |
|
516 | + $filename = basename($file_path); |
|
517 | 517 | //now remove the first period and everything after |
518 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
518 | + $pos_of_first_period = strpos($filename, '.'); |
|
519 | 519 | return substr($filename, 0, $pos_of_first_period); |
520 | 520 | } |
521 | 521 | |
@@ -527,8 +527,8 @@ discard block |
||
527 | 527 | * @param string $file_path |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - public static function standardise_directory_separators( $file_path ){ |
|
531 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
530 | + public static function standardise_directory_separators($file_path) { |
|
531 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @param string $file_path |
540 | 540 | * @return string |
541 | 541 | */ |
542 | - public static function end_with_directory_separator( $file_path ){ |
|
543 | - return rtrim( $file_path, '/\\' ) . DS; |
|
542 | + public static function end_with_directory_separator($file_path) { |
|
543 | + return rtrim($file_path, '/\\').DS; |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @param $file_path |
551 | 551 | * @return string |
552 | 552 | */ |
553 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
554 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
553 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
554 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | |
@@ -568,21 +568,21 @@ discard block |
||
568 | 568 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
569 | 569 | * and values are their filepaths |
570 | 570 | */ |
571 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
571 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
572 | 572 | $class_to_folder_path = array(); |
573 | - foreach( $folder_paths as $folder_path ){ |
|
574 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
573 | + foreach ($folder_paths as $folder_path) { |
|
574 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
575 | 575 | // load WP_Filesystem and set file permissions |
576 | - $files_in_folder = glob( $folder_path . '*' ); |
|
576 | + $files_in_folder = glob($folder_path.'*'); |
|
577 | 577 | $class_to_folder_path = array(); |
578 | - if ( $files_in_folder ) { |
|
579 | - foreach( $files_in_folder as $file_path ){ |
|
578 | + if ($files_in_folder) { |
|
579 | + foreach ($files_in_folder as $file_path) { |
|
580 | 580 | //only add files, not folders |
581 | - if ( ! is_dir( $file_path )) { |
|
582 | - if ( $index_numerically ) { |
|
581 | + if ( ! is_dir($file_path)) { |
|
582 | + if ($index_numerically) { |
|
583 | 583 | $class_to_folder_path[] = $file_path; |
584 | 584 | } else { |
585 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
585 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
586 | 586 | $class_to_folder_path[$classname] = $file_path; |
587 | 587 | } |
588 | 588 | } |
@@ -602,39 +602,39 @@ discard block |
||
602 | 602 | * @throws EE_Error if filesystem credentials are required |
603 | 603 | * @return boolean success |
604 | 604 | */ |
605 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
606 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
607 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
608 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
609 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
610 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
611 | - throw new EE_Error( $msg ); |
|
605 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
606 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
607 | + if ( ! EEH_File::exists($full_source_path)) { |
|
608 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
609 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
610 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
611 | + throw new EE_Error($msg); |
|
612 | 612 | } |
613 | 613 | return FALSE; |
614 | 614 | } |
615 | 615 | |
616 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
617 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
618 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
619 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
620 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
621 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
622 | - throw new EE_Error( $msg ); |
|
616 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
617 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
618 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
619 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
620 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
621 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
622 | + throw new EE_Error($msg); |
|
623 | 623 | } |
624 | 624 | return FALSE; |
625 | 625 | } |
626 | 626 | |
627 | 627 | // load WP_Filesystem and set file permissions |
628 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file ); |
|
628 | + $wp_filesystem = EEH_File::_get_wp_filesystem($destination_file); |
|
629 | 629 | // write the file |
630 | 630 | if ( ! $wp_filesystem->copy( |
631 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), |
|
632 | - EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), |
|
631 | + EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), |
|
632 | + EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), |
|
633 | 633 | $overwrite )) { |
634 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
635 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
636 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
637 | - throw new EE_Error( $msg ); |
|
634 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
635 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
636 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
637 | + throw new EE_Error($msg); |
|
638 | 638 | } |
639 | 639 | return FALSE; |
640 | 640 | } |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @param string $filepath |
647 | 647 | * @return boolean |
648 | 648 | */ |
649 | - public static function is_in_uploads_folder( $filepath ) { |
|
649 | + public static function is_in_uploads_folder($filepath) { |
|
650 | 650 | $uploads = wp_upload_dir(); |
651 | - return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false; |
|
651 | + return strpos($filepath, $uploads['basedir']) === 0 ? true : false; |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -663,9 +663,9 @@ discard block |
||
663 | 663 | * @return string the remote filepath (eg the filepath the filesystem method, eg |
664 | 664 | * ftp or ssh, will use to access the folder |
665 | 665 | */ |
666 | - public static function convert_local_filepath_to_remote_filepath( $local_filepath ) { |
|
667 | - $wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath ); |
|
668 | - return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath ); |
|
666 | + public static function convert_local_filepath_to_remote_filepath($local_filepath) { |
|
667 | + $wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath); |
|
668 | + return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | // End of file EEH_File.helper.php |
@@ -658,8 +658,6 @@ |
||
658 | 658 | * converts it into a "remote" filepath (the filepath the currently-in-use |
659 | 659 | * $wp_filesystem needs to use access the folder or file). |
660 | 660 | * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins |
661 | - * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one |
|
662 | - * is in use, so you need to provide it |
|
663 | 661 | * @param string $local_filepath the filepath to the folder/file locally |
664 | 662 | * @throws EE_Error if filesystem credentials are required |
665 | 663 | * @return string the remote filepath (eg the filepath the filesystem method, eg |