@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @subpackage includes/classes/EE_Transaction.class.php |
27 | 27 | * @author Brent Christensen |
28 | 28 | */ |
29 | -class EE_Transaction extends EE_Base_Class implements EEI_Transaction{ |
|
29 | +class EE_Transaction extends EE_Base_Class implements EEI_Transaction { |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * date_format and the second value is the time format |
39 | 39 | * @return EE_Transaction |
40 | 40 | */ |
41 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
42 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
43 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
41 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
42 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
43 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * the website will be used. |
52 | 52 | * @return EE_Attendee |
53 | 53 | */ |
54 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
55 | - return new self( $props_n_values, TRUE, $timezone ); |
|
54 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
55 | + return new self($props_n_values, TRUE, $timezone); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | public function lock() { |
70 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
71 | - $locked_transactions[ $this->ID() ] = true; |
|
72 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
70 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
71 | + $locked_transactions[$this->ID()] = true; |
|
72 | + update_option('ee_locked_transactions', $locked_transactions); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @return void |
84 | 84 | */ |
85 | 85 | public function unlock() { |
86 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
87 | - unset( $locked_transactions[ $this->ID() ] ); |
|
88 | - update_option( 'ee_locked_transactions', $locked_transactions ); |
|
86 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
87 | + unset($locked_transactions[$this->ID()]); |
|
88 | + update_option('ee_locked_transactions', $locked_transactions); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | 104 | public function is_locked() { |
105 | - $locked_transactions = get_option( 'ee_locked_transactions', array() ); |
|
106 | - return isset( $locked_transactions[ $this->ID() ] ) ? true : false; |
|
105 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
106 | + return isset($locked_transactions[$this->ID()]) ? true : false; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @access public |
115 | 115 | * @param float $total total value of transaction |
116 | 116 | */ |
117 | - public function set_total( $total = 0.00 ) { |
|
118 | - $this->set( 'TXN_total', $total ); |
|
117 | + public function set_total($total = 0.00) { |
|
118 | + $this->set('TXN_total', $total); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param float $total_paid total amount paid to date (sum of all payments) |
128 | 128 | */ |
129 | - public function set_paid( $total_paid = 0.00 ) { |
|
130 | - $this->set( 'TXN_paid', $total_paid ); |
|
129 | + public function set_paid($total_paid = 0.00) { |
|
130 | + $this->set('TXN_paid', $total_paid); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @access public |
139 | 139 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
140 | 140 | */ |
141 | - public function set_status( $status = '' ) { |
|
142 | - $this->set( 'STS_ID', $status ); |
|
141 | + public function set_status($status = '') { |
|
142 | + $this->set('STS_ID', $status); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @access public |
151 | 151 | * @param string $hash_salt required for some payment gateways |
152 | 152 | */ |
153 | - public function set_hash_salt( $hash_salt = '' ) { |
|
154 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
153 | + public function set_hash_salt($hash_salt = '') { |
|
154 | + $this->set('TXN_hash_salt', $hash_salt); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * Sets TXN_reg_steps array |
161 | 161 | * @param array $txn_reg_steps |
162 | 162 | */ |
163 | - function set_reg_steps( $txn_reg_steps ) { |
|
164 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
163 | + function set_reg_steps($txn_reg_steps) { |
|
164 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @return array |
172 | 172 | */ |
173 | 173 | function reg_steps() { |
174 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
175 | - return is_array( $TXN_reg_steps ) ? $TXN_reg_steps : array(); |
|
174 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
175 | + return is_array($TXN_reg_steps) ? $TXN_reg_steps : array(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return string of transaction's total cost, with currency symbol and decimal |
183 | 183 | */ |
184 | 184 | public function pretty_total() { |
185 | - return $this->get_pretty( 'TXN_total' ); |
|
185 | + return $this->get_pretty('TXN_total'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return string |
193 | 193 | */ |
194 | 194 | public function pretty_paid() { |
195 | - return $this->get_pretty( 'TXN_paid' ); |
|
195 | + return $this->get_pretty('TXN_paid'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | * @return float amount remaining |
205 | 205 | */ |
206 | 206 | public function remaining() { |
207 | - return (float)( $this->total() - $this->paid() ); |
|
207 | + return (float) ($this->total() - $this->paid()); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return float |
216 | 216 | */ |
217 | 217 | public function total() { |
218 | - return $this->get( 'TXN_total' ); |
|
218 | + return $this->get('TXN_total'); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return float |
227 | 227 | */ |
228 | 228 | public function paid() { |
229 | - return $this->get( 'TXN_paid' ); |
|
229 | + return $this->get('TXN_paid'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | * @access public |
237 | 237 | */ |
238 | 238 | public function get_cart_session() { |
239 | - $session_data = $this->get( 'TXN_session_data' ); |
|
240 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart ? $session_data[ 'cart' ] : NULL; |
|
239 | + $session_data = $this->get('TXN_session_data'); |
|
240 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart ? $session_data['cart'] : NULL; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @access public |
248 | 248 | */ |
249 | 249 | public function session_data() { |
250 | - $session_data = $this->get( 'TXN_session_data' ); |
|
251 | - if ( empty( $session_data ) ) { |
|
252 | - $session_data = array( 'id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array() ); |
|
250 | + $session_data = $this->get('TXN_session_data'); |
|
251 | + if (empty($session_data)) { |
|
252 | + $session_data = array('id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array()); |
|
253 | 253 | } |
254 | 254 | return $session_data; |
255 | 255 | } |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | * @access public |
263 | 263 | * @param EE_Session|array $session_data |
264 | 264 | */ |
265 | - public function set_txn_session_data( $session_data ) { |
|
266 | - if ( $session_data instanceof EE_Session ) { |
|
267 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
265 | + public function set_txn_session_data($session_data) { |
|
266 | + if ($session_data instanceof EE_Session) { |
|
267 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
268 | 268 | } else { |
269 | - $this->set( 'TXN_session_data', $session_data ); |
|
269 | + $this->set('TXN_session_data', $session_data); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @access public |
278 | 278 | */ |
279 | 279 | public function hash_salt_() { |
280 | - return $this->get( 'TXN_hash_salt' ); |
|
280 | + return $this->get('TXN_hash_salt'); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @param boolean $gmt - whether to return a unix timestamp with UTC offset applied (default) or no UTC offset applied |
298 | 298 | * @return string | int |
299 | 299 | */ |
300 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
301 | - if ( $format ) { |
|
302 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
303 | - } else if ( $gmt ) { |
|
304 | - return $this->get_raw( 'TXN_timestamp' ); |
|
300 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
301 | + if ($format) { |
|
302 | + return $this->get_pretty('TXN_timestamp'); |
|
303 | + } else if ($gmt) { |
|
304 | + return $this->get_raw('TXN_timestamp'); |
|
305 | 305 | } else { |
306 | - return $this->get( 'TXN_timestamp' ); |
|
306 | + return $this->get('TXN_timestamp'); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | * @param boolean $get_cached TRUE to retrieve cached registrations or FALSE to pull from the db |
316 | 316 | * @return EE_Registration[] |
317 | 317 | */ |
318 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
319 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) ? array( 'order_by' => array( 'Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC' ) ) : $query_params; |
|
318 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
319 | + $query_params = (empty($query_params) || ! is_array($query_params)) ? array('order_by' => array('Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC')) : $query_params; |
|
320 | 320 | $query_params = $get_cached ? array() : $query_params; |
321 | - return $this->get_many_related( 'Registration', $query_params ); |
|
321 | + return $this->get_many_related('Registration', $query_params); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
330 | 330 | */ |
331 | 331 | public function attendees() { |
332 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
332 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param array $query_params like EEM_Base::get_all |
340 | 340 | * @return EE_Payment[] |
341 | 341 | */ |
342 | - public function payments( $query_params = array() ) { |
|
343 | - return $this->get_many_related( 'Payment', $query_params ); |
|
342 | + public function payments($query_params = array()) { |
|
343 | + return $this->get_many_related('Payment', $query_params); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | * @return EE_Payment[] |
351 | 351 | */ |
352 | 352 | public function approved_payments() { |
353 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
354 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
353 | + EE_Registry::instance()->load_model('Payment'); |
|
354 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | * @param bool $show_icons |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
365 | - echo $this->pretty_status( $show_icons ); |
|
364 | + public function e_pretty_status($show_icons = FALSE) { |
|
365 | + echo $this->pretty_status($show_icons); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | * @param bool $show_icons |
373 | 373 | * @return string |
374 | 374 | */ |
375 | - public function pretty_status( $show_icons = FALSE ) { |
|
376 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
375 | + public function pretty_status($show_icons = FALSE) { |
|
376 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
377 | 377 | $icon = ''; |
378 | - switch ( $this->status_ID() ) { |
|
378 | + switch ($this->status_ID()) { |
|
379 | 379 | case EEM_Transaction::complete_status_code: |
380 | 380 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
381 | 381 | break; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
393 | 393 | break; |
394 | 394 | } |
395 | - return $icon . $status[ $this->status_ID() ]; |
|
395 | + return $icon.$status[$this->status_ID()]; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @access public |
403 | 403 | */ |
404 | 404 | public function status_ID() { |
405 | - return $this->get( 'STS_ID' ); |
|
405 | + return $this->get('STS_ID'); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return boolean |
413 | 413 | */ |
414 | 414 | public function is_free() { |
415 | - return (float)$this->get( 'TXN_total' ) == 0 ? TRUE : FALSE; |
|
415 | + return (float) $this->get('TXN_total') == 0 ? TRUE : FALSE; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | * @access public |
481 | 481 | * @return string |
482 | 482 | */ |
483 | - public function invoice_url( $type = 'html' ) { |
|
483 | + public function invoice_url($type = 'html') { |
|
484 | 484 | $REG = $this->primary_registration(); |
485 | - if ( ! $REG instanceof EE_Registration ) { |
|
485 | + if ( ! $REG instanceof EE_Registration) { |
|
486 | 486 | return ''; |
487 | 487 | } |
488 | - return $REG->invoice_url( $type ); |
|
488 | + return $REG->invoice_url($type); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @return EE_Registration |
496 | 496 | */ |
497 | 497 | public function primary_registration() { |
498 | - return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) ); |
|
498 | + return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -505,12 +505,12 @@ discard block |
||
505 | 505 | * @param string $type 'pdf' or 'html' (default is 'html') |
506 | 506 | * @return string |
507 | 507 | */ |
508 | - public function receipt_url( $type = 'html' ) { |
|
508 | + public function receipt_url($type = 'html') { |
|
509 | 509 | $REG = $this->primary_registration(); |
510 | - if ( ! $REG instanceof EE_Registration ) { |
|
510 | + if ( ! $REG instanceof EE_Registration) { |
|
511 | 511 | return ''; |
512 | 512 | } |
513 | - return $REG->receipt_url( $type ); |
|
513 | + return $REG->receipt_url($type); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
@@ -535,15 +535,15 @@ discard block |
||
535 | 535 | * @deprecated |
536 | 536 | * @return boolean |
537 | 537 | */ |
538 | - public function update_based_on_payments(){ |
|
538 | + public function update_based_on_payments() { |
|
539 | 539 | EE_Error::doing_it_wrong( |
540 | - __CLASS__ . '::' . __FUNCTION__, |
|
541 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
540 | + __CLASS__.'::'.__FUNCTION__, |
|
541 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
542 | 542 | '4.6.0' |
543 | 543 | ); |
544 | 544 | /** @type EE_Transaction_Processor $transaction_processor */ |
545 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
546 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this ); |
|
545 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
546 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @return string |
553 | 553 | */ |
554 | 554 | public function gateway_response_on_transaction() { |
555 | - $payment = $this->get_first_related( 'Payment' ); |
|
555 | + $payment = $this->get_first_related('Payment'); |
|
556 | 556 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
557 | 557 | } |
558 | 558 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * @return EE_Status |
564 | 564 | */ |
565 | 565 | public function status_obj() { |
566 | - return $this->get_first_related( 'Status' ); |
|
566 | + return $this->get_first_related('Status'); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param array $query_params like EEM_Base::get_all |
574 | 574 | * @return EE_Extra_Meta |
575 | 575 | */ |
576 | - public function extra_meta( $query_params = array() ) { |
|
577 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
576 | + public function extra_meta($query_params = array()) { |
|
577 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param EE_Registration $registration |
585 | 585 | * @return EE_Base_Class the relation was added to |
586 | 586 | */ |
587 | - public function add_registration( EE_Registration $registration ) { |
|
588 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
587 | + public function add_registration(EE_Registration $registration) { |
|
588 | + return $this->_add_relation_to($registration, 'Registration'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | * @param int $registration_or_id |
597 | 597 | * @return EE_Base_Class that was removed from being related |
598 | 598 | */ |
599 | - public function remove_registration_with_id( $registration_or_id ) { |
|
600 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
599 | + public function remove_registration_with_id($registration_or_id) { |
|
600 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * @return EE_Line_Item[] |
608 | 608 | */ |
609 | 609 | public function items_purchased() { |
610 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
610 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | * @param EE_Line_Item $line_item |
618 | 618 | * @return EE_Base_Class the relation was added to |
619 | 619 | */ |
620 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
621 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
620 | + public function add_line_item(EE_Line_Item $line_item) { |
|
621 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param array $query_params |
629 | 629 | * @return EE_Line_Item[] |
630 | 630 | */ |
631 | - public function line_items( $query_params = array() ) { |
|
632 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
631 | + public function line_items($query_params = array()) { |
|
632 | + return $this->get_many_related('Line_Item', $query_params); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * @return EE_Line_Item[] |
640 | 640 | */ |
641 | 641 | public function tax_items() { |
642 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
642 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | |
@@ -650,10 +650,10 @@ discard block |
||
650 | 650 | * @return EE_Line_Item |
651 | 651 | */ |
652 | 652 | public function total_line_item() { |
653 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
654 | - if( ! $item ){ |
|
655 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
656 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
653 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
654 | + if ( ! $item) { |
|
655 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
656 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
657 | 657 | } |
658 | 658 | return $item; |
659 | 659 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function tax_total() { |
669 | 669 | $tax_line_item = $this->tax_total_line_item(); |
670 | - if ( $tax_line_item ) { |
|
670 | + if ($tax_line_item) { |
|
671 | 671 | return $tax_line_item->total(); |
672 | 672 | } else { |
673 | 673 | return 0; |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @return EE_Line_Item |
682 | 682 | */ |
683 | 683 | public function tax_total_line_item() { |
684 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
684 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | |
@@ -690,20 +690,20 @@ discard block |
||
690 | 690 | * Gets the array of billing info for the gateway and for this transaction's primary registration's attendee. |
691 | 691 | * @return EE_Form_Section_Proper |
692 | 692 | */ |
693 | - public function billing_info(){ |
|
693 | + public function billing_info() { |
|
694 | 694 | $payment_method = $this->payment_method(); |
695 | - if ( !$payment_method){ |
|
695 | + if ( ! $payment_method) { |
|
696 | 696 | EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
697 | 697 | return false; |
698 | 698 | } |
699 | 699 | $primary_reg = $this->primary_registration(); |
700 | - if ( ! $primary_reg ) { |
|
701 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
700 | + if ( ! $primary_reg) { |
|
701 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
702 | 702 | return FALSE; |
703 | 703 | } |
704 | 704 | $attendee = $primary_reg->attendee(); |
705 | - if ( ! $attendee ) { |
|
706 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
705 | + if ( ! $attendee) { |
|
706 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
707 | 707 | return FALSE; |
708 | 708 | } |
709 | 709 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | * offline ones, dont' create payments) |
739 | 739 | * @return EE_Payment_Method |
740 | 740 | */ |
741 | - function payment_method(){ |
|
741 | + function payment_method() { |
|
742 | 742 | $pm = $this->get_first_related('Payment_Method'); |
743 | - if( $pm instanceof EE_Payment_Method ){ |
|
743 | + if ($pm instanceof EE_Payment_Method) { |
|
744 | 744 | return $pm; |
745 | - }else{ |
|
745 | + } else { |
|
746 | 746 | $last_payment = $this->last_payment(); |
747 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
747 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
748 | 748 | return $last_payment->payment_method(); |
749 | - }else{ |
|
749 | + } else { |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | } |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | * @return EE_Payment |
758 | 758 | */ |
759 | 759 | public function last_payment() { |
760 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
760 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
764 | 764 | * Gets all the line items which are unrelated to tickets on this transaction |
765 | 765 | * @return EE_Line_Item[] |
766 | 766 | */ |
767 | - public function non_ticket_line_items(){ |
|
768 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
767 | + public function non_ticket_line_items() { |
|
768 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
41 | 41 | * @return boolean success |
42 | 42 | */ |
43 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
44 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
43 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
44 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
45 | 45 | $line_item = EE_Line_Item::new_instance(array( |
46 | 46 | 'LIN_name' => $name, |
47 | 47 | 'LIN_desc' => $description, |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | 'LIN_quantity' => $quantity, |
50 | 50 | 'LIN_percent' => null, |
51 | 51 | 'LIN_is_taxable' => $taxable, |
52 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
53 | - 'LIN_total' => floatval( $unit_price ) * intval( $quantity ), |
|
52 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
53 | + 'LIN_total' => floatval($unit_price) * intval($quantity), |
|
54 | 54 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
55 | 55 | 'LIN_code' => $code, |
56 | 56 | )); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $line_item, |
60 | 60 | $parent_line_item |
61 | 61 | ); |
62 | - return self::add_item( $parent_line_item, $line_item ); |
|
62 | + return self::add_item($parent_line_item, $line_item); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param boolean $taxable |
81 | 81 | * @return boolean success |
82 | 82 | */ |
83 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
83 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
84 | 84 | $line_item = EE_Line_Item::new_instance(array( |
85 | 85 | 'LIN_name' => $name, |
86 | 86 | 'LIN_desc' => $description, |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | 'LIN_percent' => $percentage_amount, |
89 | 89 | 'LIN_quantity' => NULL, |
90 | 90 | 'LIN_is_taxable' => $taxable, |
91 | - 'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )), |
|
91 | + 'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)), |
|
92 | 92 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
93 | 93 | 'LIN_parent' => $parent_line_item->ID() |
94 | 94 | )); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
97 | 97 | $line_item |
98 | 98 | ); |
99 | - return self::add_item( $parent_line_item, $line_item ); |
|
99 | + return self::add_item($parent_line_item, $line_item); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | * @return \EE_Line_Item |
118 | 118 | * @throws \EE_Error |
119 | 119 | */ |
120 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
121 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
122 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
120 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
121 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
122 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
123 | 123 | } |
124 | 124 | // either increment the qty for an existing ticket |
125 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
125 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
126 | 126 | // or add a new one |
127 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
128 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
127 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
128 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
129 | 129 | } |
130 | 130 | $total_line_item->recalculate_total_including_taxes(); |
131 | 131 | return $line_item; |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | * @return \EE_Line_Item |
142 | 142 | * @throws \EE_Error |
143 | 143 | */ |
144 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
144 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
145 | 145 | $line_item = null; |
146 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
147 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
148 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
149 | - if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) { |
|
146 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
147 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
148 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
149 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) { |
|
150 | 150 | $line_item = $ticket_line_item; |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
155 | - if ( $line_item instanceof EE_Line_Item ) { |
|
156 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
155 | + if ($line_item instanceof EE_Line_Item) { |
|
156 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
157 | 157 | return $line_item; |
158 | 158 | } |
159 | 159 | return null; |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | * @param int $qty |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
170 | - if( ! $line_item->is_percent() ) { |
|
169 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
170 | + if ( ! $line_item->is_percent()) { |
|
171 | 171 | $qty += $line_item->quantity(); |
172 | - $line_item->set_quantity( $qty ); |
|
173 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
172 | + $line_item->set_quantity($qty); |
|
173 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
174 | 174 | } |
175 | - foreach( $line_item->children() as $child ) { |
|
176 | - if( $child->is_sub_line_item() ) { |
|
177 | - EEH_Line_Item::update_quantity( $child, $line_item->quantity() ); |
|
175 | + foreach ($line_item->children() as $child) { |
|
176 | + if ($child->is_sub_line_item()) { |
|
177 | + EEH_Line_Item::update_quantity($child, $line_item->quantity()); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | } |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | * @param EE_Line_Item $line_item |
186 | 186 | * @param int $new_quantity |
187 | 187 | */ |
188 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
189 | - if( ! $line_item->is_percent() ) { |
|
190 | - $line_item->set_quantity( $new_quantity ); |
|
191 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
188 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
189 | + if ( ! $line_item->is_percent()) { |
|
190 | + $line_item->set_quantity($new_quantity); |
|
191 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
192 | 192 | } |
193 | - foreach( $line_item->children() as $child ) { |
|
194 | - if( $child->is_sub_line_item() ) { |
|
195 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
193 | + foreach ($line_item->children() as $child) { |
|
194 | + if ($child->is_sub_line_item()) { |
|
195 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -207,45 +207,45 @@ discard block |
||
207 | 207 | * @return \EE_Line_Item |
208 | 208 | * @throws \EE_Error |
209 | 209 | */ |
210 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
210 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
211 | 211 | $datetimes = $ticket->datetimes(); |
212 | - $first_datetime = reset( $datetimes ); |
|
213 | - if( $first_datetime instanceof EE_Datetime && |
|
214 | - $first_datetime->event() instanceof EE_Event ) { |
|
212 | + $first_datetime = reset($datetimes); |
|
213 | + if ($first_datetime instanceof EE_Datetime && |
|
214 | + $first_datetime->event() instanceof EE_Event) { |
|
215 | 215 | $first_datetime_name = $first_datetime->event()->name(); |
216 | 216 | } else { |
217 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
217 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
218 | 218 | } |
219 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
219 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
220 | 220 | // get event subtotal line |
221 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
222 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
223 | - throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
221 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
222 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
223 | + throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
224 | 224 | } |
225 | 225 | // add $ticket to cart |
226 | - $line_item = EE_Line_Item::new_instance( array( |
|
226 | + $line_item = EE_Line_Item::new_instance(array( |
|
227 | 227 | 'LIN_name' => $ticket->name(), |
228 | - 'LIN_desc' => $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event, |
|
228 | + 'LIN_desc' => $ticket->description() != '' ? $ticket->description().' '.$event : $event, |
|
229 | 229 | 'LIN_unit_price' => $ticket->price(), |
230 | 230 | 'LIN_quantity' => $qty, |
231 | 231 | 'LIN_is_taxable' => $ticket->taxable(), |
232 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
232 | + 'LIN_order' => count($events_sub_total->children()), |
|
233 | 233 | 'LIN_total' => $ticket->price() * $qty, |
234 | 234 | 'LIN_type' => EEM_Line_Item::type_line_item, |
235 | 235 | 'OBJ_ID' => $ticket->ID(), |
236 | 236 | 'OBJ_type' => 'Ticket' |
237 | - ) ); |
|
237 | + )); |
|
238 | 238 | $line_item = apply_filters( |
239 | 239 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
240 | 240 | $line_item |
241 | 241 | ); |
242 | - $events_sub_total->add_child_line_item( $line_item ); |
|
242 | + $events_sub_total->add_child_line_item($line_item); |
|
243 | 243 | //now add the sub-line items |
244 | 244 | $running_total_for_ticket = 0; |
245 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
245 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
246 | 246 | $sign = $price->is_discount() ? -1 : 1; |
247 | 247 | $price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty; |
248 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
248 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
249 | 249 | 'LIN_name' => $price->name(), |
250 | 250 | 'LIN_desc' => $price->desc(), |
251 | 251 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
256 | 256 | 'OBJ_ID' => $price->ID(), |
257 | 257 | 'OBJ_type' => 'Price' |
258 | - ) ); |
|
258 | + )); |
|
259 | 259 | $sub_line_item = apply_filters( |
260 | 260 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
261 | 261 | $sub_line_item |
262 | 262 | ); |
263 | - if ( $price->is_percent() ) { |
|
264 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
263 | + if ($price->is_percent()) { |
|
264 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
265 | 265 | } else { |
266 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
266 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
267 | 267 | } |
268 | 268 | $running_total_for_ticket += $price_total; |
269 | - $line_item->add_child_line_item( $sub_line_item ); |
|
269 | + $line_item->add_child_line_item($sub_line_item); |
|
270 | 270 | } |
271 | 271 | return $line_item; |
272 | 272 | } |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param EE_Line_Item $item to be added |
285 | 285 | * @return boolean |
286 | 286 | */ |
287 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
288 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
289 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
287 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
288 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
289 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
290 | 290 | $success = $pre_tax_subtotal->add_child_line_item($item); |
291 | - }else{ |
|
291 | + } else { |
|
292 | 292 | return FALSE; |
293 | 293 | } |
294 | 294 | $total_line_item->recalculate_total_including_taxes(); |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
303 | 303 | * @return \EE_Line_Item |
304 | 304 | */ |
305 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
306 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
307 | - return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item ); |
|
305 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
306 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
307 | + return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -314,9 +314,9 @@ discard block |
||
314 | 314 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
315 | 315 | * @return \EE_Line_Item |
316 | 316 | */ |
317 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
318 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
319 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
317 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
318 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
319 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @param EE_Transaction $transaction |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
331 | - if( $transaction ){ |
|
330 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
331 | + if ($transaction) { |
|
332 | 332 | /** @type EEM_Transaction $EEM_Transaction */ |
333 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
334 | - $transaction = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
335 | - $line_item->set_TXN_ID( $transaction ); |
|
333 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
334 | + $transaction = $EEM_Transaction->ensure_is_ID($transaction); |
|
335 | + $line_item->set_TXN_ID($transaction); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param EE_Transaction $transaction |
346 | 346 | * @return \EE_Line_Item of type total |
347 | 347 | */ |
348 | - public static function create_total_line_item( $transaction = NULL ){ |
|
349 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
348 | + public static function create_total_line_item($transaction = NULL) { |
|
349 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
350 | 350 | 'LIN_code' => 'total', |
351 | 351 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
352 | 352 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
357 | 357 | $total_line_item |
358 | 358 | ); |
359 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
360 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
361 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
359 | + self::set_TXN_ID($total_line_item, $transaction); |
|
360 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
361 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
362 | 362 | return $total_line_item; |
363 | 363 | } |
364 | 364 | |
@@ -370,19 +370,19 @@ discard block |
||
370 | 370 | * @param EE_Transaction $transaction |
371 | 371 | * @return EE_Line_Item |
372 | 372 | */ |
373 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
374 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
373 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
374 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
375 | 375 | 'LIN_code' => 'pre-tax-subtotal', |
376 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
376 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
377 | 377 | 'LIN_type' => EEM_Line_Item::type_sub_total |
378 | - ) ); |
|
378 | + )); |
|
379 | 379 | $pre_tax_line_item = apply_filters( |
380 | 380 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
381 | 381 | $pre_tax_line_item |
382 | 382 | ); |
383 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
384 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
385 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
383 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
384 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
385 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
386 | 386 | return $pre_tax_line_item; |
387 | 387 | } |
388 | 388 | |
@@ -395,21 +395,21 @@ discard block |
||
395 | 395 | * @param EE_Transaction $transaction |
396 | 396 | * @return EE_Line_Item |
397 | 397 | */ |
398 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
398 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
399 | 399 | $tax_line_item = EE_Line_Item::new_instance(array( |
400 | 400 | 'LIN_code' => 'taxes', |
401 | 401 | 'LIN_name' => __('Taxes', 'event_espresso'), |
402 | 402 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
403 | - 'LIN_order' => 1000,//this should always come last |
|
403 | + 'LIN_order' => 1000, //this should always come last |
|
404 | 404 | )); |
405 | 405 | $tax_line_item = apply_filters( |
406 | 406 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
407 | 407 | $tax_line_item |
408 | 408 | ); |
409 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
410 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
409 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
410 | + $total_line_item->add_child_line_item($tax_line_item); |
|
411 | 411 | //and lastly, add the actual taxes |
412 | - self::apply_taxes( $total_line_item ); |
|
412 | + self::apply_taxes($total_line_item); |
|
413 | 413 | return $tax_line_item; |
414 | 414 | } |
415 | 415 | |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @param EE_Event $event |
423 | 423 | * @return EE_Line_Item |
424 | 424 | */ |
425 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
425 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
426 | 426 | $event_line_item = EE_Line_Item::new_instance(array( |
427 | - 'LIN_code' => self::get_event_code( $event ), |
|
428 | - 'LIN_name' => self::get_event_name( $event ), |
|
429 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
427 | + 'LIN_code' => self::get_event_code($event), |
|
428 | + 'LIN_name' => self::get_event_name($event), |
|
429 | + 'LIN_desc' => self::get_event_desc($event), |
|
430 | 430 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
431 | 431 | 'OBJ_type' => 'Event', |
432 | 432 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
436 | 436 | $event_line_item |
437 | 437 | ); |
438 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
439 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
438 | + self::set_TXN_ID($event_line_item, $transaction); |
|
439 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
440 | 440 | return $event_line_item; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * @param EE_Event $event |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public static function get_event_code( $event ) { |
|
449 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
448 | + public static function get_event_code($event) { |
|
449 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param EE_Event $event |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public static function get_event_name( $event ) { |
|
458 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
457 | + public static function get_event_name($event) { |
|
458 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * @param EE_Event $event |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public static function get_event_desc( $event ) { |
|
466 | + public static function get_event_desc($event) { |
|
467 | 467 | return $event instanceof EE_Event ? $event->short_description() : ''; |
468 | 468 | } |
469 | 469 | |
@@ -477,16 +477,16 @@ discard block |
||
477 | 477 | * @throws \EE_Error |
478 | 478 | * @return EE_Line_Item |
479 | 479 | */ |
480 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
480 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | - if( ! $first_datetime instanceof EE_Datetime ){ |
|
483 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) ); |
|
482 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
483 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())); |
|
484 | 484 | } |
485 | 485 | $event = $first_datetime->event(); |
486 | - if ( ! $event instanceof EE_Event ) { |
|
487 | - throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) ); |
|
486 | + if ( ! $event instanceof EE_Event) { |
|
487 | + throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID())); |
|
488 | 488 | } |
489 | - return EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
489 | + return EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -495,31 +495,31 @@ discard block |
||
495 | 495 | * @param EE_Event $event |
496 | 496 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
497 | 497 | */ |
498 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
498 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
499 | 499 | /** @type EE_Event $event */ |
500 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
500 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
501 | 501 | $event_line_item = NULL; |
502 | 502 | $found = false; |
503 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
503 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
504 | 504 | // default event subtotal, we should only ever find this the first time this method is called |
505 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
505 | + if ( ! $event_line_item->OBJ_ID()) { |
|
506 | 506 | // let's use this! but first... set the event details |
507 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
507 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
508 | 508 | $found = true; |
509 | 509 | break; |
510 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
510 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
511 | 511 | // found existing line item for this event in the cart, so break out of loop and use this one |
512 | 512 | $found = true; |
513 | 513 | break; |
514 | 514 | } |
515 | 515 | } |
516 | - if ( ! $found ) { |
|
516 | + if ( ! $found) { |
|
517 | 517 | //there is no event sub-total yet, so add it |
518 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
518 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
519 | 519 | // create a new "event" subtotal below that |
520 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
520 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
521 | 521 | // and set the event details |
522 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
522 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
523 | 523 | } |
524 | 524 | return $event_line_item; |
525 | 525 | } |
@@ -533,14 +533,14 @@ discard block |
||
533 | 533 | * @param EE_Transaction $transaction |
534 | 534 | * @return EE_Line_Item |
535 | 535 | */ |
536 | - public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){ |
|
537 | - if ( $event instanceof EE_Event ) { |
|
538 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
539 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
540 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
541 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
536 | + public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) { |
|
537 | + if ($event instanceof EE_Event) { |
|
538 | + $event_line_item->set_code(self::get_event_code($event)); |
|
539 | + $event_line_item->set_name(self::get_event_name($event)); |
|
540 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
541 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
542 | 542 | } |
543 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
543 | + self::set_TXN_ID($event_line_item, $transaction); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | |
@@ -551,19 +551,19 @@ discard block |
||
551 | 551 | * any old taxes are removed |
552 | 552 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
553 | 553 | */ |
554 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
554 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
555 | 555 | /** @type EEM_Price $EEM_Price */ |
556 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
556 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
557 | 557 | // get array of taxes via Price Model |
558 | 558 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
559 | - ksort( $ordered_taxes ); |
|
560 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
559 | + ksort($ordered_taxes); |
|
560 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
561 | 561 | //just to be safe, remove its old tax line items |
562 | 562 | $taxes_line_item->delete_children_line_items(); |
563 | 563 | //loop thru taxes |
564 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
565 | - foreach ( $taxes as $tax ) { |
|
566 | - if ( $tax instanceof EE_Price ) { |
|
564 | + foreach ($ordered_taxes as $order => $taxes) { |
|
565 | + foreach ($taxes as $tax) { |
|
566 | + if ($tax instanceof EE_Price) { |
|
567 | 567 | $tax_line_item = EE_Line_Item::new_instance( |
568 | 568 | array( |
569 | 569 | 'LIN_name' => $tax->name(), |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
582 | 582 | $tax_line_item |
583 | 583 | ); |
584 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
584 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | } |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
597 | 597 | * @return float |
598 | 598 | */ |
599 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
600 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
601 | - if( ! $taxes_subtotal->children()){ |
|
602 | - self::apply_taxes( $total_line_item ); |
|
599 | + public static function ensure_taxes_applied($total_line_item) { |
|
600 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
601 | + if ( ! $taxes_subtotal->children()) { |
|
602 | + self::apply_taxes($total_line_item); |
|
603 | 603 | } |
604 | 604 | return $taxes_subtotal->total(); |
605 | 605 | } |
@@ -612,16 +612,16 @@ discard block |
||
612 | 612 | * @param EE_Line_Item $parent_line_item |
613 | 613 | * @return bool |
614 | 614 | */ |
615 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
615 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
616 | 616 | $deleted = 0; |
617 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
618 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
619 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
620 | - if ( $child_line_item->ID() ) { |
|
617 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
618 | + if ($child_line_item instanceof EE_Line_Item) { |
|
619 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
620 | + if ($child_line_item->ID()) { |
|
621 | 621 | $child_line_item->delete(); |
622 | - unset( $child_line_item ); |
|
622 | + unset($child_line_item); |
|
623 | 623 | } else { |
624 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
624 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
625 | 625 | } |
626 | 626 | $deleted++; |
627 | 627 | } |
@@ -643,25 +643,25 @@ discard block |
||
643 | 643 | * @param array|bool|string $line_item_codes |
644 | 644 | * @return int number of items successfully removed |
645 | 645 | */ |
646 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
646 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
647 | 647 | |
648 | - if( $total_line_item->type() != EEM_Line_Item::type_total ){ |
|
649 | - EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' ); |
|
648 | + if ($total_line_item->type() != EEM_Line_Item::type_total) { |
|
649 | + EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18'); |
|
650 | 650 | } |
651 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
651 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
652 | 652 | |
653 | 653 | // check if only a single line_item_id was passed |
654 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
654 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
655 | 655 | // place single line_item_id in an array to appear as multiple line_item_ids |
656 | - $line_item_codes = array ( $line_item_codes ); |
|
656 | + $line_item_codes = array($line_item_codes); |
|
657 | 657 | } |
658 | 658 | $removals = 0; |
659 | 659 | // cycle thru line_item_ids |
660 | - foreach ( $line_item_codes as $line_item_id ) { |
|
660 | + foreach ($line_item_codes as $line_item_id) { |
|
661 | 661 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
662 | 662 | } |
663 | 663 | |
664 | - if ( $removals > 0 ) { |
|
664 | + if ($removals > 0) { |
|
665 | 665 | $total_line_item->recalculate_taxes_and_tax_total(); |
666 | 666 | return $removals; |
667 | 667 | } else { |
@@ -684,32 +684,32 @@ discard block |
||
684 | 684 | * $amount will be added onto it; otherwise will simply set the taxes to match $amount |
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | - public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
|
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
687 | + public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false) { |
|
688 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
689 | 689 | $taxable_total = $total_line_item->taxable_total(); |
690 | 690 | |
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
691 | + if ($add_to_existing_line_item) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
693 | + EEM_Line_Item::instance()->delete(array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID()))); |
|
694 | 694 | } else { |
695 | 695 | $new_tax = null; |
696 | 696 | $tax_subtotal->delete_children_line_items(); |
697 | 697 | } |
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
698 | + if ($new_tax) { |
|
699 | + $new_tax->set_total($new_tax->total() + $amount); |
|
700 | + $new_tax->set_percent($taxable_total ? ($new_tax->total()) / $taxable_total * 100 : 0); |
|
701 | 701 | } else { |
702 | 702 | //no existing tax item. Create it |
703 | - $new_tax = EE_Line_Item::new_instance( array( |
|
703 | + $new_tax = EE_Line_Item::new_instance(array( |
|
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
705 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
706 | 706 | 'LIN_desc' => $description ? $description : '', |
707 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
707 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
708 | 708 | 'LIN_total' => $amount, |
709 | 709 | 'LIN_parent' => $tax_subtotal->ID(), |
710 | 710 | 'LIN_type' => EEM_Line_Item::type_tax, |
711 | 711 | 'LIN_code' => $code |
712 | - ) ); |
|
712 | + )); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | $new_tax = apply_filters( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $total_line_item |
719 | 719 | ); |
720 | 720 | $new_tax->save(); |
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
721 | + $tax_subtotal->set_total($new_tax->total()); |
|
722 | 722 | $tax_subtotal->save(); |
723 | 723 | $total_line_item->recalculate_total_including_taxes(); |
724 | 724 | return $new_tax; |
@@ -734,17 +734,17 @@ discard block |
||
734 | 734 | * it will be whitelisted (ie, except from becoming taxable) |
735 | 735 | * @param boolean $taxable |
736 | 736 | */ |
737 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ) { |
|
738 | - if( $code_substring_for_whitelist !== null ) { |
|
739 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
737 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null) { |
|
738 | + if ($code_substring_for_whitelist !== null) { |
|
739 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
740 | 740 | } else { |
741 | 741 | $whitelisted = false; |
742 | 742 | } |
743 | - if( $line_item->is_line_item() && ! $whitelisted ) { |
|
744 | - $line_item->set_is_taxable( $taxable ); |
|
743 | + if ($line_item->is_line_item() && ! $whitelisted) { |
|
744 | + $line_item->set_is_taxable($taxable); |
|
745 | 745 | } |
746 | - foreach( $line_item->children() as $child_line_item ) { |
|
747 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
746 | + foreach ($line_item->children() as $child_line_item) { |
|
747 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
748 | 748 | } |
749 | 749 | } |
750 | 750 | |
@@ -757,8 +757,8 @@ discard block |
||
757 | 757 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
758 | 758 | * @return EE_Line_Item[] |
759 | 759 | */ |
760 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
761 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
760 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
761 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * @param string $obj_type |
772 | 772 | * @return EE_Line_Item[] |
773 | 773 | */ |
774 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
775 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type ); |
|
774 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
775 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
785 | 785 | * @return EE_Line_Item[] |
786 | 786 | */ |
787 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
788 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
787 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
788 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | * @param string $obj_type |
799 | 799 | * @return EE_Line_Item[] |
800 | 800 | */ |
801 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
802 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
801 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
802 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
811 | 811 | * @return EE_Line_Item[] |
812 | 812 | */ |
813 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
814 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
813 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
814 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
823 | 823 | * @return EE_Line_Item[] |
824 | 824 | */ |
825 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
826 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
825 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
826 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | * @param string $line_item_type one of the EEM_Line_Item constants |
837 | 837 | * @return EE_Line_Item[] |
838 | 838 | */ |
839 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
840 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
839 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
840 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | |
@@ -850,15 +850,15 @@ discard block |
||
850 | 850 | * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching |
851 | 851 | * @return EE_Line_Item[] |
852 | 852 | */ |
853 | - protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) { |
|
853 | + protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) { |
|
854 | 854 | $objects = array(); |
855 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
856 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
857 | - if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) { |
|
855 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
856 | + if ($child_line_item instanceof EE_Line_Item) { |
|
857 | + if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) { |
|
858 | 858 | $objects[] = $child_line_item; |
859 | 859 | } else { |
860 | 860 | //go-through-all-its children looking for more matches |
861 | - $objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type )); |
|
861 | + $objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type)); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | } |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param array $OBJ_IDs array of OBJ_IDs |
877 | 877 | * @return EE_Line_Item[] |
878 | 878 | */ |
879 | - public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) { |
|
880 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
879 | + public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) { |
|
880 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | |
@@ -890,15 +890,15 @@ discard block |
||
890 | 890 | * @param array $OBJ_IDs array of OBJ_IDs |
891 | 891 | * @return EE_Line_Item[] |
892 | 892 | */ |
893 | - protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) { |
|
893 | + protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) { |
|
894 | 894 | $objects = array(); |
895 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
896 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
897 | - if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) { |
|
895 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
896 | + if ($child_line_item instanceof EE_Line_Item) { |
|
897 | + if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) { |
|
898 | 898 | $objects[] = $child_line_item; |
899 | 899 | } else { |
900 | 900 | //go-through-all-its children looking for more matches |
901 | - $objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs )); |
|
901 | + $objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs)); |
|
902 | 902 | } |
903 | 903 | } |
904 | 904 | } |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $type like one of the EEM_Line_Item::type_* |
917 | 917 | * @return EE_Line_Item |
918 | 918 | */ |
919 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
920 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
919 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
920 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * @param string $code any value used for LIN_code |
931 | 931 | * @return EE_Line_Item |
932 | 932 | */ |
933 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
934 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
933 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
934 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | * @param string $value any value stored in $search_field |
945 | 945 | * @return EE_Line_Item |
946 | 946 | */ |
947 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
948 | - foreach( $parent_line_item->children() as $child ){ |
|
949 | - if ( $child->get( $search_field ) == $value ){ |
|
947 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
948 | + foreach ($parent_line_item->children() as $child) { |
|
949 | + if ($child->get($search_field) == $value) { |
|
950 | 950 | return $child; |
951 | 951 | } |
952 | 952 | } |
953 | - foreach( $parent_line_item->children() as $child ){ |
|
954 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
955 | - if ( $descendant_found ){ |
|
953 | + foreach ($parent_line_item->children() as $child) { |
|
954 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
955 | + if ($descendant_found) { |
|
956 | 956 | return $descendant_found; |
957 | 957 | } |
958 | 958 | } |
@@ -968,22 +968,22 @@ discard block |
||
968 | 968 | * @param int $indentation |
969 | 969 | * @return void |
970 | 970 | */ |
971 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
971 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
972 | 972 | echo "\n<br />"; |
973 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
973 | + for ($i = 0; $i < $indentation; $i++) { |
|
974 | 974 | echo " - "; |
975 | 975 | } |
976 | - if( $line_item->is_percent() ) { |
|
977 | - $breakdown = $line_item->percent() . '%'; |
|
976 | + if ($line_item->is_percent()) { |
|
977 | + $breakdown = $line_item->percent().'%'; |
|
978 | 978 | } else { |
979 | - $breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity(); |
|
979 | + $breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity(); |
|
980 | 980 | } |
981 | - echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")"; |
|
982 | - if( $line_item->is_taxable() ){ |
|
981 | + echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")"; |
|
982 | + if ($line_item->is_taxable()) { |
|
983 | 983 | echo " * taxable"; |
984 | 984 | } |
985 | - if( $line_item->children() ){ |
|
986 | - foreach($line_item->children() as $child){ |
|
985 | + if ($line_item->children()) { |
|
986 | + foreach ($line_item->children() as $child) { |
|
987 | 987 | self::visualize($child, $indentation + 1); |
988 | 988 | } |
989 | 989 | } |
@@ -1024,88 +1024,88 @@ discard block |
||
1024 | 1024 | * is theirs, which can be done with |
1025 | 1025 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1026 | 1026 | */ |
1027 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1027 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1028 | 1028 | //init running grand total if not already |
1029 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1030 | - $running_totals[ 'total' ] = 0; |
|
1029 | + if ( ! isset($running_totals['total'])) { |
|
1030 | + $running_totals['total'] = 0; |
|
1031 | 1031 | } |
1032 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1033 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1032 | + if ( ! isset($running_totals['taxable'])) { |
|
1033 | + $running_totals['taxable'] = array('total' => 0); |
|
1034 | 1034 | } |
1035 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1036 | - switch ( $child_line_item->type() ) { |
|
1035 | + foreach ($line_item->children() as $child_line_item) { |
|
1036 | + switch ($child_line_item->type()) { |
|
1037 | 1037 | |
1038 | 1038 | case EEM_Line_Item::type_sub_total : |
1039 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1039 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1040 | 1040 | //combine arrays but preserve numeric keys |
1041 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1042 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1043 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1041 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1042 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1043 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1044 | 1044 | break; |
1045 | 1045 | |
1046 | 1046 | case EEM_Line_Item::type_tax_sub_total : |
1047 | 1047 | |
1048 | 1048 | //find how much the taxes percentage is |
1049 | - if ( $child_line_item->percent() != 0 ) { |
|
1049 | + if ($child_line_item->percent() != 0) { |
|
1050 | 1050 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1051 | 1051 | } else { |
1052 | 1052 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1053 | 1053 | } |
1054 | 1054 | //and apply to all the taxable totals, and add to the pretax totals |
1055 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1055 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1056 | 1056 | //"total" and "taxable" array key is an exception |
1057 | - if ( $line_item_id === 'taxable' ) { |
|
1057 | + if ($line_item_id === 'taxable') { |
|
1058 | 1058 | continue; |
1059 | 1059 | } |
1060 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1061 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1060 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1061 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1062 | 1062 | } |
1063 | 1063 | break; |
1064 | 1064 | |
1065 | 1065 | case EEM_Line_Item::type_line_item : |
1066 | 1066 | |
1067 | 1067 | // ticket line items or ???? |
1068 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1068 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1069 | 1069 | // kk it's a ticket |
1070 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1070 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1071 | 1071 | //huh? that shouldn't happen. |
1072 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1072 | + $running_totals['total'] += $child_line_item->total(); |
|
1073 | 1073 | } else { |
1074 | 1074 | //its not in our running totals yet. great. |
1075 | - if ( $child_line_item->is_taxable() ) { |
|
1075 | + if ($child_line_item->is_taxable()) { |
|
1076 | 1076 | $taxable_amount = $child_line_item->unit_price(); |
1077 | 1077 | } else { |
1078 | 1078 | $taxable_amount = 0; |
1079 | 1079 | } |
1080 | 1080 | // are we only calculating totals for some tickets? |
1081 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1082 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1083 | - $running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0; |
|
1081 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1082 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1083 | + $running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0; |
|
1084 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0; |
|
1085 | 1085 | } else { |
1086 | 1086 | $quantity = $child_line_item->quantity(); |
1087 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1088 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1087 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1088 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1089 | 1089 | } |
1090 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1091 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1090 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1091 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1092 | 1092 | } |
1093 | 1093 | } else { |
1094 | 1094 | // it's some other type of item added to the cart |
1095 | 1095 | // it should affect the running totals |
1096 | 1096 | // basically we want to convert it into a PERCENT modifier. Because |
1097 | 1097 | // more clearly affect all registration's final price equally |
1098 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1; |
|
1099 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1098 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1; |
|
1099 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1100 | 1100 | //the "taxable" array key is an exception |
1101 | - if ( $line_item_id === 'taxable' ) { |
|
1101 | + if ($line_item_id === 'taxable') { |
|
1102 | 1102 | continue; |
1103 | 1103 | } |
1104 | 1104 | // update the running totals |
1105 | 1105 | // yes this actually even works for the running grand total! |
1106 | - $running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | - if ( $child_line_item->is_taxable() ) { |
|
1108 | - $running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1106 | + $running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total; |
|
1107 | + if ($child_line_item->is_taxable()) { |
|
1108 | + $running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1109 | 1109 | } |
1110 | 1110 | } |
1111 | 1111 | } |
@@ -1124,15 +1124,15 @@ discard block |
||
1124 | 1124 | * @param EE_Registration[] $registrations |
1125 | 1125 | * @return \EE_Line_Item |
1126 | 1126 | */ |
1127 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1128 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1129 | - foreach ( $line_item->children() as $child_li ) { |
|
1130 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1127 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1128 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1129 | + foreach ($line_item->children() as $child_li) { |
|
1130 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1131 | 1131 | } |
1132 | 1132 | //if this is the grand total line item, make sure the totals all add up |
1133 | 1133 | //(we could have duplicated this logic AS we copied the line items, but |
1134 | 1134 | //it seems DRYer this way) |
1135 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1135 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1136 | 1136 | $copy_li->recalculate_total_including_taxes(); |
1137 | 1137 | } |
1138 | 1138 | return $copy_li; |
@@ -1147,26 +1147,26 @@ discard block |
||
1147 | 1147 | * @return EE_Line_Item |
1148 | 1148 | * @param EE_Registration[] $registrations |
1149 | 1149 | */ |
1150 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1150 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1151 | 1151 | $new_li_fields = $line_item->model_field_array(); |
1152 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1152 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1153 | 1153 | $line_item->OBJ_type() === 'Ticket' |
1154 | 1154 | ) { |
1155 | 1155 | $count = 0; |
1156 | - foreach ( $registrations as $registration ) { |
|
1157 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1156 | + foreach ($registrations as $registration) { |
|
1157 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1158 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1159 | 1159 | ) { |
1160 | 1160 | $count++; |
1161 | 1161 | } |
1162 | 1162 | } |
1163 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1163 | + $new_li_fields['LIN_quantity'] = $count; |
|
1164 | 1164 | } |
1165 | 1165 | //don't set the total. We'll leave that up to the code that calculates it |
1166 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1167 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1168 | - unset( $new_li_fields[ 'LIN_total' ] ); |
|
1169 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1166 | + unset($new_li_fields['LIN_ID']); |
|
1167 | + unset($new_li_fields['LIN_parent']); |
|
1168 | + unset($new_li_fields['LIN_total']); |
|
1169 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | |
@@ -1178,19 +1178,19 @@ discard block |
||
1178 | 1178 | * @param EE_Line_Item $line_item |null |
1179 | 1179 | * @return \EE_Line_Item|null |
1180 | 1180 | */ |
1181 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1182 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1183 | - if ( $copied_li === null ) { |
|
1181 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1182 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1183 | + if ($copied_li === null) { |
|
1184 | 1184 | return null; |
1185 | 1185 | } |
1186 | 1186 | //if this is an event subtotal, we want to only include it if it |
1187 | 1187 | //has a non-zero total and at least one ticket line item child |
1188 | 1188 | $ticket_children = 0; |
1189 | - foreach ( $line_item->children() as $child_li ) { |
|
1190 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1191 | - if ( $child_li_copy !== null ) { |
|
1192 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1193 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1189 | + foreach ($line_item->children() as $child_li) { |
|
1190 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1191 | + if ($child_li_copy !== null) { |
|
1192 | + $copied_li->add_child_line_item($child_li_copy); |
|
1193 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1194 | 1194 | $child_li_copy->OBJ_type() === 'Ticket' |
1195 | 1195 | ) { |
1196 | 1196 | $ticket_children++; |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | } |
1200 | 1200 | //if this is an event subtotal with NO ticket children |
1201 | 1201 | //we basically want to ignore it |
1202 | - if ( $line_item->type() === EEM_Line_Item::type_sub_total && |
|
1202 | + if ($line_item->type() === EEM_Line_Item::type_sub_total && |
|
1203 | 1203 | $line_item->OBJ_type() === 'Event' && |
1204 | 1204 | $ticket_children === 0 && |
1205 | 1205 | $line_item->total() === 0 |
@@ -1217,8 +1217,8 @@ discard block |
||
1217 | 1217 | * @param EE_Line_Item $line_item |
1218 | 1218 | * @return EE_Line_Item |
1219 | 1219 | */ |
1220 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1221 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1220 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1221 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1222 | 1222 | $line_item->OBJ_type() === 'Ticket' && |
1223 | 1223 | $line_item->quantity() == 0 |
1224 | 1224 | ) { |
@@ -1226,9 +1226,9 @@ discard block |
||
1226 | 1226 | } |
1227 | 1227 | $new_li_fields = $line_item->model_field_array(); |
1228 | 1228 | //don't set the total. We'll leave that up to the code that calculates it |
1229 | - unset( $new_li_fields[ 'LIN_ID' ] ); |
|
1230 | - unset( $new_li_fields[ 'LIN_parent' ] ); |
|
1231 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1229 | + unset($new_li_fields['LIN_ID']); |
|
1230 | + unset($new_li_fields['LIN_parent']); |
|
1231 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1242,9 +1242,9 @@ discard block |
||
1242 | 1242 | * @param EE_Line_Item $total_line_item |
1243 | 1243 | * @return \EE_Line_Item |
1244 | 1244 | */ |
1245 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1246 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1247 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1245 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1246 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1247 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
@@ -1254,9 +1254,9 @@ discard block |
||
1254 | 1254 | * @param EE_Transaction $transaction |
1255 | 1255 | * @return \EE_Line_Item |
1256 | 1256 | */ |
1257 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1258 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1259 | - return self::create_total_line_item( $transaction ); |
|
1257 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1258 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1259 | + return self::create_total_line_item($transaction); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
@@ -1267,9 +1267,9 @@ discard block |
||
1267 | 1267 | * @param EE_Transaction $transaction |
1268 | 1268 | * @return \EE_Line_Item |
1269 | 1269 | */ |
1270 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1272 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1270 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1271 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1272 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | |
@@ -1280,9 +1280,9 @@ discard block |
||
1280 | 1280 | * @param EE_Transaction $transaction |
1281 | 1281 | * @return \EE_Line_Item |
1282 | 1282 | */ |
1283 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1285 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1283 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1284 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1285 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | * @param EE_Transaction $transaction |
1294 | 1294 | * @return \EE_Line_Item |
1295 | 1295 | */ |
1296 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1298 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1296 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1297 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1298 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
471 | - * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | - * line item the ticket's purchase should be added onto |
|
473 | - * |
|
474 | - * @access public |
|
475 | - * @param EE_Line_Item $grand_total the grand total line item |
|
476 | - * @param EE_Ticket $ticket |
|
477 | - * @throws \EE_Error |
|
478 | - * @return EE_Line_Item |
|
479 | - */ |
|
471 | + * Given the grand total line item and a ticket, finds the event sub-total |
|
472 | + * line item the ticket's purchase should be added onto |
|
473 | + * |
|
474 | + * @access public |
|
475 | + * @param EE_Line_Item $grand_total the grand total line item |
|
476 | + * @param EE_Ticket $ticket |
|
477 | + * @throws \EE_Error |
|
478 | + * @return EE_Line_Item |
|
479 | + */ |
|
480 | 480 | public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
481 | 481 | $first_datetime = $ticket->first_datetime(); |
482 | 482 | if( ! $first_datetime instanceof EE_Datetime ){ |
@@ -685,21 +685,21 @@ discard block |
||
685 | 685 | * @return EE_Line_Item the new tax line item created |
686 | 686 | */ |
687 | 687 | public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ){ |
688 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | - $taxable_total = $total_line_item->taxable_total(); |
|
690 | - |
|
691 | - if( $add_to_existing_line_item ) { |
|
692 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | - EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | - } else { |
|
695 | - $new_tax = null; |
|
696 | - $tax_subtotal->delete_children_line_items(); |
|
697 | - } |
|
698 | - if( $new_tax ) { |
|
699 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | - $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | - } else { |
|
702 | - //no existing tax item. Create it |
|
688 | + $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
689 | + $taxable_total = $total_line_item->taxable_total(); |
|
690 | + |
|
691 | + if( $add_to_existing_line_item ) { |
|
692 | + $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
693 | + EEM_Line_Item::instance()->delete( array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) ); |
|
694 | + } else { |
|
695 | + $new_tax = null; |
|
696 | + $tax_subtotal->delete_children_line_items(); |
|
697 | + } |
|
698 | + if( $new_tax ) { |
|
699 | + $new_tax->set_total( $new_tax->total() + $amount ); |
|
700 | + $new_tax->set_percent( $taxable_total ? ( $new_tax->total() ) / $taxable_total * 100 : 0 ); |
|
701 | + } else { |
|
702 | + //no existing tax item. Create it |
|
703 | 703 | $new_tax = EE_Line_Item::new_instance( array( |
704 | 704 | 'TXN_ID' => $total_line_item->TXN_ID(), |
705 | 705 | 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
@@ -712,16 +712,16 @@ discard block |
||
712 | 712 | ) ); |
713 | 713 | } |
714 | 714 | |
715 | - $new_tax = apply_filters( |
|
715 | + $new_tax = apply_filters( |
|
716 | 716 | 'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal', |
717 | 717 | $new_tax, |
718 | 718 | $total_line_item |
719 | - ); |
|
720 | - $new_tax->save(); |
|
721 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | - $tax_subtotal->save(); |
|
723 | - $total_line_item->recalculate_total_including_taxes(); |
|
724 | - return $new_tax; |
|
719 | + ); |
|
720 | + $new_tax->save(); |
|
721 | + $tax_subtotal->set_total( $new_tax->total() ); |
|
722 | + $tax_subtotal->save(); |
|
723 | + $total_line_item->recalculate_total_including_taxes(); |
|
724 | + return $new_tax; |
|
725 | 725 | } |
726 | 726 | |
727 | 727 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -21,37 +21,37 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param EE_PMT_Paypal_Standard $payment_method_type |
23 | 23 | */ |
24 | - public function __construct( $payment_method_type ){ |
|
24 | + public function __construct($payment_method_type) { |
|
25 | 25 | parent::__construct( |
26 | 26 | array( |
27 | 27 | 'payment_method_type' => $payment_method_type, |
28 | 28 | 'extra_meta_inputs' => array( |
29 | - 'paypal_id' => new EE_Text_Input( array( |
|
30 | - 'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
31 | - 'html_help_text' => __( "Typically [email protected]", 'event_espresso' ), |
|
29 | + 'paypal_id' => new EE_Text_Input(array( |
|
30 | + 'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
31 | + 'html_help_text' => __("Typically [email protected]", 'event_espresso'), |
|
32 | 32 | 'required' => true |
33 | - ) ), |
|
34 | - 'image_url' => new EE_Admin_File_Uploader_Input( array( |
|
35 | - 'html_help_text' => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ), |
|
36 | - 'html_label_text' => __( 'Image URL', 'event_espresso' ) |
|
37 | - ) ), |
|
38 | - 'paypal_taxes' => new EE_Yes_No_Input( array( |
|
39 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
40 | - 'html_help_text' => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ), |
|
33 | + )), |
|
34 | + 'image_url' => new EE_Admin_File_Uploader_Input(array( |
|
35 | + 'html_help_text' => __("Used for your business/personal logo on the PayPal page", 'event_espresso'), |
|
36 | + 'html_label_text' => __('Image URL', 'event_espresso') |
|
37 | + )), |
|
38 | + 'paypal_taxes' => new EE_Yes_No_Input(array( |
|
39 | + 'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
40 | + 'html_help_text' => __('Whether Paypal should add taxes to the order', 'event_espresso'), |
|
41 | 41 | 'default' => false |
42 | - ) ), |
|
43 | - 'paypal_shipping' => new EE_Yes_No_Input( array( |
|
44 | - 'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ), |
|
45 | - 'html_help_text' => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ), |
|
42 | + )), |
|
43 | + 'paypal_shipping' => new EE_Yes_No_Input(array( |
|
44 | + 'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()), |
|
45 | + 'html_help_text' => __('Whether Paypal should add shipping surcharges', 'event_espresso'), |
|
46 | 46 | 'default' => false |
47 | - ) ), |
|
48 | - 'shipping_details' => new EE_Select_Input( array( |
|
49 | - EE_PMT_Paypal_Standard::shipping_info_none => __( "Do not prompt for an address", 'event_espresso' ), |
|
50 | - EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ), |
|
51 | - EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' ) |
|
52 | - ) ), |
|
47 | + )), |
|
48 | + 'shipping_details' => new EE_Select_Input(array( |
|
49 | + EE_PMT_Paypal_Standard::shipping_info_none => __("Do not prompt for an address", 'event_espresso'), |
|
50 | + EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'), |
|
51 | + EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso') |
|
52 | + )), |
|
53 | 53 | ), |
54 | - 'before_form_content_template' => $payment_method_type->file_folder() . DS . 'templates' . DS . 'paypal_standard_settings_before_form.template.php', |
|
54 | + 'before_form_content_template' => $payment_method_type->file_folder().DS.'templates'.DS.'paypal_standard_settings_before_form.template.php', |
|
55 | 55 | ) |
56 | 56 | ); |
57 | 57 | } |
@@ -61,28 +61,28 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @param array $req_data |
63 | 63 | */ |
64 | - protected function _normalize( $req_data ) { |
|
65 | - parent::_normalize( $req_data ); |
|
66 | - $paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' ); |
|
67 | - $paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' ); |
|
68 | - $paypal_requests_address_info = $this->get_input_value( 'shipping_details' ); |
|
64 | + protected function _normalize($req_data) { |
|
65 | + parent::_normalize($req_data); |
|
66 | + $paypal_calculates_shipping = $this->get_input_value('paypal_shipping'); |
|
67 | + $paypal_calculates_taxes = $this->get_input_value('paypal_taxes'); |
|
68 | + $paypal_requests_address_info = $this->get_input_value('shipping_details'); |
|
69 | 69 | if ( |
70 | - ( $paypal_calculates_shipping || $paypal_calculates_taxes ) && |
|
70 | + ($paypal_calculates_shipping || $paypal_calculates_taxes) && |
|
71 | 71 | $paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none |
72 | 72 | ) { |
73 | 73 | //they want paypal to calculate taxes or shipping. They need to ask for |
74 | 74 | //address info, otherwise paypal can't calculate taxes or shipping |
75 | 75 | /** @type EE_Select_Input $shipping_details_input */ |
76 | - $shipping_details_input = $this->get_input( 'shipping_details' ); |
|
77 | - $shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional ); |
|
76 | + $shipping_details_input = $this->get_input('shipping_details'); |
|
77 | + $shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional); |
|
78 | 78 | $shipping_details_input_options = $shipping_details_input->options(); |
79 | 79 | EE_Error::add_attention( |
80 | 80 | sprintf( |
81 | - __( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ), |
|
82 | - strip_tags( $shipping_details_input->html_label_text() ), |
|
83 | - isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] ) |
|
84 | - ? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] |
|
85 | - : __( 'Unknown', 'event_espresso' ) |
|
81 | + __('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'), |
|
82 | + strip_tags($shipping_details_input->html_label_text()), |
|
83 | + isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]) |
|
84 | + ? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional] |
|
85 | + : __('Unknown', 'event_espresso') |
|
86 | 86 | ), |
87 | 87 | __FILE__, __FUNCTION__, __LINE__ |
88 | 88 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | parent::set_settings($settings_array); |
78 | 78 | if($this->_debug_mode){ |
79 | 79 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
80 | - }else{ |
|
80 | + } else{ |
|
81 | 81 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
82 | 82 | } |
83 | 83 | } |
@@ -340,8 +340,9 @@ discard block |
||
340 | 340 | $update_info = array(); |
341 | 341 | foreach ( $raw_post_array as $keyval ) { |
342 | 342 | $keyval = explode( '=', $keyval ); |
343 | - if ( count( $keyval ) == 2 ) |
|
344 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
343 | + if ( count( $keyval ) == 2 ) { |
|
344 | + $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
345 | + } |
|
345 | 346 | } |
346 | 347 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
347 | 348 | $req = 'cmd=_notify-validate'; |
@@ -456,16 +456,16 @@ |
||
456 | 456 | |
457 | 457 | //might paypal have changed the taxes? |
458 | 458 | if( $this->_paypal_taxes && $payment_was_itemized ){ |
459 | - //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
460 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
461 | - $this->_line_item->set_total_tax_to( |
|
462 | - $transaction->total_line_item(), |
|
463 | - floatval( $update_info['tax'] ), |
|
464 | - __( 'Taxes', 'event_espresso' ), |
|
465 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | - 'paypal_tax' |
|
467 | - ); |
|
468 | - $grand_total_needs_resaving = TRUE; |
|
459 | + //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
|
460 | + $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
461 | + $this->_line_item->set_total_tax_to( |
|
462 | + $transaction->total_line_item(), |
|
463 | + floatval( $update_info['tax'] ), |
|
464 | + __( 'Taxes', 'event_espresso' ), |
|
465 | + __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | + 'paypal_tax' |
|
467 | + ); |
|
468 | + $grand_total_needs_resaving = TRUE; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return EEG_Paypal_Standard |
69 | 69 | */ |
70 | 70 | public function __construct() { |
71 | - $this->set_uses_separate_IPN_request( true ) ; |
|
71 | + $this->set_uses_separate_IPN_request(true); |
|
72 | 72 | parent::__construct(); |
73 | 73 | } |
74 | 74 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
79 | 79 | * @param array $settings_array |
80 | 80 | */ |
81 | - public function set_settings($settings_array){ |
|
81 | + public function set_settings($settings_array) { |
|
82 | 82 | parent::set_settings($settings_array); |
83 | - if($this->_debug_mode){ |
|
83 | + if ($this->_debug_mode) { |
|
84 | 84 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
87 | 87 | } |
88 | 88 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment provider's website |
98 | 98 | * @return EEI_Payment |
99 | 99 | */ |
100 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){ |
|
100 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
101 | 101 | $redirect_args = array(); |
102 | 102 | $transaction = $payment->transaction(); |
103 | 103 | $primary_registrant = $transaction->primary_registration(); |
@@ -107,42 +107,42 @@ discard block |
||
107 | 107 | |
108 | 108 | $total_discounts_to_cart_total = $transaction->paid(); |
109 | 109 | //only itemize the order if we're paying for the rest of the order's amount |
110 | - if( $payment->amount() == $transaction->total() ) { |
|
111 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
110 | + if ($payment->amount() == $transaction->total()) { |
|
111 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
112 | 112 | //this payment is for the remaining transaction amount, |
113 | 113 | //keep track of exactly how much the itemized order amount equals |
114 | 114 | $itemized_sum = 0; |
115 | 115 | $shipping_previously_added = 0; |
116 | 116 | //so let's show all the line items |
117 | - foreach($total_line_item->get_items() as $line_item){ |
|
118 | - if ( $line_item instanceof EE_Line_Item ) { |
|
117 | + foreach ($total_line_item->get_items() as $line_item) { |
|
118 | + if ($line_item instanceof EE_Line_Item) { |
|
119 | 119 | //it's some kind of discount |
120 | - if( $line_item->total() < 0 ) { |
|
121 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
120 | + if ($line_item->total() < 0) { |
|
121 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
122 | 122 | $itemized_sum += $line_item->total(); |
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | //dont include shipping again. |
126 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
126 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
127 | 127 | $shipping_previously_added = $line_item->total(); |
128 | 128 | continue; |
129 | 129 | } |
130 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
131 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
130 | + $redirect_args['item_name_'.$item_num] = substr( |
|
131 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
132 | 132 | 0, 127 |
133 | 133 | ); |
134 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
135 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
134 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
135 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
136 | 136 | //if we're not letting PayPal calculate shipping, tell them its 0 |
137 | - if ( ! $this->_paypal_shipping ) { |
|
138 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
139 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
137 | + if ( ! $this->_paypal_shipping) { |
|
138 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
139 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
140 | 140 | } |
141 | 141 | $item_num++; |
142 | 142 | $itemized_sum += $line_item->total(); |
143 | 143 | } |
144 | 144 | } |
145 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
145 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
146 | 146 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
147 | 147 | //and the itemized sum is LESS than the transaction total |
148 | 148 | //add another line item |
@@ -152,47 +152,47 @@ discard block |
||
152 | 152 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
153 | 153 | 2 |
154 | 154 | ); |
155 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
155 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
156 | 156 | //itemized sum is too big |
157 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
158 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
159 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
160 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
161 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
162 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
157 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
158 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
159 | + $redirect_args['item_name_'.$item_num] = substr( |
|
160 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
161 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
162 | + $redirect_args['quantity_'.$item_num] = 1; |
|
163 | 163 | $item_num++; |
164 | 164 | } |
165 | - if( $total_discounts_to_cart_total > 0 ) { |
|
166 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
165 | + if ($total_discounts_to_cart_total > 0) { |
|
166 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
167 | 167 | } |
168 | 168 | //add our taxes to the order if we're NOT using PayPal's |
169 | - if( ! $this->_paypal_taxes ){ |
|
169 | + if ( ! $this->_paypal_taxes) { |
|
170 | 170 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
171 | 171 | } |
172 | 172 | } else { |
173 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
173 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
174 | 174 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
175 | - $redirect_args['item_name_' . $item_num] = substr( |
|
176 | - sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ), |
|
175 | + $redirect_args['item_name_'.$item_num] = substr( |
|
176 | + sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()), |
|
177 | 177 | 0, 127 |
178 | 178 | ); |
179 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
180 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
181 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
179 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
180 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
181 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
182 | 182 | $redirect_args['tax_cart'] = '0'; |
183 | 183 | $item_num++; |
184 | 184 | } |
185 | 185 | |
186 | - if($this->_debug_mode){ |
|
187 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | - $redirect_args['amount_' . $item_num] = 0; |
|
186 | + if ($this->_debug_mode) { |
|
187 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | + $redirect_args['amount_'.$item_num] = 0; |
|
189 | 189 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
190 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
190 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
191 | 191 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
192 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
192 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
193 | 193 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
194 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
195 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
194 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
195 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $redirect_args['business'] = $this->_paypal_id; |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | $redirect_args['cmd'] = '_cart'; |
203 | 203 | $redirect_args['upload'] = 1; |
204 | 204 | $redirect_args['currency_code'] = $payment->currency_code(); |
205 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
206 | - if($this->_image_url){ |
|
205 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
206 | + if ($this->_image_url) { |
|
207 | 207 | $redirect_args['image_url'] = $this->_image_url; |
208 | 208 | } |
209 | 209 | $redirect_args['no_shipping'] = $this->_shipping_details; |
210 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
210 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
211 | 211 | |
212 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
212 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
213 | 213 | |
214 | 214 | $payment->set_redirect_url($this->_gateway_url); |
215 | 215 | $payment->set_redirect_args($redirect_args); |
@@ -230,55 +230,55 @@ discard block |
||
230 | 230 | * @return \EEI_Payment updated |
231 | 231 | * @throws \EE_Error |
232 | 232 | */ |
233 | - public function handle_payment_update( $update_info, $transaction ){ |
|
233 | + public function handle_payment_update($update_info, $transaction) { |
|
234 | 234 | //verify there's payment data that's been sent |
235 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
235 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
236 | 236 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
237 | 237 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
238 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
238 | + if (isset($update_info['tx'])) { |
|
239 | 239 | return $transaction->last_payment(); |
240 | 240 | } else { |
241 | 241 | return null; |
242 | 242 | } |
243 | 243 | } |
244 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
245 | - if ( ! $payment instanceof EEI_Payment ) { |
|
244 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
245 | + if ( ! $payment instanceof EEI_Payment) { |
|
246 | 246 | $payment = $transaction->last_payment(); |
247 | 247 | } |
248 | 248 | // ok, then validate the IPN. Even if we've already processed this payment, |
249 | 249 | // let PayPal know we don't want to hear from them anymore! |
250 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
250 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
251 | 251 | return $payment; |
252 | 252 | } |
253 | 253 | //ok, well let's process this payment then! |
254 | - switch ( $update_info[ 'payment_status' ] ) { |
|
254 | + switch ($update_info['payment_status']) { |
|
255 | 255 | |
256 | 256 | case 'Completed' : |
257 | 257 | $status = $this->_pay_model->approved_status(); |
258 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
258 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'Pending' : |
262 | 262 | $status = $this->_pay_model->pending_status(); |
263 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
263 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
264 | 264 | break; |
265 | 265 | |
266 | 266 | case 'Denied' : |
267 | 267 | $status = $this->_pay_model->declined_status(); |
268 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
268 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'Expired' : |
272 | 272 | case 'Failed' : |
273 | 273 | $status = $this->_pay_model->failed_status(); |
274 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
274 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
275 | 275 | break; |
276 | 276 | |
277 | 277 | case 'Refunded' : |
278 | 278 | case 'Partially_Refunded' : |
279 | 279 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
280 | 280 | $status = $this->_pay_model->approved_status(); |
281 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
281 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | case 'Voided' : |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | case 'Canceled_Reversal' : |
287 | 287 | default : |
288 | 288 | $status = $this->_pay_model->cancelled_status(); |
289 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
289 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
290 | 290 | break; |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | 294 | //check if we've already processed this payment |
295 | - if ( $payment instanceof EEI_Payment ) { |
|
295 | + if ($payment instanceof EEI_Payment) { |
|
296 | 296 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
297 | - if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) { |
|
297 | + if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) { |
|
298 | 298 | // DUPLICATED IPN! dont bother updating transaction foo!; |
299 | - $message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() ); |
|
299 | + $message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID()); |
|
300 | 300 | } else { |
301 | 301 | // new payment yippee !!! |
302 | - $payment->set_status( $status ); |
|
303 | - $payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) ); |
|
304 | - $payment->set_gateway_response( $gateway_response ); |
|
305 | - $payment->set_details( $update_info ); |
|
306 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
307 | - $message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) ); |
|
302 | + $payment->set_status($status); |
|
303 | + $payment->set_amount(floatval($update_info['mc_gross'])); |
|
304 | + $payment->set_gateway_response($gateway_response); |
|
305 | + $payment->set_details($update_info); |
|
306 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
307 | + $message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso')); |
|
308 | 308 | } |
309 | 309 | $this->log( |
310 | 310 | array( |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | $payment |
317 | 317 | ); |
318 | 318 | } |
319 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
319 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
320 | 320 | // kill request here if this is a refund |
321 | - if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded' ) { |
|
322 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) { |
|
323 | - status_header( 200 ); |
|
321 | + if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') { |
|
322 | + if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) { |
|
323 | + status_header(200); |
|
324 | 324 | exit(); |
325 | 325 | } |
326 | 326 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @param EE_Payment|EEI_Payment $payment |
337 | 337 | * @return boolean |
338 | 338 | */ |
339 | - public function validate_ipn( $update_info, $payment ) { |
|
339 | + public function validate_ipn($update_info, $payment) { |
|
340 | 340 | //allow us to skip validating IPNs with PayPal (useful for testing) |
341 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
341 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
342 | 342 | return true; |
343 | 343 | } |
344 | 344 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
347 | 347 | // Instead, read raw POST data from the input stream. |
348 | 348 | // @see https://gist.github.com/xcommerce-gists/3440401 |
349 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
350 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
349 | + $raw_post_data = file_get_contents('php://input'); |
|
350 | + $raw_post_array = explode('&', $raw_post_data); |
|
351 | 351 | $update_info = array(); |
352 | - foreach ( $raw_post_array as $keyval ) { |
|
353 | - $keyval = explode( '=', $keyval ); |
|
354 | - if ( count( $keyval ) == 2 ) |
|
355 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
352 | + foreach ($raw_post_array as $keyval) { |
|
353 | + $keyval = explode('=', $keyval); |
|
354 | + if (count($keyval) == 2) |
|
355 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
356 | 356 | } |
357 | 357 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
358 | 358 | $req = 'cmd=_notify-validate'; |
359 | - $get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false; |
|
360 | - foreach ( $update_info as $key => $value ) { |
|
361 | - if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) { |
|
362 | - $value = urlencode( stripslashes( $value ) ); |
|
359 | + $get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false; |
|
360 | + foreach ($update_info as $key => $value) { |
|
361 | + if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) { |
|
362 | + $value = urlencode(stripslashes($value)); |
|
363 | 363 | } else { |
364 | - $value = urlencode( $value ); |
|
364 | + $value = urlencode($value); |
|
365 | 365 | } |
366 | 366 | $req .= "&$key=$value"; |
367 | 367 | } |
@@ -371,21 +371,21 @@ discard block |
||
371 | 371 | array( |
372 | 372 | 'body' => $req, |
373 | 373 | 'sslverify' => false, |
374 | - 'timeout' => 60 , |
|
374 | + 'timeout' => 60, |
|
375 | 375 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
376 | 376 | // plz see: https://github.com/websharks/s2member/issues/610 |
377 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
377 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | // then check the response |
381 | - if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) { |
|
381 | + if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) { |
|
382 | 382 | return true; |
383 | 383 | } else { |
384 | 384 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
385 | 385 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
386 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $response[ 'body' ] ) ); |
|
387 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
388 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
386 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $response['body'])); |
|
387 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
388 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
389 | 389 | // log the results |
390 | 390 | $this->log( |
391 | 391 | array( |
@@ -407,9 +407,9 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function _process_response_url() { |
409 | 409 | EE_Registry::instance()->load_helper('URL'); |
410 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
410 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
411 | 411 | $url = is_ssl() ? 'https://' : 'http://'; |
412 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
412 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
413 | 413 | $url .= EEH_URL::filter_input_server_url(); |
414 | 414 | } else { |
415 | 415 | $url = 'unknown'; |
@@ -425,30 +425,30 @@ discard block |
||
425 | 425 | * like the taxes or shipping |
426 | 426 | * @param EEI_Payment $payment |
427 | 427 | */ |
428 | - public function update_txn_based_on_payment( $payment ) { |
|
428 | + public function update_txn_based_on_payment($payment) { |
|
429 | 429 | $update_info = $payment->details(); |
430 | 430 | $transaction = $payment->transaction(); |
431 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
432 | - if( ! $transaction ){ |
|
433 | - $this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment ); |
|
431 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
432 | + if ( ! $transaction) { |
|
433 | + $this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment); |
|
434 | 434 | return; |
435 | 435 | } |
436 | - if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) { |
|
436 | + if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) { |
|
437 | 437 | $this->log( |
438 | 438 | array( |
439 | 439 | 'url' => $this->_process_response_url(), |
440 | - 'message' => __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ), |
|
440 | + 'message' => __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'), |
|
441 | 441 | 'payment' => $payment->model_field_array() |
442 | 442 | ), |
443 | 443 | $payment |
444 | 444 | ); |
445 | 445 | return; |
446 | 446 | } |
447 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
447 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
448 | 448 | $this->log( |
449 | 449 | array( |
450 | 450 | 'url' => $this->_process_response_url(), |
451 | - 'message' => __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ), |
|
451 | + 'message' => __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'), |
|
452 | 452 | 'payment' => $payment->model_field_array() |
453 | 453 | ), |
454 | 454 | $payment |
@@ -458,43 +458,43 @@ discard block |
||
458 | 458 | $grand_total_needs_resaving = false; |
459 | 459 | |
460 | 460 | //might paypal have changed the taxes? |
461 | - if( $this->_paypal_taxes && $payment_was_itemized ){ |
|
461 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
462 | 462 | //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
463 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
463 | + $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping'); |
|
464 | 464 | $this->_line_item->set_total_tax_to( |
465 | 465 | $transaction->total_line_item(), |
466 | - floatval( $update_info['tax'] ), |
|
467 | - __( 'Taxes', 'event_espresso' ), |
|
468 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
466 | + floatval($update_info['tax']), |
|
467 | + __('Taxes', 'event_espresso'), |
|
468 | + __('Calculated by Paypal', 'event_espresso'), |
|
469 | 469 | 'paypal_tax' |
470 | 470 | ); |
471 | 471 | $grand_total_needs_resaving = TRUE; |
472 | 472 | } |
473 | 473 | |
474 | - $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
|
474 | + $shipping_amount = floatval($update_info['mc_shipping']); |
|
475 | 475 | //might paypal have added shipping? |
476 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
476 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
477 | 477 | $this->_line_item->add_unrelated_item( |
478 | 478 | $transaction->total_line_item(), |
479 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
479 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
480 | 480 | $shipping_amount, |
481 | 481 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
482 | 482 | 1, |
483 | 483 | false, |
484 | - 'paypal_shipping_' . $transaction->ID() |
|
484 | + 'paypal_shipping_'.$transaction->ID() |
|
485 | 485 | ); |
486 | 486 | $grand_total_needs_resaving = true; |
487 | 487 | } |
488 | 488 | |
489 | - if( $grand_total_needs_resaving ){ |
|
490 | - $transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
491 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
492 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
489 | + if ($grand_total_needs_resaving) { |
|
490 | + $transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID()); |
|
491 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
492 | + $registration_processor->update_registration_final_prices($transaction); |
|
493 | 493 | } |
494 | 494 | $this->log( |
495 | 495 | array( |
496 | 496 | 'url' => $this->_process_response_url(), |
497 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
497 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
498 | 498 | 'transaction (updated)' => $transaction->model_field_array(), |
499 | 499 | 'payment (updated)' => $payment->model_field_array(), |
500 | 500 | 'use_paypal_shipping' => $this->_paypal_shipping, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * The main purpose of this method is to return the parent for the model object |
99 | 99 | * |
100 | 100 | * @access public |
101 | - * @return int |
|
101 | + * @return boolean |
|
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | 104 | return $this->get( 'parent' ); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | /** |
110 | 110 | * return the _status property |
111 | - * @return string |
|
111 | + * @return boolean |
|
112 | 112 | */ |
113 | 113 | public function status() { |
114 | 114 | return $this->get( 'status' ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
132 | 132 | * @access protected |
133 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
133 | + * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array representing width and height in pixels (i.e. array(32,32) ). |
|
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class using the given size params. |
161 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
161 | + * @param integer[] $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
|
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | 164 | public function feature_image_url( $size = 'thumbnail' ) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * This is a method for restoring this_obj using details from the given $revision_id |
173 | 173 | * |
174 | 174 | * @param int $revision_id ID of the revision we're getting data from |
175 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
175 | + * @param string[] $related_obj_names if included this will be used to restore for related obj |
|
176 | 176 | * if not included then we just do restore on the meta. |
177 | 177 | * We will accept an array of related_obj_names for restoration here. |
178 | 178 | * @param array $where_query You can optionally include an array of key=>value pairs |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
228 | 228 | * @param string $meta_key |
229 | 229 | * @param boolean $single |
230 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
230 | + * @return string|null <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | |
257 | 257 | /** |
258 | 258 | * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
259 | - * @param mixed $meta_key |
|
260 | - * @param mixed $meta_value |
|
259 | + * @param string $meta_key |
|
260 | + * @param boolean $meta_value |
|
261 | 261 | * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
262 | 262 | * @throws EE_Error |
263 | 263 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
276 | 276 | * |
277 | - * @param mixed $meta_key |
|
277 | + * @param string $meta_key |
|
278 | 278 | * @param mixed $meta_value |
279 | 279 | * @throws EE_Error |
280 | 280 | * @return boolean False for failure. True for success. |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * Gets all the term-taxonomies for this CPT |
303 | 303 | * @param array $query_params |
304 | - * @return EE_Term_Taxonomy |
|
304 | + * @return EE_Base_Class[] |
|
305 | 305 | */ |
306 | 306 | public function term_taxonomies( $query_params = array() ) { |
307 | 307 | return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $parent_term_taxonomy_id optional |
48 | 48 | * @return EE_Term_Taxonomy |
49 | 49 | */ |
50 | - function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) { |
|
51 | - return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id ); |
|
50 | + function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) { |
|
51 | + return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | * @param string $category_name |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - function remove_event_category( $category_name ) { |
|
62 | - return $this->get_model()->remove_event_category( $this, $category_name ); |
|
61 | + function remove_event_category($category_name) { |
|
62 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @param EE_Term_Taxonomy $term_taxonomy |
71 | 71 | * @return EE_Base_Class the relation was removed from |
72 | 72 | */ |
73 | - function remove_relation_to_term_taxonomy( $term_taxonomy ) { |
|
74 | - if ( !$term_taxonomy ) { |
|
75 | - EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
73 | + function remove_relation_to_term_taxonomy($term_taxonomy) { |
|
74 | + if ( ! $term_taxonomy) { |
|
75 | + EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return NULL; |
77 | 77 | } |
78 | - $term_taxonomy->set_count( $term_taxonomy->count() - 1 ); |
|
78 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
79 | 79 | $term_taxonomy->save(); |
80 | - return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' ); |
|
80 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return int |
102 | 102 | */ |
103 | 103 | public function parent() { |
104 | - return $this->get( 'parent' ); |
|
104 | + return $this->get('parent'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @return string |
112 | 112 | */ |
113 | 113 | public function status() { |
114 | - return $this->get( 'status' ); |
|
114 | + return $this->get('status'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string $status |
121 | 121 | */ |
122 | - public function set_status( $status ) { |
|
123 | - $this->set( 'status', $status ); |
|
122 | + public function set_status($status) { |
|
123 | + $this->set('status', $status); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | * @param string|array $attr Optional. Query string or array of attributes. |
135 | 135 | * @return string HTML image element |
136 | 136 | */ |
137 | - protected function _get_feature_image( $size, $attr ) { |
|
137 | + protected function _get_feature_image($size, $attr) { |
|
138 | 138 | //first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
139 | - $attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr; |
|
140 | - $cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key; |
|
141 | - $this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr ); |
|
142 | - return $this->_feature_image[ $cache_key ]; |
|
139 | + $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
140 | + $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key; |
|
141 | + $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
142 | + return $this->_feature_image[$cache_key]; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | * @param string|array $attr |
151 | 151 | * @return string of html |
152 | 152 | */ |
153 | - public function feature_image( $size = 'thumbnail', $attr = '' ) { |
|
154 | - return $this->_get_feature_image( $size, $attr ); |
|
153 | + public function feature_image($size = 'thumbnail', $attr = '') { |
|
154 | + return $this->_get_feature_image($size, $attr); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32). |
162 | 162 | * @return string|boolean the url of the image or false if not found |
163 | 163 | */ |
164 | - public function feature_image_url( $size = 'thumbnail' ) { |
|
165 | - $attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size ); |
|
166 | - return !empty( $attachment ) ? $attachment[ 0 ] : FALSE; |
|
164 | + public function feature_image_url($size = 'thumbnail') { |
|
165 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
166 | + return ! empty($attachment) ? $attachment[0] : FALSE; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -185,37 +185,37 @@ discard block |
||
185 | 185 | * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names sent); |
186 | 186 | * @return void |
187 | 187 | */ |
188 | - public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) { |
|
188 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) { |
|
189 | 189 | //get revision object |
190 | - $revision_obj = $this->get_model()->get_one_by_ID( $revision_id ); |
|
191 | - if ( $revision_obj instanceof EE_CPT_Base ) { |
|
190 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
191 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
192 | 192 | //no related_obj_name so we assume we're saving a revision on this object. |
193 | - if ( empty( $related_obj_names ) ) { |
|
193 | + if (empty($related_obj_names)) { |
|
194 | 194 | $fields = $this->get_model()->get_meta_table_fields(); |
195 | - foreach ( $fields as $field ) { |
|
196 | - $this->set( $field, $revision_obj->get( $field ) ); |
|
195 | + foreach ($fields as $field) { |
|
196 | + $this->set($field, $revision_obj->get($field)); |
|
197 | 197 | } |
198 | 198 | $this->save(); |
199 | 199 | } |
200 | - $related_obj_names = (array)$related_obj_names; |
|
201 | - foreach ( $related_obj_names as $related_name ) { |
|
200 | + $related_obj_names = (array) $related_obj_names; |
|
201 | + foreach ($related_obj_names as $related_name) { |
|
202 | 202 | //related_obj_name so we're saving a revision on an object related to this object |
203 | 203 | //do we have $where_query params for this related object? If we do then we include that. |
204 | - $cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array(); |
|
205 | - $where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array(); |
|
206 | - $related_objs = $this->get_many_related( $related_name, $where_params ); |
|
207 | - $revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params ); |
|
204 | + $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array(); |
|
205 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
206 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
207 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
208 | 208 | //load helper |
209 | - EE_Registry::instance()->load_helper( 'Array' ); |
|
209 | + EE_Registry::instance()->load_helper('Array'); |
|
210 | 210 | //remove related objs from this object that are not in revision |
211 | 211 | //array_diff *should* work cause I think objects are indexed by ID? |
212 | - $related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs ); |
|
213 | - foreach ( $related_to_remove as $rr ) { |
|
214 | - $this->_remove_relation_to( $rr, $related_name, $cols_n_values ); |
|
212 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
213 | + foreach ($related_to_remove as $rr) { |
|
214 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
215 | 215 | } |
216 | 216 | //add all related objs attached to revision to this object |
217 | - foreach ( $revision_related_objs as $r_obj ) { |
|
218 | - $this->_add_relation_to( $r_obj, $related_name, $cols_n_values ); |
|
217 | + foreach ($revision_related_objs as $r_obj) { |
|
218 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li> |
232 | 232 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul> |
233 | 233 | */ |
234 | - public function get_post_meta( $meta_key = NULL, $single = FALSE ) { |
|
235 | - return get_post_meta( $this->ID(), $meta_key, $single ); |
|
234 | + public function get_post_meta($meta_key = NULL, $single = FALSE) { |
|
235 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @throws EE_Error |
246 | 246 | * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false. |
247 | 247 | */ |
248 | - public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) { |
|
249 | - if ( !$this->ID() ) { |
|
250 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
248 | + public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) { |
|
249 | + if ( ! $this->ID()) { |
|
250 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
251 | 251 | } |
252 | - return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value ); |
|
252 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | * @throws EE_Error |
263 | 263 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned. |
264 | 264 | */ |
265 | - public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) { |
|
266 | - if ( !$this->ID() ) { |
|
267 | - throw new EE_Error( sprintf( __( "You must save this custom post type before adding or updating a post meta field", "event_espresso" ) ) ); |
|
265 | + public function add_post_meta($meta_key, $meta_value, $unique = FALSE) { |
|
266 | + if ( ! $this->ID()) { |
|
267 | + throw new EE_Error(sprintf(__("You must save this custom post type before adding or updating a post meta field", "event_espresso"))); |
|
268 | 268 | } |
269 | - return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique ); |
|
269 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -279,11 +279,11 @@ discard block |
||
279 | 279 | * @throws EE_Error |
280 | 280 | * @return boolean False for failure. True for success. |
281 | 281 | */ |
282 | - public function delete_post_meta( $meta_key, $meta_value = '' ) { |
|
283 | - if ( ! $this->ID() ) { |
|
284 | - throw new EE_Error( sprintf( __( "Can not delete post meta field for a post that has never been saved.", "event_espresso" ) ) ); |
|
282 | + public function delete_post_meta($meta_key, $meta_value = '') { |
|
283 | + if ( ! $this->ID()) { |
|
284 | + throw new EE_Error(sprintf(__("Can not delete post meta field for a post that has never been saved.", "event_espresso"))); |
|
285 | 285 | } |
286 | - return delete_post_meta( $this->ID(), $meta_key, $meta_value ); |
|
286 | + return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @return string |
294 | 294 | */ |
295 | 295 | public function get_permalink() { |
296 | - return get_permalink( $this->ID() ); |
|
296 | + return get_permalink($this->ID()); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param array $query_params |
304 | 304 | * @return EE_Term_Taxonomy |
305 | 305 | */ |
306 | - public function term_taxonomies( $query_params = array() ) { |
|
307 | - return $this->get_many_related( 'Term_Taxonomy', $query_params ); |
|
306 | + public function term_taxonomies($query_params = array()) { |
|
307 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @access public |
84 | 84 | * @param string $new_status |
85 | 85 | * @param bool $use_default |
86 | - * @return bool|void |
|
86 | + * @return boolean |
|
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | 89 | public function set_status( $new_status = null, $use_default = false ) { |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @access public |
1065 | 1065 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1066 | - * @return mixed void|string |
|
1066 | + * @return string void|string |
|
1067 | 1067 | */ |
1068 | 1068 | public function pretty_active_status( $echo = TRUE ) { |
1069 | 1069 | $active_status = $this->get_active_status(); |
@@ -352,8 +352,7 @@ discard block |
||
352 | 352 | $short_desc = $this->get( 'EVT_short_desc' ); |
353 | 353 | if ( !empty( $short_desc ) || $not_full_desc ) { |
354 | 354 | return $short_desc; |
355 | - } |
|
356 | - else { |
|
355 | + } else { |
|
357 | 356 | $full_desc = $this->get( 'EVT_desc' ); |
358 | 357 | return wp_trim_words( $full_desc, $num_words, $more ); |
359 | 358 | } |
@@ -965,8 +964,7 @@ discard block |
||
965 | 964 | public function is_sold_out( $actual = FALSE ) { |
966 | 965 | if ( ! $actual ) { |
967 | 966 | return $this->status() == EEM_Event::sold_out; |
968 | - } |
|
969 | - else { |
|
967 | + } else { |
|
970 | 968 | return $this->perform_sold_out_status_check(); |
971 | 969 | } |
972 | 970 | } |
@@ -1158,8 +1156,7 @@ discard block |
||
1158 | 1156 | public function get_permalink() { |
1159 | 1157 | if ( $this->external_url() ) { |
1160 | 1158 | return $this->external_url(); |
1161 | - } |
|
1162 | - else { |
|
1159 | + } else { |
|
1163 | 1160 | return parent::get_permalink(); |
1164 | 1161 | } |
1165 | 1162 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * date_format and the second value is the time format |
36 | 36 | * @return EE_Event |
37 | 37 | */ |
38 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
39 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
40 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
38 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
40 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * the website will be used. |
49 | 49 | * @return EE_Event |
50 | 50 | */ |
51 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
52 | - return new self( $props_n_values, TRUE, $timezone ); |
|
51 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
52 | + return new self($props_n_values, TRUE, $timezone); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param mixed $field_value |
62 | 62 | * @param bool $use_default |
63 | 63 | */ |
64 | - public function set( $field_name, $field_value, $use_default = false ) { |
|
65 | - switch ( $field_name ) { |
|
64 | + public function set($field_name, $field_value, $use_default = false) { |
|
65 | + switch ($field_name) { |
|
66 | 66 | case 'status' : |
67 | - $this->set_status( $field_value, $use_default ); |
|
67 | + $this->set_status($field_value, $use_default); |
|
68 | 68 | break; |
69 | 69 | default : |
70 | - parent::set( $field_name, $field_value, $use_default ); |
|
70 | + parent::set($field_name, $field_value, $use_default); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -86,29 +86,29 @@ discard block |
||
86 | 86 | * @return bool|void |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public function set_status( $new_status = null, $use_default = false ) { |
|
89 | + public function set_status($new_status = null, $use_default = false) { |
|
90 | 90 | // get current Event status |
91 | 91 | $old_status = $this->status(); |
92 | 92 | // if status has changed |
93 | - if ( $old_status != $new_status ) { |
|
93 | + if ($old_status != $new_status) { |
|
94 | 94 | // TO sold_out |
95 | - if ( $new_status == EEM_Event::sold_out ) { |
|
95 | + if ($new_status == EEM_Event::sold_out) { |
|
96 | 96 | // save the previous event status so that we can revert if the event is no longer sold out |
97 | - $this->add_post_meta( '_previous_event_status', $old_status ); |
|
98 | - do_action( 'AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status ); |
|
97 | + $this->add_post_meta('_previous_event_status', $old_status); |
|
98 | + do_action('AHEE__EE_Event__set_status__to_sold_out', $this, $old_status, $new_status); |
|
99 | 99 | // OR FROM sold_out |
100 | - } else if ( $old_status == EEM_Event::sold_out ) { |
|
101 | - $this->delete_post_meta( '_previous_event_status' ); |
|
102 | - do_action( 'AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status ); |
|
100 | + } else if ($old_status == EEM_Event::sold_out) { |
|
101 | + $this->delete_post_meta('_previous_event_status'); |
|
102 | + do_action('AHEE__EE_Event__set_status__from_sold_out', $this, $old_status, $new_status); |
|
103 | 103 | } |
104 | 104 | // update status |
105 | - parent::set( 'status', $new_status, $use_default ); |
|
106 | - do_action( 'AHEE__EE_Event__set_status__after_update', $this ); |
|
105 | + parent::set('status', $new_status, $use_default); |
|
106 | + do_action('AHEE__EE_Event__set_status__after_update', $this); |
|
107 | 107 | return true; |
108 | 108 | } else { |
109 | 109 | // even though the old value matches the new value, it's still good to |
110 | 110 | // allow the parent set method to have a say |
111 | - parent::set( 'status', $new_status, $use_default ); |
|
111 | + parent::set('status', $new_status, $use_default); |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * @param array $query_params like EEM_Base::get_all |
122 | 122 | * @return EE_Datetime[] |
123 | 123 | */ |
124 | - public function datetimes( $query_params = array() ) { |
|
125 | - return $this->get_many_related( 'Datetime', $query_params ); |
|
124 | + public function datetimes($query_params = array()) { |
|
125 | + return $this->get_many_related('Datetime', $query_params); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return EE_Datetime[] |
134 | 134 | */ |
135 | 135 | public function datetimes_in_chronological_order() { |
136 | - return $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) ); |
|
136 | + return $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC'))); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param null $limit |
150 | 150 | * @return \EE_Datetime[] |
151 | 151 | */ |
152 | - public function datetimes_ordered( $show_expired = true, $show_deleted = false, $limit = null ) { |
|
153 | - return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_event_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted, $limit ); |
|
152 | + public function datetimes_ordered($show_expired = true, $show_deleted = false, $limit = null) { |
|
153 | + return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_event_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted, $limit); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return EE_Datetime |
161 | 161 | */ |
162 | 162 | public function first_datetime() { |
163 | - return $this->get_first_related( 'Datetime' ); |
|
163 | + return $this->get_first_related('Datetime'); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @param bool $try_to_exclude_deleted |
172 | 172 | * @return EE_Datetime |
173 | 173 | */ |
174 | - public function primary_datetime( $try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE ) { |
|
175 | - if ( !empty ( $this->_Primary_Datetime ) ) { |
|
174 | + public function primary_datetime($try_to_exclude_expired = TRUE, $try_to_exclude_deleted = TRUE) { |
|
175 | + if ( ! empty ($this->_Primary_Datetime)) { |
|
176 | 176 | return $this->_Primary_Datetime; |
177 | 177 | } |
178 | - $this->_Primary_Datetime = EEM_Datetime::instance( $this->_timezone )->get_primary_datetime_for_event( $this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted ); |
|
178 | + $this->_Primary_Datetime = EEM_Datetime::instance($this->_timezone)->get_primary_datetime_for_event($this->ID(), $try_to_exclude_expired, $try_to_exclude_deleted); |
|
179 | 179 | return $this->_Primary_Datetime; |
180 | 180 | } |
181 | 181 | |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | * @param array $query_params like EEM_Base::get_all |
187 | 187 | * @return EE_Ticket[] |
188 | 188 | */ |
189 | - public function tickets( $query_params = array() ) { |
|
189 | + public function tickets($query_params = array()) { |
|
190 | 190 | //first get all datetimes |
191 | 191 | $datetimes = $this->datetimes_ordered(); |
192 | - if ( ! $datetimes ) { |
|
192 | + if ( ! $datetimes) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | $datetime_ids = array(); |
197 | - foreach ( $datetimes as $datetime ) { |
|
197 | + foreach ($datetimes as $datetime) { |
|
198 | 198 | $datetime_ids[] = $datetime->ID(); |
199 | 199 | } |
200 | 200 | |
201 | - $where_params = array( 'Datetime.DTT_ID' => array( 'IN', $datetime_ids ) ); |
|
201 | + $where_params = array('Datetime.DTT_ID' => array('IN', $datetime_ids)); |
|
202 | 202 | |
203 | 203 | //if incoming $query_params has where conditions let's merge but not override existing. |
204 | - if ( is_array( $query_params ) && isset( $query_params[0]) ) { |
|
205 | - $where_params = array_merge( $query_params[0], $where_params ); |
|
206 | - unset( $query_params[0] ); |
|
204 | + if (is_array($query_params) && isset($query_params[0])) { |
|
205 | + $where_params = array_merge($query_params[0], $where_params); |
|
206 | + unset($query_params[0]); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | //now add $where_params to $query_params |
210 | 210 | $query_params[0] = $where_params; |
211 | 211 | |
212 | - return EEM_Ticket::instance()->get_all( $query_params ); |
|
212 | + return EEM_Ticket::instance()->get_all($query_params); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | function additional_limit() { |
221 | - return $this->get( 'EVT_additional_limit' ); |
|
221 | + return $this->get('EVT_additional_limit'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @return bool |
228 | 228 | */ |
229 | 229 | function allow_overflow() { |
230 | - return $this->get( 'EVT_allow_overflow' ); |
|
230 | + return $this->get('EVT_allow_overflow'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return bool |
237 | 237 | */ |
238 | 238 | function created() { |
239 | - return $this->get( 'EVT_created' ); |
|
239 | + return $this->get('EVT_created'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return bool |
246 | 246 | */ |
247 | 247 | function description() { |
248 | - return $this->get( 'EVT_desc' ); |
|
248 | + return $this->get('EVT_desc'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string of html |
256 | 256 | */ |
257 | 257 | function description_filtered() { |
258 | - return $this->get_pretty( 'EVT_desc' ); |
|
258 | + return $this->get_pretty('EVT_desc'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @return bool |
265 | 265 | */ |
266 | 266 | function display_description() { |
267 | - return $this->get( 'EVT_display_desc' ); |
|
267 | + return $this->get('EVT_display_desc'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return bool |
274 | 274 | */ |
275 | 275 | function display_ticket_selector() { |
276 | - return (bool)$this->get( 'EVT_display_ticket_selector' ); |
|
276 | + return (bool) $this->get('EVT_display_ticket_selector'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return bool |
283 | 283 | */ |
284 | 284 | function external_url() { |
285 | - return $this->get( 'EVT_external_URL' ); |
|
285 | + return $this->get('EVT_external_URL'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | function member_only() { |
294 | - return $this->get( 'EVT_member_only' ); |
|
294 | + return $this->get('EVT_member_only'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @return bool |
301 | 301 | */ |
302 | 302 | function phone() { |
303 | - return $this->get( 'EVT_phone' ); |
|
303 | + return $this->get('EVT_phone'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return bool |
310 | 310 | */ |
311 | 311 | function modified() { |
312 | - return $this->get( 'EVT_modified' ); |
|
312 | + return $this->get('EVT_modified'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @return bool |
319 | 319 | */ |
320 | 320 | function name() { |
321 | - return $this->get( 'EVT_name' ); |
|
321 | + return $this->get('EVT_name'); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return bool |
328 | 328 | */ |
329 | 329 | function order() { |
330 | - return $this->get( 'EVT_order' ); |
|
330 | + return $this->get('EVT_order'); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @return bool|string |
337 | 337 | */ |
338 | 338 | function default_registration_status() { |
339 | - $event_default_registration_status = $this->get( 'EVT_default_registration_status' ); |
|
340 | - return !empty( $event_default_registration_status ) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
339 | + $event_default_registration_status = $this->get('EVT_default_registration_status'); |
|
340 | + return ! empty($event_default_registration_status) ? $event_default_registration_status : EE_Registry::instance()->CFG->registration->default_STS_ID; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * @param bool $not_full_desc |
349 | 349 | * @return bool|string |
350 | 350 | */ |
351 | - function short_description( $num_words = 55, $more = NULL, $not_full_desc = FALSE ) { |
|
352 | - $short_desc = $this->get( 'EVT_short_desc' ); |
|
353 | - if ( !empty( $short_desc ) || $not_full_desc ) { |
|
351 | + function short_description($num_words = 55, $more = NULL, $not_full_desc = FALSE) { |
|
352 | + $short_desc = $this->get('EVT_short_desc'); |
|
353 | + if ( ! empty($short_desc) || $not_full_desc) { |
|
354 | 354 | return $short_desc; |
355 | 355 | } |
356 | 356 | else { |
357 | - $full_desc = $this->get( 'EVT_desc' ); |
|
358 | - return wp_trim_words( $full_desc, $num_words, $more ); |
|
357 | + $full_desc = $this->get('EVT_desc'); |
|
358 | + return wp_trim_words($full_desc, $num_words, $more); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @return bool |
366 | 366 | */ |
367 | 367 | function slug() { |
368 | - return $this->get( 'EVT_slug' ); |
|
368 | + return $this->get('EVT_slug'); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @return bool |
375 | 375 | */ |
376 | 376 | function timezone_string() { |
377 | - return $this->get( 'EVT_timezone_string' ); |
|
377 | + return $this->get('EVT_timezone_string'); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @return bool |
384 | 384 | */ |
385 | 385 | function visible_on() { |
386 | - return $this->get( 'EVT_visible_on' ); |
|
386 | + return $this->get('EVT_visible_on'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @return bool |
393 | 393 | */ |
394 | 394 | function wp_user() { |
395 | - return $this->get( 'EVT_wp_user' ); |
|
395 | + return $this->get('EVT_wp_user'); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return bool |
402 | 402 | */ |
403 | 403 | function donations() { |
404 | - return $this->get( 'EVT_donations' ); |
|
404 | + return $this->get('EVT_donations'); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -409,8 +409,8 @@ discard block |
||
409 | 409 | /** |
410 | 410 | * @param $limit |
411 | 411 | */ |
412 | - function set_additional_limit( $limit ) { |
|
413 | - $this->set( 'EVT_additional_limit', $limit ); |
|
412 | + function set_additional_limit($limit) { |
|
413 | + $this->set('EVT_additional_limit', $limit); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | /** |
419 | 419 | * @param $created |
420 | 420 | */ |
421 | - function set_created( $created ) { |
|
422 | - $this->set( 'EVT_created', $created ); |
|
421 | + function set_created($created) { |
|
422 | + $this->set('EVT_created', $created); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | /** |
428 | 428 | * @param $desc |
429 | 429 | */ |
430 | - function set_description( $desc ) { |
|
431 | - $this->set( 'EVT_desc', $desc ); |
|
430 | + function set_description($desc) { |
|
431 | + $this->set('EVT_desc', $desc); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | /** |
437 | 437 | * @param $display_desc |
438 | 438 | */ |
439 | - function set_display_description( $display_desc ) { |
|
440 | - $this->set( 'EVT_display_desc', $display_desc ); |
|
439 | + function set_display_description($display_desc) { |
|
440 | + $this->set('EVT_display_desc', $display_desc); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | /** |
446 | 446 | * @param $display_ticket_selector |
447 | 447 | */ |
448 | - function set_display_ticket_selector( $display_ticket_selector ) { |
|
449 | - $this->set( 'EVT_display_ticket_selector', $display_ticket_selector ); |
|
448 | + function set_display_ticket_selector($display_ticket_selector) { |
|
449 | + $this->set('EVT_display_ticket_selector', $display_ticket_selector); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | /** |
455 | 455 | * @param $external_url |
456 | 456 | */ |
457 | - function set_external_url( $external_url ) { |
|
458 | - $this->set( 'EVT_external_URL', $external_url ); |
|
457 | + function set_external_url($external_url) { |
|
458 | + $this->set('EVT_external_URL', $external_url); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | /** |
464 | 464 | * @param $member_only |
465 | 465 | */ |
466 | - function set_member_only( $member_only ) { |
|
467 | - $this->set( 'EVT_member_only', $member_only ); |
|
466 | + function set_member_only($member_only) { |
|
467 | + $this->set('EVT_member_only', $member_only); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | /** |
473 | 473 | * @param $event_phone |
474 | 474 | */ |
475 | - function set_event_phone( $event_phone ) { |
|
476 | - $this->set( 'EVT_phone', $event_phone ); |
|
475 | + function set_event_phone($event_phone) { |
|
476 | + $this->set('EVT_phone', $event_phone); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | /** |
482 | 482 | * @param $modified |
483 | 483 | */ |
484 | - function set_modified( $modified ) { |
|
485 | - $this->set( 'EVT_modified', $modified ); |
|
484 | + function set_modified($modified) { |
|
485 | + $this->set('EVT_modified', $modified); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | /** |
491 | 491 | * @param $name |
492 | 492 | */ |
493 | - function set_name( $name ) { |
|
494 | - $this->set( 'EVT_name', $name ); |
|
493 | + function set_name($name) { |
|
494 | + $this->set('EVT_name', $name); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | /** |
500 | 500 | * @param $order |
501 | 501 | */ |
502 | - function set_order( $order ) { |
|
503 | - $this->set( 'EVT_order', $order ); |
|
502 | + function set_order($order) { |
|
503 | + $this->set('EVT_order', $order); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -508,8 +508,8 @@ discard block |
||
508 | 508 | /** |
509 | 509 | * @param $short_desc |
510 | 510 | */ |
511 | - function set_short_description( $short_desc ) { |
|
512 | - $this->set( 'EVT_short_desc', $short_desc ); |
|
511 | + function set_short_description($short_desc) { |
|
512 | + $this->set('EVT_short_desc', $short_desc); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | /** |
518 | 518 | * @param $slug |
519 | 519 | */ |
520 | - function set_slug( $slug ) { |
|
521 | - $this->set( 'EVT_slug', $slug ); |
|
520 | + function set_slug($slug) { |
|
521 | + $this->set('EVT_slug', $slug); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | /** |
527 | 527 | * @param $timezone_string |
528 | 528 | */ |
529 | - function set_timezone_string( $timezone_string ) { |
|
530 | - $this->set( 'EVT_timezone_string', $timezone_string ); |
|
529 | + function set_timezone_string($timezone_string) { |
|
530 | + $this->set('EVT_timezone_string', $timezone_string); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * @param $visible_on |
537 | 537 | */ |
538 | - function set_visible_on( $visible_on ) { |
|
539 | - $this->set( 'EVT_visible_on', $visible_on ); |
|
538 | + function set_visible_on($visible_on) { |
|
539 | + $this->set('EVT_visible_on', $visible_on); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | /** |
545 | 545 | * @param $wp_user |
546 | 546 | */ |
547 | - function set_wp_user( $wp_user ) { |
|
548 | - $this->set( 'EVT_wp_user', $wp_user ); |
|
547 | + function set_wp_user($wp_user) { |
|
548 | + $this->set('EVT_wp_user', $wp_user); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | /** |
554 | 554 | * @param $default_registration_status |
555 | 555 | */ |
556 | - function set_default_registration_status( $default_registration_status ) { |
|
557 | - $this->set( 'EVT_default_registration_status', $default_registration_status ); |
|
556 | + function set_default_registration_status($default_registration_status) { |
|
557 | + $this->set('EVT_default_registration_status', $default_registration_status); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | /** |
563 | 563 | * @param $donations |
564 | 564 | */ |
565 | - function set_donations( $donations ) { |
|
566 | - $this->set( 'EVT_donations', $donations ); |
|
565 | + function set_donations($donations) { |
|
566 | + $this->set('EVT_donations', $donations); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | * @param EE_Venue /int $venue_id_or_obj |
574 | 574 | * @return EE_Venue |
575 | 575 | */ |
576 | - function add_venue( $venue_id_or_obj ) { |
|
577 | - return $this->_add_relation_to( $venue_id_or_obj, 'Venue' ); |
|
576 | + function add_venue($venue_id_or_obj) { |
|
577 | + return $this->_add_relation_to($venue_id_or_obj, 'Venue'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @param EE_Venue /int $venue_id_or_obj |
585 | 585 | * @return EE_Venue |
586 | 586 | */ |
587 | - function remove_venue( $venue_id_or_obj ) { |
|
588 | - return $this->_remove_relation_to( $venue_id_or_obj, 'Venue' ); |
|
587 | + function remove_venue($venue_id_or_obj) { |
|
588 | + return $this->_remove_relation_to($venue_id_or_obj, 'Venue'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | * @param array $query_params like EEM_Base::get_all's $query_params |
596 | 596 | * @return EE_Venue[] |
597 | 597 | */ |
598 | - function venues( $query_params = array() ) { |
|
599 | - return $this->get_many_related( 'Venue', $query_params ); |
|
598 | + function venues($query_params = array()) { |
|
599 | + return $this->get_many_related('Venue', $query_params); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | */ |
609 | 609 | private function _has_ID_and_is_published() { |
610 | 610 | // first check if event id is present and not NULL, then check if this event is published (or any of the equivalent "published" statuses) |
611 | - return ( $this->ID() && $this->ID() !== NULL && ( $this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled ) ) ? TRUE : FALSE; |
|
611 | + return ($this->ID() && $this->ID() !== NULL && ($this->status() == 'publish' || $this->status() == EEM_Event::sold_out || $this->status() == EEM_Event::postponed || $this->status() == EEM_Event::cancelled)) ? TRUE : FALSE; |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -620,21 +620,21 @@ discard block |
||
620 | 620 | */ |
621 | 621 | public function is_upcoming() { |
622 | 622 | // check if event id is present and if this event is published |
623 | - if ( $this->is_inactive() ) { |
|
623 | + if ($this->is_inactive()) { |
|
624 | 624 | return FALSE; |
625 | 625 | } |
626 | 626 | // set initial value |
627 | 627 | $upcoming = FALSE; |
628 | 628 | //next let's get all datetimes and loop through them |
629 | 629 | $datetimes = $this->datetimes_in_chronological_order(); |
630 | - foreach ( $datetimes as $datetime ) { |
|
631 | - if ( $datetime instanceof EE_Datetime ) { |
|
630 | + foreach ($datetimes as $datetime) { |
|
631 | + if ($datetime instanceof EE_Datetime) { |
|
632 | 632 | //if this dtt is expired then we continue cause one of the other datetimes might be upcoming. |
633 | - if ( $datetime->is_expired() ) { |
|
633 | + if ($datetime->is_expired()) { |
|
634 | 634 | continue; |
635 | 635 | } |
636 | 636 | //if this dtt is active then we return false. |
637 | - if ( $datetime->is_active() ) { |
|
637 | + if ($datetime->is_active()) { |
|
638 | 638 | return FALSE; |
639 | 639 | } |
640 | 640 | //otherwise let's check upcoming status |
@@ -651,21 +651,21 @@ discard block |
||
651 | 651 | */ |
652 | 652 | public function is_active() { |
653 | 653 | // check if event id is present and if this event is published |
654 | - if ( $this->is_inactive() ) { |
|
654 | + if ($this->is_inactive()) { |
|
655 | 655 | return FALSE; |
656 | 656 | } |
657 | 657 | // set initial value |
658 | 658 | $active = FALSE; |
659 | 659 | //next let's get all datetimes and loop through them |
660 | 660 | $datetimes = $this->datetimes_in_chronological_order(); |
661 | - foreach ( $datetimes as $datetime ) { |
|
662 | - if ( $datetime instanceof EE_Datetime ) { |
|
661 | + foreach ($datetimes as $datetime) { |
|
662 | + if ($datetime instanceof EE_Datetime) { |
|
663 | 663 | //if this dtt is expired then we continue cause one of the other datetimes might be active. |
664 | - if ( $datetime->is_expired() ) { |
|
664 | + if ($datetime->is_expired()) { |
|
665 | 665 | continue; |
666 | 666 | } |
667 | 667 | //if this dtt is upcoming then we return false. |
668 | - if ( $datetime->is_upcoming() ) { |
|
668 | + if ($datetime->is_upcoming()) { |
|
669 | 669 | return FALSE; |
670 | 670 | } |
671 | 671 | //otherwise let's check active status |
@@ -682,17 +682,17 @@ discard block |
||
682 | 682 | */ |
683 | 683 | public function is_expired() { |
684 | 684 | // check if event id is present and if this event is published |
685 | - if ( $this->is_inactive() ) { |
|
685 | + if ($this->is_inactive()) { |
|
686 | 686 | return FALSE; |
687 | 687 | } |
688 | 688 | // set initial value |
689 | 689 | $expired = FALSE; |
690 | 690 | //first let's get all datetimes and loop through them |
691 | 691 | $datetimes = $this->datetimes_in_chronological_order(); |
692 | - foreach ( $datetimes as $datetime ) { |
|
693 | - if ( $datetime instanceof EE_Datetime ) { |
|
692 | + foreach ($datetimes as $datetime) { |
|
693 | + if ($datetime instanceof EE_Datetime) { |
|
694 | 694 | //if this dtt is upcoming or active then we return false. |
695 | - if ( $datetime->is_upcoming() || $datetime->is_active() ) { |
|
695 | + if ($datetime->is_upcoming() || $datetime->is_active()) { |
|
696 | 696 | return FALSE; |
697 | 697 | } |
698 | 698 | //otherwise let's check active status |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function is_inactive() { |
711 | 711 | // check if event id is present and if this event is published |
712 | - if ( $this->_has_ID_and_is_published() ) { |
|
712 | + if ($this->_has_ID_and_is_published()) { |
|
713 | 713 | return FALSE; |
714 | 714 | } |
715 | 715 | return TRUE; |
@@ -727,37 +727,37 @@ discard block |
||
727 | 727 | */ |
728 | 728 | public function perform_sold_out_status_check() { |
729 | 729 | // get all unexpired untrashed tickets |
730 | - $tickets = $this->tickets( array( |
|
730 | + $tickets = $this->tickets(array( |
|
731 | 731 | array( |
732 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
732 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
733 | 733 | 'TKT_deleted' => false |
734 | 734 | ) |
735 | 735 | )); |
736 | 736 | // if all the tickets are just expired, then don't update the event status to sold out |
737 | - if ( empty( $tickets )) { |
|
737 | + if (empty($tickets)) { |
|
738 | 738 | return true; |
739 | 739 | } |
740 | 740 | // set initial value |
741 | 741 | $spaces_remaining = 0; |
742 | - foreach( $tickets as $ticket ) { |
|
743 | - if ( $ticket instanceof EE_Ticket ) { |
|
744 | - $spaces_remaining += $ticket->qty( 'saleable' ); |
|
742 | + foreach ($tickets as $ticket) { |
|
743 | + if ($ticket instanceof EE_Ticket) { |
|
744 | + $spaces_remaining += $ticket->qty('saleable'); |
|
745 | 745 | } |
746 | 746 | } |
747 | - if ( $spaces_remaining === 0 ) { |
|
748 | - $this->set_status( EEM_Event::sold_out ); |
|
749 | - if ( !is_admin() || ( is_admin() && defined( 'DOING_AJAX' ) ) ) { |
|
747 | + if ($spaces_remaining === 0) { |
|
748 | + $this->set_status(EEM_Event::sold_out); |
|
749 | + if ( ! is_admin() || (is_admin() && defined('DOING_AJAX'))) { |
|
750 | 750 | $this->save(); |
751 | 751 | } |
752 | 752 | $sold_out = TRUE; |
753 | 753 | } else { |
754 | 754 | $sold_out = FALSE; |
755 | 755 | // was event previously marked as sold out ? |
756 | - if ( $this->status() == EEM_Event::sold_out ) { |
|
756 | + if ($this->status() == EEM_Event::sold_out) { |
|
757 | 757 | // revert status to previous value, if it was set |
758 | - $previous_event_status = $this->get_post_meta( '_previous_event_status', true ); |
|
759 | - if ( $previous_event_status ) { |
|
760 | - $this->set_status( $previous_event_status ); |
|
758 | + $previous_event_status = $this->get_post_meta('_previous_event_status', true); |
|
759 | + if ($previous_event_status) { |
|
760 | + $this->set_status($previous_event_status); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | } |
@@ -781,15 +781,15 @@ discard block |
||
781 | 781 | */ |
782 | 782 | public function spaces_remaining_for_sale() { |
783 | 783 | //first get total available spaces including consideration for tickets that have already sold. |
784 | - $spaces_available = $this->total_available_spaces( true ); |
|
784 | + $spaces_available = $this->total_available_spaces(true); |
|
785 | 785 | |
786 | 786 | //if total available = 0, then exit right away because that means everything is expired. |
787 | - if ( $spaces_available === 0 ) { |
|
787 | + if ($spaces_available === 0) { |
|
788 | 788 | return 0; |
789 | 789 | } |
790 | 790 | |
791 | 791 | //subtract total approved registrations from spaces available to get how many are remaining. |
792 | - $spots_taken = EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
792 | + $spots_taken = EEM_Registration::instance()->count(array(array('EVT_ID' => $this->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
793 | 793 | $spaces_remaining = $spaces_available - $spots_taken; |
794 | 794 | |
795 | 795 | return $spaces_remaining > 0 ? $spaces_remaining : 0; |
@@ -822,29 +822,29 @@ discard block |
||
822 | 822 | * |
823 | 823 | * @return int|float (Note: if EE_INF is returned its considered a float by PHP) |
824 | 824 | */ |
825 | - public function total_available_spaces( $current_total_available = false ) { |
|
825 | + public function total_available_spaces($current_total_available = false) { |
|
826 | 826 | $spaces_available = 0; |
827 | 827 | |
828 | 828 | //first get all tickets on the event and include expired tickets |
829 | - $tickets = $this->tickets( array( 'default_where_conditions' => 'none' ) ); |
|
829 | + $tickets = $this->tickets(array('default_where_conditions' => 'none')); |
|
830 | 830 | $ticket_sums = array(); |
831 | 831 | $datetime_limits = array(); |
832 | 832 | |
833 | 833 | //loop through tickets and normalize them |
834 | - foreach ( $tickets as $ticket ) { |
|
835 | - $datetimes = $ticket->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
834 | + foreach ($tickets as $ticket) { |
|
835 | + $datetimes = $ticket->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
836 | 836 | |
837 | - if ( empty( $datetimes ) ) { |
|
837 | + if (empty($datetimes)) { |
|
838 | 838 | continue; |
839 | 839 | } |
840 | 840 | |
841 | 841 | //first datetime should be the lowest datetime |
842 | - $least_datetime = reset( $datetimes ); |
|
842 | + $least_datetime = reset($datetimes); |
|
843 | 843 | |
844 | 844 | //lets reset the ticket quantity to be the lower of either the lowest datetime reg limit or the ticket quantity |
845 | 845 | //IF datetimes sold (and we're not doing current live total available, then use spaces remaining for datetime, not reg_limit. |
846 | - if ( $current_total_available ) { |
|
847 | - if ( $ticket->is_remaining() ) { |
|
846 | + if ($current_total_available) { |
|
847 | + if ($ticket->is_remaining()) { |
|
848 | 848 | $remaining = $ticket->remaining(); |
849 | 849 | } else { |
850 | 850 | $spaces_available += $ticket->sold(); |
@@ -852,23 +852,23 @@ discard block |
||
852 | 852 | continue; |
853 | 853 | } |
854 | 854 | } else { |
855 | - $remaining = min( $ticket->qty(), $least_datetime->reg_limit() ); |
|
855 | + $remaining = min($ticket->qty(), $least_datetime->reg_limit()); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | //if $ticket_limit == infinity then let's drop out right away and just return that because any infinity amount trumps all other "available" amounts. |
859 | - if ( $remaining == EE_INF ) { |
|
859 | + if ($remaining == EE_INF) { |
|
860 | 860 | return EE_INF; |
861 | 861 | } |
862 | 862 | |
863 | 863 | //multiply normalized $tkt quantity by the number of datetimes on the ticket as the "sum" |
864 | 864 | //also include the sum of all the datetime reg limits on the ticket for breaking ties. |
865 | - $ticket_sums[$ticket->ID()]['sum'] = $remaining * count( $datetimes ); |
|
865 | + $ticket_sums[$ticket->ID()]['sum'] = $remaining * count($datetimes); |
|
866 | 866 | $ticket_sums[$ticket->ID()]['datetime_sums'] = 0; |
867 | - foreach ( $datetimes as $datetime ) { |
|
868 | - if ( $datetime->reg_limit() === EE_INF ) { |
|
867 | + foreach ($datetimes as $datetime) { |
|
868 | + if ($datetime->reg_limit() === EE_INF) { |
|
869 | 869 | $ticket_sums[$ticket->ID()]['datetime_sums'] = EE_INF; |
870 | 870 | } else { |
871 | - $ticket_sums[ $ticket->ID() ]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
871 | + $ticket_sums[$ticket->ID()]['datetime_sums'] += $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
|
872 | 872 | } |
873 | 873 | $datetime_limits[$datetime->ID()] = $current_total_available ? $datetime->spaces_remaining() : $datetime->reg_limit(); |
874 | 874 | } |
@@ -879,74 +879,74 @@ discard block |
||
879 | 879 | //ticket quantity by the number of datetimes on the ticket). For tie-breakers, then the next sort is based on the |
880 | 880 | //ticket with the greatest sum of all remaining datetime->spaces_remaining() ( or $datetime->reg_limit() if not |
881 | 881 | //$current_total_available ) for the datetimes on the ticket. |
882 | - usort( $ticket_sums, function( $a, $b ) { |
|
883 | - if ( $a['sum'] == $b['sum'] ) { |
|
884 | - if ( $a['datetime_sums'] == $b['datetime_sums'] ) { |
|
882 | + usort($ticket_sums, function($a, $b) { |
|
883 | + if ($a['sum'] == $b['sum']) { |
|
884 | + if ($a['datetime_sums'] == $b['datetime_sums']) { |
|
885 | 885 | return 0; |
886 | 886 | } |
887 | 887 | |
888 | 888 | return $a['datetime_sums'] < $b['datetime_sums'] ? 1 : -1; |
889 | 889 | } |
890 | - return ( $a['sum'] < $b['sum'] ) ? -1 : 1; |
|
890 | + return ($a['sum'] < $b['sum']) ? -1 : 1; |
|
891 | 891 | }); |
892 | 892 | |
893 | 893 | //now let's loop through the sorted tickets and simulate sellouts |
894 | - foreach ( $ticket_sums as $ticket_info ) { |
|
895 | - if ( $ticket_info['ticket'] instanceof EE_Ticket ) { |
|
894 | + foreach ($ticket_sums as $ticket_info) { |
|
895 | + if ($ticket_info['ticket'] instanceof EE_Ticket) { |
|
896 | 896 | |
897 | - $datetimes = $ticket_info['ticket']->datetimes( array( 'order_by' => array( 'DTT_reg_limit' => 'ASC' ) ) ); |
|
897 | + $datetimes = $ticket_info['ticket']->datetimes(array('order_by' => array('DTT_reg_limit' => 'ASC'))); |
|
898 | 898 | //need to sort these $datetimes by remaining (only if $current_total_available) |
899 | 899 | //setup datetimes for simulation |
900 | 900 | $ticket_datetimes_remaining = array(); |
901 | - foreach( $datetimes as $datetime ) { |
|
901 | + foreach ($datetimes as $datetime) { |
|
902 | 902 | $ticket_datetimes_remaining[$datetime->ID()]['rem'] = $datetime_limits[$datetime->ID()]; |
903 | 903 | $ticket_datetimes_remaining[$datetime->ID()]['datetime'] = $datetime; |
904 | 904 | } |
905 | - usort( $ticket_datetimes_remaining, function( $a, $b ) { |
|
906 | - if ( $a['rem'] == $b['rem'] ) { |
|
905 | + usort($ticket_datetimes_remaining, function($a, $b) { |
|
906 | + if ($a['rem'] == $b['rem']) { |
|
907 | 907 | return 0; |
908 | 908 | } |
909 | - return ( $a['rem'] < $b['rem'] ) ? -1 : 1; |
|
909 | + return ($a['rem'] < $b['rem']) ? -1 : 1; |
|
910 | 910 | }); |
911 | 911 | |
912 | 912 | |
913 | 913 | //get the remaining on the first datetime (which should be the one with the least remaining) and that is |
914 | 914 | //what we add to the spaces_available running total. Then we need to decrease the remaining on our datetime tracker. |
915 | - $lowest_datetime = reset( $ticket_datetimes_remaining ); |
|
915 | + $lowest_datetime = reset($ticket_datetimes_remaining); |
|
916 | 916 | |
917 | 917 | //need to get the lower of; what the remaining is on the lowest datetime, and the remaining on the ticket. |
918 | 918 | // If this ends up being 0 (because of previous tickets in our simulation selling out), then it has already |
919 | 919 | // been tracked on $spaces available and this ticket is now sold out for the simulation, so we can continue |
920 | 920 | // to the next ticket. |
921 | - if ( $current_total_available ) { |
|
922 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->remaining() ); |
|
921 | + if ($current_total_available) { |
|
922 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->remaining()); |
|
923 | 923 | } else { |
924 | - $remaining = min( $lowest_datetime['rem'], $ticket_info['ticket']->qty() ); |
|
924 | + $remaining = min($lowest_datetime['rem'], $ticket_info['ticket']->qty()); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | //if $remaining is infinite that means that all datetimes on this ticket are infinite but we've made it here because all |
928 | 928 | //tickets have a quantity. So we don't have to track datetimes, we can just use ticket quantities for total |
929 | 929 | //available. |
930 | - if ( $remaining === EE_INF ) { |
|
930 | + if ($remaining === EE_INF) { |
|
931 | 931 | $spaces_available += $ticket_info['ticket']->qty(); |
932 | 932 | continue; |
933 | 933 | } |
934 | 934 | |
935 | 935 | //if ticket has sold amounts then we also need to add that (but only if doing live counts) |
936 | - if ( $current_total_available ) { |
|
936 | + if ($current_total_available) { |
|
937 | 937 | $spaces_available += $ticket_info['ticket']->sold(); |
938 | 938 | } |
939 | 939 | |
940 | - if ( $remaining <= 0 ) { |
|
940 | + if ($remaining <= 0) { |
|
941 | 941 | continue; |
942 | 942 | } else { |
943 | 943 | $spaces_available += $remaining; |
944 | 944 | } |
945 | 945 | |
946 | 946 | //loop through the datetimes and sell them out! |
947 | - foreach ( $ticket_datetimes_remaining as $datetime_info ) { |
|
948 | - if ( $datetime_info['datetime'] instanceof EE_Datetime ) { |
|
949 | - $datetime_limits[ $datetime_info['datetime']->ID() ] += - $remaining; |
|
947 | + foreach ($ticket_datetimes_remaining as $datetime_info) { |
|
948 | + if ($datetime_info['datetime'] instanceof EE_Datetime) { |
|
949 | + $datetime_limits[$datetime_info['datetime']->ID()] += - $remaining; |
|
950 | 950 | } |
951 | 951 | } |
952 | 952 | } |
@@ -962,8 +962,8 @@ discard block |
||
962 | 962 | * @param bool $actual whether or not to perform calculations to not only figure the actual status but also to flip the status if necessary to sold out If false, we just check the existing status of the event |
963 | 963 | * @return boolean |
964 | 964 | */ |
965 | - public function is_sold_out( $actual = FALSE ) { |
|
966 | - if ( ! $actual ) { |
|
965 | + public function is_sold_out($actual = FALSE) { |
|
966 | + if ( ! $actual) { |
|
967 | 967 | return $this->status() == EEM_Event::sold_out; |
968 | 968 | } |
969 | 969 | else { |
@@ -1008,30 +1008,30 @@ discard block |
||
1008 | 1008 | * |
1009 | 1009 | * @return bool | string - based on EE_Datetime active constants or FALSE if error. |
1010 | 1010 | */ |
1011 | - public function get_active_status( $reset = false ) { |
|
1011 | + public function get_active_status($reset = false) { |
|
1012 | 1012 | // if the active status has already been set, then just use that value (unless we are resetting it) |
1013 | - if ( ! empty( $this->_active_status ) && ! $reset ) { |
|
1013 | + if ( ! empty($this->_active_status) && ! $reset) { |
|
1014 | 1014 | return $this->_active_status; |
1015 | 1015 | } |
1016 | 1016 | //first check if event id is present on this object |
1017 | - if ( ! $this->ID() ) { |
|
1017 | + if ( ! $this->ID()) { |
|
1018 | 1018 | return false; |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - $where_params_for_event = array( array( 'EVT_ID' => $this->ID() ) ); |
|
1021 | + $where_params_for_event = array(array('EVT_ID' => $this->ID())); |
|
1022 | 1022 | |
1023 | 1023 | //if event is published: |
1024 | - if ( $this->status() === 'publish' ) { |
|
1024 | + if ($this->status() === 'publish') { |
|
1025 | 1025 | //active? |
1026 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::active, $where_params_for_event ) > 0 ) { |
|
1026 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::active, $where_params_for_event) > 0) { |
|
1027 | 1027 | $this->_active_status = EE_Datetime::active; |
1028 | 1028 | } else { |
1029 | 1029 | //upcoming? |
1030 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::upcoming, $where_params_for_event ) > 0 ) { |
|
1030 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::upcoming, $where_params_for_event) > 0) { |
|
1031 | 1031 | $this->_active_status = EE_Datetime::upcoming; |
1032 | 1032 | } else { |
1033 | 1033 | //expired? |
1034 | - if ( EEM_Datetime::instance()->get_datetime_count_for_status( EE_Datetime::expired, $where_params_for_event ) > 0 ) { |
|
1034 | + if (EEM_Datetime::instance()->get_datetime_count_for_status(EE_Datetime::expired, $where_params_for_event) > 0) { |
|
1035 | 1035 | $this->_active_status = EE_Datetime::expired; |
1036 | 1036 | } else { |
1037 | 1037 | //it would be odd if things make it this far because it basically means there are no datetime's |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | } else { |
1044 | 1044 | //the event is not published, so let's just set it's active status according to its' post status |
1045 | - switch ( $this->status() ) { |
|
1045 | + switch ($this->status()) { |
|
1046 | 1046 | case EEM_Event::sold_out : |
1047 | 1047 | $this->_active_status = EE_Datetime::sold_out; |
1048 | 1048 | break; |
@@ -1068,10 +1068,10 @@ discard block |
||
1068 | 1068 | * @param boolean $echo whether to return (FALSE), or echo out the result (TRUE) |
1069 | 1069 | * @return mixed void|string |
1070 | 1070 | */ |
1071 | - public function pretty_active_status( $echo = TRUE ) { |
|
1071 | + public function pretty_active_status($echo = TRUE) { |
|
1072 | 1072 | $active_status = $this->get_active_status(); |
1073 | - $status = '<span class="ee-status event-active-status-' . $active_status . '">' . EEH_Template::pretty_status( $active_status, FALSE, 'sentence' ) . '</span>'; |
|
1074 | - if ( $echo ) { |
|
1073 | + $status = '<span class="ee-status event-active-status-'.$active_status.'">'.EEH_Template::pretty_status($active_status, FALSE, 'sentence').'</span>'; |
|
1074 | + if ($echo) { |
|
1075 | 1075 | echo $status; |
1076 | 1076 | return ''; |
1077 | 1077 | } |
@@ -1085,12 +1085,12 @@ discard block |
||
1085 | 1085 | */ |
1086 | 1086 | public function get_number_of_tickets_sold() { |
1087 | 1087 | $tkt_sold = 0; |
1088 | - if ( !$this->ID() ) { |
|
1088 | + if ( ! $this->ID()) { |
|
1089 | 1089 | return 0; |
1090 | 1090 | } |
1091 | 1091 | $datetimes = $this->datetimes(); |
1092 | - foreach ( $datetimes as $datetime ) { |
|
1093 | - if ( $datetime instanceof EE_Datetime ) { |
|
1092 | + foreach ($datetimes as $datetime) { |
|
1093 | + if ($datetime instanceof EE_Datetime) { |
|
1094 | 1094 | $tkt_sold += $datetime->sold(); |
1095 | 1095 | } |
1096 | 1096 | } |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | * @return int |
1106 | 1106 | */ |
1107 | 1107 | public function get_count_of_all_registrations() { |
1108 | - return EEM_Event::instance()->count_related( $this, 'Registration' ); |
|
1108 | + return EEM_Event::instance()->count_related($this, 'Registration'); |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | |
@@ -1115,9 +1115,9 @@ discard block |
||
1115 | 1115 | * @return EE_Ticket |
1116 | 1116 | */ |
1117 | 1117 | public function get_ticket_with_earliest_start_time() { |
1118 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1119 | - $query_params = array( $where, 'order_by' => array( 'TKT_start_date' => 'ASC' ) ); |
|
1120 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1118 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1119 | + $query_params = array($where, 'order_by' => array('TKT_start_date' => 'ASC')); |
|
1120 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | 1123 | |
@@ -1127,9 +1127,9 @@ discard block |
||
1127 | 1127 | * @return EE_Ticket |
1128 | 1128 | */ |
1129 | 1129 | public function get_ticket_with_latest_end_time() { |
1130 | - $where[ 'Datetime.EVT_ID' ] = $this->ID(); |
|
1131 | - $query_params = array( $where, 'order_by' => array( 'TKT_end_date' => 'DESC' ) ); |
|
1132 | - return EE_Registry::instance()->load_model( 'Ticket' )->get_one( $query_params ); |
|
1130 | + $where['Datetime.EVT_ID'] = $this->ID(); |
|
1131 | + $query_params = array($where, 'order_by' => array('TKT_end_date' => 'DESC')); |
|
1132 | + return EE_Registry::instance()->load_model('Ticket')->get_one($query_params); |
|
1133 | 1133 | } |
1134 | 1134 | |
1135 | 1135 | |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | public function tickets_on_sale() { |
1142 | 1142 | $earliest_ticket = $this->get_ticket_with_earliest_start_time(); |
1143 | 1143 | $latest_ticket = $this->get_ticket_with_latest_end_time(); |
1144 | - if ( !$latest_ticket instanceof EE_Ticket && !$earliest_ticket instanceof EE_Ticket ) { |
|
1144 | + if ( ! $latest_ticket instanceof EE_Ticket && ! $earliest_ticket instanceof EE_Ticket) { |
|
1145 | 1145 | return FALSE; |
1146 | 1146 | } |
1147 | 1147 | //check on sale for these two tickets. |
1148 | - if ( $latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale() ) { |
|
1148 | + if ($latest_ticket->is_on_sale() || $earliest_ticket->is_on_sale()) { |
|
1149 | 1149 | return TRUE; |
1150 | 1150 | } |
1151 | 1151 | return FALSE; |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | * @return string |
1160 | 1160 | */ |
1161 | 1161 | public function get_permalink() { |
1162 | - if ( $this->external_url() ) { |
|
1162 | + if ($this->external_url()) { |
|
1163 | 1163 | return $this->external_url(); |
1164 | 1164 | } |
1165 | 1165 | else { |
@@ -1174,10 +1174,10 @@ discard block |
||
1174 | 1174 | * @param array $query_params like EEM_Base::get_all |
1175 | 1175 | * @return EE_Term |
1176 | 1176 | */ |
1177 | - public function first_event_category( $query_params = array() ) { |
|
1178 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1179 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1180 | - return EEM_Term::instance()->get_one( $query_params ); |
|
1177 | + public function first_event_category($query_params = array()) { |
|
1178 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1179 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1180 | + return EEM_Term::instance()->get_one($query_params); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | |
@@ -1187,10 +1187,10 @@ discard block |
||
1187 | 1187 | * @param array $query_params |
1188 | 1188 | * @return EE_Term[] |
1189 | 1189 | */ |
1190 | - public function get_all_event_categories( $query_params = array() ) { |
|
1191 | - $query_params[ 0 ][ 'Term_Taxonomy.taxonomy' ] = 'espresso_event_categories'; |
|
1192 | - $query_params[ 0 ][ 'Term_Taxonomy.Event.EVT_ID' ] = $this->ID(); |
|
1193 | - return EEM_Term::instance()->get_all( $query_params ); |
|
1190 | + public function get_all_event_categories($query_params = array()) { |
|
1191 | + $query_params[0]['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1192 | + $query_params[0]['Term_Taxonomy.Event.EVT_ID'] = $this->ID(); |
|
1193 | + return EEM_Term::instance()->get_all($query_params); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | /** |
@@ -1198,8 +1198,8 @@ discard block |
||
1198 | 1198 | * @param array $query_params @see EEM_Base::get_all |
1199 | 1199 | * @return EE_Question_Group[] |
1200 | 1200 | */ |
1201 | - public function question_groups($query_params = array()){ |
|
1202 | - $query_params = ! empty( $query_params ) ? $query_params : array( 'order_by' => array( 'QSG_order' => 'ASC' )); |
|
1201 | + public function question_groups($query_params = array()) { |
|
1202 | + $query_params = ! empty($query_params) ? $query_params : array('order_by' => array('QSG_order' => 'ASC')); |
|
1203 | 1203 | return $this->get_many_related('Question_Group', $query_params); |
1204 | 1204 | } |
1205 | 1205 | |
@@ -1239,12 +1239,12 @@ discard block |
||
1239 | 1239 | */ |
1240 | 1240 | public function get_admin_edit_link() { |
1241 | 1241 | EE_Registry::instance()->load_helper('URL'); |
1242 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1242 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1243 | 1243 | 'page' => 'espresso_events', |
1244 | 1244 | 'action' => 'edit', |
1245 | 1245 | 'post' => $this->ID() |
1246 | 1246 | ), |
1247 | - admin_url( 'admin.php' ) |
|
1247 | + admin_url('admin.php') |
|
1248 | 1248 | ); |
1249 | 1249 | } |
1250 | 1250 | |
@@ -1257,11 +1257,11 @@ discard block |
||
1257 | 1257 | */ |
1258 | 1258 | public function get_admin_settings_link() { |
1259 | 1259 | EE_Registry::instance()->load_helper('URL'); |
1260 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1260 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1261 | 1261 | 'page' => 'espresso_events', |
1262 | 1262 | 'action' => 'default_event_settings' |
1263 | 1263 | ), |
1264 | - admin_url( 'admin.php' ) |
|
1264 | + admin_url('admin.php') |
|
1265 | 1265 | ); |
1266 | 1266 | } |
1267 | 1267 | |
@@ -1277,11 +1277,11 @@ discard block |
||
1277 | 1277 | public function get_admin_overview_link() { |
1278 | 1278 | |
1279 | 1279 | EE_Registry::instance()->load_helper('URL'); |
1280 | - return EEH_URL::add_query_args_and_nonce( array( |
|
1280 | + return EEH_URL::add_query_args_and_nonce(array( |
|
1281 | 1281 | 'page' => 'espresso_events', |
1282 | 1282 | 'action' => 'default' |
1283 | 1283 | ), |
1284 | - admin_url( 'admin.php' ) |
|
1284 | + admin_url('admin.php') |
|
1285 | 1285 | ); |
1286 | 1286 | } |
1287 | 1287 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | 'espresso_events' => 'edit' |
68 | 68 | ); |
69 | 69 | |
70 | - add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) ); |
|
70 | + add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function _ajax_hooks() { |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | 'edit' => __('Update Event', 'event_espresso'), |
94 | 94 | 'add_category' => __('Save New Category', 'event_espresso'), |
95 | 95 | 'edit_category' => __('Update Category', 'event_espresso'), |
96 | - 'template_settings' => __( 'Update Settings', 'event_espresso' ) |
|
96 | + 'template_settings' => __('Update Settings', 'event_espresso') |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | protected function _set_page_routes() { |
102 | 102 | //load formatter helper |
103 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
103 | + EE_Registry::instance()->load_helper('Formatter'); |
|
104 | 104 | //load field generator helper |
105 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
105 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
106 | 106 | |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0; |
|
109 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
110 | 110 | |
111 | 111 | |
112 | 112 | $this->_page_routes = array( |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'help_tour' => array( |
321 | 321 | 'Event_Editor_Help_Tour' |
322 | 322 | ), |
323 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | 324 | 'require_nonce' => FALSE |
325 | 325 | ), |
326 | 326 | 'edit' => array( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | 'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ), |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => FALSE |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'filename' => 'events_default_settings_status' |
399 | 399 | ) |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour'), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => FALSE |
403 | 403 | ), |
404 | 404 | //template settings |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | 'filename' => 'general_settings_templates' |
415 | 415 | ) |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => FALSE |
419 | 419 | ), |
420 | 420 | //event category stuff |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'label' => __('Edit Category', 'event_espresso'), |
439 | 439 | 'order' => 15, |
440 | 440 | 'persistent' => FALSE, |
441 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
441 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
442 | 442 | ), |
443 | 443 | 'help_tabs' => array( |
444 | 444 | 'edit_category_help_tab' => array( |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | |
509 | 509 | public function load_scripts_styles() { |
510 | 510 | |
511 | - wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
511 | + wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
512 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
513 | 513 | wp_enqueue_style('events-admin-css'); |
514 | 514 | wp_enqueue_style('ee-cat-admin'); |
515 | 515 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
516 | 516 | //registers for all views |
517 | 517 | //scripts |
518 | - wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
518 | + wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | public function load_scripts_styles_edit() { |
534 | 534 | //styles |
535 | 535 | wp_enqueue_style('espresso-ui-theme'); |
536 | - wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
536 | + wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
537 | 537 | wp_enqueue_style('event-editor-css'); |
538 | 538 | |
539 | 539 | //scripts |
540 | - wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION ); |
|
540 | + wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION); |
|
541 | 541 | wp_enqueue_script('event-datetime-metabox'); |
542 | 542 | |
543 | 543 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | |
573 | 573 | |
574 | 574 | public function admin_init() { |
575 | - EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ); |
|
575 | + EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | |
@@ -593,45 +593,45 @@ discard block |
||
593 | 593 | */ |
594 | 594 | public function verify_event_edit($event = NULL) { |
595 | 595 | // no event? |
596 | - if ( empty( $event )) { |
|
596 | + if (empty($event)) { |
|
597 | 597 | // set event |
598 | 598 | $event = $this->_cpt_model_obj; |
599 | 599 | } |
600 | 600 | // STILL no event? |
601 | - if ( empty ( $event )) { |
|
601 | + if (empty ($event)) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | 604 | // first check if event is active. |
605 | - if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) { |
|
605 | + if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) { |
|
606 | 606 | return; |
607 | 607 | } |
608 | 608 | $orig_status = $event->status(); |
609 | 609 | //made it here so it IS active... next check that any of the tickets are sold. |
610 | - if ( $event->is_sold_out( true ) ) { |
|
611 | - if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out ) { |
|
610 | + if ($event->is_sold_out(true)) { |
|
611 | + if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) { |
|
612 | 612 | EE_Error::add_attention( |
613 | 613 | sprintf( |
614 | - __( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso' ), |
|
615 | - EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' ) |
|
614 | + __('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', 'event_espresso'), |
|
615 | + EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence') |
|
616 | 616 | ) |
617 | 617 | ); |
618 | 618 | } |
619 | 619 | return; |
620 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
620 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
621 | 621 | EE_Error::add_attention( |
622 | 622 | sprintf( |
623 | - __( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | - 'event_espresso' ), |
|
625 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
623 | + __('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
624 | + 'event_espresso'), |
|
625 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
626 | 626 | ) |
627 | 627 | ); |
628 | 628 | } |
629 | 629 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
630 | - if ( ! $event->tickets_on_sale() ) { |
|
630 | + if ( ! $event->tickets_on_sale()) { |
|
631 | 631 | return; |
632 | 632 | } |
633 | 633 | //made it here so show warning |
634 | - EE_Error::add_attention( $this->_edit_event_warning() ); |
|
634 | + EE_Error::add_attention($this->_edit_event_warning()); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | ), |
672 | 672 | ); |
673 | 673 | |
674 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
674 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
675 | 675 | $this->_views['trash'] = array( |
676 | 676 | 'slug' => 'trash', |
677 | 677 | 'label' => __('Trash', 'event_espresso'), |
@@ -701,39 +701,39 @@ discard block |
||
701 | 701 | 'desc' => __('View Registrations for Event', 'event_espresso') |
702 | 702 | ) |
703 | 703 | ); |
704 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
704 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
705 | 705 | $statuses = array( |
706 | 706 | 'sold_out_status' => array( |
707 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
708 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' ) |
|
707 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
708 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence') |
|
709 | 709 | ), |
710 | 710 | 'active_status' => array( |
711 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
712 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' ) |
|
711 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
712 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence') |
|
713 | 713 | ), |
714 | 714 | 'upcoming_status' => array( |
715 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
716 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' ) |
|
715 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
716 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence') |
|
717 | 717 | ), |
718 | 718 | 'postponed_status' => array( |
719 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
720 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' ) |
|
719 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
720 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence') |
|
721 | 721 | ), |
722 | 722 | 'cancelled_status' => array( |
723 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
724 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' ) |
|
723 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
724 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence') |
|
725 | 725 | ), |
726 | 726 | 'expired_status' => array( |
727 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
728 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' ) |
|
727 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
728 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence') |
|
729 | 729 | ), |
730 | 730 | 'inactive_status' => array( |
731 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
732 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' ) |
|
731 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
732 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence') |
|
733 | 733 | ) |
734 | 734 | ); |
735 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
736 | - return array_merge( $items, $statuses ); |
|
735 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
736 | + return array_merge($items, $statuses); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -745,8 +745,8 @@ discard block |
||
745 | 745 | * @return EEM_Event |
746 | 746 | */ |
747 | 747 | private function _event_model() { |
748 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
749 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
748 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
749 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
750 | 750 | } |
751 | 751 | return $this->_event_model; |
752 | 752 | } |
@@ -765,12 +765,12 @@ discard block |
||
765 | 765 | * @param string $new_slug what the slug is |
766 | 766 | * @return string The new html string for the permalink area |
767 | 767 | */ |
768 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
768 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
769 | 769 | //make sure this is only when editing |
770 | - if ( !empty( $id ) ) { |
|
771 | - $post = get_post( $id ); |
|
772 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> '; |
|
773 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">'; |
|
770 | + if ( ! empty($id)) { |
|
771 | + $post = get_post($id); |
|
772 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> '; |
|
773 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">'; |
|
774 | 774 | } |
775 | 775 | return $return; |
776 | 776 | } |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @return string html for generated table |
787 | 787 | */ |
788 | 788 | protected function _events_overview_list_table() { |
789 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
790 | - $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) . |
|
789 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
790 | + $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button'). |
|
791 | 791 | $this->_display_legend($this->_event_legend_items()); |
792 | 792 | $this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2'); |
793 | 793 | $this->display_admin_list_table_page_with_no_sidebar(); |
@@ -805,51 +805,51 @@ discard block |
||
805 | 805 | |
806 | 806 | |
807 | 807 | |
808 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
808 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
809 | 809 | |
810 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
810 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
811 | 811 | //getout we're not processing an event save. |
812 | 812 | return; |
813 | 813 | } |
814 | 814 | |
815 | 815 | $event_values = array( |
816 | - 'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
817 | - 'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
816 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
817 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
818 | 818 | 'EVT_additional_limit' => min( |
819 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
820 | - !empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | - 'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | - 'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
823 | - 'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
824 | - 'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | - 'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL, |
|
826 | - 'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL |
|
819 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
820 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ), |
|
821 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
822 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
823 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
824 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL, |
|
825 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL, |
|
826 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL |
|
827 | 827 | ); |
828 | 828 | |
829 | 829 | //update event |
830 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
830 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
834 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
835 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
834 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
835 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
836 | 836 | |
837 | 837 | |
838 | 838 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
839 | - $event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) ); |
|
839 | + $event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update'))); |
|
840 | 840 | |
841 | 841 | $att_success = TRUE; |
842 | 842 | |
843 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
844 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
845 | - $att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
843 | + foreach ($event_update_callbacks as $e_callback) { |
|
844 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
845 | + $att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | //any errors? |
849 | - if ( $success && FALSE === $att_success ) { |
|
850 | - EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
851 | - } else if ( $success === FALSE ) { |
|
852 | - EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
849 | + if ($success && FALSE === $att_success) { |
|
850 | + EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
851 | + } else if ($success === FALSE) { |
|
852 | + EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @see parent::restore_item() |
861 | 861 | */ |
862 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
862 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
863 | 863 | //copy existing event meta to new post |
864 | 864 | $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
865 | - if ( $post_evt instanceof EE_Event ) { |
|
865 | + if ($post_evt instanceof EE_Event) { |
|
866 | 866 | //meta revision restore |
867 | - $post_evt->restore_revision( $revision_id ); |
|
867 | + $post_evt->restore_revision($revision_id); |
|
868 | 868 | //related objs restore |
869 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
869 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -879,52 +879,52 @@ discard block |
||
879 | 879 | * @param array $data The request data from the form |
880 | 880 | * @return bool Success or fail. |
881 | 881 | */ |
882 | - protected function _default_venue_update( $evtobj, $data ) { |
|
883 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
882 | + protected function _default_venue_update($evtobj, $data) { |
|
883 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
884 | 884 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
885 | 885 | $rows_affected = NULL; |
886 | - $venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL; |
|
886 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL; |
|
887 | 887 | |
888 | 888 | // very important. If we don't have a venue name... |
889 | 889 | // then we'll get out because not necessary to create empty venue |
890 | - if ( empty( $data['venue_title'] ) ) { |
|
890 | + if (empty($data['venue_title'])) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $venue_array = array( |
895 | 895 | 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
896 | - 'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL, |
|
897 | - 'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL, |
|
898 | - 'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL, |
|
899 | - 'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL, |
|
900 | - 'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL, |
|
901 | - 'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL, |
|
902 | - 'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL, |
|
903 | - 'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL, |
|
904 | - 'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL, |
|
905 | - 'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL, |
|
906 | - 'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL, |
|
907 | - 'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL, |
|
908 | - 'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL, |
|
909 | - 'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | - 'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL, |
|
911 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
896 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL, |
|
897 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL, |
|
898 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL, |
|
899 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL, |
|
900 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL, |
|
901 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL, |
|
902 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL, |
|
903 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL, |
|
904 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL, |
|
905 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL, |
|
906 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL, |
|
907 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL, |
|
908 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL, |
|
909 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL, |
|
910 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL, |
|
911 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
912 | 912 | 'status' => 'publish' |
913 | 913 | ); |
914 | 914 | |
915 | 915 | |
916 | 916 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
917 | - if ( !empty( $venue_id ) ) { |
|
918 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
919 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
917 | + if ( ! empty($venue_id)) { |
|
918 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
919 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
920 | 920 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
921 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
921 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
922 | 922 | return $rows_affected > 0 ? TRUE : FALSE; |
923 | 923 | } else { |
924 | 924 | //we insert the venue |
925 | - $venue_id = $venue_model->insert( $venue_array ); |
|
926 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
927 | - return !empty( $venue_id ) ? TRUE : FALSE; |
|
925 | + $venue_id = $venue_model->insert($venue_array); |
|
926 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
927 | + return ! empty($venue_id) ? TRUE : FALSE; |
|
928 | 928 | } |
929 | 929 | //when we have the ancestor come in it's already been handled by the revision save. |
930 | 930 | } |
@@ -938,55 +938,55 @@ discard block |
||
938 | 938 | * @param array $data The request data from the form |
939 | 939 | * @return bool success or fail |
940 | 940 | */ |
941 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
941 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
942 | 942 | $success = true; |
943 | 943 | $saved_dtt = null; |
944 | 944 | $saved_tickets = array(); |
945 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
945 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
946 | 946 | |
947 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
947 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
948 | 948 | //trim all values to ensure any excess whitespace is removed. |
949 | - $dtt = array_map( 'trim', $dtt ); |
|
950 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
949 | + $dtt = array_map('trim', $dtt); |
|
950 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
951 | 951 | $datetime_values = array( |
952 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
952 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
953 | 953 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
954 | 954 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
955 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
955 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
956 | 956 | 'DTT_order' => $row, |
957 | 957 | ); |
958 | 958 | |
959 | 959 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
960 | 960 | |
961 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
962 | - $DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
963 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
964 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
965 | - foreach ( $datetime_values as $field => $value ) { |
|
966 | - $DTM->set( $field, $value ); |
|
961 | + if ( ! empty($dtt['DTT_ID'])) { |
|
962 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']); |
|
963 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
964 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
965 | + foreach ($datetime_values as $field => $value) { |
|
966 | + $DTM->set($field, $value); |
|
967 | 967 | } |
968 | 968 | |
969 | 969 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
970 | 970 | $saved_dtts[$DTM->ID()] = $DTM; |
971 | 971 | } else { |
972 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE ); |
|
973 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
974 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
975 | - $DTM->set_timezone( $evtobj->get_timezone() ); |
|
976 | - foreach ( $datetime_values as $field => $value ) { |
|
977 | - $DTM->set( $field, $value ); |
|
972 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE); |
|
973 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
974 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
975 | + $DTM->set_timezone($evtobj->get_timezone()); |
|
976 | + foreach ($datetime_values as $field => $value) { |
|
977 | + $DTM->set($field, $value); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | $DTM->save(); |
981 | 981 | |
982 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
982 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
983 | 983 | |
984 | 984 | //load DTT helper |
985 | 985 | EE_Registry::instance()->load_helper('DTT_Helper'); |
986 | 986 | |
987 | 987 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
988 | - if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) { |
|
989 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') ); |
|
988 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
989 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
990 | 990 | $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
991 | 991 | $DTT->save(); |
992 | 992 | } |
@@ -994,45 +994,45 @@ discard block |
||
994 | 994 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
995 | 995 | $saved_dtt = $DTT; |
996 | 996 | |
997 | - $success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
997 | + $success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now. |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | //no dtts get deleted so we don't do any of that logic here. |
1001 | 1001 | //update tickets next |
1002 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
1003 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1004 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1002 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1003 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1004 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1005 | 1005 | $update_prices = false; |
1006 | - $ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1006 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1007 | 1007 | |
1008 | 1008 | // trim inputs to ensure any excess whitespace is removed. |
1009 | - $tkt = array_map( 'trim', $tkt ); |
|
1009 | + $tkt = array_map('trim', $tkt); |
|
1010 | 1010 | |
1011 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1011 | + if (empty($tkt['TKT_start_date'])) { |
|
1012 | 1012 | //let's use now in the set timezone. |
1013 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1014 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1013 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1014 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1017 | + if (empty($tkt['TKT_end_date'])) { |
|
1018 | 1018 | //use the start date of the first datetime |
1019 | 1019 | $dtt = $evtobj->first_datetime(); |
1020 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] ); |
|
1020 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | $TKT_values = array( |
1024 | - 'TKT_ID' => !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
1025 | - 'TTM_ID' => !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1026 | - 'TKT_name' => !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1027 | - 'TKT_description' => !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1024 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
1025 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1026 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1027 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1028 | 1028 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1029 | 1029 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1030 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ], |
|
1032 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1033 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1030 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1031 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1032 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1033 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1034 | 1034 | 'TKT_row' => $row, |
1035 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1035 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1036 | 1036 | 'TKT_price' => $ticket_price |
1037 | 1037 | ); |
1038 | 1038 | |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | |
1041 | 1041 | |
1042 | 1042 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
1043 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1043 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1044 | 1044 | $TKT_values['TKT_ID'] = 0; |
1045 | 1045 | $TKT_values['TKT_is_default'] = 0; |
1046 | 1046 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1051,58 +1051,58 @@ discard block |
||
1051 | 1051 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1052 | 1052 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1053 | 1053 | |
1054 | - if ( !empty( $tkt['TKT_ID'] ) ) { |
|
1055 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1056 | - if ( $TKT instanceof EE_Ticket ) { |
|
1057 | - $ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false; |
|
1054 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1055 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']); |
|
1056 | + if ($TKT instanceof EE_Ticket) { |
|
1057 | + $ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false; |
|
1058 | 1058 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1059 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false; |
|
1060 | - $TKT->set_date_format( $incoming_date_formats[ 0 ] ); |
|
1061 | - $TKT->set_time_format( $incoming_date_formats[ 1 ] ); |
|
1059 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false; |
|
1060 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1061 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1062 | 1062 | //set new values |
1063 | - foreach ( $TKT_values as $field => $value ) { |
|
1064 | - if ( $field == 'TKT_qty' ) { |
|
1065 | - $TKT->set_qty( $value ); |
|
1063 | + foreach ($TKT_values as $field => $value) { |
|
1064 | + if ($field == 'TKT_qty') { |
|
1065 | + $TKT->set_qty($value); |
|
1066 | 1066 | } else { |
1067 | - $TKT->set( $field, $value ); |
|
1067 | + $TKT->set($field, $value); |
|
1068 | 1068 | } |
1069 | 1069 | } |
1070 | 1070 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1071 | - if ( $create_new_TKT ) { |
|
1071 | + if ($create_new_TKT) { |
|
1072 | 1072 | //archive the old ticket first |
1073 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1073 | + $TKT->set('TKT_deleted', 1); |
|
1074 | 1074 | $TKT->save(); |
1075 | 1075 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1076 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1076 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1077 | 1077 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1078 | 1078 | $TKT = clone $TKT; |
1079 | - $TKT->set( 'TKT_ID', 0 ); |
|
1080 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1081 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1082 | - $TKT->set( 'TKT_sold', 0 ); |
|
1079 | + $TKT->set('TKT_ID', 0); |
|
1080 | + $TKT->set('TKT_deleted', 0); |
|
1081 | + $TKT->set('TKT_price', $ticket_price); |
|
1082 | + $TKT->set('TKT_sold', 0); |
|
1083 | 1083 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1084 | 1084 | $update_prices = true; |
1085 | 1085 | } |
1086 | 1086 | //make sure price is set if it hasn't been already |
1087 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1087 | + $TKT->set('TKT_price', $ticket_price); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | } else { |
1091 | 1091 | //no TKT_id so a new TKT |
1092 | 1092 | $TKT_values['TKT_price'] = $ticket_price; |
1093 | - $TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE ); |
|
1094 | - if ( $TKT instanceof EE_Ticket ) { |
|
1093 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE); |
|
1094 | + if ($TKT instanceof EE_Ticket) { |
|
1095 | 1095 | //need to reset values to properly account for the date formats |
1096 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1097 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1098 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1096 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1097 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1098 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1099 | 1099 | |
1100 | 1100 | //set new values |
1101 | - foreach ( $TKT_values as $field => $value ) { |
|
1102 | - if ( $field == 'TKT_qty' ) { |
|
1103 | - $TKT->set_qty( $value ); |
|
1101 | + foreach ($TKT_values as $field => $value) { |
|
1102 | + if ($field == 'TKT_qty') { |
|
1103 | + $TKT->set_qty($value); |
|
1104 | 1104 | } else { |
1105 | - $TKT->set( $field, $value ); |
|
1105 | + $TKT->set($field, $value); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
@@ -1110,32 +1110,32 @@ discard block |
||
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | // cap ticket qty by datetime reg limits |
1113 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1113 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1114 | 1114 | //update ticket. |
1115 | 1115 | $TKT->save(); |
1116 | 1116 | |
1117 | 1117 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
1118 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
1119 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
1118 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1119 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1120 | 1120 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1121 | 1121 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
1122 | 1122 | $TKT->save(); |
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | //initially let's add the ticket to the dtt |
1126 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1126 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1127 | 1127 | |
1128 | 1128 | $saved_tickets[$TKT->ID()] = $TKT; |
1129 | 1129 | |
1130 | 1130 | //add prices to ticket |
1131 | - $this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices ); |
|
1131 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1132 | 1132 | } |
1133 | 1133 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1134 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1134 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1135 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1136 | 1136 | |
1137 | - foreach ( $tickets_removed as $id ) { |
|
1138 | - $id = absint( $id ); |
|
1137 | + foreach ($tickets_removed as $id) { |
|
1138 | + $id = absint($id); |
|
1139 | 1139 | |
1140 | 1140 | //get the ticket for this id |
1141 | 1141 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1144 | 1144 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
1145 | 1145 | |
1146 | - foreach( $dtts as $dtt ) { |
|
1146 | + foreach ($dtts as $dtt) { |
|
1147 | 1147 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1154,7 +1154,7 @@ discard block |
||
1154 | 1154 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1155 | 1155 | $tkt_to_remove->delete_permanently(); |
1156 | 1156 | } |
1157 | - return array( $saved_dtt, $saved_tickets ); |
|
1157 | + return array($saved_dtt, $saved_tickets); |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | |
@@ -1169,31 +1169,31 @@ discard block |
||
1169 | 1169 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1170 | 1170 | * @return void |
1171 | 1171 | */ |
1172 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) { |
|
1173 | - foreach ( $prices as $row => $prc ) { |
|
1172 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) { |
|
1173 | + foreach ($prices as $row => $prc) { |
|
1174 | 1174 | $PRC_values = array( |
1175 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
1176 | - 'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL, |
|
1177 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1178 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1179 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1175 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
1176 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL, |
|
1177 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1178 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1179 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1180 | 1180 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1181 | 1181 | 'PRC_order' => $row |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1184 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1185 | 1185 | $PRC_values['PRC_ID'] = 0; |
1186 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
1186 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
1187 | 1187 | } else { |
1188 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1188 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1189 | 1189 | //update this price with new values |
1190 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1191 | - $PRC->set( $field, $newprc ); |
|
1190 | + foreach ($PRC_values as $field => $newprc) { |
|
1191 | + $PRC->set($field, $newprc); |
|
1192 | 1192 | } |
1193 | 1193 | $PRC->save(); |
1194 | 1194 | } |
1195 | 1195 | |
1196 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1196 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1216,33 +1216,33 @@ discard block |
||
1216 | 1216 | |
1217 | 1217 | return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
1218 | 1218 | |
1219 | - $postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL; |
|
1219 | + $postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL; |
|
1220 | 1220 | |
1221 | 1221 | |
1222 | 1222 | //if no postid then get out cause we need it for stuff in here |
1223 | - if ( empty( $postid ) ) return; |
|
1223 | + if (empty($postid)) return; |
|
1224 | 1224 | |
1225 | 1225 | |
1226 | 1226 | //handle datetime saves |
1227 | 1227 | $items = array(); |
1228 | 1228 | |
1229 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $postid ); |
|
1230 | - $event = $this->_event_model()->get_one( array($get_one_where) ); |
|
1229 | + $get_one_where = array($this->_event_model()->primary_key_name() => $postid); |
|
1230 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
1231 | 1231 | |
1232 | 1232 | //now let's get the attached datetimes from the most recent autosave |
1233 | 1233 | $dtts = $event->get_many_related('Datetime'); |
1234 | 1234 | |
1235 | 1235 | $dtt_ids = array(); |
1236 | - foreach( $dtts as $dtt ) { |
|
1236 | + foreach ($dtts as $dtt) { |
|
1237 | 1237 | $dtt_ids[] = $dtt->ID(); |
1238 | 1238 | $order = $dtt->order(); |
1239 | 1239 | $this->_template_args['data']['items']['ID-'.$order] = $dtt->ID(); |
1240 | 1240 | } |
1241 | - $this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids ); |
|
1241 | + $this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids); |
|
1242 | 1242 | |
1243 | 1243 | //handle DECAF venues |
1244 | 1244 | //we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event. |
1245 | - if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) { |
|
1245 | + if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) { |
|
1246 | 1246 | $venue = $event->get_first_related('Venue'); |
1247 | 1247 | $this->_template_args['data']['items']['venue-id'] = $venue->ID(); |
1248 | 1248 | } |
@@ -1253,23 +1253,23 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $ticket_ids = array(); |
1255 | 1255 | $price_ids = array(); |
1256 | - foreach ( $tickets as $ticket ) { |
|
1256 | + foreach ($tickets as $ticket) { |
|
1257 | 1257 | $ticket_ids[] = $price->ID(); |
1258 | 1258 | $ticket_order = $price->get('TKT_order'); |
1259 | - $this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID(); |
|
1260 | - $this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID(); |
|
1259 | + $this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID(); |
|
1260 | + $this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID(); |
|
1261 | 1261 | |
1262 | 1262 | //now we have to make sure the prices are updated appropriately |
1263 | 1263 | $prices = $ticket->get_many_related('Prices'); |
1264 | 1264 | |
1265 | - foreach ( $prices as $price ) { |
|
1265 | + foreach ($prices as $price) { |
|
1266 | 1266 | $price_ids[] = $price->ID(); |
1267 | 1267 | $price_order = $price->get('PRC_order'); |
1268 | - $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID(); |
|
1269 | - $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID(); |
|
1270 | - $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default'); |
|
1268 | + $this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID(); |
|
1269 | + $this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID(); |
|
1270 | + $this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default'); |
|
1271 | 1271 | } |
1272 | - $this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids); |
|
1272 | + $this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids); |
|
1273 | 1273 | } |
1274 | 1274 | $this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids); |
1275 | 1275 | } |
@@ -1287,12 +1287,12 @@ discard block |
||
1287 | 1287 | private function _generate_publish_box_extra_content() { |
1288 | 1288 | |
1289 | 1289 | //load formatter helper |
1290 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
1290 | + EE_Registry::instance()->load_helper('Formatter'); |
|
1291 | 1291 | |
1292 | 1292 | //args for getting related registrations |
1293 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1294 | - $not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) ); |
|
1295 | - $pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) ); |
|
1293 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1294 | + $not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved)); |
|
1295 | + $pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment)); |
|
1296 | 1296 | |
1297 | 1297 | |
1298 | 1298 | // publish box |
@@ -1321,9 +1321,9 @@ discard block |
||
1321 | 1321 | ), |
1322 | 1322 | REG_ADMIN_URL |
1323 | 1323 | ), |
1324 | - 'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ), |
|
1325 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ), |
|
1326 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ), |
|
1324 | + 'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args), |
|
1325 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args), |
|
1326 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args), |
|
1327 | 1327 | 'misc_pub_section_class' => apply_filters( |
1328 | 1328 | 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
1329 | 1329 | 'misc-pub-section' |
@@ -1342,9 +1342,9 @@ discard block |
||
1342 | 1342 | 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
1343 | 1343 | $this->_cpt_model_obj |
1344 | 1344 | ); |
1345 | - $publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean(); |
|
1345 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1346 | 1346 | // load template |
1347 | - EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args ); |
|
1347 | + EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
@@ -1376,16 +1376,16 @@ discard block |
||
1376 | 1376 | $this->verify_cpt_object(); |
1377 | 1377 | add_meta_box( |
1378 | 1378 | 'espresso_event_editor_tickets', |
1379 | - __( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1380 | - array( $this, 'ticket_metabox' ), |
|
1379 | + __('Event Datetime & Ticket', 'event_espresso'), |
|
1380 | + array($this, 'ticket_metabox'), |
|
1381 | 1381 | $this->page_slug, |
1382 | 1382 | 'normal', |
1383 | 1383 | 'high' |
1384 | 1384 | ); |
1385 | 1385 | add_meta_box( |
1386 | 1386 | 'espresso_event_editor_event_options', |
1387 | - __( 'Event Registration Options', 'event_espresso' ), |
|
1388 | - array( $this, 'registration_options_meta_box' ), |
|
1387 | + __('Event Registration Options', 'event_espresso'), |
|
1388 | + array($this, 'registration_options_meta_box'), |
|
1389 | 1389 | $this->page_slug, |
1390 | 1390 | 'side', |
1391 | 1391 | 'default' |
@@ -1415,38 +1415,38 @@ discard block |
||
1415 | 1415 | 'disabled' => '' |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL; |
|
1418 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL; |
|
1419 | 1419 | |
1420 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1420 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1421 | 1421 | |
1422 | 1422 | /** |
1423 | 1423 | * 1. Start with retrieving Datetimes |
1424 | 1424 | * 2. Fore each datetime get related tickets |
1425 | 1425 | * 3. For each ticket get related prices |
1426 | 1426 | */ |
1427 | - $times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id ); |
|
1428 | - EE_Registry::instance()->load_helper('DTT_Helper' ); |
|
1427 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1428 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1429 | 1429 | /** @type EE_Datetime $first_datetime */ |
1430 | - $first_datetime = array_slice( $times, 0, 1 ); |
|
1430 | + $first_datetime = array_slice($times, 0, 1); |
|
1431 | 1431 | //do we get related tickets? |
1432 | - if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) { |
|
1433 | - foreach ( $times as $time ) { |
|
1434 | - if ( $time instanceof EE_Datetime ) { |
|
1432 | + if ($first_datetime[0]->get('DTT_ID') !== 0) { |
|
1433 | + foreach ($times as $time) { |
|
1434 | + if ($time instanceof EE_Datetime) { |
|
1435 | 1435 | $existing_datetime_ids[] = $time->get('DTT_ID'); |
1436 | 1436 | $template_args['time'] = $time; |
1437 | 1437 | $related_tickets = $time->tickets( |
1438 | 1438 | array( |
1439 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1439 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1440 | 1440 | 'default_where_conditions' => 'none' |
1441 | 1441 | ) |
1442 | 1442 | ); |
1443 | 1443 | |
1444 | - if ( !empty($related_tickets) ) { |
|
1444 | + if ( ! empty($related_tickets)) { |
|
1445 | 1445 | $template_args['total_ticket_rows'] = count($related_tickets); |
1446 | 1446 | $row = 0; |
1447 | - foreach ( $related_tickets as $ticket ) { |
|
1447 | + foreach ($related_tickets as $ticket) { |
|
1448 | 1448 | $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
1449 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row ); |
|
1449 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row); |
|
1450 | 1450 | |
1451 | 1451 | $row++; |
1452 | 1452 | } |
@@ -1454,7 +1454,7 @@ discard block |
||
1454 | 1454 | $template_args['total_ticket_rows'] = 1; |
1455 | 1455 | /** @type EE_Ticket $ticket */ |
1456 | 1456 | $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
1457 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1457 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | } |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | $template_args['time'] = $times[0]; |
1463 | 1463 | /** @type EE_Ticket $ticket */ |
1464 | 1464 | $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
1465 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1465 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1466 | 1466 | // NOTE: we're just sending the first default row |
1467 | 1467 | // (decaf can't manage default tickets so this should be sufficient); |
1468 | 1468 | } |
@@ -1471,8 +1471,8 @@ discard block |
||
1471 | 1471 | $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
1472 | 1472 | $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
1473 | 1473 | $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
1474 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE ); |
|
1475 | - $template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' ); |
|
1474 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE); |
|
1475 | + $template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'); |
|
1476 | 1476 | EEH_Template::display_template($template, $template_args); |
1477 | 1477 | } |
1478 | 1478 | |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | * @param int $row |
1488 | 1488 | * @return string generated html for the ticket row. |
1489 | 1489 | */ |
1490 | - private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) { |
|
1490 | + private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) { |
|
1491 | 1491 | $template_args = array( |
1492 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1493 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '', |
|
1492 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1493 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '', |
|
1494 | 1494 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1495 | 1495 | 'TKT_ID' => $ticket->get('TKT_ID'), |
1496 | 1496 | 'TKT_name' => $ticket->get('TKT_name'), |
1497 | 1497 | 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
1498 | 1498 | 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
1499 | 1499 | 'TKT_is_default' => $ticket->get('TKT_is_default'), |
1500 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty','input'), |
|
1500 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1501 | 1501 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1502 | 1502 | 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
1503 | - 'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | - 'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled' |
|
1503 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1504 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled' |
|
1505 | 1505 | ); |
1506 | 1506 | |
1507 | 1507 | $price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object(); |
@@ -1517,23 +1517,23 @@ discard block |
||
1517 | 1517 | |
1518 | 1518 | //make sure we have default start and end dates if skeleton |
1519 | 1519 | //handle rows that should NOT be empty |
1520 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1520 | + if (empty($template_args['TKT_start_date'])) { |
|
1521 | 1521 | //if empty then the start date will be now. |
1522 | 1522 | $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1525 | + if (empty($template_args['TKT_end_date'])) { |
|
1526 | 1526 | //get the earliest datetime (if present); |
1527 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1527 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1528 | 1528 | |
1529 | - if ( !empty( $earliest_dtt ) ) |
|
1529 | + if ( ! empty($earliest_dtt)) |
|
1530 | 1530 | $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
1531 | 1531 | else |
1532 | - $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) ); |
|
1532 | + $template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y"))); |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | - $template_args = array_merge( $template_args, $price_args ); |
|
1536 | - $template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1535 | + $template_args = array_merge($template_args, $price_args); |
|
1536 | + $template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket); |
|
1537 | 1537 | return EEH_Template::display_template($template, $template_args, TRUE); |
1538 | 1538 | } |
1539 | 1539 | |
@@ -1562,8 +1562,8 @@ discard block |
||
1562 | 1562 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status()); |
1563 | 1563 | $template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description()); |
1564 | 1564 | $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false); |
1565 | - $template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values ); |
|
1566 | - $templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php'; |
|
1565 | + $template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values); |
|
1566 | + $templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php'; |
|
1567 | 1567 | EEH_Template::display_template($templatepath, $template_args); |
1568 | 1568 | } |
1569 | 1569 | |
@@ -1591,21 +1591,21 @@ discard block |
||
1591 | 1591 | $EEME = $this->_event_model(); |
1592 | 1592 | |
1593 | 1593 | $offset = ($current_page - 1) * $per_page; |
1594 | - $limit = $count ? NULL : $offset . ',' . $per_page; |
|
1594 | + $limit = $count ? NULL : $offset.','.$per_page; |
|
1595 | 1595 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1596 | 1596 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1597 | 1597 | |
1598 | 1598 | if (isset($this->_req_data['month_range'])) { |
1599 | 1599 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1600 | - $month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1600 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1601 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1602 | 1602 | } |
1603 | 1603 | |
1604 | 1604 | $where = array(); |
1605 | 1605 | |
1606 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL; |
|
1606 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL; |
|
1607 | 1607 | //determine what post_status our condition will have for the query. |
1608 | - switch ( $status ) { |
|
1608 | + switch ($status) { |
|
1609 | 1609 | case 'month' : |
1610 | 1610 | case 'today' : |
1611 | 1611 | case NULL : |
@@ -1613,7 +1613,7 @@ discard block |
||
1613 | 1613 | break; |
1614 | 1614 | |
1615 | 1615 | case 'draft' : |
1616 | - $where['status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1616 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1617 | 1617 | break; |
1618 | 1618 | |
1619 | 1619 | default : |
@@ -1621,43 +1621,43 @@ discard block |
||
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | //categories? |
1624 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1624 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL; |
|
1625 | 1625 | |
1626 | - if ( !empty ( $category ) ) { |
|
1626 | + if ( ! empty ($category)) { |
|
1627 | 1627 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1628 | 1628 | $where['Term_Taxonomy.term_id'] = $category; |
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | //date where conditions |
1632 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1632 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1633 | 1633 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1634 | - $DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) ); |
|
1635 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1636 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) ); |
|
1637 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) ); |
|
1634 | + $DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone())); |
|
1635 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1636 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1637 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1638 | 1638 | } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
1639 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1640 | - $start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) ); |
|
1641 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1642 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1643 | - } else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) { |
|
1644 | - $now = date( 'Y-m-01' ); |
|
1645 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1646 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1647 | - $end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1648 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1639 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1640 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1641 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1642 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1643 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1644 | + $now = date('Y-m-01'); |
|
1645 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1646 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1647 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1648 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | |
1652 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1653 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1652 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1653 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1654 | 1654 | } else { |
1655 | - if ( ! isset( $where['status'] ) ) { |
|
1656 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1655 | + if ( ! isset($where['status'])) { |
|
1656 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1657 | 1657 | $where['OR'] = array( |
1658 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1658 | + 'status*restrict_private' => array('!=', 'private'), |
|
1659 | 1659 | 'AND' => array( |
1660 | - 'status*inclusive' => array( '=', 'private' ), |
|
1660 | + 'status*inclusive' => array('=', 'private'), |
|
1661 | 1661 | 'EVT_wp_user' => get_current_user_id() |
1662 | 1662 | ) |
1663 | 1663 | ); |
@@ -1665,16 +1665,16 @@ discard block |
||
1665 | 1665 | } |
1666 | 1666 | } |
1667 | 1667 | |
1668 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1669 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1668 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1669 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1670 | 1670 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1671 | 1671 | } |
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | |
1675 | 1675 | //search query handling |
1676 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1677 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1676 | + if (isset($this->_req_data['s'])) { |
|
1677 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1678 | 1678 | $where['OR'] = array( |
1679 | 1679 | 'EVT_name' => array('LIKE', $search_string), |
1680 | 1680 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1683,32 +1683,32 @@ discard block |
||
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | |
1686 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1687 | - $query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data ); |
|
1686 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1687 | + $query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data); |
|
1688 | 1688 | |
1689 | 1689 | |
1690 | 1690 | //let's first check if we have special requests coming in. |
1691 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1692 | - switch ( $this->_req_data['active_status'] ) { |
|
1691 | + if (isset($this->_req_data['active_status'])) { |
|
1692 | + switch ($this->_req_data['active_status']) { |
|
1693 | 1693 | case 'upcoming' : |
1694 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1694 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1695 | 1695 | break; |
1696 | 1696 | |
1697 | 1697 | case 'expired' : |
1698 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1698 | + return $EEME->get_expired_events($query_params, $count); |
|
1699 | 1699 | break; |
1700 | 1700 | |
1701 | 1701 | case 'active' : |
1702 | - return $EEME->get_active_events( $query_params, $count ); |
|
1702 | + return $EEME->get_active_events($query_params, $count); |
|
1703 | 1703 | break; |
1704 | 1704 | |
1705 | 1705 | case 'inactive' : |
1706 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1706 | + return $EEME->get_inactive_events($query_params, $count); |
|
1707 | 1707 | break; |
1708 | 1708 | } |
1709 | 1709 | } |
1710 | 1710 | |
1711 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1711 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1712 | 1712 | |
1713 | 1713 | return $events; |
1714 | 1714 | } |
@@ -1717,23 +1717,23 @@ discard block |
||
1717 | 1717 | |
1718 | 1718 | |
1719 | 1719 | //handling for WordPress CPT actions (trash, restore, delete) |
1720 | - public function trash_cpt_item( $post_id ) { |
|
1720 | + public function trash_cpt_item($post_id) { |
|
1721 | 1721 | $this->_req_data['EVT_ID'] = $post_id; |
1722 | - $this->_trash_or_restore_event( 'trash', FALSE ); |
|
1722 | + $this->_trash_or_restore_event('trash', FALSE); |
|
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | |
1726 | 1726 | |
1727 | 1727 | |
1728 | - public function restore_cpt_item( $post_id ) { |
|
1728 | + public function restore_cpt_item($post_id) { |
|
1729 | 1729 | $this->_req_data['EVT_ID'] = $post_id; |
1730 | - $this->_trash_or_restore_event( 'draft', FALSE ); |
|
1730 | + $this->_trash_or_restore_event('draft', FALSE); |
|
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | |
1734 | - public function delete_cpt_item( $post_id ) { |
|
1734 | + public function delete_cpt_item($post_id) { |
|
1735 | 1735 | $this->_req_data['EVT_ID'] = $post_id; |
1736 | - $this->_delete_event( FALSE ); |
|
1736 | + $this->_delete_event(FALSE); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | * @param string $event_status |
1746 | 1746 | * @return void |
1747 | 1747 | */ |
1748 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) { |
|
1748 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) { |
|
1749 | 1749 | //determine the event id and set to array. |
1750 | 1750 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE; |
1751 | 1751 | // loop thru events |
@@ -1753,7 +1753,7 @@ discard block |
||
1753 | 1753 | // clean status |
1754 | 1754 | $event_status = sanitize_key($event_status); |
1755 | 1755 | // grab status |
1756 | - if (!empty($event_status)) { |
|
1756 | + if ( ! empty($event_status)) { |
|
1757 | 1757 | $success = $this->_change_event_status($EVT_ID, $event_status); |
1758 | 1758 | } else { |
1759 | 1759 | $success = FALSE; |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | } |
1768 | 1768 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1769 | 1769 | |
1770 | - if ( $redirect_after ) |
|
1770 | + if ($redirect_after) |
|
1771 | 1771 | $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
1772 | 1772 | } |
1773 | 1773 | |
@@ -1782,7 +1782,7 @@ discard block |
||
1782 | 1782 | // clean status |
1783 | 1783 | $event_status = sanitize_key($event_status); |
1784 | 1784 | // grab status |
1785 | - if (!empty($event_status)) { |
|
1785 | + if ( ! empty($event_status)) { |
|
1786 | 1786 | $success = TRUE; |
1787 | 1787 | //determine the event id and set to array. |
1788 | 1788 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
@@ -1817,15 +1817,15 @@ discard block |
||
1817 | 1817 | * @param string $event_status |
1818 | 1818 | * @return bool |
1819 | 1819 | */ |
1820 | - private function _change_event_status( $EVT_ID = 0, $event_status = '') { |
|
1820 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1821 | 1821 | // grab event id |
1822 | - if (!$EVT_ID) { |
|
1822 | + if ( ! $EVT_ID) { |
|
1823 | 1823 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1824 | 1824 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1825 | 1825 | return FALSE; |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1828 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1829 | 1829 | |
1830 | 1830 | // clean status |
1831 | 1831 | $event_status = sanitize_key($event_status); |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | $hook = FALSE; |
1852 | 1852 | } |
1853 | 1853 | //use class to change status |
1854 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1854 | + $this->_cpt_model_obj->set_status($event_status); |
|
1855 | 1855 | $success = $this->_cpt_model_obj->save(); |
1856 | 1856 | |
1857 | 1857 | if ($success === FALSE) { |
@@ -1873,15 +1873,15 @@ discard block |
||
1873 | 1873 | * @access protected |
1874 | 1874 | * @param bool $redirect_after |
1875 | 1875 | */ |
1876 | - protected function _delete_event( $redirect_after = TRUE ) { |
|
1876 | + protected function _delete_event($redirect_after = TRUE) { |
|
1877 | 1877 | //determine the event id and set to array. |
1878 | 1878 | $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL; |
1879 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1879 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1880 | 1880 | |
1881 | 1881 | |
1882 | 1882 | // loop thru events |
1883 | 1883 | if ($EVT_ID) { |
1884 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1884 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1885 | 1885 | // get list of events with no prices |
1886 | 1886 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
1887 | 1887 | // remove this event from the list of events with no prices |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1896 | 1896 | } |
1897 | 1897 | |
1898 | - if ( $redirect_after ) |
|
1898 | + if ($redirect_after) |
|
1899 | 1899 | $this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash')); |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1913,12 +1913,12 @@ discard block |
||
1913 | 1913 | $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
1914 | 1914 | // loop thru events |
1915 | 1915 | foreach ($EVT_IDs as $EVT_ID) { |
1916 | - $EVT_ID = absint( $EVT_ID ); |
|
1917 | - if ( $EVT_ID ) { |
|
1918 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
1916 | + $EVT_ID = absint($EVT_ID); |
|
1917 | + if ($EVT_ID) { |
|
1918 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
1919 | 1919 | $success = $results !== FALSE ? $success : FALSE; |
1920 | 1920 | // remove this event from the list of events with no prices |
1921 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1921 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1922 | 1922 | } else { |
1923 | 1923 | $success = FALSE; |
1924 | 1924 | $msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso'); |
@@ -1938,21 +1938,21 @@ discard block |
||
1938 | 1938 | * @param int $EVT_ID |
1939 | 1939 | * @return bool |
1940 | 1940 | */ |
1941 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
1941 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
1942 | 1942 | // grab event id |
1943 | - if ( ! $EVT_ID ) { |
|
1943 | + if ( ! $EVT_ID) { |
|
1944 | 1944 | $msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso'); |
1945 | 1945 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1946 | 1946 | return FALSE; |
1947 | 1947 | } |
1948 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1948 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1949 | 1949 | |
1950 | 1950 | //need to delete related tickets and prices first. |
1951 | 1951 | $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
1952 | - foreach ( $datetimes as $datetime ) { |
|
1952 | + foreach ($datetimes as $datetime) { |
|
1953 | 1953 | $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
1954 | 1954 | $tickets = $datetime->get_many_related('Ticket'); |
1955 | - foreach ( $tickets as $ticket ) { |
|
1955 | + foreach ($tickets as $ticket) { |
|
1956 | 1956 | $ticket->_remove_relation_to($datetime, 'Datetime'); |
1957 | 1957 | $ticket->delete_related_permanently('Price'); |
1958 | 1958 | $ticket->delete_permanently(); |
@@ -1962,14 +1962,14 @@ discard block |
||
1962 | 1962 | |
1963 | 1963 | //what about related venues or terms? |
1964 | 1964 | $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
1965 | - foreach ( $venues as $venue ) { |
|
1965 | + foreach ($venues as $venue) { |
|
1966 | 1966 | $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
1967 | 1967 | } |
1968 | 1968 | |
1969 | 1969 | //any attached question groups? |
1970 | 1970 | $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
1971 | - if ( !empty( $question_groups ) ) { |
|
1972 | - foreach ( $question_groups as $question_group ) { |
|
1971 | + if ( ! empty($question_groups)) { |
|
1972 | + foreach ($question_groups as $question_group) { |
|
1973 | 1973 | $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
1974 | 1974 | } |
1975 | 1975 | } |
@@ -1978,12 +1978,12 @@ discard block |
||
1978 | 1978 | |
1979 | 1979 | |
1980 | 1980 | //Message Template Groups |
1981 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
1981 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
1982 | 1982 | |
1983 | 1983 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
1984 | 1984 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
1985 | 1985 | |
1986 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
1986 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
1987 | 1987 | $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
1988 | 1988 | } |
1989 | 1989 | |
@@ -1997,7 +1997,7 @@ discard block |
||
1997 | 1997 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
1998 | 1998 | return FALSE; |
1999 | 1999 | } |
2000 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted' ); |
|
2000 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted'); |
|
2001 | 2001 | return TRUE; |
2002 | 2002 | } |
2003 | 2003 | |
@@ -2014,7 +2014,7 @@ discard block |
||
2014 | 2014 | */ |
2015 | 2015 | public function total_events() { |
2016 | 2016 | |
2017 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2017 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2018 | 2018 | return $count; |
2019 | 2019 | } |
2020 | 2020 | |
@@ -2029,10 +2029,10 @@ discard block |
||
2029 | 2029 | */ |
2030 | 2030 | public function total_events_draft() { |
2031 | 2031 | $where = array( |
2032 | - 'status' => array( 'IN', array('draft', 'auto-draft' ) ) |
|
2032 | + 'status' => array('IN', array('draft', 'auto-draft')) |
|
2033 | 2033 | ); |
2034 | 2034 | |
2035 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2035 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2036 | 2036 | return $count; |
2037 | 2037 | } |
2038 | 2038 | |
@@ -2051,7 +2051,7 @@ discard block |
||
2051 | 2051 | 'status' => 'trash' |
2052 | 2052 | ); |
2053 | 2053 | |
2054 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2054 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2055 | 2055 | return $count; |
2056 | 2056 | } |
2057 | 2057 | |
@@ -2079,11 +2079,11 @@ discard block |
||
2079 | 2079 | // translated |
2080 | 2080 | TRUE |
2081 | 2081 | ); |
2082 | - $this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment; |
|
2082 | + $this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment; |
|
2083 | 2083 | |
2084 | 2084 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2085 | 2085 | $this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE); |
2086 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE); |
|
2086 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE); |
|
2087 | 2087 | $this->display_admin_page_with_sidebar(); |
2088 | 2088 | } |
2089 | 2089 | |
@@ -2109,9 +2109,9 @@ discard block |
||
2109 | 2109 | |
2110 | 2110 | protected function _template_settings() { |
2111 | 2111 | $this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso'); |
2112 | - $this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />'; |
|
2113 | - $this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>'; |
|
2114 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2112 | + $this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />'; |
|
2113 | + $this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>'; |
|
2114 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | |
@@ -2124,22 +2124,22 @@ discard block |
||
2124 | 2124 | * @return void |
2125 | 2125 | */ |
2126 | 2126 | private function _set_category_object() { |
2127 | - if ( isset( $this->_category->id ) && !empty( $this->_category->id ) ) |
|
2127 | + if (isset($this->_category->id) && ! empty($this->_category->id)) |
|
2128 | 2128 | return; //already have the category object so get out. |
2129 | 2129 | |
2130 | 2130 | //set default category object |
2131 | 2131 | $this->_set_empty_category_object(); |
2132 | 2132 | |
2133 | 2133 | //only set if we've got an id |
2134 | - if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) { |
|
2134 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2135 | 2135 | return; |
2136 | 2136 | } |
2137 | 2137 | |
2138 | 2138 | $category_id = absint($this->_req_data['EVT_CAT_ID']); |
2139 | 2139 | |
2140 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2140 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2141 | 2141 | |
2142 | - if ( !empty( $term ) ) { |
|
2142 | + if ( ! empty($term)) { |
|
2143 | 2143 | $this->_category->category_name = $term->name; |
2144 | 2144 | $this->_category->category_identifier = $term->slug; |
2145 | 2145 | $this->_category->category_desc = $term->description; |
@@ -2153,13 +2153,13 @@ discard block |
||
2153 | 2153 | |
2154 | 2154 | private function _set_empty_category_object() { |
2155 | 2155 | $this->_category = new stdClass(); |
2156 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2156 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2157 | 2157 | $this->_category->id = $this->_category->parent = 0; |
2158 | 2158 | } |
2159 | 2159 | |
2160 | 2160 | |
2161 | 2161 | protected function _category_list_table() { |
2162 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2162 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2163 | 2163 | $this->_search_btn_label = __('Categories', 'event_espresso'); |
2164 | 2164 | $this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2'); |
2165 | 2165 | $this->display_admin_list_table_page_with_sidebar(); |
@@ -2169,22 +2169,22 @@ discard block |
||
2169 | 2169 | protected function _category_details($view) { |
2170 | 2170 | |
2171 | 2171 | //load formatter helper |
2172 | - EE_Registry::instance()->load_helper( 'Formatter' ); |
|
2172 | + EE_Registry::instance()->load_helper('Formatter'); |
|
2173 | 2173 | //load field generator helper |
2174 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
2174 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
2175 | 2175 | |
2176 | 2176 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2177 | 2177 | $this->_set_add_edit_form_tags($route); |
2178 | 2178 | |
2179 | 2179 | $this->_set_category_object(); |
2180 | - $id = !empty($this->_category->id) ? $this->_category->id : ''; |
|
2180 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2181 | 2181 | |
2182 | 2182 | $delete_action = 'delete_category'; |
2183 | 2183 | |
2184 | 2184 | //custom redirect |
2185 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url ); |
|
2185 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url); |
|
2186 | 2186 | |
2187 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2187 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2188 | 2188 | |
2189 | 2189 | //take care of contents |
2190 | 2190 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
@@ -2198,25 +2198,25 @@ discard block |
||
2198 | 2198 | 'type' => 'wp_editor', |
2199 | 2199 | 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
2200 | 2200 | 'class' => 'my_editor_custom', |
2201 | - 'wpeditor_args' => array('media_buttons' => FALSE ) |
|
2201 | + 'wpeditor_args' => array('media_buttons' => FALSE) |
|
2202 | 2202 | ); |
2203 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2203 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2204 | 2204 | |
2205 | - $all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) ); |
|
2205 | + $all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id))); |
|
2206 | 2206 | |
2207 | 2207 | //setup category select for term parents. |
2208 | 2208 | $category_select_values[] = array( |
2209 | 2209 | 'text' => __('No Parent', 'event_espresso'), |
2210 | 2210 | 'id' => 0 |
2211 | 2211 | ); |
2212 | - foreach ( $all_terms as $term ) { |
|
2212 | + foreach ($all_terms as $term) { |
|
2213 | 2213 | $category_select_values[] = array( |
2214 | 2214 | 'text' => $term->name, |
2215 | 2215 | 'id' => $term->term_id |
2216 | 2216 | ); |
2217 | 2217 | } |
2218 | 2218 | |
2219 | - $category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent ); |
|
2219 | + $category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent); |
|
2220 | 2220 | |
2221 | 2221 | $template_args = array( |
2222 | 2222 | 'category' => $this->_category, |
@@ -2226,15 +2226,15 @@ discard block |
||
2226 | 2226 | 'disable' => '', |
2227 | 2227 | 'disabled_message' => FALSE |
2228 | 2228 | ); |
2229 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2230 | - return EEH_Template::display_template($template, $template_args, TRUE ); |
|
2229 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2230 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
2231 | 2231 | } |
2232 | 2232 | |
2233 | 2233 | |
2234 | 2234 | protected function _delete_categories() { |
2235 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2235 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id']; |
|
2236 | 2236 | |
2237 | - foreach ( $cat_ids as $cat_id ) { |
|
2237 | + foreach ($cat_ids as $cat_id) { |
|
2238 | 2238 | $this->_delete_category($cat_id); |
2239 | 2239 | } |
2240 | 2240 | |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | $query_args = array( |
2243 | 2243 | 'action' => 'category_list' |
2244 | 2244 | ); |
2245 | - $this->_redirect_after_action(0,'','',$query_args); |
|
2245 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2246 | 2246 | |
2247 | 2247 | } |
2248 | 2248 | |
@@ -2252,61 +2252,61 @@ discard block |
||
2252 | 2252 | |
2253 | 2253 | protected function _delete_category($cat_id) { |
2254 | 2254 | global $wpdb; |
2255 | - $cat_id = absint( $cat_id ); |
|
2256 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2255 | + $cat_id = absint($cat_id); |
|
2256 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | |
2260 | 2260 | |
2261 | 2261 | protected function _insert_or_update_category($new_category) { |
2262 | 2262 | |
2263 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE ); |
|
2263 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE); |
|
2264 | 2264 | $success = 0; //we already have a success message so lets not send another. |
2265 | 2265 | |
2266 | - if ( $cat_id ) { |
|
2266 | + if ($cat_id) { |
|
2267 | 2267 | $query_args = array( |
2268 | 2268 | 'action' => 'edit_category', |
2269 | 2269 | 'EVT_CAT_ID' => $cat_id |
2270 | 2270 | ); |
2271 | 2271 | } else { |
2272 | - $query_args = array( 'action' => 'add_category' ); |
|
2272 | + $query_args = array('action' => 'add_category'); |
|
2273 | 2273 | } |
2274 | - $this->_redirect_after_action( $success, '','', $query_args, TRUE ); |
|
2274 | + $this->_redirect_after_action($success, '', '', $query_args, TRUE); |
|
2275 | 2275 | |
2276 | 2276 | } |
2277 | 2277 | |
2278 | 2278 | |
2279 | 2279 | |
2280 | - private function _insert_category( $update = FALSE ) { |
|
2280 | + private function _insert_category($update = FALSE) { |
|
2281 | 2281 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2282 | - $category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2283 | - $category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2284 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2282 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2283 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2284 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2285 | 2285 | |
2286 | - if ( empty( $category_name ) ) { |
|
2287 | - $msg = __( 'You must add a name for the category.', 'event_espresso' ); |
|
2288 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2286 | + if (empty($category_name)) { |
|
2287 | + $msg = __('You must add a name for the category.', 'event_espresso'); |
|
2288 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2289 | 2289 | return false; |
2290 | 2290 | } |
2291 | 2291 | |
2292 | - $term_args=array( |
|
2292 | + $term_args = array( |
|
2293 | 2293 | 'name'=>$category_name, |
2294 | 2294 | 'description'=>$category_desc, |
2295 | 2295 | 'parent'=>$category_parent |
2296 | 2296 | ); |
2297 | 2297 | //was the category_identifier input disabled? |
2298 | - if(isset($this->_req_data['category_identifier'])){ |
|
2298 | + if (isset($this->_req_data['category_identifier'])) { |
|
2299 | 2299 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2300 | 2300 | } |
2301 | - $insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2301 | + $insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2302 | 2302 | |
2303 | - if ( !is_array( $insert_ids ) ) { |
|
2304 | - $msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' ); |
|
2305 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2303 | + if ( ! is_array($insert_ids)) { |
|
2304 | + $msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso'); |
|
2305 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2306 | 2306 | } else { |
2307 | 2307 | $cat_id = $insert_ids['term_id']; |
2308 | - $msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name ); |
|
2309 | - EE_Error::add_success( $msg ); |
|
2308 | + $msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name); |
|
2309 | + EE_Error::add_success($msg); |
|
2310 | 2310 | } |
2311 | 2311 | |
2312 | 2312 | return $cat_id; |
@@ -2315,32 +2315,32 @@ discard block |
||
2315 | 2315 | |
2316 | 2316 | |
2317 | 2317 | |
2318 | - public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) { |
|
2318 | + public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) { |
|
2319 | 2319 | global $wpdb; |
2320 | 2320 | |
2321 | 2321 | //testing term stuff |
2322 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | - $limit = ($current_page-1)*$per_page; |
|
2322 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2323 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2324 | + $limit = ($current_page - 1) * $per_page; |
|
2325 | 2325 | |
2326 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2326 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2327 | 2327 | |
2328 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2329 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2328 | + if (isset($this->_req_data['s'])) { |
|
2329 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2330 | 2330 | $where['OR'] = array( |
2331 | - 'Term.name' => array( 'LIKE', $sstr), |
|
2332 | - 'description' => array( 'LIKE', $sstr ) |
|
2331 | + 'Term.name' => array('LIKE', $sstr), |
|
2332 | + 'description' => array('LIKE', $sstr) |
|
2333 | 2333 | ); |
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | $query_params = array( |
2337 | - $where , |
|
2338 | - 'order_by' => array( $orderby => $order ), |
|
2339 | - 'limit' => $limit . ',' . $per_page, |
|
2337 | + $where, |
|
2338 | + 'order_by' => array($orderby => $order), |
|
2339 | + 'limit' => $limit.','.$per_page, |
|
2340 | 2340 | 'force_join' => array('Term') |
2341 | 2341 | ); |
2342 | 2342 | |
2343 | - $categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2343 | + $categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2344 | 2344 | |
2345 | 2345 | return $categories; |
2346 | 2346 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | /** |
185 | 185 | * returns the text for displaying the question to users |
186 | 186 | * @access public |
187 | - * @return string |
|
187 | + * @return boolean |
|
188 | 188 | */ |
189 | 189 | public function display_text() { |
190 | 190 | return $this->get( 'QST_display_text' ); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | /** |
196 | 196 | * returns the text for the administrative label |
197 | 197 | * @access public |
198 | - * @return string |
|
198 | + * @return boolean |
|
199 | 199 | */ |
200 | 200 | public function admin_label() { |
201 | 201 | return $this->get( 'QST_admin_label' ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | /** |
207 | 207 | * returns the attendee column name for this question |
208 | 208 | * @access public |
209 | - * @return string |
|
209 | + * @return boolean |
|
210 | 210 | */ |
211 | 211 | public function system_ID() { |
212 | 212 | return $this->get( 'QST_system' ); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * returns the text which should be displayed when a user |
230 | 230 | * doesn't answer this question in a form |
231 | 231 | * @access public |
232 | - * @return string |
|
232 | + * @return boolean |
|
233 | 233 | */ |
234 | 234 | public function required_text() { |
235 | 235 | return $this->get( 'QST_required_text' ); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * returns the type of this question |
242 | 242 | * @access public |
243 | - * @return string |
|
243 | + * @return boolean |
|
244 | 244 | */ |
245 | 245 | public function type() { |
246 | 246 | return $this->get( 'QST_type' ); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * returns an integer showing where this question should |
253 | 253 | * be placed in a sequence of questions |
254 | 254 | * @access public |
255 | - * @return int |
|
255 | + * @return boolean |
|
256 | 256 | */ |
257 | 257 | public function order() { |
258 | 258 | return $this->get( 'QST_order' ); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | /** |
276 | 276 | * returns the id the wordpress user who created this question |
277 | 277 | * @access public |
278 | - * @return int |
|
278 | + * @return boolean |
|
279 | 279 | */ |
280 | 280 | public function wp_user() { |
281 | 281 | return $this->get( 'QST_wp_user' ); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * Adds an option for this question. Note: if the option were previously associated with a different |
370 | 370 | * Question, that relationship will be overwritten. |
371 | 371 | * @param EE_Question_Option $option |
372 | - * @return boolean success |
|
372 | + * @return EE_Base_Class success |
|
373 | 373 | */ |
374 | 374 | public function add_option( EE_Question_Option $option ) { |
375 | 375 | return $this->_add_relation_to( $option, 'Question_Option' ); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * Marks the option as deleted. |
394 | 394 | * @param EE_Question_Option $option |
395 | - * @return boolean success |
|
395 | + * @return EE_Base_Class success |
|
396 | 396 | */ |
397 | 397 | public function remove_option( EE_Question_Option $option ) { |
398 | 398 | return $this->_remove_relation_to( $option, 'Question_Option' ); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Returns the question's maximum allowed response size |
464 | - * @return int|float |
|
464 | + * @return boolean |
|
465 | 465 | */ |
466 | 466 | public function max() { |
467 | 467 | return $this->get( 'QST_max' ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * date_format and the second value is the time format |
38 | 38 | * @return EE_Question |
39 | 39 | */ |
40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * the website will be used. |
51 | 51 | * @return EE_Question |
52 | 52 | */ |
53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
54 | + return new self($props_n_values, TRUE, $timezone); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @access public |
63 | 63 | * @param string $QST_display_text |
64 | 64 | */ |
65 | - public function set_display_text( $QST_display_text = '' ) { |
|
66 | - $this->set( 'QST_display_text', $QST_display_text ); |
|
65 | + public function set_display_text($QST_display_text = '') { |
|
66 | + $this->set('QST_display_text', $QST_display_text); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @param string $QST_admin_label |
76 | 76 | */ |
77 | - public function set_admin_label( $QST_admin_label = '' ) { |
|
78 | - $this->set( 'QST_admin_label', $QST_admin_label ); |
|
77 | + public function set_admin_label($QST_admin_label = '') { |
|
78 | + $this->set('QST_admin_label', $QST_admin_label); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @param mixed $QST_system |
88 | 88 | */ |
89 | - public function set_system_ID( $QST_system = '' ) { |
|
90 | - $this->set( 'QST_system', $QST_system ); |
|
89 | + public function set_system_ID($QST_system = '') { |
|
90 | + $this->set('QST_system', $QST_system); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @param string $QST_type |
100 | 100 | */ |
101 | - public function set_question_type( $QST_type = '' ) { |
|
102 | - $this->set( 'QST_type', $QST_type ); |
|
101 | + public function set_question_type($QST_type = '') { |
|
102 | + $this->set('QST_type', $QST_type); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @access public |
111 | 111 | * @param bool $QST_required |
112 | 112 | */ |
113 | - public function set_required( $QST_required = FALSE ) { |
|
114 | - $this->set( 'QST_required', $QST_required ); |
|
113 | + public function set_required($QST_required = FALSE) { |
|
114 | + $this->set('QST_required', $QST_required); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @access public |
123 | 123 | * @param string $QST_required_text |
124 | 124 | */ |
125 | - public function set_required_text( $QST_required_text = '' ) { |
|
126 | - $this->set( 'QST_required_text', $QST_required_text ); |
|
125 | + public function set_required_text($QST_required_text = '') { |
|
126 | + $this->set('QST_required_text', $QST_required_text); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @access public |
135 | 135 | * @param int $QST_order |
136 | 136 | */ |
137 | - public function set_order( $QST_order = 0 ) { |
|
138 | - $this->set( 'QST_order', $QST_order ); |
|
137 | + public function set_order($QST_order = 0) { |
|
138 | + $this->set('QST_order', $QST_order); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | * @param bool $QST_admin_only |
148 | 148 | */ |
149 | - public function set_admin_only( $QST_admin_only = FALSE ) { |
|
150 | - $this->set( 'QST_admin_only', $QST_admin_only ); |
|
149 | + public function set_admin_only($QST_admin_only = FALSE) { |
|
150 | + $this->set('QST_admin_only', $QST_admin_only); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @access public |
159 | 159 | * @param int $QST_wp_user |
160 | 160 | */ |
161 | - public function set_wp_user( $QST_wp_user = 1 ) { |
|
162 | - $this->set( 'QST_wp_user', $QST_wp_user ); |
|
161 | + public function set_wp_user($QST_wp_user = 1) { |
|
162 | + $this->set('QST_wp_user', $QST_wp_user); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param bool $QST_deleted |
177 | 177 | */ |
178 | - public function set_deleted( $QST_deleted = FALSE ) { |
|
179 | - $this->set( 'QST_deleted', $QST_deleted ); |
|
178 | + public function set_deleted($QST_deleted = FALSE) { |
|
179 | + $this->set('QST_deleted', $QST_deleted); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * @return string |
188 | 188 | */ |
189 | 189 | public function display_text() { |
190 | - return $this->get( 'QST_display_text' ); |
|
190 | + return $this->get('QST_display_text'); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string |
199 | 199 | */ |
200 | 200 | public function admin_label() { |
201 | - return $this->get( 'QST_admin_label' ); |
|
201 | + return $this->get('QST_admin_label'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return string |
210 | 210 | */ |
211 | 211 | public function system_ID() { |
212 | - return $this->get( 'QST_system' ); |
|
212 | + return $this->get('QST_system'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return boolean |
221 | 221 | */ |
222 | 222 | public function required() { |
223 | - return $this->get( 'QST_required' ); |
|
223 | + return $this->get('QST_required'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return string |
233 | 233 | */ |
234 | 234 | public function required_text() { |
235 | - return $this->get( 'QST_required_text' ); |
|
235 | + return $this->get('QST_required_text'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return string |
244 | 244 | */ |
245 | 245 | public function type() { |
246 | - return $this->get( 'QST_type' ); |
|
246 | + return $this->get('QST_type'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return int |
256 | 256 | */ |
257 | 257 | public function order() { |
258 | - return $this->get( 'QST_order' ); |
|
258 | + return $this->get('QST_order'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return boolean |
268 | 268 | */ |
269 | 269 | public function admin_only() { |
270 | - return $this->get( 'QST_admin_only' ); |
|
270 | + return $this->get('QST_admin_only'); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return int |
279 | 279 | */ |
280 | 280 | public function wp_user() { |
281 | - return $this->get( 'QST_wp_user' ); |
|
281 | + return $this->get('QST_wp_user'); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | public function deleted() { |
292 | - return $this->get( 'QST_deleted' ); |
|
292 | + return $this->get('QST_deleted'); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return EE_Answer[] |
300 | 300 | */ |
301 | 301 | public function answers() { |
302 | - return $this->get_many_related( 'Answer' ); |
|
302 | + return $this->get_many_related('Answer'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return boolean true = has answers, false = no answers. |
310 | 310 | */ |
311 | 311 | public function has_answers() { |
312 | - return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE; |
|
312 | + return $this->count_related('Answer') > 0 ? TRUE : FALSE; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return EE_Question_Group[] |
320 | 320 | */ |
321 | 321 | public function question_groups() { |
322 | - return $this->get_many_related( 'Question_Group' ); |
|
322 | + return $this->get_many_related('Question_Group'); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -333,24 +333,24 @@ discard block |
||
333 | 333 | * whether it was trashed or not. |
334 | 334 | * @return EE_Question_Option[] |
335 | 335 | */ |
336 | - public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) { |
|
337 | - if ( ! $this->ID() ) { |
|
336 | + public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) { |
|
337 | + if ( ! $this->ID()) { |
|
338 | 338 | return array(); |
339 | 339 | } |
340 | 340 | $query_params = array(); |
341 | - if ( $selected_value_to_always_include ) { |
|
342 | - if ( is_array( $selected_value_to_always_include ) ) { |
|
343 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include ); |
|
341 | + if ($selected_value_to_always_include) { |
|
342 | + if (is_array($selected_value_to_always_include)) { |
|
343 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
344 | 344 | } else { |
345 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include; |
|
345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
346 | 346 | } |
347 | 347 | } |
348 | - if ( $notDeletedOptionsOnly ) { |
|
349 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE; |
|
348 | + if ($notDeletedOptionsOnly) { |
|
349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = FALSE; |
|
350 | 350 | } |
351 | 351 | //order by QSO_order |
352 | - $query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' ); |
|
353 | - return $this->get_many_related( 'Question_Option', $query_params ); |
|
352 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
353 | + return $this->get_many_related('Question_Option', $query_params); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return \EE_Question_Option[] |
361 | 361 | */ |
362 | 362 | public function temp_options() { |
363 | - return $this->_model_relations[ 'Question_Option' ]; |
|
363 | + return $this->_model_relations['Question_Option']; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param EE_Question_Option $option |
372 | 372 | * @return boolean success |
373 | 373 | */ |
374 | - public function add_option( EE_Question_Option $option ) { |
|
375 | - return $this->_add_relation_to( $option, 'Question_Option' ); |
|
374 | + public function add_option(EE_Question_Option $option) { |
|
375 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param EE_Question_Option $option |
383 | 383 | * @return boolean success |
384 | 384 | */ |
385 | - public function add_temp_option( EE_Question_Option $option ) { |
|
386 | - $this->_model_relations[ 'Question_Option' ][ ] = $option; |
|
385 | + public function add_temp_option(EE_Question_Option $option) { |
|
386 | + $this->_model_relations['Question_Option'][] = $option; |
|
387 | 387 | return TRUE; |
388 | 388 | } |
389 | 389 | |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | * @param EE_Question_Option $option |
395 | 395 | * @return boolean success |
396 | 396 | */ |
397 | - public function remove_option( EE_Question_Option $option ) { |
|
398 | - return $this->_remove_relation_to( $option, 'Question_Option' ); |
|
397 | + public function remove_option(EE_Question_Option $option) { |
|
398 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | * @return bool |
405 | 405 | */ |
406 | 406 | public function is_system_question() { |
407 | - $system_ID = $this->get( 'QST_system' ); |
|
408 | - return ! empty( $system_ID ) ? TRUE : FALSE; |
|
407 | + $system_ID = $this->get('QST_system'); |
|
408 | + return ! empty($system_ID) ? TRUE : FALSE; |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | */ |
419 | 419 | public function set_order_to_latest() { |
420 | 420 | $latest_order = $this->get_model()->get_latest_question_order(); |
421 | - $latest_order ++; |
|
422 | - $this->set( 'QST_order', $latest_order ); |
|
421 | + $latest_order++; |
|
422 | + $this->set('QST_order', $latest_order); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -438,20 +438,20 @@ discard block |
||
438 | 438 | * Duplicates this question and its question options |
439 | 439 | * @return \EE_Question |
440 | 440 | */ |
441 | - public function duplicate( $options = array() ) { |
|
441 | + public function duplicate($options = array()) { |
|
442 | 442 | $new_question = clone $this; |
443 | - $new_question->set( 'QST_ID', null ); |
|
444 | - $new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) ); |
|
445 | - $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
|
446 | - $new_question->set_system_ID( null ); |
|
447 | - $new_question->set_wp_user( get_current_user_id() ); |
|
443 | + $new_question->set('QST_ID', null); |
|
444 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
445 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
446 | + $new_question->set_system_ID(null); |
|
447 | + $new_question->set_wp_user(get_current_user_id()); |
|
448 | 448 | //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
449 | - $new_question->set_deleted( false ); |
|
449 | + $new_question->set_deleted(false); |
|
450 | 450 | $success = $new_question->save(); |
451 | - if( $success ) { |
|
451 | + if ($success) { |
|
452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
453 | - foreach( $this->options() as $question_option ) { |
|
454 | - $question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) ); |
|
453 | + foreach ($this->options() as $question_option) { |
|
454 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
455 | 455 | } |
456 | 456 | return $new_question; |
457 | 457 | } else { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | * @return int|float |
465 | 465 | */ |
466 | 466 | public function max() { |
467 | - return $this->get( 'QST_max' ); |
|
467 | + return $this->get('QST_max'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param int|float $new_max |
473 | 473 | * @return int|float |
474 | 474 | */ |
475 | - public function set_max( $new_max ) { |
|
476 | - return $this->set( 'QST_max', $new_max ); |
|
475 | + public function set_max($new_max) { |
|
476 | + return $this->set('QST_max', $new_max); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 |
@@ -8,36 +8,36 @@ |
||
8 | 8 | * @subpackage Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php. |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | protected $_max_length; |
14 | 14 | |
15 | - public function __construct( $validation_error_message = NULL, $max_length = EE_INF ) { |
|
15 | + public function __construct($validation_error_message = NULL, $max_length = EE_INF) { |
|
16 | 16 | $this->_max_length = $max_length; |
17 | - if( $validation_error_message === null ) { |
|
18 | - $validation_error_message = sprintf( __( 'Input is too long. Maximum number of characters is %1$s', 'event_espresso' ), $max_length ); |
|
17 | + if ($validation_error_message === null) { |
|
18 | + $validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length); |
|
19 | 19 | } |
20 | - parent::__construct( $validation_error_message ); |
|
20 | + parent::__construct($validation_error_message); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param $normalized_value |
25 | 25 | */ |
26 | 26 | public function validate($normalized_value) { |
27 | - if( $this->_max_length !== EE_INF && |
|
27 | + if ($this->_max_length !== EE_INF && |
|
28 | 28 | $normalized_value && |
29 | - is_string( $normalized_value ) && |
|
30 | - strlen( $normalized_value ) > $this->_max_length){ |
|
31 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'maxlength' ); |
|
29 | + is_string($normalized_value) && |
|
30 | + strlen($normalized_value) > $this->_max_length) { |
|
31 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - function get_jquery_validation_rule_array(){ |
|
39 | - if( $this->_max_length !== EE_INF ) { |
|
40 | - return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) ); |
|
38 | + function get_jquery_validation_rule_array() { |
|
39 | + if ($this->_max_length !== EE_INF) { |
|
40 | + return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message())); |
|
41 | 41 | } else { |
42 | 42 | return array(); |
43 | 43 | } |