@@ -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 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @param array $props_n_values |
33 | 33 | * @return EE_Term_Taxonomy |
34 | 34 | */ |
35 | - public static function new_instance( $props_n_values = array() ) { |
|
36 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
37 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
35 | + public static function new_instance($props_n_values = array()) { |
|
36 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
37 | + return $has_object ? $has_object : new self($props_n_values); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * @param array $props_n_values |
44 | 44 | * @return EE_Term_Taxonomy |
45 | 45 | */ |
46 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
47 | - return new self( $props_n_values, TRUE ); |
|
46 | + public static function new_instance_from_db($props_n_values = array()) { |
|
47 | + return new self($props_n_values, TRUE); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | function taxonomy() { |
57 | - return $this->get( 'taxonomy' ); |
|
57 | + return $this->get('taxonomy'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @param string $taxonomy |
65 | 65 | * @return boolean |
66 | 66 | */ |
67 | - function set_taxonomy( $taxonomy ) { |
|
68 | - $this->set( 'taxonomy', $taxonomy ); |
|
67 | + function set_taxonomy($taxonomy) { |
|
68 | + $this->set('taxonomy', $taxonomy); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @return int |
76 | 76 | */ |
77 | 77 | function count() { |
78 | - return $this->get( 'term_count' ); |
|
78 | + return $this->get('term_count'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $term_count |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | - function set_count( $term_count ) { |
|
89 | - $this->set( 'term_count', $term_count ); |
|
88 | + function set_count($term_count) { |
|
89 | + $this->set('term_count', $term_count); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return EE_Term |
97 | 97 | */ |
98 | 98 | function term() { |
99 | - return $this->get_first_related( 'Term' ); |
|
99 | + return $this->get_first_related('Term'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | - * @return boolean |
|
45 | + * @return boolean|null |
|
46 | 46 | */ |
47 | 47 | public function initialize_reg_step() { |
48 | 48 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | |
171 | 171 | /** |
172 | - * @return boolean |
|
172 | + * @return boolean|null |
|
173 | 173 | */ |
174 | 174 | public function update_reg_step() { |
175 | 175 | EE_Error::doing_it_wrong( __CLASS__ . '::' . __FILE__, __( 'Can not call update_reg_step() on the Finalize Registration reg step.', 'event_espresso'), '4.6.0' ); |
@@ -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 |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @param string $timezone |
36 | 36 | * @return EE_Ticket_Template|mixed |
37 | 37 | */ |
38 | - public static function new_instance( $props_n_values = array(), $timezone = '' ) { |
|
39 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone ); |
|
40 | - return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone ); |
|
38 | + public static function new_instance($props_n_values = array(), $timezone = '') { |
|
39 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
40 | + return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param string $timezone |
48 | 48 | * @return EE_Ticket_Template |
49 | 49 | */ |
50 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) { |
|
51 | - return new self( $props_n_values, TRUE, $timezone ); |
|
50 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') { |
|
51 | + return new self($props_n_values, TRUE, $timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 |
@@ -742,11 +742,11 @@ |
||
742 | 742 | $pm = $this->get_first_related('Payment_Method'); |
743 | 743 | if( $pm instanceof EE_Payment_Method ){ |
744 | 744 | return $pm; |
745 | - }else{ |
|
745 | + } else{ |
|
746 | 746 | $last_payment = $this->last_payment(); |
747 | 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 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function |
413 | 413 | * for getting attendees and how many registrations they each have for an event) |
414 | 414 | * |
415 | - * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
415 | + * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function attendees() { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * Gets all the extra meta info on this payment |
694 | 694 | * |
695 | 695 | * @param array $query_params like EEM_Base::get_all |
696 | - * @return EE_Extra_Meta |
|
696 | + * @return EE_Base_Class[] |
|
697 | 697 | * @throws \EE_Error |
698 | 698 | */ |
699 | 699 | public function extra_meta( $query_params = array() ) { |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | * Sets PMD_ID |
871 | 871 | * |
872 | 872 | * @param int $PMD_ID |
873 | - * @return boolean |
|
873 | + * @return boolean|null |
|
874 | 874 | * @throws \EE_Error |
875 | 875 | */ |
876 | 876 | public function set_payment_method_ID($PMD_ID) { |
@@ -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 | * EE_Transaction class |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @return EE_Transaction |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
38 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
37 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
38 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
39 | 39 | $txn = $has_object |
40 | 40 | ? $has_object |
41 | - : new self( $props_n_values, false, $timezone, $date_formats ); |
|
42 | - if ( ! $has_object ) { |
|
43 | - $txn->set_old_txn_status( $txn->status_ID() ); |
|
41 | + : new self($props_n_values, false, $timezone, $date_formats); |
|
42 | + if ( ! $has_object) { |
|
43 | + $txn->set_old_txn_status($txn->status_ID()); |
|
44 | 44 | } |
45 | 45 | return $txn; |
46 | 46 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @return EE_Transaction |
55 | 55 | * @throws \EE_Error |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - $txn = new self( $props_n_values, TRUE, $timezone ); |
|
59 | - $txn->set_old_txn_status( $txn->status_ID() ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + $txn = new self($props_n_values, TRUE, $timezone); |
|
59 | + $txn->set_old_txn_status($txn->status_ID()); |
|
60 | 60 | return $txn; |
61 | 61 | } |
62 | 62 | |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function lock() { |
75 | 75 | // attempt to set lock, but if that fails... |
76 | - if ( ! $this->add_extra_meta( 'lock', time(), true ) ) { |
|
76 | + if ( ! $this->add_extra_meta('lock', time(), true)) { |
|
77 | 77 | // then attempt to remove the lock in case it is expired |
78 | - if ( $this->_remove_expired_lock() ) { |
|
78 | + if ($this->_remove_expired_lock()) { |
|
79 | 79 | // if removal was successful, then try setting lock again |
80 | 80 | $this->lock(); |
81 | 81 | } else { |
82 | 82 | // but if the lock can not be removed, then throw an exception |
83 | 83 | throw new EE_Error( |
84 | 84 | sprintf( |
85 | - __( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ), |
|
85 | + __('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'), |
|
86 | 86 | $this->ID() |
87 | 87 | ) |
88 | 88 | ); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @throws \EE_Error |
102 | 102 | */ |
103 | 103 | public function unlock() { |
104 | - return $this->delete_extra_meta( 'lock' ); |
|
104 | + return $this->delete_extra_meta('lock'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function is_locked() { |
124 | 124 | // if TXN is not locked, then return false immediately |
125 | - if ( ! $this->_get_lock() ) { |
|
125 | + if ( ! $this->_get_lock()) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | // if not, then let's try and remove the lock in case it's expired... |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws \EE_Error |
144 | 144 | */ |
145 | 145 | protected function _get_lock() { |
146 | - return (int)$this->get_extra_meta( 'lock', true, 0 ); |
|
146 | + return (int) $this->get_extra_meta('lock', true, 0); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function _remove_expired_lock() { |
160 | 160 | $locked = $this->_get_lock(); |
161 | - if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) { |
|
161 | + if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) { |
|
162 | 162 | return $this->unlock(); |
163 | 163 | } |
164 | 164 | return 0; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param float $total total value of transaction |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_total( $total = 0.00 ) { |
|
177 | - $this->set( 'TXN_total', (float)$total ); |
|
176 | + public function set_total($total = 0.00) { |
|
177 | + $this->set('TXN_total', (float) $total); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param float $total_paid total amount paid to date (sum of all payments) |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_paid( $total_paid = 0.00 ) { |
|
190 | - $this->set( 'TXN_paid', (float)$total_paid ); |
|
189 | + public function set_paid($total_paid = 0.00) { |
|
190 | + $this->set('TXN_paid', (float) $total_paid); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_status( $status = '' ) { |
|
203 | - $this->set( 'STS_ID', $status ); |
|
202 | + public function set_status($status = '') { |
|
203 | + $this->set('STS_ID', $status); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $hash_salt required for some payment gateways |
213 | 213 | * @throws \EE_Error |
214 | 214 | */ |
215 | - public function set_hash_salt( $hash_salt = '' ) { |
|
216 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
215 | + public function set_hash_salt($hash_salt = '') { |
|
216 | + $this->set('TXN_hash_salt', $hash_salt); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | * @param array $txn_reg_steps |
225 | 225 | * @throws \EE_Error |
226 | 226 | */ |
227 | - public function set_reg_steps( array $txn_reg_steps ) { |
|
228 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
227 | + public function set_reg_steps(array $txn_reg_steps) { |
|
228 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @throws \EE_Error |
238 | 238 | */ |
239 | 239 | public function reg_steps() { |
240 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
241 | - return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array(); |
|
240 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
241 | + return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array(); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @throws \EE_Error |
249 | 249 | */ |
250 | 250 | public function pretty_total() { |
251 | - return $this->get_pretty( 'TXN_total' ); |
|
251 | + return $this->get_pretty('TXN_total'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @throws \EE_Error |
261 | 261 | */ |
262 | 262 | public function pretty_paid() { |
263 | - return $this->get_pretty( 'TXN_paid' ); |
|
263 | + return $this->get_pretty('TXN_paid'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @throws \EE_Error |
274 | 274 | */ |
275 | 275 | public function remaining() { |
276 | - return (float)( $this->total() - $this->paid() ); |
|
276 | + return (float) ($this->total() - $this->paid()); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @throws \EE_Error |
287 | 287 | */ |
288 | 288 | public function total() { |
289 | - return (float)$this->get( 'TXN_total' ); |
|
289 | + return (float) $this->get('TXN_total'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @throws \EE_Error |
300 | 300 | */ |
301 | 301 | public function paid() { |
302 | - return (float)$this->get( 'TXN_paid' ); |
|
302 | + return (float) $this->get('TXN_paid'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @throws \EE_Error |
312 | 312 | */ |
313 | 313 | public function get_cart_session() { |
314 | - $session_data = (array)$this->get( 'TXN_session_data' ); |
|
315 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart |
|
316 | - ? $session_data[ 'cart' ] |
|
314 | + $session_data = (array) $this->get('TXN_session_data'); |
|
315 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart |
|
316 | + ? $session_data['cart'] |
|
317 | 317 | : null; |
318 | 318 | } |
319 | 319 | |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | * @throws \EE_Error |
327 | 327 | */ |
328 | 328 | public function session_data() { |
329 | - $session_data = $this->get( 'TXN_session_data' ); |
|
330 | - if ( empty( $session_data ) ) { |
|
329 | + $session_data = $this->get('TXN_session_data'); |
|
330 | + if (empty($session_data)) { |
|
331 | 331 | $session_data = array( |
332 | 332 | 'id' => null, |
333 | 333 | 'user_id' => null, |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | * @param EE_Session|array $session_data |
351 | 351 | * @throws \EE_Error |
352 | 352 | */ |
353 | - public function set_txn_session_data( $session_data ) { |
|
354 | - if ( $session_data instanceof EE_Session ) { |
|
355 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
353 | + public function set_txn_session_data($session_data) { |
|
354 | + if ($session_data instanceof EE_Session) { |
|
355 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
356 | 356 | } else { |
357 | - $this->set( 'TXN_session_data', $session_data ); |
|
357 | + $this->set('TXN_session_data', $session_data); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @throws \EE_Error |
368 | 368 | */ |
369 | 369 | public function hash_salt_() { |
370 | - return $this->get( 'TXN_hash_salt' ); |
|
370 | + return $this->get('TXN_hash_salt'); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | * @return string | int |
388 | 388 | * @throws \EE_Error |
389 | 389 | */ |
390 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
391 | - if ( $format ) { |
|
392 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
393 | - } else if ( $gmt ) { |
|
394 | - return $this->get_raw( 'TXN_timestamp' ); |
|
390 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
391 | + if ($format) { |
|
392 | + return $this->get_pretty('TXN_timestamp'); |
|
393 | + } else if ($gmt) { |
|
394 | + return $this->get_raw('TXN_timestamp'); |
|
395 | 395 | } else { |
396 | - return $this->get( 'TXN_timestamp' ); |
|
396 | + return $this->get('TXN_timestamp'); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * @return EE_Registration[] |
408 | 408 | * @throws \EE_Error |
409 | 409 | */ |
410 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
411 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) |
|
410 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
411 | + $query_params = (empty($query_params) || ! is_array($query_params)) |
|
412 | 412 | ? array( |
413 | 413 | 'order_by' => array( |
414 | 414 | 'Event.EVT_name' => 'ASC', |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | ) |
419 | 419 | : $query_params; |
420 | 420 | $query_params = $get_cached ? array() : $query_params; |
421 | - return $this->get_many_related( 'Registration', $query_params ); |
|
421 | + return $this->get_many_related('Registration', $query_params); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @throws \EE_Error |
432 | 432 | */ |
433 | 433 | public function attendees() { |
434 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
434 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * @return EE_Payment[] |
444 | 444 | * @throws \EE_Error |
445 | 445 | */ |
446 | - public function payments( $query_params = array() ) { |
|
447 | - return $this->get_many_related( 'Payment', $query_params ); |
|
446 | + public function payments($query_params = array()) { |
|
447 | + return $this->get_many_related('Payment', $query_params); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | * @throws \EE_Error |
457 | 457 | */ |
458 | 458 | public function approved_payments() { |
459 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
460 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
459 | + EE_Registry::instance()->load_model('Payment'); |
|
460 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | * @return string |
470 | 470 | * @throws \EE_Error |
471 | 471 | */ |
472 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
473 | - echo $this->pretty_status( $show_icons ); |
|
472 | + public function e_pretty_status($show_icons = FALSE) { |
|
473 | + echo $this->pretty_status($show_icons); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | * @return string |
483 | 483 | * @throws \EE_Error |
484 | 484 | */ |
485 | - public function pretty_status( $show_icons = FALSE ) { |
|
486 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
485 | + public function pretty_status($show_icons = FALSE) { |
|
486 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
487 | 487 | $icon = ''; |
488 | - switch ( $this->status_ID() ) { |
|
488 | + switch ($this->status_ID()) { |
|
489 | 489 | case EEM_Transaction::complete_status_code: |
490 | 490 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
491 | 491 | break; |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
503 | 503 | break; |
504 | 504 | } |
505 | - return $icon . $status[ $this->status_ID() ]; |
|
505 | + return $icon.$status[$this->status_ID()]; |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @throws \EE_Error |
515 | 515 | */ |
516 | 516 | public function status_ID() { |
517 | - return $this->get( 'STS_ID' ); |
|
517 | + return $this->get('STS_ID'); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @throws \EE_Error |
527 | 527 | */ |
528 | 528 | public function is_free() { |
529 | - return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' ); |
|
529 | + return EEH_Money::compare_floats($this->get('TXN_total'), 0, '=='); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * @return string |
607 | 607 | * @throws \EE_Error |
608 | 608 | */ |
609 | - public function invoice_url( $type = 'html' ) { |
|
609 | + public function invoice_url($type = 'html') { |
|
610 | 610 | $REG = $this->primary_registration(); |
611 | - if ( ! $REG instanceof EE_Registration ) { |
|
611 | + if ( ! $REG instanceof EE_Registration) { |
|
612 | 612 | return ''; |
613 | 613 | } |
614 | - return $REG->invoice_url( $type ); |
|
614 | + return $REG->invoice_url($type); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | * @throws \EE_Error |
624 | 624 | */ |
625 | 625 | public function primary_registration() { |
626 | - return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) ); |
|
626 | + return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -635,12 +635,12 @@ discard block |
||
635 | 635 | * @return string |
636 | 636 | * @throws \EE_Error |
637 | 637 | */ |
638 | - public function receipt_url( $type = 'html' ) { |
|
638 | + public function receipt_url($type = 'html') { |
|
639 | 639 | $REG = $this->primary_registration(); |
640 | - if ( ! $REG instanceof EE_Registration ) { |
|
640 | + if ( ! $REG instanceof EE_Registration) { |
|
641 | 641 | return ''; |
642 | 642 | } |
643 | - return $REG->receipt_url( $type ); |
|
643 | + return $REG->receipt_url($type); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | * @throws \EE_Error |
666 | 666 | */ |
667 | 667 | public function gateway_response_on_transaction() { |
668 | - $payment = $this->get_first_related( 'Payment' ); |
|
668 | + $payment = $this->get_first_related('Payment'); |
|
669 | 669 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
670 | 670 | } |
671 | 671 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @throws \EE_Error |
679 | 679 | */ |
680 | 680 | public function status_obj() { |
681 | - return $this->get_first_related( 'Status' ); |
|
681 | + return $this->get_first_related('Status'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -690,8 +690,8 @@ discard block |
||
690 | 690 | * @return EE_Extra_Meta |
691 | 691 | * @throws \EE_Error |
692 | 692 | */ |
693 | - public function extra_meta( $query_params = array() ) { |
|
694 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
693 | + public function extra_meta($query_params = array()) { |
|
694 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | |
@@ -703,8 +703,8 @@ discard block |
||
703 | 703 | * @return EE_Base_Class the relation was added to |
704 | 704 | * @throws \EE_Error |
705 | 705 | */ |
706 | - public function add_registration( EE_Registration $registration ) { |
|
707 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
706 | + public function add_registration(EE_Registration $registration) { |
|
707 | + return $this->_add_relation_to($registration, 'Registration'); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | |
@@ -717,8 +717,8 @@ discard block |
||
717 | 717 | * @return EE_Base_Class that was removed from being related |
718 | 718 | * @throws \EE_Error |
719 | 719 | */ |
720 | - public function remove_registration_with_id( $registration_or_id ) { |
|
721 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
720 | + public function remove_registration_with_id($registration_or_id) { |
|
721 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @throws \EE_Error |
731 | 731 | */ |
732 | 732 | public function items_purchased() { |
733 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
733 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | * @return EE_Base_Class the relation was added to |
743 | 743 | * @throws \EE_Error |
744 | 744 | */ |
745 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
746 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
745 | + public function add_line_item(EE_Line_Item $line_item) { |
|
746 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | |
@@ -755,8 +755,8 @@ discard block |
||
755 | 755 | * @return EE_Line_Item[] |
756 | 756 | * @throws \EE_Error |
757 | 757 | */ |
758 | - public function line_items( $query_params = array() ) { |
|
759 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
758 | + public function line_items($query_params = array()) { |
|
759 | + return $this->get_many_related('Line_Item', $query_params); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @throws \EE_Error |
769 | 769 | */ |
770 | 770 | public function tax_items() { |
771 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
771 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | * @return \EE_Line_Item |
782 | 782 | * @throws \EE_Error |
783 | 783 | */ |
784 | - public function total_line_item( $create_if_not_found = true ) { |
|
785 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
786 | - if( ! $item && $create_if_not_found ){ |
|
787 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
784 | + public function total_line_item($create_if_not_found = true) { |
|
785 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
786 | + if ( ! $item && $create_if_not_found) { |
|
787 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
788 | 788 | } |
789 | 789 | return $item; |
790 | 790 | } |
@@ -800,10 +800,10 @@ discard block |
||
800 | 800 | */ |
801 | 801 | public function tax_total() { |
802 | 802 | $tax_line_item = $this->tax_total_line_item(); |
803 | - if ( $tax_line_item ) { |
|
804 | - return (float)$tax_line_item->total(); |
|
803 | + if ($tax_line_item) { |
|
804 | + return (float) $tax_line_item->total(); |
|
805 | 805 | } else { |
806 | - return (float)0; |
|
806 | + return (float) 0; |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | * @throws \EE_Error |
817 | 817 | */ |
818 | 818 | public function tax_total_line_item() { |
819 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
819 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | |
@@ -827,20 +827,20 @@ discard block |
||
827 | 827 | * @return EE_Form_Section_Proper |
828 | 828 | * @throws \EE_Error |
829 | 829 | */ |
830 | - public function billing_info(){ |
|
830 | + public function billing_info() { |
|
831 | 831 | $payment_method = $this->payment_method(); |
832 | - if ( !$payment_method){ |
|
832 | + if ( ! $payment_method) { |
|
833 | 833 | 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__); |
834 | 834 | return false; |
835 | 835 | } |
836 | 836 | $primary_reg = $this->primary_registration(); |
837 | - if ( ! $primary_reg ) { |
|
838 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
837 | + if ( ! $primary_reg) { |
|
838 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
839 | 839 | return FALSE; |
840 | 840 | } |
841 | 841 | $attendee = $primary_reg->attendee(); |
842 | - if ( ! $attendee ) { |
|
843 | - 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__ ); |
|
842 | + if ( ! $attendee) { |
|
843 | + 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__); |
|
844 | 844 | return FALSE; |
845 | 845 | } |
846 | 846 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -881,15 +881,15 @@ discard block |
||
881 | 881 | * @return EE_Payment_Method |
882 | 882 | * @throws \EE_Error |
883 | 883 | */ |
884 | - public function payment_method(){ |
|
884 | + public function payment_method() { |
|
885 | 885 | $pm = $this->get_first_related('Payment_Method'); |
886 | - if( $pm instanceof EE_Payment_Method ){ |
|
886 | + if ($pm instanceof EE_Payment_Method) { |
|
887 | 887 | return $pm; |
888 | - }else{ |
|
888 | + } else { |
|
889 | 889 | $last_payment = $this->last_payment(); |
890 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
890 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
891 | 891 | return $last_payment->payment_method(); |
892 | - }else{ |
|
892 | + } else { |
|
893 | 893 | return NULL; |
894 | 894 | } |
895 | 895 | } |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | * @throws \EE_Error |
905 | 905 | */ |
906 | 906 | public function last_payment() { |
907 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
907 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | * @return EE_Line_Item[] |
916 | 916 | * @throws \EE_Error |
917 | 917 | */ |
918 | - public function non_ticket_line_items(){ |
|
919 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
918 | + public function non_ticket_line_items() { |
|
919 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | public function update_based_on_payments() |
965 | 965 | { |
966 | 966 | EE_Error::doing_it_wrong( |
967 | - __CLASS__ . '::' . __FUNCTION__, |
|
967 | + __CLASS__.'::'.__FUNCTION__, |
|
968 | 968 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
969 | 969 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
970 | 970 | '4.6.0' |
@@ -988,9 +988,9 @@ discard block |
||
988 | 988 | /** |
989 | 989 | * @param string $old_txn_status |
990 | 990 | */ |
991 | - public function set_old_txn_status( $old_txn_status ) { |
|
991 | + public function set_old_txn_status($old_txn_status) { |
|
992 | 992 | // only set the first time |
993 | - if ( $this->_old_txn_status === null ) { |
|
993 | + if ($this->_old_txn_status === null) { |
|
994 | 994 | $this->_old_txn_status = $old_txn_status; |
995 | 995 | } |
996 | 996 | } |
@@ -1019,17 +1019,17 @@ discard block |
||
1019 | 1019 | * @param bool $check_all |
1020 | 1020 | * @return boolean | int |
1021 | 1021 | */ |
1022 | - private function _reg_steps_completed( $reg_step_slug = '', $check_all = true ) { |
|
1022 | + private function _reg_steps_completed($reg_step_slug = '', $check_all = true) { |
|
1023 | 1023 | $reg_steps = $this->reg_steps(); |
1024 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps ) ) { |
|
1024 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
1025 | 1025 | return false; |
1026 | 1026 | } |
1027 | 1027 | // loop thru reg steps array) |
1028 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
1028 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
1029 | 1029 | // if NOT checking ALL steps (only checking one step) |
1030 | - if ( ! $check_all ) { |
|
1030 | + if ( ! $check_all) { |
|
1031 | 1031 | // and this is the one |
1032 | - if ( $slug === $reg_step_slug ) { |
|
1032 | + if ($slug === $reg_step_slug) { |
|
1033 | 1033 | return $reg_step_completed; |
1034 | 1034 | } else { |
1035 | 1035 | // skip to next reg step in loop |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | // $check_all must be true, else we would never have gotten to this point |
1040 | - if ( $slug === $reg_step_slug ) { |
|
1040 | + if ($slug === $reg_step_slug) { |
|
1041 | 1041 | // if we reach this point, then we are testing either: |
1042 | 1042 | // all_reg_steps_completed_except() or |
1043 | 1043 | // all_reg_steps_completed_except_final_step(), |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | // ie: "is everything completed except the final step?" |
1047 | 1047 | // "that is correct... the final step is not completed, but all others are." |
1048 | 1048 | return $reg_step_completed !== true ? true : false; |
1049 | - } else if ( $reg_step_completed !== true ) { |
|
1049 | + } else if ($reg_step_completed !== true) { |
|
1050 | 1050 | // if any reg step is NOT completed, then ALL steps are not completed |
1051 | 1051 | return false; |
1052 | 1052 | } |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | * @param string $exception |
1081 | 1081 | * @return boolean |
1082 | 1082 | */ |
1083 | - public function all_reg_steps_completed_except( $exception = '' ) { |
|
1084 | - return $this->_reg_steps_completed( $exception ); |
|
1083 | + public function all_reg_steps_completed_except($exception = '') { |
|
1084 | + return $this->_reg_steps_completed($exception); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | * @return boolean |
1097 | 1097 | */ |
1098 | 1098 | public function all_reg_steps_completed_except_final_step() { |
1099 | - return $this->_reg_steps_completed( 'finalize_registration' ); |
|
1099 | + return $this->_reg_steps_completed('finalize_registration'); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | * @param string $reg_step_slug |
1112 | 1112 | * @return boolean | int |
1113 | 1113 | */ |
1114 | - public function reg_step_completed( $reg_step_slug ) { |
|
1115 | - return $this->_reg_steps_completed( $reg_step_slug, false ); |
|
1114 | + public function reg_step_completed($reg_step_slug) { |
|
1115 | + return $this->_reg_steps_completed($reg_step_slug, false); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | * @return boolean | int |
1128 | 1128 | */ |
1129 | 1129 | public function final_reg_step_completed() { |
1130 | - return $this->_reg_steps_completed( 'finalize_registration', false ); |
|
1130 | + return $this->_reg_steps_completed('finalize_registration', false); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1141,8 +1141,8 @@ discard block |
||
1141 | 1141 | * @return boolean |
1142 | 1142 | * @throws \EE_Error |
1143 | 1143 | */ |
1144 | - public function set_reg_step_initiated( $reg_step_slug ) { |
|
1145 | - return $this->_set_reg_step_completed_status( $reg_step_slug, time() ); |
|
1144 | + public function set_reg_step_initiated($reg_step_slug) { |
|
1145 | + return $this->_set_reg_step_completed_status($reg_step_slug, time()); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * @return boolean |
1157 | 1157 | * @throws \EE_Error |
1158 | 1158 | */ |
1159 | - public function set_reg_step_completed( $reg_step_slug ) { |
|
1160 | - return $this->_set_reg_step_completed_status( $reg_step_slug, true ); |
|
1159 | + public function set_reg_step_completed($reg_step_slug) { |
|
1160 | + return $this->_set_reg_step_completed_status($reg_step_slug, true); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | |
@@ -1171,8 +1171,8 @@ discard block |
||
1171 | 1171 | * @return boolean |
1172 | 1172 | * @throws \EE_Error |
1173 | 1173 | */ |
1174 | - public function set_reg_step_not_completed( $reg_step_slug ) { |
|
1175 | - return $this->_set_reg_step_completed_status( $reg_step_slug, false ); |
|
1174 | + public function set_reg_step_not_completed($reg_step_slug) { |
|
1175 | + return $this->_set_reg_step_completed_status($reg_step_slug, false); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | |
@@ -1187,37 +1187,37 @@ discard block |
||
1187 | 1187 | * @return boolean |
1188 | 1188 | * @throws \EE_Error |
1189 | 1189 | */ |
1190 | - private function _set_reg_step_completed_status( $reg_step_slug, $status ) { |
|
1190 | + private function _set_reg_step_completed_status($reg_step_slug, $status) { |
|
1191 | 1191 | // validate status |
1192 | - $status = is_bool( $status ) || is_int( $status ) ? $status : false; |
|
1192 | + $status = is_bool($status) || is_int($status) ? $status : false; |
|
1193 | 1193 | // get reg steps array |
1194 | 1194 | $txn_reg_steps = $this->reg_steps(); |
1195 | 1195 | // if reg step does NOT exist |
1196 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] ) ) { |
|
1196 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | // if we're trying to complete a step that is already completed |
1200 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
1200 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
1201 | 1201 | return true; |
1202 | 1202 | } |
1203 | 1203 | // if we're trying to complete a step that hasn't even started |
1204 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
1204 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
1205 | 1205 | return false; |
1206 | 1206 | } |
1207 | 1207 | // if current status value matches the incoming value (no change) |
1208 | 1208 | // type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890 |
1209 | - if ( (int) $txn_reg_steps[ $reg_step_slug ] === (int) $status ) { |
|
1209 | + if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) { |
|
1210 | 1210 | // this will happen in cases where multiple AJAX requests occur during the same step |
1211 | 1211 | return true; |
1212 | 1212 | } |
1213 | 1213 | // if we're trying to set a start time, but it has already been set... |
1214 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] ) ) { |
|
1214 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
1215 | 1215 | // skip the update below, but don't return FALSE so that errors won't be displayed |
1216 | 1216 | return true; |
1217 | 1217 | } |
1218 | 1218 | // update completed status |
1219 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
1220 | - $this->set_reg_steps( $txn_reg_steps ); |
|
1219 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
1220 | + $this->set_reg_steps($txn_reg_steps); |
|
1221 | 1221 | $this->save(); |
1222 | 1222 | return true; |
1223 | 1223 | } |
@@ -1233,11 +1233,11 @@ discard block |
||
1233 | 1233 | * @param string $reg_step_slug |
1234 | 1234 | * @return void |
1235 | 1235 | */ |
1236 | - public function remove_reg_step( $reg_step_slug ) { |
|
1236 | + public function remove_reg_step($reg_step_slug) { |
|
1237 | 1237 | // get reg steps array |
1238 | 1238 | $txn_reg_steps = $this->reg_steps(); |
1239 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
1240 | - $this->set_reg_steps( $txn_reg_steps ); |
|
1239 | + unset($txn_reg_steps[$reg_step_slug]); |
|
1240 | + $this->set_reg_steps($txn_reg_steps); |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | |
@@ -1251,11 +1251,11 @@ discard block |
||
1251 | 1251 | * @param bool $save |
1252 | 1252 | * @return bool |
1253 | 1253 | */ |
1254 | - public function toggle_failed_transaction_status( $save = true ) { |
|
1254 | + public function toggle_failed_transaction_status($save = true) { |
|
1255 | 1255 | // if TXN status is still set as "failed"... |
1256 | - if ( $this->status_ID() === EEM_Transaction::failed_status_code ) { |
|
1257 | - $this->set_status( EEM_Transaction::abandoned_status_code ); |
|
1258 | - if ( $save ) { |
|
1256 | + if ($this->status_ID() === EEM_Transaction::failed_status_code) { |
|
1257 | + $this->set_status(EEM_Transaction::abandoned_status_code); |
|
1258 | + if ($save) { |
|
1259 | 1259 | $this->save(); |
1260 | 1260 | } |
1261 | 1261 | return true; |
@@ -1284,10 +1284,10 @@ discard block |
||
1284 | 1284 | $this->primary_registration() instanceof EE_Registration |
1285 | 1285 | && $this->primary_registration()->attendee() instanceof EE_Attendee |
1286 | 1286 | ) { |
1287 | - $this->set_status( EEM_Transaction::incomplete_status_code ); |
|
1287 | + $this->set_status(EEM_Transaction::incomplete_status_code); |
|
1288 | 1288 | } else { |
1289 | 1289 | // no contact record? yer abandoned! |
1290 | - $this->set_status( EEM_Transaction::abandoned_status_code ); |
|
1290 | + $this->set_status(EEM_Transaction::abandoned_status_code); |
|
1291 | 1291 | } |
1292 | 1292 | return true; |
1293 | 1293 | } |
@@ -1301,16 +1301,16 @@ discard block |
||
1301 | 1301 | * updates the TXN status based on the amount paid |
1302 | 1302 | */ |
1303 | 1303 | public function verify_abandoned_transaction_status() { |
1304 | - if ( $this->status_ID() !== EEM_Transaction::abandoned_status_code ) { |
|
1304 | + if ($this->status_ID() !== EEM_Transaction::abandoned_status_code) { |
|
1305 | 1305 | return; |
1306 | 1306 | } |
1307 | - $payments = $this->get_many_related( 'Payment' ); |
|
1308 | - if ( ! empty( $payments ) ) { |
|
1309 | - foreach ( $payments as $payment ) { |
|
1310 | - if ( $payment instanceof EE_Payment ) { |
|
1307 | + $payments = $this->get_many_related('Payment'); |
|
1308 | + if ( ! empty($payments)) { |
|
1309 | + foreach ($payments as $payment) { |
|
1310 | + if ($payment instanceof EE_Payment) { |
|
1311 | 1311 | // kk this TXN should NOT be abandoned |
1312 | 1312 | $this->update_status_based_on_total_paid(); |
1313 | - if ( is_admin() && ! ( defined('DOING_AJAX') && DOING_AJAX ) ) { |
|
1313 | + if (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
1314 | 1314 | EE_Error::add_attention( |
1315 | 1315 | sprintf( |
1316 | 1316 | esc_html__( |
@@ -1326,8 +1326,8 @@ discard block |
||
1326 | 1326 | $finalized = $this->final_reg_step_completed(); |
1327 | 1327 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
1328 | 1328 | // but has not yet been fully completed (TRUE) |
1329 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
1330 | - $this->set_reg_step_completed( 'finalize_registration' ); |
|
1329 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
1330 | + $this->set_reg_step_completed('finalize_registration'); |
|
1331 | 1331 | $this->save(); |
1332 | 1332 | } |
1333 | 1333 | } |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | |
106 | 106 | |
107 | 107 | /** |
108 | - * retrieve a single attendee from db via their ID |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param $ATT_ID |
|
112 | - * @return mixed array on success, FALSE on fail |
|
108 | + * retrieve a single attendee from db via their ID |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param $ATT_ID |
|
112 | + * @return mixed array on success, FALSE on fail |
|
113 | 113 | * @deprecated |
114 | - */ |
|
114 | + */ |
|
115 | 115 | public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
116 | 116 | // retrieve a particular EE_Attendee |
117 | 117 | return $this->get_one_by_ID( $ATT_ID ); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | /** |
124 | - * retrieve a single attendee from db via their ID |
|
125 | - * |
|
126 | - * @access public |
|
127 | - * @param array $where_cols_n_values |
|
128 | - * @return mixed array on success, FALSE on fail |
|
129 | - */ |
|
124 | + * retrieve a single attendee from db via their ID |
|
125 | + * |
|
126 | + * @access public |
|
127 | + * @param array $where_cols_n_values |
|
128 | + * @return mixed array on success, FALSE on fail |
|
129 | + */ |
|
130 | 130 | public function get_attendee( $where_cols_n_values = array() ) { |
131 | 131 | |
132 | 132 | if ( empty( $where_cols_n_values )) { |
@@ -174,20 +174,20 @@ discard block |
||
174 | 174 | |
175 | 175 | |
176 | 176 | /** |
177 | - * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate |
|
178 | - * EE_Attendee objects. |
|
179 | - * |
|
180 | - * @since 4.3.0 |
|
181 | - * @param array $ids array of EE_Registration ids |
|
182 | - * @return EE_Attendee[] |
|
183 | - */ |
|
184 | - public function get_array_of_contacts_from_reg_ids( $ids ) { |
|
185 | - $ids = (array) $ids; |
|
186 | - $_where = array( |
|
187 | - 'Registration.REG_ID' => array( 'in', $ids ) |
|
188 | - ); |
|
189 | - return $this->get_all( array( $_where ) ); |
|
190 | - } |
|
177 | + * Takes an incoming array of EE_Registration ids and sends back a list of corresponding non duplicate |
|
178 | + * EE_Attendee objects. |
|
179 | + * |
|
180 | + * @since 4.3.0 |
|
181 | + * @param array $ids array of EE_Registration ids |
|
182 | + * @return EE_Attendee[] |
|
183 | + */ |
|
184 | + public function get_array_of_contacts_from_reg_ids( $ids ) { |
|
185 | + $ids = (array) $ids; |
|
186 | + $_where = array( |
|
187 | + 'Registration.REG_ID' => array( 'in', $ids ) |
|
188 | + ); |
|
189 | + return $this->get_all( array( $_where ) ); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | 193 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -257,7 +257,7 @@ |
||
257 | 257 | * @param int $TXN_ID |
258 | 258 | * @param int $ATT_ID |
259 | 259 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
260 | - * @return mixed array on success, FALSE on fail |
|
260 | + * @return EE_Base_Class|null array on success, FALSE on fail |
|
261 | 261 | */ |
262 | 262 | public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
263 | 263 | return $this->get_one(array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * |
@@ -21,60 +21,60 @@ discard block |
||
21 | 21 | * Please instead use the EEM_Attendee::system_question_* constants |
22 | 22 | * @deprecated |
23 | 23 | */ |
24 | - const fname_question_id=1; |
|
24 | + const fname_question_id = 1; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @deprecated |
28 | 28 | */ |
29 | - const lname_question_id=2; |
|
29 | + const lname_question_id = 2; |
|
30 | 30 | |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @deprecated |
34 | 34 | */ |
35 | - const email_question_id=3; |
|
35 | + const email_question_id = 3; |
|
36 | 36 | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @deprecated |
40 | 40 | */ |
41 | - const address_question_id=4; |
|
41 | + const address_question_id = 4; |
|
42 | 42 | |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @deprecated |
46 | 46 | */ |
47 | - const address2_question_id=5; |
|
47 | + const address2_question_id = 5; |
|
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @deprecated |
52 | 52 | */ |
53 | - const city_question_id=6; |
|
53 | + const city_question_id = 6; |
|
54 | 54 | |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @deprecated |
58 | 58 | */ |
59 | - const state_question_id=7; |
|
59 | + const state_question_id = 7; |
|
60 | 60 | |
61 | 61 | |
62 | 62 | /** |
63 | 63 | * @deprecated |
64 | 64 | */ |
65 | - const country_question_id=8; |
|
65 | + const country_question_id = 8; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @deprecated |
70 | 70 | */ |
71 | - const zip_question_id=9; |
|
71 | + const zip_question_id = 9; |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @deprecated |
76 | 76 | */ |
77 | - const phone_question_id=10; |
|
77 | + const phone_question_id = 10; |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * When looking for questions that correspond to attendee fields, |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @access protected |
120 | 120 | * @param null $timezone |
121 | 121 | */ |
122 | - protected function __construct( $timezone = NULL ) { |
|
123 | - $this->singular_item = __('Attendee','event_espresso'); |
|
124 | - $this->plural_item = __('Attendees','event_espresso'); |
|
122 | + protected function __construct($timezone = NULL) { |
|
123 | + $this->singular_item = __('Attendee', 'event_espresso'); |
|
124 | + $this->plural_item = __('Attendees', 'event_espresso'); |
|
125 | 125 | $this->_tables = array( |
126 | 126 | 'Attendee_CPT'=> new EE_Primary_Table('posts', 'ID'), |
127 | 127 | 'Attendee_Meta'=>new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID') |
@@ -132,40 +132,40 @@ discard block |
||
132 | 132 | 'ATT_full_name'=>new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"), false, __("Unknown", "event_espresso")), |
133 | 133 | 'ATT_bio'=>new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"), false, __("No Biography Provided", "event_espresso")), |
134 | 134 | 'ATT_slug'=>new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false), |
135 | - 'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, EE_Datetime_Field::now ), |
|
135 | + 'ATT_created'=>new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, EE_Datetime_Field::now), |
|
136 | 136 | 'ATT_short_bio'=>new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), |
137 | - 'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, EE_Datetime_Field::now ), |
|
138 | - 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false ), |
|
137 | + 'ATT_modified'=>new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), FALSE, EE_Datetime_Field::now), |
|
138 | + 'ATT_author'=>new EE_WP_User_Field('post_author', __("Creator ID of the first Event attended", "event_espresso"), false), |
|
139 | 139 | 'ATT_parent'=>new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), false, 0), |
140 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'),// EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
140 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_attendees'), // EE_DB_Only_Text_Field('post_type', __("Post Type of Attendee", "event_espresso"), false,'espresso_attendees'), |
|
141 | 141 | 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish') |
142 | 142 | ), |
143 | 143 | 'Attendee_Meta'=>array( |
144 | - 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID','event_espresso'), false), |
|
144 | + 'ATTM_ID'=> new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false), |
|
145 | 145 | 'ATT_ID_fk'=>new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false), |
146 | - 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name','event_espresso'), true, ''), |
|
147 | - 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name','event_espresso'), true, ''), |
|
148 | - 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1','event_espresso'), true, ''), |
|
149 | - 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2','event_espresso'), true, ''), |
|
150 | - 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City','event_espresso'), true, ''), |
|
151 | - 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State','event_espresso'), true,0,'State'), |
|
152 | - 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country','event_espresso'), true,'','Country'), |
|
153 | - 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code','event_espresso'), true, ''), |
|
154 | - 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address','event_espresso'), true, ''), |
|
155 | - 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone','event_espresso'), true, '') |
|
146 | + 'ATT_fname'=>new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), |
|
147 | + 'ATT_lname'=>new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), |
|
148 | + 'ATT_address'=>new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''), |
|
149 | + 'ATT_address2'=>new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''), |
|
150 | + 'ATT_city'=>new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), |
|
151 | + 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'), |
|
152 | + 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'), |
|
153 | + 'ATT_zip'=>new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), |
|
154 | + 'ATT_email'=>new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), |
|
155 | + 'ATT_phone'=>new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '') |
|
156 | 156 | )); |
157 | 157 | $this->_model_relations = array( |
158 | 158 | 'Registration'=>new EE_Has_Many_Relation(), |
159 | 159 | 'State'=>new EE_Belongs_To_Relation(), |
160 | 160 | 'Country'=>new EE_Belongs_To_Relation(), |
161 | - 'Event'=>new EE_HABTM_Relation('Registration', FALSE ), |
|
161 | + 'Event'=>new EE_HABTM_Relation('Registration', FALSE), |
|
162 | 162 | 'WP_User' => new EE_Belongs_To_Relation(), |
163 | - 'Message' => new EE_Has_Many_Any_Relation( false ), //allow deletion of attendees even if they have messages in the queue for them. |
|
163 | + 'Message' => new EE_Has_Many_Any_Relation(false), //allow deletion of attendees even if they have messages in the queue for them. |
|
164 | 164 | 'Term_Relationship' => new EE_Has_Many_Relation(), |
165 | 165 | 'Term_Taxonomy'=>new EE_HABTM_Relation('Term_Relationship'), |
166 | 166 | ); |
167 | 167 | $this->_caps_slug = 'contacts'; |
168 | - parent::__construct( $timezone ); |
|
168 | + parent::__construct($timezone); |
|
169 | 169 | |
170 | 170 | } |
171 | 171 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | * @param string $system_question_string |
176 | 176 | * @return string|null if not found |
177 | 177 | */ |
178 | - public function get_attendee_field_for_system_question( $system_question_string ) { |
|
179 | - return isset( $this->_system_question_to_attendee_field_name[ $system_question_string ] ) ? $this->_system_question_to_attendee_field_name[ $system_question_string ] : null; |
|
178 | + public function get_attendee_field_for_system_question($system_question_string) { |
|
179 | + return isset($this->_system_question_to_attendee_field_name[$system_question_string]) ? $this->_system_question_to_attendee_field_name[$system_question_string] : null; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param EE_Transaction/int $transaction_id_or_obj EE_Transaction or its ID |
188 | 188 | * @return EE_Attendee[] |
189 | 189 | */ |
190 | - public function get_attendees_for_transaction( $transaction_id_or_obj ){ |
|
191 | - return $this->get_all( array( array( |
|
190 | + public function get_attendees_for_transaction($transaction_id_or_obj) { |
|
191 | + return $this->get_all(array(array( |
|
192 | 192 | 'Registration.Transaction.TXN_ID' => $transaction_id_or_obj instanceof EE_Transaction ? $transaction_id_or_obj->ID() : $transaction_id_or_obj |
193 | 193 | ))); |
194 | 194 | } |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | * @return mixed array on success, FALSE on fail |
204 | 204 | * @deprecated |
205 | 205 | */ |
206 | - public function get_attendee_by_ID( $ATT_ID = FALSE ) { |
|
206 | + public function get_attendee_by_ID($ATT_ID = FALSE) { |
|
207 | 207 | // retrieve a particular EE_Attendee |
208 | - return $this->get_one_by_ID( $ATT_ID ); |
|
208 | + return $this->get_one_by_ID($ATT_ID); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param array $where_cols_n_values |
219 | 219 | * @return mixed array on success, FALSE on fail |
220 | 220 | */ |
221 | - public function get_attendee( $where_cols_n_values = array() ) { |
|
221 | + public function get_attendee($where_cols_n_values = array()) { |
|
222 | 222 | |
223 | - if ( empty( $where_cols_n_values )) { |
|
223 | + if (empty($where_cols_n_values)) { |
|
224 | 224 | return FALSE; |
225 | 225 | } |
226 | - $attendee = $this->get_all( array($where_cols_n_values )); |
|
227 | - if ( ! empty( $attendee )) { |
|
228 | - return array_shift( $attendee ); |
|
226 | + $attendee = $this->get_all(array($where_cols_n_values)); |
|
227 | + if ( ! empty($attendee)) { |
|
228 | + return array_shift($attendee); |
|
229 | 229 | } else { |
230 | 230 | return FALSE; |
231 | 231 | } |
@@ -241,20 +241,20 @@ discard block |
||
241 | 241 | * @param array $where_cols_n_values |
242 | 242 | * @return bool|mixed |
243 | 243 | */ |
244 | - public function find_existing_attendee( $where_cols_n_values = NULL ) { |
|
244 | + public function find_existing_attendee($where_cols_n_values = NULL) { |
|
245 | 245 | // search by combo of first and last names plus the email address |
246 | - $attendee_data_keys = array( 'ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email ); |
|
246 | + $attendee_data_keys = array('ATT_fname' => $this->_ATT_fname, 'ATT_lname' => $this->_ATT_lname, 'ATT_email' => $this->_ATT_email); |
|
247 | 247 | // no search params means attendee object already exists. |
248 | - $where_cols_n_values = is_array( $where_cols_n_values ) && ! empty( $where_cols_n_values ) ? $where_cols_n_values : $attendee_data_keys; |
|
248 | + $where_cols_n_values = is_array($where_cols_n_values) && ! empty($where_cols_n_values) ? $where_cols_n_values : $attendee_data_keys; |
|
249 | 249 | $valid_data = TRUE; |
250 | 250 | // check for required values |
251 | - $valid_data = isset( $where_cols_n_values['ATT_fname'] ) && ! empty( $where_cols_n_values['ATT_fname'] ) ? $valid_data : FALSE; |
|
252 | - $valid_data = isset( $where_cols_n_values['ATT_lname'] ) && ! empty( $where_cols_n_values['ATT_lname'] ) ? $valid_data : FALSE; |
|
253 | - $valid_data = isset( $where_cols_n_values['ATT_email'] ) && ! empty( $where_cols_n_values['ATT_email'] ) ? $valid_data : FALSE; |
|
251 | + $valid_data = isset($where_cols_n_values['ATT_fname']) && ! empty($where_cols_n_values['ATT_fname']) ? $valid_data : FALSE; |
|
252 | + $valid_data = isset($where_cols_n_values['ATT_lname']) && ! empty($where_cols_n_values['ATT_lname']) ? $valid_data : FALSE; |
|
253 | + $valid_data = isset($where_cols_n_values['ATT_email']) && ! empty($where_cols_n_values['ATT_email']) ? $valid_data : FALSE; |
|
254 | 254 | |
255 | - if ( $valid_data ) { |
|
256 | - $attendee = $this->get_attendee( $where_cols_n_values ); |
|
257 | - if ( $attendee instanceof EE_Attendee ) { |
|
255 | + if ($valid_data) { |
|
256 | + $attendee = $this->get_attendee($where_cols_n_values); |
|
257 | + if ($attendee instanceof EE_Attendee) { |
|
258 | 258 | return $attendee; |
259 | 259 | } |
260 | 260 | } |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * @param array $ids array of EE_Registration ids |
273 | 273 | * @return EE_Attendee[] |
274 | 274 | */ |
275 | - public function get_array_of_contacts_from_reg_ids( $ids ) { |
|
275 | + public function get_array_of_contacts_from_reg_ids($ids) { |
|
276 | 276 | $ids = (array) $ids; |
277 | 277 | $_where = array( |
278 | - 'Registration.REG_ID' => array( 'in', $ids ) |
|
278 | + 'Registration.REG_ID' => array('in', $ids) |
|
279 | 279 | ); |
280 | - return $this->get_all( array( $_where ) ); |
|
280 | + return $this->get_all(array($_where)); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $field = $this->get_a_field_of_type('EE_WP_Post_Status_Field'); |
119 | 119 | if($field){ |
120 | 120 | return $field->get_name(); |
121 | - }else{ |
|
121 | + } else{ |
|
122 | 122 | throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
123 | 123 | } |
124 | 124 | } |
@@ -193,14 +193,16 @@ discard block |
||
193 | 193 | public function get_meta_table_fields( $all = FALSE ) { |
194 | 194 | $all_fields = $fields_to_return = array(); |
195 | 195 | foreach ( $this->_tables as $alias => $table_obj ) { |
196 | - if ( $table_obj instanceof EE_Secondary_Table ) |
|
197 | - $all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields ); |
|
196 | + if ( $table_obj instanceof EE_Secondary_Table ) { |
|
197 | + $all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields ); |
|
198 | + } |
|
198 | 199 | } |
199 | 200 | |
200 | 201 | if ( !$all ) { |
201 | 202 | foreach ( $all_fields as $name => $obj ) { |
202 | - if ( $obj instanceof EE_DB_Only_Field_Base ) |
|
203 | - continue; |
|
203 | + if ( $obj instanceof EE_DB_Only_Field_Base ) { |
|
204 | + continue; |
|
205 | + } |
|
204 | 206 | $fields_to_return[] = $name; |
205 | 207 | } |
206 | 208 | } else { |
@@ -248,7 +250,7 @@ discard block |
||
248 | 250 | 'parent'=>$parent_term_taxonomy_id |
249 | 251 | )); |
250 | 252 | $term_taxonomy->save(); |
251 | - }else{ |
|
253 | + } else{ |
|
252 | 254 | $term_taxonomy->set_count($term_taxonomy->count() + 1); |
253 | 255 | $term_taxonomy->save(); |
254 | 256 | } |
@@ -366,7 +368,7 @@ discard block |
||
366 | 368 | if( ! $has_all_necessary_fields_for_table){ |
367 | 369 | |
368 | 370 | return $this->get_one_by_ID($post['ID']); |
369 | - }else{ |
|
371 | + } else{ |
|
370 | 372 | return $this->instantiate_class_from_array_or_object($post); |
371 | 373 | } |
372 | 374 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -define('EE_Event_Category_Taxonomy','espresso_event_category'); |
|
2 | +define('EE_Event_Category_Taxonomy', 'espresso_event_category'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EEM_CPT_Base |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @author Mike Nelson |
17 | 17 | * |
18 | 18 | */ |
19 | -abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{ |
|
19 | +abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var string post_status_publish - the wp post status for published cpts |
@@ -69,55 +69,55 @@ discard block |
||
69 | 69 | * @param string $timezone |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - protected function __construct( $timezone = NULL ){ |
|
72 | + protected function __construct($timezone = NULL) { |
|
73 | 73 | |
74 | 74 | //adds a relationship to Term_Taxonomy for all these models. For this to work |
75 | 75 | //Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly |
76 | 76 | //eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry |
77 | 77 | //with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value |
78 | 78 | //must also be new EE_HABTM_Relation('Term_Relationship'); |
79 | - $this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship'); |
|
79 | + $this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship'); |
|
80 | 80 | $primary_table_name = NULL; |
81 | 81 | //add the common _status field to all CPT primary tables. |
82 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
83 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
82 | + foreach ($this->_tables as $alias => $table_obj) { |
|
83 | + if ($table_obj instanceof EE_Primary_Table) { |
|
84 | 84 | $primary_table_name = $alias; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | //set default wp post statuses if child has not already set. |
88 | - if ( ! isset( $this->_fields[$primary_table_name]['status'] )) { |
|
88 | + if ( ! isset($this->_fields[$primary_table_name]['status'])) { |
|
89 | 89 | $this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft'); |
90 | 90 | } |
91 | - if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){ |
|
92 | - $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, ''); |
|
91 | + if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) { |
|
92 | + $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, ''); |
|
93 | 93 | } |
94 | - if( ! isset( $this->_fields[$primary_table_name]['pinged'])){ |
|
95 | - $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, ''); |
|
94 | + if ( ! isset($this->_fields[$primary_table_name]['pinged'])) { |
|
95 | + $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, ''); |
|
96 | 96 | } |
97 | 97 | |
98 | - if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){ |
|
99 | - $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open'); |
|
98 | + if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) { |
|
99 | + $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open'); |
|
100 | 100 | } |
101 | 101 | |
102 | - if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){ |
|
102 | + if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) { |
|
103 | 103 | $this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open'); |
104 | 104 | } |
105 | 105 | |
106 | - if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){ |
|
107 | - $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, ''); |
|
106 | + if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) { |
|
107 | + $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, ''); |
|
108 | 108 | } |
109 | - if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) { |
|
109 | + if ( ! isset($this->_model_relations['Post_Meta'])) { |
|
110 | 110 | //don't block deletes though because we want to maintain the current behaviour |
111 | - $this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false ); |
|
111 | + $this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false); |
|
112 | 112 | } |
113 | - if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
113 | + if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
114 | 114 | //nothing was set during child constructor, so set default |
115 | - $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() ); |
|
115 | + $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type()); |
|
116 | 116 | } |
117 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) { |
|
117 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
118 | 118 | //nothing was set during child constructor, so set default |
119 | 119 | //it's ok for child classes to specify this, but generally this is more DRY |
120 | - $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() ); |
|
120 | + $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type()); |
|
121 | 121 | } |
122 | 122 | parent::__construct($timezone); |
123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function public_event_stati() { |
132 | 132 | // @see wp-includes/post.php |
133 | - return get_post_stati( array( 'public' => TRUE )); |
|
133 | + return get_post_stati(array('public' => TRUE)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return string |
142 | 142 | * @throws EE_Error |
143 | 143 | */ |
144 | - public function deleted_field_name(){ |
|
144 | + public function deleted_field_name() { |
|
145 | 145 | throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso"))); |
146 | 146 | } |
147 | 147 | |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @throws EE_Error |
154 | 154 | */ |
155 | - public function post_status_field_name(){ |
|
155 | + public function post_status_field_name() { |
|
156 | 156 | $field = $this->get_a_field_of_type('EE_WP_Post_Status_Field'); |
157 | - if($field){ |
|
157 | + if ($field) { |
|
158 | 158 | return $field->get_name(); |
159 | - }else{ |
|
160 | - throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
159 | + } else { |
|
160 | + throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | * @param array $query_params like EEM_Base::get_all's $query_params |
169 | 169 | * @return array like EEM_Base::get_all's $query_params |
170 | 170 | */ |
171 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
172 | - $post_status_field_name=$this->post_status_field_name(); |
|
173 | - $query_params[0][$post_status_field_name]=self::post_status_trashed; |
|
171 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
172 | + $post_status_field_name = $this->post_status_field_name(); |
|
173 | + $query_params[0][$post_status_field_name] = self::post_status_trashed; |
|
174 | 174 | return $query_params; |
175 | 175 | } |
176 | 176 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
185 | - $query_params[ 'default_where_conditions' ] = 'minimum'; |
|
184 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
185 | + $query_params['default_where_conditions'] = 'minimum'; |
|
186 | 186 | return $query_params; |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | * @param array $query_params like EEM_Base::get_all |
195 | 195 | * @return boolean success |
196 | 196 | */ |
197 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
198 | - $post_status_field_name=$this->post_status_field_name(); |
|
197 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
198 | + $post_status_field_name = $this->post_status_field_name(); |
|
199 | 199 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
200 | 200 | $new_status = $delete ? self::post_status_trashed : 'draft'; |
201 | - if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) { |
|
201 | + if ($this->update(array($post_status_field_name=>$new_status), $query_params)) { |
|
202 | 202 | return TRUE; |
203 | 203 | } else { |
204 | 204 | return FALSE; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function meta_table() { |
217 | 217 | $meta_table = $this->_get_other_tables(); |
218 | - $meta_table = reset( $meta_table ); |
|
218 | + $meta_table = reset($meta_table); |
|
219 | 219 | return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL; |
220 | 220 | } |
221 | 221 | |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | * @param bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields. Defaults to false (no db only fields) |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public function get_meta_table_fields( $all = FALSE ) { |
|
230 | + public function get_meta_table_fields($all = FALSE) { |
|
231 | 231 | $all_fields = $fields_to_return = array(); |
232 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
233 | - if ( $table_obj instanceof EE_Secondary_Table ) |
|
234 | - $all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields ); |
|
232 | + foreach ($this->_tables as $alias => $table_obj) { |
|
233 | + if ($table_obj instanceof EE_Secondary_Table) |
|
234 | + $all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields); |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( !$all ) { |
|
238 | - foreach ( $all_fields as $name => $obj ) { |
|
239 | - if ( $obj instanceof EE_DB_Only_Field_Base ) |
|
237 | + if ( ! $all) { |
|
238 | + foreach ($all_fields as $name => $obj) { |
|
239 | + if ($obj instanceof EE_DB_Only_Field_Base) |
|
240 | 240 | continue; |
241 | 241 | $fields_to_return[] = $name; |
242 | 242 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $parent_term_taxonomy_id |
260 | 260 | * @return EE_Term_Taxonomy |
261 | 261 | */ |
262 | - function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){ |
|
262 | + function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) { |
|
263 | 263 | //create term |
264 | - require_once( EE_MODELS . 'EEM_Term.model.php'); |
|
264 | + require_once(EE_MODELS.'EEM_Term.model.php'); |
|
265 | 265 | //first, check for a term by the same name or slug |
266 | 266 | $category_slug = sanitize_title($category_name); |
267 | - $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug)))); |
|
268 | - if( ! $term ){ |
|
267 | + $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug)))); |
|
268 | + if ( ! $term) { |
|
269 | 269 | $term = EE_Term::new_instance(array( |
270 | 270 | 'name'=>$category_name, |
271 | 271 | 'slug'=>$category_slug |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | $term->save(); |
274 | 274 | } |
275 | 275 | //make sure there's a term-taxonomy entry too |
276 | - require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php'); |
|
277 | - $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
276 | + require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php'); |
|
277 | + $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
278 | 278 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
279 | - if( ! $term_taxonomy ){ |
|
279 | + if ( ! $term_taxonomy) { |
|
280 | 280 | $term_taxonomy = EE_Term_Taxonomy::new_instance(array( |
281 | 281 | 'term_id'=>$term->ID(), |
282 | 282 | 'taxonomy'=>EE_Event_Category_Taxonomy, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'parent'=>$parent_term_taxonomy_id |
286 | 286 | )); |
287 | 287 | $term_taxonomy->save(); |
288 | - }else{ |
|
288 | + } else { |
|
289 | 289 | $term_taxonomy->set_count($term_taxonomy->count() + 1); |
290 | 290 | $term_taxonomy->save(); |
291 | 291 | } |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | * @param string $category_name name of the event category (term) |
301 | 301 | * @return bool |
302 | 302 | */ |
303 | - function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){ |
|
303 | + function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) { |
|
304 | 304 | //find the term_taxonomy by that name |
305 | - $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
305 | + $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
306 | 306 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
307 | - if( $term_taxonomy ){ |
|
307 | + if ($term_taxonomy) { |
|
308 | 308 | $term_taxonomy->set_count($term_taxonomy->count() - 1); |
309 | 309 | $term_taxonomy->save(); |
310 | 310 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @param string|array $attr Optional. Query string or array of attributes. |
325 | 325 | * @return string HTML image element |
326 | 326 | */ |
327 | - public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) { |
|
328 | - return get_the_post_thumbnail( $id, $size, $attr ); |
|
327 | + public function get_feature_image($id, $size = 'thumbnail', $attr = '') { |
|
328 | + return get_the_post_thumbnail($id, $size, $attr); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | * @global array $wp_post_statuses set in wp core for storing all the post stati |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public function get_post_statuses(){ |
|
341 | + public function get_post_statuses() { |
|
342 | 342 | global $wp_post_statuses; |
343 | 343 | $statuses = array(); |
344 | - foreach($wp_post_statuses as $post_status => $args_object){ |
|
344 | + foreach ($wp_post_statuses as $post_status => $args_object) { |
|
345 | 345 | $statuses[$post_status] = $args_object->label; |
346 | 346 | } |
347 | 347 | return $statuses; |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | public function get_status_array() { |
357 | 357 | $statuses = $this->get_post_statuses(); |
358 | 358 | //first the global filter |
359 | - $statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses ); |
|
359 | + $statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses); |
|
360 | 360 | //now the class specific filter |
361 | - $statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses ); |
|
361 | + $statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses); |
|
362 | 362 | return $statuses; |
363 | 363 | } |
364 | 364 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function get_custom_post_statuses() { |
372 | 372 | $new_stati = array(); |
373 | - foreach ( $this->_custom_stati as $status => $props ) { |
|
373 | + foreach ($this->_custom_stati as $status => $props) { |
|
374 | 374 | $new_stati[$status] = $props['label']; |
375 | 375 | } |
376 | 376 | return $new_stati; |
@@ -386,24 +386,24 @@ discard block |
||
386 | 386 | * @param WP_Post|array $post |
387 | 387 | * @return EE_CPT_Base |
388 | 388 | */ |
389 | - public function instantiate_class_from_post_object_orig($post){ |
|
390 | - $post = (array)$post; |
|
389 | + public function instantiate_class_from_post_object_orig($post) { |
|
390 | + $post = (array) $post; |
|
391 | 391 | $has_all_necessary_fields_for_table = true; |
392 | 392 | //check if the post has fields on the meta table already |
393 | - foreach($this->_get_other_tables() as $table_obj){ |
|
393 | + foreach ($this->_get_other_tables() as $table_obj) { |
|
394 | 394 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
395 | - foreach($fields_for_that_table as $field_obj){ |
|
396 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
397 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
395 | + foreach ($fields_for_that_table as $field_obj) { |
|
396 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
397 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
398 | 398 | $has_all_necessary_fields_for_table = false; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | 402 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
403 | - if( ! $has_all_necessary_fields_for_table){ |
|
403 | + if ( ! $has_all_necessary_fields_for_table) { |
|
404 | 404 | |
405 | 405 | return $this->get_one_by_ID($post['ID']); |
406 | - }else{ |
|
406 | + } else { |
|
407 | 407 | return $this->instantiate_class_from_array_or_object($post); |
408 | 408 | } |
409 | 409 | } |
@@ -414,30 +414,30 @@ discard block |
||
414 | 414 | * @param null $post |
415 | 415 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class |
416 | 416 | */ |
417 | - public function instantiate_class_from_post_object( $post = NULL ){ |
|
418 | - if ( empty( $post )) { |
|
417 | + public function instantiate_class_from_post_object($post = NULL) { |
|
418 | + if (empty($post)) { |
|
419 | 419 | global $post; |
420 | 420 | } |
421 | - $post = (array)$post; |
|
421 | + $post = (array) $post; |
|
422 | 422 | $tables_needing_to_be_queried = array(); |
423 | 423 | //check if the post has fields on the meta table already |
424 | - foreach($this->get_tables() as $table_obj){ |
|
424 | + foreach ($this->get_tables() as $table_obj) { |
|
425 | 425 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
426 | - foreach($fields_for_that_table as $field_obj){ |
|
427 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
428 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
426 | + foreach ($fields_for_that_table as $field_obj) { |
|
427 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
428 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
429 | 429 | $tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | 433 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
434 | - if( $tables_needing_to_be_queried){ |
|
435 | - if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){ |
|
434 | + if ($tables_needing_to_be_queried) { |
|
435 | + if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) { |
|
436 | 436 | //so we're only missing data from a secondary table. Well that's not too hard to query for |
437 | 437 | $table_to_query = reset($tables_needing_to_be_queried); |
438 | - $missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A )); |
|
439 | - if ( ! empty( $missing_data )) { |
|
440 | - $post = array_merge( $post, $missing_data ); |
|
438 | + $missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A)); |
|
439 | + if ( ! empty($missing_data)) { |
|
440 | + $post = array_merge($post, $missing_data); |
|
441 | 441 | } |
442 | 442 | } else { |
443 | 443 | return $this->get_one_by_ID($post['ID']); |
@@ -454,15 +454,15 @@ discard block |
||
454 | 454 | * @throws EE_Error |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function post_type(){ |
|
457 | + public function post_type() { |
|
458 | 458 | $post_type_field = NULL; |
459 | - foreach($this->field_settings(true) as $field_obj){ |
|
460 | - if($field_obj instanceof EE_WP_Post_Type_Field){ |
|
461 | - $post_type_field = $field_obj;break; |
|
459 | + foreach ($this->field_settings(true) as $field_obj) { |
|
460 | + if ($field_obj instanceof EE_WP_Post_Type_Field) { |
|
461 | + $post_type_field = $field_obj; break; |
|
462 | 462 | } |
463 | 463 | } |
464 | - if($post_type_field == NULL){ |
|
465 | - throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this))); |
|
464 | + if ($post_type_field == NULL) { |
|
465 | + throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this))); |
|
466 | 466 | } |
467 | 467 | return $post_type_field->get_default_value(); |
468 | 468 | } |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | |
84 | 84 | |
85 | 85 | /** |
86 | - * _get_countries |
|
87 | - * |
|
88 | - * @access public |
|
89 | - * @return array |
|
90 | - */ |
|
86 | + * _get_countries |
|
87 | + * |
|
88 | + * @access public |
|
89 | + * @return array |
|
90 | + */ |
|
91 | 91 | public function get_all_countries() { |
92 | 92 | if ( ! self::$_all_countries ) { |
93 | 93 | self::$_all_countries = $this->get_all( array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 ))); |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * _get_countries |
|
100 | - * Gets and caches the list of active countries. If you know the list of active countries |
|
101 | - * has changed during this request, first use EEM_Country::reset() to flush the cache |
|
102 | - * @access public |
|
103 | - * @return array |
|
104 | - */ |
|
99 | + * _get_countries |
|
100 | + * Gets and caches the list of active countries. If you know the list of active countries |
|
101 | + * has changed during this request, first use EEM_Country::reset() to flush the cache |
|
102 | + * @access public |
|
103 | + * @return array |
|
104 | + */ |
|
105 | 105 | public function get_all_active_countries() { |
106 | 106 | if ( ! self::$_active_countries ) { |
107 | 107 | self::$_active_countries = $this->get_all( array( array( 'CNT_active' => TRUE ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 ))); |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | * Resets the country |
37 | 37 | * @return EEM_Country |
38 | 38 | */ |
39 | - public static function reset( $timezone = NULL ){ |
|
39 | + public static function reset($timezone = NULL) { |
|
40 | 40 | self::$_active_countries = NULL; |
41 | 41 | self::$_all_countries = NULL; |
42 | - return parent::reset( $timezone ); |
|
42 | + return parent::reset($timezone); |
|
43 | 43 | } |
44 | 44 | |
45 | - protected function __construct( $timezone = NULL ){ |
|
46 | - $this->singular_item = __('Country','event_espresso'); |
|
47 | - $this->plural_item = __('Countries','event_espresso'); |
|
45 | + protected function __construct($timezone = NULL) { |
|
46 | + $this->singular_item = __('Country', 'event_espresso'); |
|
47 | + $this->plural_item = __('Countries', 'event_espresso'); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | $this->_tables = array( |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | ); |
53 | 53 | $this->_fields = array( |
54 | 54 | 'Country'=>array( |
55 | - 'CNT_active' => new EE_Boolean_Field('CNT_active', __('Country Appears in Dropdown Select Lists','event_espresso'), false, true), |
|
56 | - 'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', __('Country ISO Code','event_espresso')), |
|
57 | - 'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', __('Country ISO3 Code','event_espresso'), false,''), |
|
58 | - 'RGN_ID'=>new EE_Integer_Field('RGN_ID', __('Region ID','event_espresso'), false,0),//should be a foreign key, but no region table exists yet |
|
59 | - 'CNT_name'=>new EE_Plain_Text_Field('CNT_name', __('Country Name','event_espresso'), false,''), |
|
60 | - 'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', __('Country Currency Code','event_espresso'), false), |
|
61 | - 'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', __('Currency Name Singular','event_espresso'), false), |
|
62 | - 'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', __('Currency Name Plural','event_espresso'), false), |
|
63 | - 'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', __('Currency Sign','event_espresso'), false), |
|
64 | - 'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', __('Currency Sign Before Number','event_espresso'), false, true), |
|
65 | - 'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', __('Currency Decimal Places','event_espresso'), false, 2), |
|
66 | - 'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', __('Currency Decimal Mark','event_espresso'), false, '.'), |
|
67 | - 'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', __('Currency Thousands Seperator','event_espresso'), false, ','), |
|
68 | - 'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', __('Country Telephone Code','event_espresso'), false, ''), |
|
69 | - 'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', __('Country is Member of EU','event_espresso'), false, false) |
|
55 | + 'CNT_active' => new EE_Boolean_Field('CNT_active', __('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true), |
|
56 | + 'CNT_ISO'=> new EE_Primary_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso')), |
|
57 | + 'CNT_ISO3'=>new EE_All_Caps_Text_Field('CNT_ISO3', __('Country ISO3 Code', 'event_espresso'), false, ''), |
|
58 | + 'RGN_ID'=>new EE_Integer_Field('RGN_ID', __('Region ID', 'event_espresso'), false, 0), //should be a foreign key, but no region table exists yet |
|
59 | + 'CNT_name'=>new EE_Plain_Text_Field('CNT_name', __('Country Name', 'event_espresso'), false, ''), |
|
60 | + 'CNT_cur_code'=>new EE_All_Caps_Text_Field('CNT_cur_code', __('Country Currency Code', 'event_espresso'), false), |
|
61 | + 'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', __('Currency Name Singular', 'event_espresso'), false), |
|
62 | + 'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', __('Currency Name Plural', 'event_espresso'), false), |
|
63 | + 'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', __('Currency Sign', 'event_espresso'), false), |
|
64 | + 'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', __('Currency Sign Before Number', 'event_espresso'), false, true), |
|
65 | + 'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2), |
|
66 | + 'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', __('Currency Decimal Mark', 'event_espresso'), false, '.'), |
|
67 | + 'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', __('Currency Thousands Seperator', 'event_espresso'), false, ','), |
|
68 | + 'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', __('Country Telephone Code', 'event_espresso'), false, ''), |
|
69 | + 'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', __('Country is Member of EU', 'event_espresso'), false, false) |
|
70 | 70 | )); |
71 | 71 | $this->_model_relations = array( |
72 | 72 | 'Attendee'=>new EE_Has_Many_Relation(), |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | 'Venue'=>new EE_Has_Many_Relation(), |
75 | 75 | ); |
76 | 76 | //only anyone to view, but only those with the default role can do anything |
77 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
77 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
78 | 78 | |
79 | - parent::__construct( $timezone ); |
|
79 | + parent::__construct($timezone); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @return array |
90 | 90 | */ |
91 | 91 | public function get_all_countries() { |
92 | - if ( ! self::$_all_countries ) { |
|
93 | - self::$_all_countries = $this->get_all( array( 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array( 0,99999 ))); |
|
92 | + if ( ! self::$_all_countries) { |
|
93 | + self::$_all_countries = $this->get_all(array('order_by'=>array('CNT_name'=>'ASC'), 'limit'=> array(0, 99999))); |
|
94 | 94 | } |
95 | 95 | return self::$_all_countries; |
96 | 96 | } |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * @return array |
104 | 104 | */ |
105 | 105 | public function get_all_active_countries() { |
106 | - if ( ! self::$_active_countries ) { |
|
107 | - self::$_active_countries = $this->get_all( array( array( 'CNT_active' => TRUE ), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array( 0, 99999 ))); |
|
106 | + if ( ! self::$_active_countries) { |
|
107 | + self::$_active_countries = $this->get_all(array(array('CNT_active' => TRUE), 'order_by'=>array('CNT_name'=>'ASC'), 'limit'=>array(0, 99999))); |
|
108 | 108 | } |
109 | 109 | return self::$_active_countries; |
110 | 110 | } |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @param string $country_ISO |
115 | 115 | * @return string |
116 | 116 | */ |
117 | - public function get_country_name_by_ISO( $country_ISO ){ |
|
118 | - if( isset( self::$_all_countries[ $country_ISO ] ) && |
|
119 | - self::$_all_countries[ $country_ISO ] instanceof EE_Country ){ |
|
120 | - return self::$_all_countries[ $country_ISO ]->name(); |
|
117 | + public function get_country_name_by_ISO($country_ISO) { |
|
118 | + if (isset(self::$_all_countries[$country_ISO]) && |
|
119 | + self::$_all_countries[$country_ISO] instanceof EE_Country) { |
|
120 | + return self::$_all_countries[$country_ISO]->name(); |
|
121 | 121 | } |
122 | - $names = $this->get_col( array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name' ); |
|
123 | - if( is_array( $names ) && ! empty( $names ) ){ |
|
124 | - return reset( $names ); |
|
125 | - }else{ |
|
122 | + $names = $this->get_col(array(array('CNT_ISO' => $country_ISO), 'limit' => 1), 'CNT_name'); |
|
123 | + if (is_array($names) && ! empty($names)) { |
|
124 | + return reset($names); |
|
125 | + } else { |
|
126 | 126 | return ''; |
127 | 127 | } |
128 | 128 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,22 +25,22 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EEM_Currency_Payment_Method extends EEM_Base{ |
|
28 | +class EEM_Currency_Payment_Method extends EEM_Base { |
|
29 | 29 | // private instance of the Attendee object |
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | 32 | |
33 | - protected function __construct( $timezone = NULL ) { |
|
34 | - $this->singular_item = __('Currency Usable by Payment Method','event_espresso'); |
|
35 | - $this->plural_item = __('Currencies Usable by Payment Methods','event_espresso'); |
|
33 | + protected function __construct($timezone = NULL) { |
|
34 | + $this->singular_item = __('Currency Usable by Payment Method', 'event_espresso'); |
|
35 | + $this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso'); |
|
36 | 36 | $this->_tables = array( |
37 | - 'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method','CPM_ID') |
|
37 | + 'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID') |
|
38 | 38 | ); |
39 | 39 | $this->_fields = array( |
40 | 40 | 'Currency_Payment_Method'=>array( |
41 | - 'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID','event_espresso')), |
|
42 | - 'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code','event_espresso'), false, 0, 'Currency'), |
|
43 | - 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID','event_espresso'), false, 0, 'Payment_Method') |
|
41 | + 'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')), |
|
42 | + 'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, 0, 'Currency'), |
|
43 | + 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method') |
|
44 | 44 | ) |
45 | 45 | ); |
46 | 46 | $this->_model_relations = array( |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | 'Payment_Method'=>new EE_Belongs_To_Relation() |
49 | 49 | ); |
50 | 50 | //this model is generally available for reading |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
52 | 52 | $this->_caps_slug = 'payment_methods'; |
53 | - parent::__construct( $timezone ); |
|
53 | + parent::__construct($timezone); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | /** |
6 | 7 | * Event Espresso |
7 | 8 | * |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -191,7 +193,7 @@ discard block |
||
191 | 193 | $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
192 | 194 | if($results){ |
193 | 195 | return array_shift($results); |
194 | - }else{ |
|
196 | + } else{ |
|
195 | 197 | return NULL; |
196 | 198 | } |
197 | 199 | } |
@@ -318,7 +320,7 @@ discard block |
||
318 | 320 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
319 | 321 | if($results){ |
320 | 322 | return array_shift($results); |
321 | - }else{ |
|
323 | + } else{ |
|
322 | 324 | return null; |
323 | 325 | } |
324 | 326 | } |
@@ -351,7 +353,9 @@ discard block |
||
351 | 353 | break; |
352 | 354 | |
353 | 355 | case 'expired' : |
354 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
356 | + if ( isset( $where_params['Event.status'] ) ) { |
|
357 | + unset( $where_params['Event.status'] ); |
|
358 | + } |
|
355 | 359 | //get events to exclude |
356 | 360 | $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) ); |
357 | 361 | //first get all events that have datetimes where its not expired. |
@@ -378,7 +382,9 @@ discard block |
||
378 | 382 | break; |
379 | 383 | |
380 | 384 | case 'inactive' : |
381 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
385 | + if ( isset( $where_params['Event.status'] ) ) { |
|
386 | + unset( $where_params['Event.status'] ); |
|
387 | + } |
|
382 | 388 | if ( isset( $where_params['OR'] ) ) { |
383 | 389 | $where_params['AND']['OR'] = $where_params['OR']; |
384 | 390 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | |
76 | 76 | |
77 | 77 | /** |
78 | - * create new blank datetime |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
82 | - */ |
|
78 | + * create new blank datetime |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
82 | + */ |
|
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
103 | - * get event start date from db |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @param int $EVT_ID |
|
107 | - * @return EE_Datetime[] array on success, FALSE on fail |
|
108 | - */ |
|
103 | + * get event start date from db |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @param int $EVT_ID |
|
107 | + * @return EE_Datetime[] array on success, FALSE on fail |
|
108 | + */ |
|
109 | 109 | public function get_all_event_dates( $EVT_ID = 0 ) { |
110 | 110 | if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
111 | 111 | return $this->create_new_blank_datetime(); |
@@ -250,14 +250,14 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
254 | - * only by start date |
|
255 | - * @param int $TKT_ID |
|
256 | - * @param boolean $include_expired |
|
257 | - * @param boolean $include_deleted |
|
258 | - * @param int $limit |
|
259 | - * @return EE_Datetime[] |
|
260 | - */ |
|
253 | + * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered |
|
254 | + * only by start date |
|
255 | + * @param int $TKT_ID |
|
256 | + * @param boolean $include_expired |
|
257 | + * @param boolean $include_deleted |
|
258 | + * @param int $limit |
|
259 | + * @return EE_Datetime[] |
|
260 | + */ |
|
261 | 261 | public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
262 | 262 | //sanitize TKT_ID |
263 | 263 | $TKT_ID = intval( $TKT_ID ); |
@@ -443,7 +443,7 @@ |
||
443 | 443 | /** |
444 | 444 | * This returns an array of counts of datetimes in the database for each Datetime status that can be queried. |
445 | 445 | * |
446 | - * @param array $stati_to_include If included you can restrict the statuses we return counts for by including the stati |
|
446 | + * @param string[] $stati_to_include If included you can restrict the statuses we return counts for by including the stati |
|
447 | 447 | * you want counts for as values in the array. An empty array returns counts for all valid |
448 | 448 | * stati. |
449 | 449 | * @param array $query_params If included can be used to refine the conditions for returning the count (i.e. only for |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Post_Content_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
56 | 56 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
57 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
58 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
57 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
58 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
59 | 59 | )); |
60 | 60 | $this->_model_relations = array( |
61 | 61 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | ); |
65 | 65 | $this->_model_chain_to_wp_user = 'Event'; |
66 | 66 | //this model is generally available for reading |
67 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
71 | - parent::__construct( $timezone ); |
|
67 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
71 | + parent::__construct($timezone); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,16 +83,16 @@ discard block |
||
83 | 83 | public function create_new_blank_datetime() { |
84 | 84 | $blank_datetime = EE_Datetime::new_instance( |
85 | 85 | array( |
86 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
87 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
86 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
88 | 88 | 'DTT_order' => 1, |
89 | 89 | 'DTT_reg_limit' => EE_INF |
90 | 90 | ), |
91 | 91 | $this->_timezone |
92 | 92 | ); |
93 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
94 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
95 | - return array( $blank_datetime ); |
|
93 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
94 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
95 | + return array($blank_datetime); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param int $EVT_ID |
107 | 107 | * @return EE_Datetime[] array on success, FALSE on fail |
108 | 108 | */ |
109 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
110 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
109 | + public function get_all_event_dates($EVT_ID = 0) { |
|
110 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
111 | 111 | return $this->create_new_blank_datetime(); |
112 | 112 | } |
113 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
113 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | 114 | |
115 | - if ( empty( $results ) ) { |
|
115 | + if (empty($results)) { |
|
116 | 116 | return $this->create_new_blank_datetime(); |
117 | 117 | } |
118 | 118 | |
@@ -133,26 +133,26 @@ discard block |
||
133 | 133 | * the given number |
134 | 134 | * @return EE_Datetime[] |
135 | 135 | */ |
136 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
136 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
137 | 137 | |
138 | 138 | //sanitize EVT_ID |
139 | - $EVT_ID = intval( $EVT_ID ); |
|
139 | + $EVT_ID = intval($EVT_ID); |
|
140 | 140 | |
141 | 141 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
142 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
143 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
142 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
143 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
144 | 144 | |
145 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
145 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
146 | 146 | |
147 | - if( ! $include_expired){ |
|
148 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
147 | + if ( ! $include_expired) { |
|
148 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
149 | 149 | } |
150 | - if( $include_deleted){ |
|
151 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
150 | + if ($include_deleted) { |
|
151 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
152 | 152 | } |
153 | 153 | |
154 | - $result = $this->get_all( $query_params ); |
|
155 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
154 | + $result = $this->get_all($query_params); |
|
155 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
156 | 156 | return $result; |
157 | 157 | } |
158 | 158 | |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param int $limit |
168 | 168 | * @return EE_Datetime[] |
169 | 169 | */ |
170 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
171 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
170 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
171 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
172 | 172 | 'limit'=>$limit, |
173 | 173 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
174 | 174 | 'default_where_conditions' => 'none')); |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param boolean $include_deleted |
184 | 184 | * @return EE_Datetime |
185 | 185 | */ |
186 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
187 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | - if($results){ |
|
186 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
187 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
188 | + if ($results) { |
|
189 | 189 | return array_shift($results); |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | return NULL; |
192 | 192 | } |
193 | 193 | } |
@@ -201,16 +201,16 @@ discard block |
||
201 | 201 | * @param bool $try_to_exclude_deleted |
202 | 202 | * @return \EE_Datetime |
203 | 203 | */ |
204 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
205 | - if($try_to_exclude_expired){ |
|
206 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
207 | - if($non_expired){ |
|
204 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
205 | + if ($try_to_exclude_expired) { |
|
206 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
207 | + if ($non_expired) { |
|
208 | 208 | return $non_expired; |
209 | 209 | } |
210 | 210 | } |
211 | - if($try_to_exclude_deleted){ |
|
211 | + if ($try_to_exclude_deleted) { |
|
212 | 212 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
213 | - if($expired_even){ |
|
213 | + if ($expired_even) { |
|
214 | 214 | return $expired_even; |
215 | 215 | } |
216 | 216 | } |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * @param int $limit |
230 | 230 | * @return EE_Datetime[] |
231 | 231 | */ |
232 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
232 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
233 | 233 | //sanitize EVT_ID |
234 | - $EVT_ID = intval( $EVT_ID ); |
|
234 | + $EVT_ID = intval($EVT_ID); |
|
235 | 235 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
236 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
237 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | - if( ! $include_expired){ |
|
239 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
236 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
237 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
238 | + if ( ! $include_expired) { |
|
239 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
240 | 240 | } |
241 | - if( $include_deleted){ |
|
242 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
241 | + if ($include_deleted) { |
|
242 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
243 | 243 | } |
244 | - if($limit){ |
|
244 | + if ($limit) { |
|
245 | 245 | $query_params['limit'] = $limit; |
246 | 246 | } |
247 | - $result = $this->get_all( $query_params ); |
|
248 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
247 | + $result = $this->get_all($query_params); |
|
248 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
249 | 249 | return $result; |
250 | 250 | } |
251 | 251 | |
@@ -258,23 +258,23 @@ discard block |
||
258 | 258 | * @param int $limit |
259 | 259 | * @return EE_Datetime[] |
260 | 260 | */ |
261 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
261 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
262 | 262 | //sanitize TKT_ID |
263 | - $TKT_ID = intval( $TKT_ID ); |
|
263 | + $TKT_ID = intval($TKT_ID); |
|
264 | 264 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
265 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
266 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | - if( ! $include_expired){ |
|
268 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
265 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
266 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
267 | + if ( ! $include_expired) { |
|
268 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
269 | 269 | } |
270 | - if( $include_deleted){ |
|
271 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
270 | + if ($include_deleted) { |
|
271 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
272 | 272 | } |
273 | - if($limit){ |
|
273 | + if ($limit) { |
|
274 | 274 | $query_params['limit'] = $limit; |
275 | 275 | } |
276 | - $result = $this->get_all( $query_params ); |
|
277 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
276 | + $result = $this->get_all($query_params); |
|
277 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
278 | 278 | return $result; |
279 | 279 | } |
280 | 280 | |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * that number |
291 | 291 | * @return EE_Datetime[] |
292 | 292 | */ |
293 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
293 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
294 | 294 | //sanitize id. |
295 | - $TKT_ID = intval( $TKT_ID ); |
|
295 | + $TKT_ID = intval($TKT_ID); |
|
296 | 296 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
297 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
298 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
299 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
300 | - if( ! $include_expired){ |
|
301 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
297 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
298 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
299 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
300 | + if ( ! $include_expired) { |
|
301 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
302 | 302 | } |
303 | - if( $include_deleted){ |
|
304 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
303 | + if ($include_deleted) { |
|
304 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
305 | 305 | } |
306 | - if($limit){ |
|
306 | + if ($limit) { |
|
307 | 307 | $query_params['limit'] = $limit; |
308 | 308 | } |
309 | - $result = $this->get_all( $query_params ); |
|
310 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
309 | + $result = $this->get_all($query_params); |
|
310 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
311 | 311 | return $result; |
312 | 312 | } |
313 | 313 | |
@@ -318,11 +318,11 @@ discard block |
||
318 | 318 | * @param int $EVT_ID |
319 | 319 | * @return EE_Datetime |
320 | 320 | */ |
321 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
321 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
322 | 322 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
323 | - if($results){ |
|
323 | + if ($results) { |
|
324 | 324 | return array_shift($results); |
325 | - }else{ |
|
325 | + } else { |
|
326 | 326 | return null; |
327 | 327 | } |
328 | 328 | } |
@@ -341,77 +341,77 @@ discard block |
||
341 | 341 | * - inactive = Events that are either not published. |
342 | 342 | * @return wpdb results array |
343 | 343 | */ |
344 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
345 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
346 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
344 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
345 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
346 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
347 | 347 | |
348 | - switch ( $evt_active_status ) { |
|
348 | + switch ($evt_active_status) { |
|
349 | 349 | case 'upcoming' : |
350 | 350 | $where_params['Event.status'] = 'publish'; |
351 | 351 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
352 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
352 | + if (isset($where_params['DTT_EVT_start'])) { |
|
353 | 353 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
354 | 354 | } |
355 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
355 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
356 | 356 | break; |
357 | 357 | |
358 | 358 | case 'expired' : |
359 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
359 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
360 | 360 | //get events to exclude |
361 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
361 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
362 | 362 | //first get all events that have datetimes where its not expired. |
363 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
364 | - $event_ids = array_keys( $event_ids ); |
|
363 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
364 | + $event_ids = array_keys($event_ids); |
|
365 | 365 | |
366 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
366 | + if (isset($where_params['DTT_EVT_end'])) { |
|
367 | 367 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
368 | 368 | } |
369 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
370 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
369 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
370 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
371 | 371 | break; |
372 | 372 | |
373 | 373 | case 'active' : |
374 | 374 | $where_params['Event.status'] = 'publish'; |
375 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
375 | + if (isset($where_params['DTT_EVT_start'])) { |
|
376 | 376 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
377 | 377 | } |
378 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
378 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
379 | 379 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
380 | 380 | } |
381 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
382 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
381 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
382 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
383 | 383 | break; |
384 | 384 | |
385 | 385 | case 'inactive' : |
386 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
387 | - if ( isset( $where_params['OR'] ) ) { |
|
386 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
387 | + if (isset($where_params['OR'])) { |
|
388 | 388 | $where_params['AND']['OR'] = $where_params['OR']; |
389 | 389 | } |
390 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
390 | + if (isset($where_params['DTT_EVT_end'])) { |
|
391 | 391 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
392 | - unset( $where_params['DTT_EVT_end'] ); |
|
392 | + unset($where_params['DTT_EVT_end']); |
|
393 | 393 | } |
394 | 394 | |
395 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
395 | + if (isset($where_params['DTT_EVT_start'])) { |
|
396 | 396 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
397 | - unset( $where_params['DTT_EVT_start'] ); |
|
397 | + unset($where_params['DTT_EVT_start']); |
|
398 | 398 | } |
399 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
399 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
400 | 400 | break; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $query_params[0] = $where_params; |
404 | 404 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
405 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
405 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
406 | 406 | |
407 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
407 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
408 | 408 | |
409 | 409 | $columns_to_select = array( |
410 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
411 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
412 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
410 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
411 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
412 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
413 | 413 | ); |
414 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
414 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | * for the tickets for each datetime) |
420 | 420 | * @param EE_Datetime[] $datetimes |
421 | 421 | */ |
422 | - public function update_sold($datetimes){ |
|
423 | - foreach($datetimes as $datetime){ |
|
422 | + public function update_sold($datetimes) { |
|
423 | + foreach ($datetimes as $datetime) { |
|
424 | 424 | $datetime->update_sold(); |
425 | 425 | } |
426 | 426 | } |
@@ -435,10 +435,10 @@ discard block |
||
435 | 435 | * @param array $query_params |
436 | 436 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
437 | 437 | */ |
438 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
439 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
440 | - if ( $datetime instanceof EE_Datetime ) { |
|
441 | - return $datetime->tickets_remaining( $query_params ); |
|
438 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
439 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
440 | + if ($datetime instanceof EE_Datetime) { |
|
441 | + return $datetime->tickets_remaining($query_params); |
|
442 | 442 | } |
443 | 443 | return 0; |
444 | 444 | } |
@@ -460,36 +460,36 @@ discard block |
||
460 | 460 | * EE_Datetime::upcoming |
461 | 461 | * EE_Datetime::expired |
462 | 462 | */ |
463 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
463 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
464 | 464 | //only accept where conditions for this query. |
465 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
465 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
466 | 466 | $status_query_args = array( |
467 | 467 | EE_Datetime::active => array_merge( |
468 | 468 | $_where, |
469 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
469 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
470 | 470 | ), |
471 | 471 | EE_Datetime::upcoming => array_merge( |
472 | 472 | $_where, |
473 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
473 | + array('DTT_EVT_start' => array('>', time())) |
|
474 | 474 | ), |
475 | 475 | EE_Datetime::expired => array_merge( |
476 | 476 | $_where, |
477 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
477 | + array('DTT_EVT_end' => array('<', time())) |
|
478 | 478 | ) |
479 | 479 | ); |
480 | 480 | |
481 | - if ( ! empty( $stati_to_include ) ) { |
|
482 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
483 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
484 | - unset( $status_query_args[$status] ); |
|
481 | + if ( ! empty($stati_to_include)) { |
|
482 | + foreach (array_keys($status_query_args) as $status) { |
|
483 | + if ( ! in_array($status, $stati_to_include)) { |
|
484 | + unset($status_query_args[$status]); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | } |
488 | 488 | |
489 | 489 | //loop through and query counts for each stati. |
490 | 490 | $status_query_results = array(); |
491 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
492 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
491 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
492 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return $status_query_results; |
@@ -503,9 +503,9 @@ discard block |
||
503 | 503 | * @param array $query_params |
504 | 504 | * @return int |
505 | 505 | */ |
506 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
507 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
508 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
506 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
507 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
508 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
509 | 509 | } |
510 | 510 | |
511 | 511 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime_Ticket extends EEM_Base { |
28 | 28 | |
@@ -37,28 +37,28 @@ discard block |
||
37 | 37 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
38 | 38 | * @return void |
39 | 39 | */ |
40 | - protected function __construct( $timezone ) { |
|
41 | - $this->singular_item = __('Datetime Ticket','event_espresso'); |
|
42 | - $this->plural_item = __('Datetime Tickets','event_espresso'); |
|
40 | + protected function __construct($timezone) { |
|
41 | + $this->singular_item = __('Datetime Ticket', 'event_espresso'); |
|
42 | + $this->plural_item = __('Datetime Tickets', 'event_espresso'); |
|
43 | 43 | |
44 | 44 | $this->_tables = array( |
45 | 45 | 'Datetime_Ticket'=> new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID') |
46 | 46 | ); |
47 | 47 | $this->_fields = array( |
48 | 48 | 'Datetime_Ticket'=>array( |
49 | - 'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID','event_espresso')), |
|
50 | - 'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime','event_espresso'), false, 0, 'Datetime' ), |
|
51 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket','event_espresso'), false, 0, 'Ticket' ) |
|
49 | + 'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID', 'event_espresso')), |
|
50 | + 'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'), |
|
51 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket') |
|
52 | 52 | )); |
53 | 53 | $this->_model_relations = array( |
54 | 54 | 'Ticket'=>new EE_Belongs_To_Relation(), |
55 | 55 | 'Datetime'=>new EE_Belongs_To_Relation() |
56 | 56 | ); |
57 | 57 | //this model is generally available for reading |
58 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Datetime.Event' ); |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event' ); |
|
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event' ); |
|
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Datetime.Event', EEM_Base::caps_edit ); |
|
62 | - parent::__construct( $timezone ); |
|
58 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Datetime.Event'); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event'); |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event'); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Datetime.Event', EEM_Base::caps_edit); |
|
62 | + parent::__construct($timezone); |
|
63 | 63 | } |
64 | 64 | } //end EEM_Datetime_Ticket class |
65 | 65 | \ No newline at end of file |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |