@@ -404,10 +404,6 @@ |
||
404 | 404 | /** |
405 | 405 | * Log a "Cleared" request. |
406 | 406 | * |
407 | - * @param array $response |
|
408 | - * @param EEI_Payment $payment |
|
409 | - * @param string $info |
|
410 | - * @return void |
|
411 | 407 | */ |
412 | 408 | private function _log_clean_request( $request_prms, $payment, $info ) { |
413 | 409 | $cleaned_request_data = $request_prms; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param type $settings_array |
84 | 84 | */ |
85 | - public function set_settings( $settings_array ) { |
|
85 | + public function set_settings($settings_array) { |
|
86 | 86 | parent::set_settings($settings_array); |
87 | 87 | // Redirect URL. |
88 | - if ( $this->_debug_mode ) { |
|
88 | + if ($this->_debug_mode) { |
|
89 | 89 | $this->_base_gateway_url = 'https://api-3t.sandbox.paypal.com/nvp'; |
90 | 90 | } else { |
91 | 91 | $this->_base_gateway_url = 'https://api-3t.paypal.com/nvp'; |
@@ -100,19 +100,19 @@ discard block |
||
100 | 100 | * @param type $return_url |
101 | 101 | * @param type $cancel_url |
102 | 102 | */ |
103 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ) { |
|
104 | - if ( ! $payment instanceof EEI_Payment ) { |
|
105 | - $payment->set_gateway_response( __( 'Error. No associated payment was found.', 'event_espresso' ) ); |
|
106 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
103 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
104 | + if ( ! $payment instanceof EEI_Payment) { |
|
105 | + $payment->set_gateway_response(__('Error. No associated payment was found.', 'event_espresso')); |
|
106 | + $payment->set_status($this->_pay_model->failed_status()); |
|
107 | 107 | return $payment; |
108 | 108 | } |
109 | 109 | $transaction = $payment->transaction(); |
110 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
111 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
112 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
110 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
111 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
112 | + $payment->set_status($this->_pay_model->failed_status()); |
|
113 | 113 | return $payment; |
114 | 114 | } |
115 | - $order_description = substr( $this->_format_order_description($payment), 0, 127 ); |
|
115 | + $order_description = substr($this->_format_order_description($payment), 0, 127); |
|
116 | 116 | $primary_registration = $transaction->primary_registration(); |
117 | 117 | $primary_attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : false; |
118 | 118 | $locale = explode('-', get_bloginfo('language')); |
@@ -126,28 +126,28 @@ discard block |
||
126 | 126 | 'RETURNURL' => $return_url, |
127 | 127 | 'CANCELURL' => $cancel_url, |
128 | 128 | 'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale', |
129 | - 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | - 'BUTTONSOURCE' => 'EventEspresso_SP',//EE will blow up if you change this |
|
129 | + 'SOLUTIONTYPE' => 'Sole', // Buyer does not need to create a PayPal account to check out. This is referred to as PayPal Account Optional. |
|
130 | + 'BUTTONSOURCE' => 'EventEspresso_SP', //EE will blow up if you change this |
|
131 | 131 | 'LOCALECODE' => $locale[1] // Locale of the pages displayed by PayPal during Express Checkout. |
132 | 132 | ); |
133 | 133 | |
134 | 134 | // Show itemized list. |
135 | - if ( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
135 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
136 | 136 | $item_num = 0; |
137 | 137 | $itemized_sum = 0; |
138 | 138 | $total_line_items = $transaction->total_line_item(); |
139 | 139 | // Go through each item in the list. |
140 | - foreach ( $total_line_items->get_items() as $line_item ) { |
|
141 | - if ( $line_item instanceof EE_Line_Item ) { |
|
140 | + foreach ($total_line_items->get_items() as $line_item) { |
|
141 | + if ($line_item instanceof EE_Line_Item) { |
|
142 | 142 | // PayPal doesn't like line items with 0.00 amount, so we may skip those. |
143 | - if ( EEH_Money::compare_floats( $line_item->total(), '0.00', '==' ) ) { |
|
143 | + if (EEH_Money::compare_floats($line_item->total(), '0.00', '==')) { |
|
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | |
147 | 147 | $unit_price = $line_item->unit_price(); |
148 | 148 | $line_item_quantity = $line_item->quantity(); |
149 | 149 | // This is a discount. |
150 | - if ( $line_item->is_percent() ) { |
|
150 | + if ($line_item->is_percent()) { |
|
151 | 151 | $unit_price = $line_item->total(); |
152 | 152 | $line_item_quantity = 1; |
153 | 153 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | // Item description. |
157 | 157 | $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
158 | 158 | // Cost of individual item. |
159 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $unit_price ); |
|
159 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($unit_price); |
|
160 | 160 | // Item Number. |
161 | 161 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
162 | 162 | // Item quantity. |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
174 | 174 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
175 | 175 | |
176 | - $itemized_sum_diff_from_txn_total = round( $transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2 ); |
|
176 | + $itemized_sum_diff_from_txn_total = round($transaction->total() - $itemized_sum - $total_line_items->get_total_tax(), 2); |
|
177 | 177 | // If we were not able to recognize some item like promotion, surcharge or cancellation, |
178 | 178 | // add the difference as an extra line item. |
179 | - if ( $itemized_sum_diff_from_txn_total != 0 ) { |
|
179 | + if ($itemized_sum_diff_from_txn_total != 0) { |
|
180 | 180 | // Item Name. |
181 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr( __( 'Other (promotion/surcharge/cancellation)', 'event_espresso' ), 0, 127 ); |
|
181 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME'.$item_num] = substr(__('Other (promotion/surcharge/cancellation)', 'event_espresso'), 0, 127); |
|
182 | 182 | // Item description. |
183 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr( $line_item->desc(), 0, 127 ); |
|
183 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC'.$item_num] = substr($line_item->desc(), 0, 127); |
|
184 | 184 | // Cost of individual item. |
185 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
185 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
186 | 186 | // Item Number. |
187 | 187 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER'.$item_num] = $item_num + 1; |
188 | 188 | // Item quantity. |
@@ -192,11 +192,11 @@ discard block |
||
192 | 192 | } else { |
193 | 193 | // Just one Item. |
194 | 194 | // Item Name. |
195 | - $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr( sprintf( __('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code() ), 0, 127 ); |
|
195 | + $token_request_dtls['L_PAYMENTREQUEST_0_NAME0'] = substr(sprintf(__('Payment for %1$s', 'event_espresso'), $primary_registration->reg_code()), 0, 127); |
|
196 | 196 | // Item description. |
197 | - $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr( sprintf( __('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code() ), 0, 127 ); |
|
197 | + $token_request_dtls['L_PAYMENTREQUEST_0_DESC0'] = substr(sprintf(__('Payment of %1$s for %2$s', 'event_espresso'), $payment->amount(), $primary_registration->reg_code()), 0, 127); |
|
198 | 198 | // Cost of individual item. |
199 | - $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency( $payment->amount() ); |
|
199 | + $token_request_dtls['L_PAYMENTREQUEST_0_AMT0'] = $this->format_currency($payment->amount()); |
|
200 | 200 | // Item Number. |
201 | 201 | $token_request_dtls['L_PAYMENTREQUEST_0_NUMBER0'] = 1; |
202 | 202 | // Item quantity. |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | // Digital item is sold. |
205 | 205 | $token_request_dtls['L_PAYMENTREQUEST_0_ITEMCATEGORY0'] = 'Physical'; |
206 | 206 | // Item's sales S/H and tax amount. |
207 | - $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency( $payment->amount() ); |
|
207 | + $token_request_dtls['PAYMENTREQUEST_0_ITEMAMT'] = $this->format_currency($payment->amount()); |
|
208 | 208 | $token_request_dtls['PAYMENTREQUEST_0_TAXAMT'] = '0'; |
209 | 209 | $token_request_dtls['PAYMENTREQUEST_0_SHIPPINGAMT'] = '0'; |
210 | 210 | $token_request_dtls['PAYMENTREQUEST_0_HANDLINGAMT'] = '0'; |
211 | 211 | } |
212 | 212 | // Automatically filling out shipping and contact information. |
213 | - if ( $this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee ) { |
|
214 | - $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
213 | + if ($this->_request_shipping_addr && $primary_attendee instanceof EEI_Attendee) { |
|
214 | + $token_request_dtls['NOSHIPPING'] = '2'; // If you do not pass the shipping address, PayPal obtains it from the buyer's account profile. |
|
215 | 215 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET'] = $primary_attendee->address(); |
216 | 216 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOSTREET2'] = $primary_attendee->address2(); |
217 | 217 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOCITY'] = $primary_attendee->city(); |
@@ -220,34 +220,34 @@ discard block |
||
220 | 220 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOZIP'] = $primary_attendee->zip(); |
221 | 221 | $token_request_dtls['PAYMENTREQUEST_0_EMAIL'] = $primary_attendee->email(); |
222 | 222 | $token_request_dtls['PAYMENTREQUEST_0_SHIPTOPHONENUM'] = $primary_attendee->phone(); |
223 | - } elseif ( ! $this->_request_shipping_addr ) { |
|
223 | + } elseif ( ! $this->_request_shipping_addr) { |
|
224 | 224 | // Do not request shipping details on the PP Checkout page. |
225 | 225 | $token_request_dtls['NOSHIPPING'] = '1'; |
226 | 226 | $token_request_dtls['REQCONFIRMSHIPPING'] = '0'; |
227 | 227 | |
228 | 228 | } |
229 | 229 | // Used a business/personal logo on the PayPal page. |
230 | - if ( ! empty($this->_image_url) ) { |
|
230 | + if ( ! empty($this->_image_url)) { |
|
231 | 231 | $token_request_dtls['LOGOIMG'] = $this->_image_url; |
232 | 232 | } |
233 | 233 | // Request PayPal token. |
234 | - $token_request_response = $this->_ppExpress_request( $token_request_dtls, 'Payment Token', $payment ); |
|
235 | - $token_rstatus = $this->_ppExpress_check_response( $token_request_response ); |
|
236 | - $response_args = ( isset($token_rstatus['args']) && is_array($token_rstatus['args']) ) ? $token_rstatus['args'] : array(); |
|
237 | - if ( $token_rstatus['status'] ) { |
|
234 | + $token_request_response = $this->_ppExpress_request($token_request_dtls, 'Payment Token', $payment); |
|
235 | + $token_rstatus = $this->_ppExpress_check_response($token_request_response); |
|
236 | + $response_args = (isset($token_rstatus['args']) && is_array($token_rstatus['args'])) ? $token_rstatus['args'] : array(); |
|
237 | + if ($token_rstatus['status']) { |
|
238 | 238 | // We got the Token so we may continue with the payment and redirect the client. |
239 | - $payment->set_details( $response_args ); |
|
239 | + $payment->set_details($response_args); |
|
240 | 240 | |
241 | - $gateway_url = ( $this->_debug_mode ) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | - $payment->set_redirect_url( $gateway_url . '/checkoutnow?useraction=commit&cmd=_express-checkout&token=' . $response_args['TOKEN'] ); |
|
241 | + $gateway_url = ($this->_debug_mode) ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; |
|
242 | + $payment->set_redirect_url($gateway_url.'/checkoutnow?useraction=commit&cmd=_express-checkout&token='.$response_args['TOKEN']); |
|
243 | 243 | } else { |
244 | - if ( isset($response_args['L_ERRORCODE']) ) { |
|
245 | - $payment->set_gateway_response( $response_args['L_ERRORCODE'] . '; ' . $response_args['L_SHORTMESSAGE'] ); |
|
244 | + if (isset($response_args['L_ERRORCODE'])) { |
|
245 | + $payment->set_gateway_response($response_args['L_ERRORCODE'].'; '.$response_args['L_SHORTMESSAGE']); |
|
246 | 246 | } else { |
247 | - $payment->set_gateway_response( __( 'Error occurred while trying to setup the Express Checkout.', 'event_espresso' ) ); |
|
247 | + $payment->set_gateway_response(__('Error occurred while trying to setup the Express Checkout.', 'event_espresso')); |
|
248 | 248 | } |
249 | - $payment->set_details( $response_args ); |
|
250 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
249 | + $payment->set_details($response_args); |
|
250 | + $payment->set_status($this->_pay_model->failed_status()); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | return $payment; |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | * @param type $transaction |
264 | 264 | * @return EEI_Payment |
265 | 265 | */ |
266 | - public function handle_payment_update( $update_info, $transaction ) { |
|
267 | - $payment = ( $transaction instanceof EEI_Transaction ) ? $transaction->last_payment() : null; |
|
266 | + public function handle_payment_update($update_info, $transaction) { |
|
267 | + $payment = ($transaction instanceof EEI_Transaction) ? $transaction->last_payment() : null; |
|
268 | 268 | |
269 | - if ( $payment instanceof EEI_Payment ) { |
|
270 | - $this->log( array( 'Return from Authorization' => $update_info ), $payment ); |
|
269 | + if ($payment instanceof EEI_Payment) { |
|
270 | + $this->log(array('Return from Authorization' => $update_info), $payment); |
|
271 | 271 | |
272 | 272 | $payment_details = $payment->details(); |
273 | 273 | $transaction = $payment->transaction(); |
274 | - if ( ! $transaction instanceof EEI_Transaction ) { |
|
275 | - $payment->set_gateway_response( __( 'Could not process this payment because it has no associated transaction.', 'event_espresso' ) ); |
|
276 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
274 | + if ( ! $transaction instanceof EEI_Transaction) { |
|
275 | + $payment->set_gateway_response(__('Could not process this payment because it has no associated transaction.', 'event_espresso')); |
|
276 | + $payment->set_status($this->_pay_model->failed_status()); |
|
277 | 277 | return $payment; |
278 | 278 | } |
279 | 279 | $primary_registrant = $transaction->primary_registration(); |
280 | 280 | |
281 | 281 | // Check if we still have the token. |
282 | - if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN']) ) { |
|
283 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
282 | + if ( ! isset($payment_details['TOKEN']) || empty($payment_details['TOKEN'])) { |
|
283 | + $payment->set_status($this->_pay_model->failed_status()); |
|
284 | 284 | return $payment; |
285 | 285 | } |
286 | 286 | |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | 'TOKEN' => $payment_details['TOKEN'] |
290 | 290 | ); |
291 | 291 | // Request Customer Details. |
292 | - $cdetails_request_response = $this->_ppExpress_request( $cdetails_request_dtls, 'Customer Details', $payment ); |
|
293 | - $cdetails_rstatus = $this->_ppExpress_check_response( $cdetails_request_response ); |
|
294 | - $cdata_response_args = ( isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args']) ) ? $cdetails_rstatus['args'] : array(); |
|
295 | - if ( $cdetails_rstatus['status'] ) { |
|
292 | + $cdetails_request_response = $this->_ppExpress_request($cdetails_request_dtls, 'Customer Details', $payment); |
|
293 | + $cdetails_rstatus = $this->_ppExpress_check_response($cdetails_request_response); |
|
294 | + $cdata_response_args = (isset($cdetails_rstatus['args']) && is_array($cdetails_rstatus['args'])) ? $cdetails_rstatus['args'] : array(); |
|
295 | + if ($cdetails_rstatus['status']) { |
|
296 | 296 | // We got the PayerID so now we can Complete the transaction. |
297 | 297 | $docheckout_request_dtls = array( |
298 | 298 | 'METHOD' => 'DoExpressCheckoutPayment', |
@@ -303,39 +303,39 @@ discard block |
||
303 | 303 | 'PAYMENTREQUEST_0_CURRENCYCODE' => $payment->currency_code() |
304 | 304 | ); |
305 | 305 | // Payment Checkout/Capture. |
306 | - $docheckout_request_response = $this->_ppExpress_request( $docheckout_request_dtls, 'Do Payment', $payment ); |
|
307 | - $docheckout_rstatus = $this->_ppExpress_check_response( $docheckout_request_response ); |
|
308 | - $docheckout_response_args = ( isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args']) ) ? $docheckout_rstatus['args'] : array(); |
|
309 | - if ( $docheckout_rstatus['status'] ) { |
|
306 | + $docheckout_request_response = $this->_ppExpress_request($docheckout_request_dtls, 'Do Payment', $payment); |
|
307 | + $docheckout_rstatus = $this->_ppExpress_check_response($docheckout_request_response); |
|
308 | + $docheckout_response_args = (isset($docheckout_rstatus['args']) && is_array($docheckout_rstatus['args'])) ? $docheckout_rstatus['args'] : array(); |
|
309 | + if ($docheckout_rstatus['status']) { |
|
310 | 310 | // All is well, payment approved. |
311 | 311 | $primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : ''; |
312 | - $payment->set_extra_accntng( $primary_registration_code ); |
|
313 | - $payment->set_amount( isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval( $docheckout_response_args['PAYMENTINFO_0_AMT'] ) : 0 ); |
|
314 | - $payment->set_txn_id_chq_nmbr( isset( $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] ) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null ); |
|
315 | - $payment->set_details( $cdata_response_args ); |
|
316 | - $payment->set_gateway_response( isset( $docheckout_response_args['PAYMENTINFO_0_ACK'] ) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : '' ); |
|
317 | - $payment->set_status( $this->_pay_model->approved_status() ); |
|
312 | + $payment->set_extra_accntng($primary_registration_code); |
|
313 | + $payment->set_amount(isset($docheckout_response_args['PAYMENTINFO_0_AMT']) ? floatval($docheckout_response_args['PAYMENTINFO_0_AMT']) : 0); |
|
314 | + $payment->set_txn_id_chq_nmbr(isset($docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID']) ? $docheckout_response_args['PAYMENTINFO_0_TRANSACTIONID'] : null); |
|
315 | + $payment->set_details($cdata_response_args); |
|
316 | + $payment->set_gateway_response(isset($docheckout_response_args['PAYMENTINFO_0_ACK']) ? $docheckout_response_args['PAYMENTINFO_0_ACK'] : ''); |
|
317 | + $payment->set_status($this->_pay_model->approved_status()); |
|
318 | 318 | } else { |
319 | - if ( isset($docheckout_response_args['L_ERRORCODE']) ) { |
|
320 | - $payment->set_gateway_response( $docheckout_response_args['L_ERRORCODE'] . '; ' . $docheckout_response_args['L_SHORTMESSAGE'] ); |
|
319 | + if (isset($docheckout_response_args['L_ERRORCODE'])) { |
|
320 | + $payment->set_gateway_response($docheckout_response_args['L_ERRORCODE'].'; '.$docheckout_response_args['L_SHORTMESSAGE']); |
|
321 | 321 | } else { |
322 | - $payment->set_gateway_response( __( 'Error occurred while trying to Capture the funds.', 'event_espresso' ) ); |
|
322 | + $payment->set_gateway_response(__('Error occurred while trying to Capture the funds.', 'event_espresso')); |
|
323 | 323 | } |
324 | - $payment->set_details( $docheckout_response_args ); |
|
325 | - $payment->set_status( $this->_pay_model->declined_status() ); |
|
324 | + $payment->set_details($docheckout_response_args); |
|
325 | + $payment->set_status($this->_pay_model->declined_status()); |
|
326 | 326 | } |
327 | 327 | } else { |
328 | - if ( isset($cdata_response_args['L_ERRORCODE']) ) { |
|
329 | - $payment->set_gateway_response( $cdata_response_args['L_ERRORCODE'] . '; ' . $cdata_response_args['L_SHORTMESSAGE'] ); |
|
328 | + if (isset($cdata_response_args['L_ERRORCODE'])) { |
|
329 | + $payment->set_gateway_response($cdata_response_args['L_ERRORCODE'].'; '.$cdata_response_args['L_SHORTMESSAGE']); |
|
330 | 330 | } else { |
331 | - $payment->set_gateway_response( __( 'Error occurred while trying to get payment Details from PayPal.', 'event_espresso' ) ); |
|
331 | + $payment->set_gateway_response(__('Error occurred while trying to get payment Details from PayPal.', 'event_espresso')); |
|
332 | 332 | } |
333 | - $payment->set_details( $cdata_response_args ); |
|
334 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
333 | + $payment->set_details($cdata_response_args); |
|
334 | + $payment->set_status($this->_pay_model->failed_status()); |
|
335 | 335 | } |
336 | 336 | } else { |
337 | - $payment->set_gateway_response( __( 'Error occurred while trying to process the payment.', 'event_espresso' ) ); |
|
338 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
337 | + $payment->set_gateway_response(__('Error occurred while trying to process the payment.', 'event_espresso')); |
|
338 | + $payment->set_status($this->_pay_model->failed_status()); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $payment; |
@@ -350,16 +350,16 @@ discard block |
||
350 | 350 | * @param EEI_Payment $payment |
351 | 351 | * @return mixed |
352 | 352 | */ |
353 | - public function _ppExpress_request( $request_params, $request_text, $payment ) { |
|
353 | + public function _ppExpress_request($request_params, $request_text, $payment) { |
|
354 | 354 | $request_dtls = array( |
355 | 355 | 'VERSION' => '204.0', |
356 | - 'USER' => urlencode( $this->_api_username ), |
|
357 | - 'PWD' => urlencode( $this->_api_password ), |
|
358 | - 'SIGNATURE' => urlencode( $this->_api_signature ) |
|
356 | + 'USER' => urlencode($this->_api_username), |
|
357 | + 'PWD' => urlencode($this->_api_password), |
|
358 | + 'SIGNATURE' => urlencode($this->_api_signature) |
|
359 | 359 | ); |
360 | - $dtls = array_merge( $request_dtls, $request_params ); |
|
360 | + $dtls = array_merge($request_dtls, $request_params); |
|
361 | 361 | |
362 | - $this->_log_clean_request( $dtls, $payment, $request_text . ' Request' ); |
|
362 | + $this->_log_clean_request($dtls, $payment, $request_text.' Request'); |
|
363 | 363 | // Request Customer Details. |
364 | 364 | $request_response = wp_remote_post( |
365 | 365 | $this->_base_gateway_url, |
@@ -369,11 +369,11 @@ discard block |
||
369 | 369 | 'httpversion' => '1.1', |
370 | 370 | 'cookies' => array(), |
371 | 371 | 'headers' => array(), |
372 | - 'body' => http_build_query( $dtls ) |
|
372 | + 'body' => http_build_query($dtls) |
|
373 | 373 | ) |
374 | 374 | ); |
375 | 375 | // Log the response. |
376 | - $this->log( array( $request_text . ' Response' => $request_response), $payment ); |
|
376 | + $this->log(array($request_text.' Response' => $request_response), $payment); |
|
377 | 377 | |
378 | 378 | return $request_response; |
379 | 379 | } |
@@ -385,31 +385,31 @@ discard block |
||
385 | 385 | * @param mixed $request_response |
386 | 386 | * @return array |
387 | 387 | */ |
388 | - public function _ppExpress_check_response( $request_response ) { |
|
389 | - if ( ! is_wp_error( $request_response ) && $request_response['body'] && ! empty($request_response['body'] ) ) { |
|
388 | + public function _ppExpress_check_response($request_response) { |
|
389 | + if ( ! is_wp_error($request_response) && $request_response['body'] && ! empty($request_response['body'])) { |
|
390 | 390 | $response_args = array(); |
391 | - parse_str( urldecode($request_response['body']), $response_args ); |
|
392 | - if ( isset($response_args['ACK']) |
|
391 | + parse_str(urldecode($request_response['body']), $response_args); |
|
392 | + if (isset($response_args['ACK']) |
|
393 | 393 | && $response_args['ACK'] === 'Success' |
394 | - && ( isset($response_args['PAYERID']) |
|
394 | + && (isset($response_args['PAYERID']) |
|
395 | 395 | || isset($response_args['PAYMENTINFO_0_TRANSACTIONID']) |
396 | - || ( isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed' ) |
|
396 | + || (isset($response_args['PAYMENTSTATUS']) && $response_args['PAYMENTSTATUS'] === 'Completed') |
|
397 | 397 | || isset($response_args['TOKEN']) |
398 | 398 | ) |
399 | 399 | ) { |
400 | 400 | // Response status OK, return response parameters for further processing. |
401 | 401 | return array('status' => true, 'args' => $response_args); |
402 | 402 | } else { |
403 | - if ( isset($response_args['ACK']) ) { |
|
403 | + if (isset($response_args['ACK'])) { |
|
404 | 404 | $errors = $this->_get_errors($response_args); |
405 | - return array( 'status' => false, 'args' => $errors ); |
|
405 | + return array('status' => false, 'args' => $errors); |
|
406 | 406 | } else { |
407 | - return array( 'status' => false, 'args' => $request_response ); |
|
407 | + return array('status' => false, 'args' => $request_response); |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | } else { |
411 | 411 | // If we got here then there was an error in this request. |
412 | - return array( 'status' => false, 'args' => $request_response ); |
|
412 | + return array('status' => false, 'args' => $request_response); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | * @param string $info |
423 | 423 | * @return void |
424 | 424 | */ |
425 | - private function _log_clean_request( $request_prms, $payment, $info ) { |
|
425 | + private function _log_clean_request($request_prms, $payment, $info) { |
|
426 | 426 | $cleaned_request_data = $request_prms; |
427 | 427 | unset($cleaned_request_data['PWD']); |
428 | 428 | unset($cleaned_request_data['USER']); |
429 | 429 | unset($cleaned_request_data['SIGNATURE']); |
430 | - $this->log( array($info => $cleaned_request_data), $payment ); |
|
430 | + $this->log(array($info => $cleaned_request_data), $payment); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | * @param array $data_array |
438 | 438 | * @return array |
439 | 439 | */ |
440 | - private function _get_errors( $data_array ) { |
|
440 | + private function _get_errors($data_array) { |
|
441 | 441 | $errors = array(); |
442 | 442 | $n = 0; |
443 | - while ( isset($data_array['L_ERRORCODE' . $n . '']) ) { |
|
444 | - $l_error_code = isset($data_array['L_ERRORCODE' . $n . '']) ? $data_array['L_ERRORCODE' . $n . ''] : ''; |
|
445 | - $l_severity_code = isset($data_array['L_SEVERITYCODE' . $n . '']) ? $data_array['L_SEVERITYCODE' . $n . ''] : ''; |
|
446 | - $l_short_message = isset($data_array['L_SHORTMESSAGE' . $n . '']) ? $data_array['L_SHORTMESSAGE' . $n . ''] : ''; |
|
447 | - $l_long_message = isset($data_array['L_LONGMESSAGE' . $n . '']) ? $data_array['L_LONGMESSAGE' . $n . ''] : ''; |
|
443 | + while (isset($data_array['L_ERRORCODE'.$n.''])) { |
|
444 | + $l_error_code = isset($data_array['L_ERRORCODE'.$n.'']) ? $data_array['L_ERRORCODE'.$n.''] : ''; |
|
445 | + $l_severity_code = isset($data_array['L_SEVERITYCODE'.$n.'']) ? $data_array['L_SEVERITYCODE'.$n.''] : ''; |
|
446 | + $l_short_message = isset($data_array['L_SHORTMESSAGE'.$n.'']) ? $data_array['L_SHORTMESSAGE'.$n.''] : ''; |
|
447 | + $l_long_message = isset($data_array['L_LONGMESSAGE'.$n.'']) ? $data_array['L_LONGMESSAGE'.$n.''] : ''; |
|
448 | 448 | |
449 | - if ( $n == 0 ) { |
|
449 | + if ($n == 0) { |
|
450 | 450 | $errors = array( |
451 | 451 | 'L_ERRORCODE' => $l_error_code, |
452 | 452 | 'L_SHORTMESSAGE' => $l_short_message, |
@@ -454,10 +454,10 @@ discard block |
||
454 | 454 | 'L_SEVERITYCODE' => $l_severity_code |
455 | 455 | ); |
456 | 456 | } else { |
457 | - $errors['L_ERRORCODE'] .= ', ' . $l_error_code; |
|
458 | - $errors['L_SHORTMESSAGE'] .= ', ' . $l_short_message; |
|
459 | - $errors['L_LONGMESSAGE'] .= ', ' . $l_long_message; |
|
460 | - $errors['L_SEVERITYCODE'] .= ', ' . $l_severity_code; |
|
457 | + $errors['L_ERRORCODE'] .= ', '.$l_error_code; |
|
458 | + $errors['L_SHORTMESSAGE'] .= ', '.$l_short_message; |
|
459 | + $errors['L_LONGMESSAGE'] .= ', '.$l_long_message; |
|
460 | + $errors['L_SEVERITYCODE'] .= ', '.$l_severity_code; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | $n++; |
@@ -1,1 +1,1 @@ |
||
1 | -<?php printf( __('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">','</a>' ); ?> |
|
2 | 1 | \ No newline at end of file |
2 | +<?php printf(__('PayPal Express (Express Checkout) is an off-site payment method for accepting payments via PayPal and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', 'event_espresso'), '<a href="https://eventespresso.com/go/paypalexpress/" target="_blank">', '</a>'); ?> |
|
3 | 3 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { exit('No direct script access allowed'); } ?> |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } ?> |
|
2 | 2 | |
3 | 3 | <div id="ppexpress-sandbox-panel" class="sandbox-panel"> |
4 | 4 | |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | |
7 | 7 | <h4><?php _e('How do I test specific error codes?', 'event_espresso'); ?></h4> |
8 | 8 | <p> |
9 | - <?php _e( 'To trigger an error condition on an amount-related field, |
|
9 | + <?php _e('To trigger an error condition on an amount-related field, |
|
10 | 10 | specify a error code value as a number with two digits to the right of the decimal point. |
11 | 11 | For example, specify a value of 107.55 to trigger the 10755 error.', |
12 | - 'event_espresso');?> |
|
12 | + 'event_espresso'); ?> |
|
13 | 13 | </p> |
14 | 14 | <p> |
15 | - <?php printf( __( 'More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>');?> |
|
15 | + <?php printf(__('More details can be found here: %1$s Testing Error Conditions %2$s.', 'event_espresso'), '<a href="https://developer.paypal.com/docs/classic/lifecycle/sb_error-conditions">', '</a>'); ?> |
|
16 | 16 | </p> |
17 | 17 | |
18 | 18 | </div> |
19 | 19 | \ No newline at end of file |
@@ -15,8 +15,8 @@ |
||
15 | 15 | class EE_PMT_Paypal_Express extends EE_PMT_Base { |
16 | 16 | |
17 | 17 | /** |
18 | - * Class constructor. |
|
19 | - */ |
|
18 | + * Class constructor. |
|
19 | + */ |
|
20 | 20 | public function __construct( $pm_instance = NULL ) { |
21 | 21 | require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' ); |
22 | 22 | $this->_gateway = new EEG_Paypal_Express(); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit('NO direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * ---------------------------------------------- |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * Class constructor. |
19 | 19 | */ |
20 | - public function __construct( $pm_instance = NULL ) { |
|
21 | - require_once( $this->file_folder() . 'EEG_Paypal_Express.gateway.php' ); |
|
20 | + public function __construct($pm_instance = NULL) { |
|
21 | + require_once($this->file_folder().'EEG_Paypal_Express.gateway.php'); |
|
22 | 22 | $this->_gateway = new EEG_Paypal_Express(); |
23 | 23 | |
24 | - $this->_pretty_name = __( 'PayPal Express', 'event_espresso' ); |
|
25 | - $this->_template_path = $this->file_folder() . 'templates' . DS; |
|
26 | - $this->_default_description = __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso' ); |
|
27 | - $this->_default_button_url = $this->file_url() . 'lib' . DS . 'paypal-express-checkout-logo.png'; |
|
24 | + $this->_pretty_name = __('PayPal Express', 'event_espresso'); |
|
25 | + $this->_template_path = $this->file_folder().'templates'.DS; |
|
26 | + $this->_default_description = __('After clicking \'Finalize Registration\', you will be forwarded to PayPal website to Login and make your payment.', 'event_espresso'); |
|
27 | + $this->_default_button_url = $this->file_url().'lib'.DS.'paypal-express-checkout-logo.png'; |
|
28 | 28 | |
29 | - parent::__construct( $pm_instance ); |
|
29 | + parent::__construct($pm_instance); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -58,34 +58,34 @@ discard block |
||
58 | 58 | 'extra_meta_inputs' => array( |
59 | 59 | 'api_username' => new EE_Text_Input( |
60 | 60 | array( |
61 | - 'html_label_text'=> sprintf( __( 'API Username %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
61 | + 'html_label_text'=> sprintf(__('API Username %s', 'event_espresso'), $this->get_help_tab_link()), |
|
62 | 62 | 'required' => true, |
63 | 63 | ) |
64 | 64 | ), |
65 | 65 | 'api_password' => new EE_Text_Input( |
66 | 66 | array( |
67 | - 'html_label_text' => sprintf( __( 'API Password %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
67 | + 'html_label_text' => sprintf(__('API Password %s', 'event_espresso'), $this->get_help_tab_link()), |
|
68 | 68 | 'required' => true |
69 | 69 | ) |
70 | 70 | ), |
71 | 71 | 'api_signature' => new EE_Text_Input( |
72 | 72 | array( |
73 | - 'html_label_text' => sprintf( __( 'API Signature %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
73 | + 'html_label_text' => sprintf(__('API Signature %s', 'event_espresso'), $this->get_help_tab_link()), |
|
74 | 74 | 'required' => true |
75 | 75 | ) |
76 | 76 | ), |
77 | 77 | 'request_shipping_addr' => new EE_Yes_No_Input( |
78 | 78 | array( |
79 | - 'html_label_text' => sprintf( __( 'Request Shipping Address %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
80 | - 'html_help_text' => __( 'If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso' ), |
|
79 | + 'html_label_text' => sprintf(__('Request Shipping Address %s', 'event_espresso'), $this->get_help_tab_link()), |
|
80 | + 'html_help_text' => __('If set to "Yes", then a shipping address will be requested on the PayPal checkout page.', 'event_espresso'), |
|
81 | 81 | 'required' => true, |
82 | 82 | 'default' => true, |
83 | 83 | ) |
84 | 84 | ), |
85 | 85 | 'image_url' => new EE_Admin_File_Uploader_Input( |
86 | 86 | array( |
87 | - 'html_label_text' => sprintf( __( 'Image URL %s', 'event_espresso' ), $this->get_help_tab_link() ), |
|
88 | - 'html_help_text' => __( 'Used for your business/personal logo on the PayPal page', 'event_espresso' ), |
|
87 | + 'html_label_text' => sprintf(__('Image URL %s', 'event_espresso'), $this->get_help_tab_link()), |
|
88 | + 'html_help_text' => __('Used for your business/personal logo on the PayPal page', 'event_espresso'), |
|
89 | 89 | 'required' => false |
90 | 90 | ) |
91 | 91 | ), |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param \EE_Transaction $transaction |
103 | 103 | * @return \EE_Billing_Info_Form |
104 | 104 | */ |
105 | - public function generate_new_billing_form( EE_Transaction $transaction = null ) { |
|
106 | - if ( $this->_pm_instance->debug_mode() ) { |
|
105 | + public function generate_new_billing_form(EE_Transaction $transaction = null) { |
|
106 | + if ($this->_pm_instance->debug_mode()) { |
|
107 | 107 | $form = new EE_Billing_Info_Form( |
108 | 108 | $this->_pm_instance, |
109 | 109 | array( |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'layout_strategy' => new EE_Template_Layout( |
115 | 115 | array( |
116 | - 'layout_template_file' => $this->_template_path . 'paypal_express_debug_info.template.php', |
|
117 | - 'template_args' => array( 'debug_mode' => $this->_pm_instance->debug_mode() ) |
|
116 | + 'layout_template_file' => $this->_template_path.'paypal_express_debug_info.template.php', |
|
117 | + 'template_args' => array('debug_mode' => $this->_pm_instance->debug_mode()) |
|
118 | 118 | ) |
119 | 119 | ) |
120 | 120 | ) |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <p><strong><?php _e('PayPal Standard', 'event_espresso'); ?></strong></p> |
2 | -<p><span class="required"><?php _e('Please Note! This gateway has been deprecated and replaced with the PayPal Express payment method. ', 'event_espresso'); ?> <?php printf( __('If you still want to use this gateway, please follow the directions to %1$sactivate it here%2$s.', 'event_espresso'), "<a href='https://eventespresso.com/wiki/paypal-standard-payment-gateway/#deprecated' target='_blank'>", '</a>'); ?></span></p> |
|
2 | +<p><span class="required"><?php _e('Please Note! This gateway has been deprecated and replaced with the PayPal Express payment method. ', 'event_espresso'); ?> <?php printf(__('If you still want to use this gateway, please follow the directions to %1$sactivate it here%2$s.', 'event_espresso'), "<a href='https://eventespresso.com/wiki/paypal-standard-payment-gateway/#deprecated' target='_blank'>", '</a>'); ?></span></p> |
|
3 | 3 | <p> |
4 | 4 | <?php _e('Adjust the settings for the PayPal Standard payment gateway.', 'event_espresso'); ?> |
5 | 5 | </p> |
6 | 6 | <p> |
7 | -<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso' ), "<a href='https://www.paypal.com/multicurrency' target='_blank'>","</a>" ); ?> |
|
7 | +<?php printf(__('See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso'), "<a href='https://www.paypal.com/multicurrency' target='_blank'>", "</a>"); ?> |
|
8 | 8 | </p> |
9 | 9 | <p><strong><?php _e('PayPal Standard Settings', 'event_espresso'); ?></strong></p> |
10 | 10 | <ul> |
@@ -22,18 +22,18 @@ discard block |
||
22 | 22 | </li> |
23 | 23 | <li> |
24 | 24 | <strong><?php _e('PayPal Calculates Taxes', 'event_espresso'); ?></strong><br /> |
25 | -<?php printf( __('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>' ); ?><br/> |
|
26 | -<?php _e( 'Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso' );?> |
|
25 | +<?php printf(__('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>'); ?><br/> |
|
26 | +<?php _e('Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | 29 | <strong><?php _e('PayPal Calculates Shipping', 'event_espresso'); ?></strong><br /> |
30 | 30 | <?php _e('Similar to the "PayPal Calculates Taxes" setting, if this is set to "Yes", we will indicate to PayPal that it should calculate the shipping on each payment (if there are multiple payments for a single transaction, PayPal is permitted to add shipping charges to each payment.)', 'event_espresso'); ?><br/> |
31 | -<?php _e( 'Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso' );?> |
|
31 | +<?php _e('Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso'); ?> |
|
32 | 32 | <li> |
33 | -<strong><?php _e( 'Notes Regarding Paypal Taxes and Shipping', 'event_espresso' );?></strong><br/> |
|
34 | -<?php _e( 'If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso' );?><br/> |
|
35 | -<?php _e( 'However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso' );?><br/> |
|
36 | -<?php _e( 'Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso' );?> |
|
33 | +<strong><?php _e('Notes Regarding Paypal Taxes and Shipping', 'event_espresso'); ?></strong><br/> |
|
34 | +<?php _e('If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso'); ?><br/> |
|
35 | +<?php _e('However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso'); ?><br/> |
|
36 | +<?php _e('Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso'); ?> |
|
37 | 37 | </li> |
38 | 38 | <li> |
39 | 39 | <strong><?php _e('Shipping Address Options', 'event_espresso'); ?></strong><br /> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | } |
6 | 6 | /** |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | //define some page related constants |
30 | - define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' ); |
|
31 | - define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG )); |
|
32 | - define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS ); |
|
33 | - define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS ); |
|
34 | - define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' ); |
|
35 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
30 | + define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings'); |
|
31 | + define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG)); |
|
32 | + define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS); |
|
33 | + define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS); |
|
34 | + define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/'); |
|
35 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
36 | 36 | //check that there are active gateways on all admin page loads. but dont do it just yet |
37 | 37 | // echo "constructing payments admin page";die; |
38 | - add_action('admin_notices',array($this,'check_payment_gateway_setup')); |
|
38 | + add_action('admin_notices', array($this, 'check_payment_gateway_setup')); |
|
39 | 39 | |
40 | 40 | // Show/hide PP Standard along side PP Express. |
41 | - add_filter( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array( $this, 'unset_pp_standard' ) ); |
|
41 | + add_filter('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', array($this, 'unset_pp_standard')); |
|
42 | 42 | |
43 | 43 | parent::__construct(); |
44 | 44 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
63 | 63 | 'parent_slug' => 'espresso_events', |
64 | 64 | 'menu_slug' => EE_PAYMENTS_PG_SLUG, |
65 | - 'menu_label' => __( 'Payment Methods', 'event_espresso' ), |
|
65 | + 'menu_label' => __('Payment Methods', 'event_espresso'), |
|
66 | 66 | 'capability' => 'ee_manage_gateways', |
67 | 67 | 'admin_init_page' => $this, |
68 | 68 | ) |
@@ -76,25 +76,25 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | - public function check_payment_gateway_setup(){ |
|
79 | + public function check_payment_gateway_setup() { |
|
80 | 80 | //ONLY do this check if models can query |
81 | 81 | //and avoid a bug where when we nuke EE4's data that this causes a fatal error |
82 | 82 | //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539 |
83 | 83 | if ( |
84 | 84 | ! EE_Maintenance_Mode::instance()->models_can_query() |
85 | - || ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() ) |
|
85 | + || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) |
|
86 | 86 | ) { |
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | // ensure Payment_Method model is loaded |
92 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
93 | - $actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
94 | - if( $actives < 1 ){ |
|
92 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
93 | + $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
94 | + if ($actives < 1) { |
|
95 | 95 | $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL); |
96 | 96 | echo '<div class="error"> |
97 | - <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p> |
|
97 | + <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p> |
|
98 | 98 | </div>'; |
99 | 99 | } |
100 | 100 | } |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | * @throws \EE_Error |
106 | 106 | */ |
107 | 107 | protected function _get_table_analysis() { |
108 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
108 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
109 | 109 | return $this->_table_analysis; |
110 | 110 | } else { |
111 | 111 | throw new \EE_Error( |
112 | 112 | sprintf( |
113 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
114 | - get_class( $this ) |
|
113 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
114 | + get_class($this) |
|
115 | 115 | ) |
116 | 116 | ); |
117 | 117 | } |
@@ -122,20 +122,20 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * Hide PayPal Standard for "new" users. |
124 | 124 | */ |
125 | - public static function unset_pp_standard( $payment_method_types ) { |
|
126 | - $pps = EEM_Payment_Method::instance()->get_one_of_type( 'Paypal_Standard' ); |
|
127 | - $ppstandard_active = ( ! empty($pps) ) ? $pps->active() : false; |
|
125 | + public static function unset_pp_standard($payment_method_types) { |
|
126 | + $pps = EEM_Payment_Method::instance()->get_one_of_type('Paypal_Standard'); |
|
127 | + $ppstandard_active = ( ! empty($pps)) ? $pps->active() : false; |
|
128 | 128 | $ppstandard_active_before = false; |
129 | - if ( $pps ) { |
|
129 | + if ($pps) { |
|
130 | 130 | // PP Standard used before ? |
131 | - $paypal_id = $pps->get_extra_meta( 'paypal_id', TRUE ); |
|
132 | - if ( $paypal_id && ! empty($paypal_id) ) { |
|
131 | + $paypal_id = $pps->get_extra_meta('paypal_id', TRUE); |
|
132 | + if ($paypal_id && ! empty($paypal_id)) { |
|
133 | 133 | $ppstandard_active_before = true; |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Not using PP Standard? Then display only PayPal Express, do not show PayPal Standard. |
138 | - if ( apply_filters( 'FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before ) ) { |
|
138 | + if (apply_filters('FHEE__EE_PMT_Paypal_Express__register_payment_methods__hide_paypal_standard', ! $ppstandard_active && ! $ppstandard_active_before)) { |
|
139 | 139 | unset($payment_method_types['paypal_standard']); |
140 | 140 | } |
141 | 141 | return $payment_method_types; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <p> |
2 | - <strong><?php _e( 'PayPal Express Checkout', 'event_espresso' ); ?></strong> |
|
2 | + <strong><?php _e('PayPal Express Checkout', 'event_espresso'); ?></strong> |
|
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php _e('Please be sure to update the settings for the PayPal Express Checkout payment method.', 'event_espresso'); ?> |
6 | 6 | </p> |
7 | 7 | <p> |
8 | - <?php printf( __('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>' ); ?> |
|
8 | + <?php printf(__('For more information on how to get your API credentials, please view the %1$sPayPal Documentation%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com/docs/classic/api/apiCredentials/#create-an-api-signature">', '</a>'); ?> |
|
9 | 9 | </p> |
10 | 10 | |
11 | 11 | |
@@ -14,25 +14,25 @@ discard block |
||
14 | 14 | </p> |
15 | 15 | <ul> |
16 | 16 | <li> |
17 | - <strong><?php _e( 'API Username', 'event_espresso' ); ?></strong><br/> |
|
18 | - <?php _e( 'Your PayPal API Username.'); ?> |
|
17 | + <strong><?php _e('API Username', 'event_espresso'); ?></strong><br/> |
|
18 | + <?php _e('Your PayPal API Username.'); ?> |
|
19 | 19 | </li> |
20 | 20 | <li> |
21 | - <strong><?php _e( 'API Password', 'event_espresso' ); ?></strong><br/> |
|
22 | - <?php _e( 'Your PayPal API Password.' ); ?> |
|
21 | + <strong><?php _e('API Password', 'event_espresso'); ?></strong><br/> |
|
22 | + <?php _e('Your PayPal API Password.'); ?> |
|
23 | 23 | </li> |
24 | 24 | <li> |
25 | - <strong><?php _e( 'API Signature', 'event_espresso' ); ?></strong><br/> |
|
26 | - <?php _e( 'Your PayPal Account Signature.' ); ?> |
|
25 | + <strong><?php _e('API Signature', 'event_espresso'); ?></strong><br/> |
|
26 | + <?php _e('Your PayPal Account Signature.'); ?> |
|
27 | 27 | </li> |
28 | 28 | <li> |
29 | - <strong><?php _e( 'Request Shipping Address', 'event_espresso' ); ?></strong><br/> |
|
30 | - <?php _e( 'Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.' ); ?> |
|
29 | + <strong><?php _e('Request Shipping Address', 'event_espresso'); ?></strong><br/> |
|
30 | + <?php _e('Indicates whether or not you require the buyer\'s shipping address on file with PayPal be a confirmed address.'); ?> |
|
31 | 31 | </li> |
32 | 32 | </ul> |
33 | 33 | <p> |
34 | - <?php printf( __('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>' ); ?> |
|
34 | + <?php printf(__('For testing please use a %1$s PaypPal Sandbox account%2$s.', 'event_espresso'), '<a target="_blank" href="https://developer.paypal.com">', '</a>'); ?> |
|
35 | 35 | </p> |
36 | 36 | <p> |
37 | - <?php printf( __('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>' ); ?> |
|
37 | + <?php printf(__('Don\'t have PayPal? %1$sSign up for an account%2$s to get start right away.', 'event_espresso'), '<a target="_blank" href="hhttps://eventespresso.com/go/paypalstandard/">', '</a>'); ?> |
|
38 | 38 | </p> |
39 | 39 | \ No newline at end of file |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | * |
855 | 855 | * @param null $field_to_order_by What field is being used as the reference point. |
856 | 856 | * @param array $query_params Any additional conditions on the query. |
857 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
857 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
858 | 858 | * you can indicate just the columns you want returned |
859 | 859 | * @return array|EE_Base_Class |
860 | 860 | * @throws \EE_Error |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * |
879 | 879 | * @param null $field_to_order_by What field is being used as the reference point. |
880 | 880 | * @param array $query_params Any additional conditions on the query. |
881 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
881 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
882 | 882 | * you can indicate just the column you want returned |
883 | 883 | * @return array|EE_Base_Class |
884 | 884 | * @throws \EE_Error |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | * This method simply returns the RAW unprocessed value for the given property in this class |
948 | 948 | * |
949 | 949 | * @param string $field_name A valid fieldname |
950 | - * @return mixed Whatever the raw value stored on the property is. |
|
950 | + * @return integer|null Whatever the raw value stored on the property is. |
|
951 | 951 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
952 | 952 | */ |
953 | 953 | public function get_raw($field_name) { |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | * sets the time on a datetime property |
1239 | 1239 | * |
1240 | 1240 | * @access protected |
1241 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1241 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1242 | 1242 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1243 | 1243 | * @throws \EE_Error |
1244 | 1244 | */ |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | * sets the date on a datetime property |
1253 | 1253 | * |
1254 | 1254 | * @access protected |
1255 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1255 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1256 | 1256 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1257 | 1257 | * @throws \EE_Error |
1258 | 1258 | */ |
@@ -1309,6 +1309,7 @@ discard block |
||
1309 | 1309 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1310 | 1310 | * @param string $prepend You can include something to prepend on the timestamp |
1311 | 1311 | * @param string $append You can include something to append on the timestamp |
1312 | + * @param string $args |
|
1312 | 1313 | * @throws EE_Error |
1313 | 1314 | * @return string timestamp |
1314 | 1315 | */ |
@@ -1669,7 +1670,7 @@ discard block |
||
1669 | 1670 | * |
1670 | 1671 | * @param array $props_n_values incoming array of properties and their values |
1671 | 1672 | * @param string $classname the classname of the child class |
1672 | - * @param null $timezone |
|
1673 | + * @param string|null $timezone |
|
1673 | 1674 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1674 | 1675 | * date_format and the second value is the time format |
1675 | 1676 | * @return mixed (EE_Base_Class|bool) |
@@ -1745,7 +1746,7 @@ discard block |
||
1745 | 1746 | /** |
1746 | 1747 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1747 | 1748 | * @param string $model_classname |
1748 | - * @param null $timezone |
|
1749 | + * @param string|null $timezone |
|
1749 | 1750 | * @return EEM_Base |
1750 | 1751 | */ |
1751 | 1752 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
@@ -1422,24 +1422,24 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @throws \EE_Error |
1424 | 1424 | */ |
1425 | - public function refresh_cache_of_related_objects() { |
|
1426 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | - //this relation only stores a single model object, not an array |
|
1431 | - //but let's make it consistent |
|
1432 | - $related_objects = array( $related_objects ); |
|
1433 | - } |
|
1434 | - foreach( $related_objects as $related_object ) { |
|
1435 | - //only refresh their cache if they're in memory |
|
1436 | - if( $related_object instanceof EE_Base_Class ) { |
|
1425 | + public function refresh_cache_of_related_objects() { |
|
1426 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | + //this relation only stores a single model object, not an array |
|
1431 | + //but let's make it consistent |
|
1432 | + $related_objects = array( $related_objects ); |
|
1433 | + } |
|
1434 | + foreach( $related_objects as $related_object ) { |
|
1435 | + //only refresh their cache if they're in memory |
|
1436 | + if( $related_object instanceof EE_Base_Class ) { |
|
1437 | 1437 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1438 | - } |
|
1439 | - } |
|
1440 | - } |
|
1441 | - } |
|
1442 | - } |
|
1438 | + } |
|
1439 | + } |
|
1440 | + } |
|
1441 | + } |
|
1442 | + } |
|
1443 | 1443 | |
1444 | 1444 | |
1445 | 1445 | |
@@ -1680,7 +1680,7 @@ discard block |
||
1680 | 1680 | if ( self::_get_model( $classname )->has_primary_key_field() ) { |
1681 | 1681 | $primary_id_ref = self::_get_primary_key_name( $classname ); |
1682 | 1682 | if ( array_key_exists( $primary_id_ref, $props_n_values ) |
1683 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1683 | + && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1684 | 1684 | ) { |
1685 | 1685 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
1686 | 1686 | $props_n_values[ $primary_id_ref ] |
@@ -1832,9 +1832,9 @@ discard block |
||
1832 | 1832 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1833 | 1833 | //clear cache so future get_many_related and get_first_related() return new results. |
1834 | 1834 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1835 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1837 | - } |
|
1835 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1837 | + } |
|
1838 | 1838 | } else { |
1839 | 1839 | //this thing doesn't exist in the DB, so just cache it |
1840 | 1840 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1848,18 +1848,18 @@ discard block |
||
1848 | 1848 | } |
1849 | 1849 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1850 | 1850 | } |
1851 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1852 | - //fix the reciprocal relation too |
|
1853 | - if( $otherObject->ID() ) { |
|
1854 | - //its saved so assumed relations exist in the DB, so we can just |
|
1855 | - //clear the cache so future queries use the updated info in the DB |
|
1856 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1857 | - } else { |
|
1858 | - |
|
1859 | - //it's not saved, so it caches relations like this |
|
1860 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1861 | - } |
|
1862 | - } |
|
1851 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1852 | + //fix the reciprocal relation too |
|
1853 | + if( $otherObject->ID() ) { |
|
1854 | + //its saved so assumed relations exist in the DB, so we can just |
|
1855 | + //clear the cache so future queries use the updated info in the DB |
|
1856 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1857 | + } else { |
|
1858 | + |
|
1859 | + //it's not saved, so it caches relations like this |
|
1860 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1861 | + } |
|
1862 | + } |
|
1863 | 1863 | return $otherObject; |
1864 | 1864 | } |
1865 | 1865 | |
@@ -1890,9 +1890,9 @@ discard block |
||
1890 | 1890 | //this doesn't exist in the DB, just remove it from the cache |
1891 | 1891 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1892 | 1892 | } |
1893 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1895 | - } |
|
1893 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1895 | + } |
|
1896 | 1896 | return $otherObject; |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1915,11 +1915,11 @@ discard block |
||
1915 | 1915 | //this doesn't exist in the DB, just remove it from the cache |
1916 | 1916 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1917 | 1917 | } |
1918 | - if( is_array( $otherObjects ) ) { |
|
1919 | - foreach ( $otherObjects as $otherObject ) { |
|
1920 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1921 | - } |
|
1922 | - } |
|
1918 | + if( is_array( $otherObjects ) ) { |
|
1919 | + foreach ( $otherObjects as $otherObject ) { |
|
1920 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1921 | + } |
|
1922 | + } |
|
1923 | 1923 | return $otherObjects; |
1924 | 1924 | } |
1925 | 1925 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -110,58 +110,58 @@ discard block |
||
110 | 110 | * format. |
111 | 111 | * @throws EE_Error |
112 | 112 | */ |
113 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
113 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
114 | 114 | |
115 | - $className=get_class($this); |
|
115 | + $className = get_class($this); |
|
116 | 116 | |
117 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
118 | - $model=$this->get_model(); |
|
119 | - $model_fields = $model->field_settings( FALSE ); |
|
117 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
118 | + $model = $this->get_model(); |
|
119 | + $model_fields = $model->field_settings(FALSE); |
|
120 | 120 | // ensure $fieldValues is an array |
121 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
121 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
122 | 122 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
123 | 123 | // verify client code has not passed any invalid field names |
124 | - foreach($fieldValues as $field_name=> $field_value){ |
|
125 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
126 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
124 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
125 | + if ( ! isset($model_fields[$field_name])) { |
|
126 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
130 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
131 | 131 | |
132 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
133 | - list( $this->_dt_frmt, $this->_tm_frmt ) = $date_formats; |
|
132 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
133 | + list($this->_dt_frmt, $this->_tm_frmt) = $date_formats; |
|
134 | 134 | } else { |
135 | 135 | //set default formats for date and time |
136 | - $this->_dt_frmt = (string) get_option( 'date_format', 'Y-m-d' ); |
|
137 | - $this->_tm_frmt = (string) get_option( 'time_format', 'g:i a' ); |
|
136 | + $this->_dt_frmt = (string) get_option('date_format', 'Y-m-d'); |
|
137 | + $this->_tm_frmt = (string) get_option('time_format', 'g:i a'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | //if db model is instantiating |
141 | - if ( $bydb ){ |
|
141 | + if ($bydb) { |
|
142 | 142 | //client code has indicated these field values are from the database |
143 | - foreach( $model_fields as $fieldName => $field ){ |
|
144 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
143 | + foreach ($model_fields as $fieldName => $field) { |
|
144 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | //we're constructing a brand |
148 | 148 | //new instance of the model object. Generally, this means we'll need to do more field validation |
149 | - foreach( $model_fields as $fieldName => $field ){ |
|
150 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
149 | + foreach ($model_fields as $fieldName => $field) { |
|
150 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | //remember what values were passed to this constructor |
155 | 155 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
156 | 156 | //remember in entity mapper |
157 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
157 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
158 | 158 | $model->add_to_entity_map($this); |
159 | 159 | } |
160 | 160 | //setup all the relations |
161 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
162 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
161 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
162 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
163 | 163 | $this->_model_relations[$relation_name] = NULL; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | $this->_model_relations[$relation_name] = array(); |
166 | 166 | } |
167 | 167 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * Action done at the end of each model object construction |
170 | 170 | * @param EE_Base_Class $this the model object just created |
171 | 171 | */ |
172 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
172 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param boolean $allow_persist |
190 | 190 | * @return boolean |
191 | 191 | */ |
192 | - public function set_allow_persist( $allow_persist ) { |
|
192 | + public function set_allow_persist($allow_persist) { |
|
193 | 193 | return $this->_allow_persist = $allow_persist; |
194 | 194 | } |
195 | 195 | |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @return mixed|null |
204 | 204 | * @throws \EE_Error |
205 | 205 | */ |
206 | - public function get_original( $field_name ){ |
|
207 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
208 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
209 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
210 | - }else{ |
|
206 | + public function get_original($field_name) { |
|
207 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
208 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
209 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
210 | + } else { |
|
211 | 211 | return NULL; |
212 | 212 | } |
213 | 213 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param EE_Base_Class $obj |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function get_class($obj){ |
|
220 | + public function get_class($obj) { |
|
221 | 221 | return get_class($obj); |
222 | 222 | } |
223 | 223 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | * @param bool $use_default |
233 | 233 | * @throws \EE_Error |
234 | 234 | */ |
235 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
236 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
237 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
235 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
236 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
237 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
238 | 238 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
239 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
240 | - $field_obj->set_timezone( $this->_timezone ); |
|
241 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
242 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
239 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
240 | + $field_obj->set_timezone($this->_timezone); |
|
241 | + $field_obj->set_date_format($this->_dt_frmt); |
|
242 | + $field_obj->set_time_format($this->_tm_frmt); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
246 | 246 | //should the value be null? |
247 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
247 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
248 | 248 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
249 | 249 | |
250 | 250 | /** |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | */ |
257 | 257 | if ( |
258 | 258 | $field_obj instanceof EE_Datetime_Field |
259 | - && $this->_fields[ $field_name ] !== null |
|
259 | + && $this->_fields[$field_name] !== null |
|
260 | 260 | && ! $this->_fields[$field_name] instanceof DateTime |
261 | 261 | ) { |
262 | - empty( $this->_fields[$field_name] ) |
|
263 | - ? $this->set( $field_name, time() ) |
|
264 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
262 | + empty($this->_fields[$field_name]) |
|
263 | + ? $this->set($field_name, time()) |
|
264 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
265 | 265 | } |
266 | 266 | |
267 | - }else{ |
|
267 | + } else { |
|
268 | 268 | $this->_fields[$field_name] = $holder_of_value; |
269 | 269 | } |
270 | 270 | |
271 | 271 | //if we're not in the constructor... |
272 | 272 | //now check if what we set was a primary key |
273 | - if( |
|
273 | + if ( |
|
274 | 274 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
275 | 275 | $this->_props_n_values_provided_in_constructor |
276 | 276 | && $field_value |
277 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
278 | - ){ |
|
277 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
278 | + ) { |
|
279 | 279 | //if so, we want all this object's fields to be filled either with |
280 | 280 | //what we've explicitly set on this model |
281 | 281 | //or what we have in the db |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
284 | 284 | |
285 | 285 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
286 | - foreach($fields_on_model as $field_obj){ |
|
287 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
288 | - && $field_obj->get_name() !== $field_name ){ |
|
286 | + foreach ($fields_on_model as $field_obj) { |
|
287 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
288 | + && $field_obj->get_name() !== $field_name) { |
|
289 | 289 | |
290 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
290 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
291 | 291 | } |
292 | 292 | } |
293 | 293 | //oh this model object has an ID? well make sure its in the entity mapper |
294 | 294 | $this->get_model()->add_to_entity_map($this); |
295 | 295 | } |
296 | 296 | //let's unset any cache for this field_name from the $_cached_properties property. |
297 | - $this->_clear_cached_property( $field_name ); |
|
298 | - }else{ |
|
299 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
297 | + $this->_clear_cached_property($field_name); |
|
298 | + } else { |
|
299 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | } |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
317 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
318 | - $this->set( $field_name, $field_value ); |
|
316 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
317 | + if ($this->get_model()->has_field($field_name)) { |
|
318 | + $this->set($field_name, $field_value); |
|
319 | 319 | return true; |
320 | 320 | } else { |
321 | 321 | //ensure this object is saved first so that extra meta can be properly related. |
322 | 322 | $this->save(); |
323 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
323 | + return $this->update_extra_meta($field_name, $field_value); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | * @return mixed|null value for the field if found. null if not found. |
342 | 342 | * @throws \EE_Error |
343 | 343 | */ |
344 | - public function get_field_or_extra_meta( $field_name ) { |
|
345 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
346 | - $column_value = $this->get( $field_name ); |
|
344 | + public function get_field_or_extra_meta($field_name) { |
|
345 | + if ($this->get_model()->has_field($field_name)) { |
|
346 | + $column_value = $this->get($field_name); |
|
347 | 347 | } else { |
348 | 348 | //This isn't a column in the main table, let's see if it is in the extra meta. |
349 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
349 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
350 | 350 | } |
351 | 351 | return $column_value; |
352 | 352 | } |
@@ -362,18 +362,18 @@ discard block |
||
362 | 362 | * @return void |
363 | 363 | * @throws \EE_Error |
364 | 364 | */ |
365 | - public function set_timezone( $timezone = '' ) { |
|
366 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
365 | + public function set_timezone($timezone = '') { |
|
366 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
367 | 367 | //make sure we clear all cached properties because they won't be relevant now |
368 | 368 | $this->_clear_cached_properties(); |
369 | 369 | |
370 | 370 | //make sure we update field settings and the date for all EE_Datetime_Fields |
371 | - $model_fields = $this->get_model()->field_settings( false ); |
|
372 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
373 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
374 | - $field_obj->set_timezone( $this->_timezone ); |
|
375 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
376 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
371 | + $model_fields = $this->get_model()->field_settings(false); |
|
372 | + foreach ($model_fields as $field_name => $field_obj) { |
|
373 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
374 | + $field_obj->set_timezone($this->_timezone); |
|
375 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
376 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @param string $format should be a format recognizable by PHP date() functions. |
404 | 404 | */ |
405 | - public function set_date_format( $format ) { |
|
405 | + public function set_date_format($format) { |
|
406 | 406 | $this->_dt_frmt = $format; |
407 | 407 | //clear cached_properties because they won't be relevant now. |
408 | 408 | $this->_clear_cached_properties(); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @since 4.6 |
419 | 419 | * @param string $format should be a format recognizable by PHP date() functions. |
420 | 420 | */ |
421 | - public function set_time_format( $format ) { |
|
421 | + public function set_time_format($format) { |
|
422 | 422 | $this->_tm_frmt = $format; |
423 | 423 | //clear cached_properties because they won't be relevant now. |
424 | 424 | $this->_clear_cached_properties(); |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return mixed string|array |
437 | 437 | */ |
438 | - public function get_format( $full = true ) { |
|
439 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
438 | + public function get_format($full = true) { |
|
439 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | * @throws EE_Error |
455 | 455 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
456 | 456 | */ |
457 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
457 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
458 | 458 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
459 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
459 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
460 | 460 | return FALSE; |
461 | 461 | } |
462 | 462 | // also get "how" the object is related, or throw an error |
463 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
464 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
463 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
464 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
465 | 465 | } |
466 | 466 | // how many things are related ? |
467 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
467 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
468 | 468 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
469 | 469 | // so for these model objects just set it to be cached |
470 | 470 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -472,26 +472,26 @@ discard block |
||
472 | 472 | } else { |
473 | 473 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
474 | 474 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
475 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
475 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
476 | 476 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
477 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
477 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
478 | 478 | } |
479 | 479 | // first check for a cache_id which is normally empty |
480 | - if ( ! empty( $cache_id )) { |
|
480 | + if ( ! empty($cache_id)) { |
|
481 | 481 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
482 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
482 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
483 | 483 | $return = $cache_id; |
484 | - } elseif ( $object_to_cache->ID() ) { |
|
484 | + } elseif ($object_to_cache->ID()) { |
|
485 | 485 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
486 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
486 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
487 | 487 | $return = $object_to_cache->ID(); |
488 | 488 | } else { |
489 | 489 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
490 | 490 | $this->_model_relations[$relationName][] = $object_to_cache; |
491 | 491 | // move the internal pointer to the end of the array |
492 | - end( $this->_model_relations[$relationName] ); |
|
492 | + end($this->_model_relations[$relationName]); |
|
493 | 493 | // and grab the key so that we can return it |
494 | - $return = key( $this->_model_relations[$relationName] ); |
|
494 | + $return = key($this->_model_relations[$relationName]); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | } |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | * @return void |
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
513 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
514 | 514 | //first make sure this property exists |
515 | 515 | $this->get_model()->field_settings_for($fieldname); |
516 | 516 | |
517 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
517 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
518 | 518 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
519 | 519 | } |
520 | 520 | |
@@ -535,36 +535,36 @@ discard block |
||
535 | 535 | * @return mixed whatever the value for the property is we're retrieving |
536 | 536 | * @throws \EE_Error |
537 | 537 | */ |
538 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
538 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
539 | 539 | //verify the field exists |
540 | 540 | $this->get_model()->field_settings_for($fieldname); |
541 | 541 | |
542 | 542 | $cache_type = $pretty ? 'pretty' : 'standard'; |
543 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
543 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
544 | 544 | |
545 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
545 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
546 | 546 | return $this->_cached_properties[$fieldname][$cache_type]; |
547 | 547 | } |
548 | 548 | |
549 | 549 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
550 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
550 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
551 | 551 | /** |
552 | 552 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
553 | 553 | * formats are correct. |
554 | 554 | */ |
555 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
556 | - $field_obj->set_timezone( $this->_timezone ); |
|
557 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
558 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
555 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
556 | + $field_obj->set_timezone($this->_timezone); |
|
557 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
558 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
559 | 559 | } |
560 | 560 | |
561 | - if( ! isset($this->_fields[$fieldname])){ |
|
561 | + if ( ! isset($this->_fields[$fieldname])) { |
|
562 | 562 | $this->_fields[$fieldname] = NULL; |
563 | 563 | } |
564 | 564 | $value = $pretty |
565 | 565 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
566 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
567 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
566 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
567 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
568 | 568 | return $value; |
569 | 569 | } |
570 | 570 | return null; |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
591 | 591 | * @return void |
592 | 592 | */ |
593 | - protected function _clear_cached_property( $property_name ) { |
|
594 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
595 | - unset( $this->_cached_properties[ $property_name ] ); |
|
593 | + protected function _clear_cached_property($property_name) { |
|
594 | + if (isset($this->_cached_properties[$property_name])) { |
|
595 | + unset($this->_cached_properties[$property_name]); |
|
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * @return EE_Base_Class |
607 | 607 | * @throws \EE_Error |
608 | 608 | */ |
609 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
609 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
610 | 610 | $other_model_instance = self::_get_model_instance_with_name( |
611 | - self::_get_model_classname( $model_name ), |
|
611 | + self::_get_model_classname($model_name), |
|
612 | 612 | $this->_timezone |
613 | 613 | ); |
614 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
614 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | |
@@ -628,32 +628,32 @@ discard block |
||
628 | 628 | * @throws EE_Error |
629 | 629 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
630 | 630 | */ |
631 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
631 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
632 | 632 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
633 | 633 | $index_in_cache = ''; |
634 | - if( ! $relationship_to_model){ |
|
634 | + if ( ! $relationship_to_model) { |
|
635 | 635 | throw new EE_Error( |
636 | 636 | sprintf( |
637 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
637 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
638 | 638 | $relationName, |
639 | - get_class( $this ) |
|
639 | + get_class($this) |
|
640 | 640 | ) |
641 | 641 | ); |
642 | 642 | } |
643 | - if($clear_all){ |
|
643 | + if ($clear_all) { |
|
644 | 644 | $obj_removed = true; |
645 | 645 | $this->_model_relations[$relationName] = null; |
646 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
646 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
647 | 647 | $obj_removed = $this->_model_relations[$relationName]; |
648 | 648 | $this->_model_relations[$relationName] = null; |
649 | - }else{ |
|
650 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
649 | + } else { |
|
650 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
651 | 651 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
652 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
652 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
653 | 653 | $index_found_at = NULL; |
654 | 654 | //find this object in the array even though it has a different key |
655 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
656 | - if( |
|
655 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
656 | + if ( |
|
657 | 657 | $obj instanceof EE_Base_Class |
658 | 658 | && ( |
659 | 659 | $obj == $object_to_remove_or_index_into_array |
@@ -664,34 +664,34 @@ discard block |
||
664 | 664 | break; |
665 | 665 | } |
666 | 666 | } |
667 | - if($index_found_at){ |
|
667 | + if ($index_found_at) { |
|
668 | 668 | $index_in_cache = $index_found_at; |
669 | - }else{ |
|
669 | + } else { |
|
670 | 670 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
671 | 671 | //if it wasn't in it to begin with. So we're done |
672 | 672 | return $object_to_remove_or_index_into_array; |
673 | 673 | } |
674 | 674 | } |
675 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
675 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
676 | 676 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
677 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
678 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
677 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
678 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
679 | 679 | $index_in_cache = $index; |
680 | 680 | } |
681 | 681 | } |
682 | - }else{ |
|
682 | + } else { |
|
683 | 683 | $index_in_cache = $object_to_remove_or_index_into_array; |
684 | 684 | } |
685 | 685 | //supposedly we've found it. But it could just be that the client code |
686 | 686 | //provided a bad index/object |
687 | 687 | if ( |
688 | 688 | isset( |
689 | - $this->_model_relations[ $relationName ], |
|
690 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
689 | + $this->_model_relations[$relationName], |
|
690 | + $this->_model_relations[$relationName][$index_in_cache] |
|
691 | 691 | ) |
692 | 692 | ) { |
693 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
694 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
693 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
694 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
695 | 695 | } else { |
696 | 696 | //that thing was never cached anyways. |
697 | 697 | $obj_removed = null; |
@@ -712,24 +712,24 @@ discard block |
||
712 | 712 | * @return boolean TRUE on success, FALSE on fail |
713 | 713 | * @throws \EE_Error |
714 | 714 | */ |
715 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
715 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
716 | 716 | // verify that incoming object is of the correct type |
717 | - $obj_class = 'EE_' . $relationName; |
|
718 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
717 | + $obj_class = 'EE_'.$relationName; |
|
718 | + if ($newly_saved_object instanceof $obj_class) { |
|
719 | 719 | /* @type EE_Base_Class $newly_saved_object*/ |
720 | 720 | // now get the type of relation |
721 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
721 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
722 | 722 | // if this is a 1:1 relationship |
723 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
723 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
724 | 724 | // then just replace the cached object with the newly saved object |
725 | 725 | $this->_model_relations[$relationName] = $newly_saved_object; |
726 | 726 | return TRUE; |
727 | 727 | // or if it's some kind of sordid feral polyamorous relationship... |
728 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
728 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
729 | 729 | // then remove the current cached item |
730 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
730 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
731 | 731 | // and cache the newly saved object using it's new ID |
732 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
732 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
733 | 733 | return TRUE; |
734 | 734 | } |
735 | 735 | } |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | * @param string $relationName |
746 | 746 | * @return EE_Base_Class |
747 | 747 | */ |
748 | - public function get_one_from_cache($relationName){ |
|
749 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
750 | - if(is_array($cached_array_or_object)){ |
|
748 | + public function get_one_from_cache($relationName) { |
|
749 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
750 | + if (is_array($cached_array_or_object)) { |
|
751 | 751 | return array_shift($cached_array_or_object); |
752 | - }else{ |
|
752 | + } else { |
|
753 | 753 | return $cached_array_or_object; |
754 | 754 | } |
755 | 755 | } |
@@ -764,23 +764,23 @@ discard block |
||
764 | 764 | * @throws \EE_Error |
765 | 765 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
766 | 766 | */ |
767 | - public function get_all_from_cache($relationName){ |
|
768 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
767 | + public function get_all_from_cache($relationName) { |
|
768 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
769 | 769 | // if the result is not an array, but exists, make it an array |
770 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
770 | + $objects = is_array($objects) ? $objects : array($objects); |
|
771 | 771 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
772 | 772 | //basically, if this model object was stored in the session, and these cached model objects |
773 | 773 | //already have IDs, let's make sure they're in their model's entity mapper |
774 | 774 | //otherwise we will have duplicates next time we call |
775 | 775 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
776 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
777 | - foreach( $objects as $model_object ){ |
|
778 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
776 | + $model = EE_Registry::instance()->load_model($relationName); |
|
777 | + foreach ($objects as $model_object) { |
|
778 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
779 | 779 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
780 | - if( $model_object->ID() ){ |
|
781 | - $model->add_to_entity_map( $model_object ); |
|
780 | + if ($model_object->ID()) { |
|
781 | + $model->add_to_entity_map($model_object); |
|
782 | 782 | } |
783 | - }else{ |
|
783 | + } else { |
|
784 | 784 | throw new EE_Error( |
785 | 785 | sprintf( |
786 | 786 | __( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | 'event_espresso' |
789 | 789 | ), |
790 | 790 | $relationName, |
791 | - gettype( $model_object ) |
|
791 | + gettype($model_object) |
|
792 | 792 | ) |
793 | 793 | ); |
794 | 794 | } |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | * @return array|EE_Base_Class[] |
811 | 811 | * @throws \EE_Error |
812 | 812 | */ |
813 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
814 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
813 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
814 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
815 | 815 | ? $this->get_model()->get_primary_key_field()->get_name() |
816 | 816 | : $field_to_order_by; |
817 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
818 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
817 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
818 | + if (empty($field) || empty($current_value)) { |
|
819 | 819 | return array(); |
820 | 820 | } |
821 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
821 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | |
@@ -835,15 +835,15 @@ discard block |
||
835 | 835 | * @return array|EE_Base_Class[] |
836 | 836 | * @throws \EE_Error |
837 | 837 | */ |
838 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
839 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
838 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
839 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
840 | 840 | ? $this->get_model()->get_primary_key_field()->get_name() |
841 | 841 | : $field_to_order_by; |
842 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
843 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
842 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
843 | + if (empty($field) || empty($current_value)) { |
|
844 | 844 | return array(); |
845 | 845 | } |
846 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
846 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -859,15 +859,15 @@ discard block |
||
859 | 859 | * @return array|EE_Base_Class |
860 | 860 | * @throws \EE_Error |
861 | 861 | */ |
862 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
863 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
862 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
863 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
864 | 864 | ? $this->get_model()->get_primary_key_field()->get_name() |
865 | 865 | : $field_to_order_by; |
866 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
867 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
866 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
867 | + if (empty($field) || empty($current_value)) { |
|
868 | 868 | return array(); |
869 | 869 | } |
870 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
870 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -883,15 +883,15 @@ discard block |
||
883 | 883 | * @return array|EE_Base_Class |
884 | 884 | * @throws \EE_Error |
885 | 885 | */ |
886 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
887 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
886 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
887 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
888 | 888 | ? $this->get_model()->get_primary_key_field()->get_name() |
889 | 889 | : $field_to_order_by; |
890 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
891 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
890 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
891 | + if (empty($field) || empty($current_value)) { |
|
892 | 892 | return array(); |
893 | 893 | } |
894 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
894 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | |
@@ -904,25 +904,25 @@ discard block |
||
904 | 904 | * @param mixed $field_value_from_db |
905 | 905 | * @throws \EE_Error |
906 | 906 | */ |
907 | - public function set_from_db($field_name,$field_value_from_db){ |
|
907 | + public function set_from_db($field_name, $field_value_from_db) { |
|
908 | 908 | $field_obj = $this->get_model()->field_settings_for($field_name); |
909 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
909 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
910 | 910 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
911 | 911 | //eg, a CPT model object could have an entry in the posts table, but no |
912 | 912 | //entry in the meta table. Meaning that all its columns in the meta table |
913 | 913 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
914 | - if($field_value_from_db === NULL ){ |
|
915 | - if( $field_obj->is_nullable()){ |
|
914 | + if ($field_value_from_db === NULL) { |
|
915 | + if ($field_obj->is_nullable()) { |
|
916 | 916 | //if the field allows nulls, then let it be null |
917 | 917 | $field_value = NULL; |
918 | - }else{ |
|
918 | + } else { |
|
919 | 919 | $field_value = $field_obj->get_default_value(); |
920 | 920 | } |
921 | - }else{ |
|
922 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
921 | + } else { |
|
922 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
923 | 923 | } |
924 | 924 | $this->_fields[$field_name] = $field_value; |
925 | - $this->_clear_cached_property( $field_name ); |
|
925 | + $this->_clear_cached_property($field_name); |
|
926 | 926 | } |
927 | 927 | } |
928 | 928 | |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | * @return mixed |
939 | 939 | * @throws \EE_Error |
940 | 940 | */ |
941 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
942 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
941 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
942 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | |
@@ -972,10 +972,10 @@ discard block |
||
972 | 972 | * just null is returned (because that indicates that likely |
973 | 973 | * this field is nullable). |
974 | 974 | */ |
975 | - public function get_DateTime_object( $field_name ) { |
|
976 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
975 | + public function get_DateTime_object($field_name) { |
|
976 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
977 | 977 | |
978 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
978 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
979 | 979 | EE_Error::add_error( |
980 | 980 | sprintf( |
981 | 981 | __( |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | * @return void |
1008 | 1008 | * @throws \EE_Error |
1009 | 1009 | */ |
1010 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1010 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1011 | 1011 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1012 | 1012 | } |
1013 | 1013 | |
@@ -1021,8 +1021,8 @@ discard block |
||
1021 | 1021 | * @return void |
1022 | 1022 | * @throws \EE_Error |
1023 | 1023 | */ |
1024 | - public function f($field_name){ |
|
1025 | - $this->e($field_name,'form_input'); |
|
1024 | + public function f($field_name) { |
|
1025 | + $this->e($field_name, 'form_input'); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | * @return mixed |
1036 | 1036 | * @throws \EE_Error |
1037 | 1037 | */ |
1038 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1039 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1038 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1039 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | |
@@ -1058,36 +1058,36 @@ discard block |
||
1058 | 1058 | * if field is not a valid dtt field, or void if echoing |
1059 | 1059 | * @throws \EE_Error |
1060 | 1060 | */ |
1061 | - protected function _get_datetime( $field_name, $dt_frmt = '', $tm_frmt = '', $date_or_time = '', $echo = false ) { |
|
1061 | + protected function _get_datetime($field_name, $dt_frmt = '', $tm_frmt = '', $date_or_time = '', $echo = false) { |
|
1062 | 1062 | |
1063 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1063 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1064 | 1064 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1065 | 1065 | |
1066 | 1066 | //validate field for datetime and returns field settings if valid. |
1067 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1067 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1068 | 1068 | |
1069 | 1069 | //clear cached property if either formats are not null. |
1070 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1071 | - $this->_clear_cached_property( $field_name ); |
|
1070 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1071 | + $this->_clear_cached_property($field_name); |
|
1072 | 1072 | //reset format properties because they are used in get() |
1073 | 1073 | $this->_dt_frmt = $in_dt_frmt; |
1074 | 1074 | $this->_tm_frmt = $in_tm_frmt; |
1075 | 1075 | } |
1076 | - if ( $echo ) { |
|
1077 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1076 | + if ($echo) { |
|
1077 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1078 | 1078 | } else { |
1079 | - $field->set_date_format( $in_dt_frmt ); |
|
1079 | + $field->set_date_format($in_dt_frmt); |
|
1080 | 1080 | } |
1081 | - if ( $echo ) { |
|
1082 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1081 | + if ($echo) { |
|
1082 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1083 | 1083 | } else { |
1084 | - $field->set_time_format( $in_tm_frmt ); |
|
1084 | + $field->set_time_format($in_tm_frmt); |
|
1085 | 1085 | } |
1086 | 1086 | //set timezone in field object |
1087 | - $field->set_timezone( $this->_timezone ); |
|
1087 | + $field->set_timezone($this->_timezone); |
|
1088 | 1088 | |
1089 | 1089 | //set the output returned |
1090 | - switch ( $date_or_time ) { |
|
1090 | + switch ($date_or_time) { |
|
1091 | 1091 | |
1092 | 1092 | case 'D' : |
1093 | 1093 | $field->set_date_time_output('date'); |
@@ -1102,11 +1102,11 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
1105 | - if ( $echo ) { |
|
1106 | - $this->e( $field_name, $date_or_time ); |
|
1105 | + if ($echo) { |
|
1106 | + $this->e($field_name, $date_or_time); |
|
1107 | 1107 | return ''; |
1108 | 1108 | } |
1109 | - return $this->get( $field_name, $date_or_time ); |
|
1109 | + return $this->get($field_name, $date_or_time); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | 1112 | |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | * @return string datetime value formatted |
1120 | 1120 | * @throws \EE_Error |
1121 | 1121 | */ |
1122 | - public function get_date( $field_name, $format = NULL ) { |
|
1123 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1122 | + public function get_date($field_name, $format = NULL) { |
|
1123 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | |
@@ -1130,8 +1130,8 @@ discard block |
||
1130 | 1130 | * @param null $format |
1131 | 1131 | * @throws \EE_Error |
1132 | 1132 | */ |
1133 | - public function e_date( $field_name, $format = NULL ) { |
|
1134 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1133 | + public function e_date($field_name, $format = NULL) { |
|
1134 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | |
@@ -1144,8 +1144,8 @@ discard block |
||
1144 | 1144 | * @return string datetime value formatted |
1145 | 1145 | * @throws \EE_Error |
1146 | 1146 | */ |
1147 | - public function get_time( $field_name, $format = NULL ) { |
|
1148 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1147 | + public function get_time($field_name, $format = NULL) { |
|
1148 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | |
@@ -1155,8 +1155,8 @@ discard block |
||
1155 | 1155 | * @param null $format |
1156 | 1156 | * @throws \EE_Error |
1157 | 1157 | */ |
1158 | - public function e_time( $field_name, $format = NULL ) { |
|
1159 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1158 | + public function e_time($field_name, $format = NULL) { |
|
1159 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | * @return string datetime value formatted |
1171 | 1171 | * @throws \EE_Error |
1172 | 1172 | */ |
1173 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1174 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1173 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1174 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | * @param null $tm_frmt |
1183 | 1183 | * @throws \EE_Error |
1184 | 1184 | */ |
1185 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1186 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1185 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1186 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1197,11 +1197,11 @@ discard block |
||
1197 | 1197 | * @throws \EE_Error |
1198 | 1198 | * field name. |
1199 | 1199 | */ |
1200 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1201 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1200 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1201 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1202 | 1202 | return date_i18n( |
1203 | 1203 | $format, |
1204 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1204 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1205 | 1205 | ); |
1206 | 1206 | } |
1207 | 1207 | |
@@ -1214,14 +1214,14 @@ discard block |
||
1214 | 1214 | * @throws EE_Error |
1215 | 1215 | * @return EE_Datetime_Field |
1216 | 1216 | */ |
1217 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1217 | + protected function _get_dtt_field_settings($field_name) { |
|
1218 | 1218 | $field = $this->get_model()->field_settings_for($field_name); |
1219 | 1219 | |
1220 | 1220 | //check if field is dtt |
1221 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1221 | + if ($field instanceof EE_Datetime_Field) { |
|
1222 | 1222 | return $field; |
1223 | 1223 | } else { |
1224 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1224 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1225 | 1225 | } |
1226 | 1226 | } |
1227 | 1227 | |
@@ -1242,8 +1242,8 @@ discard block |
||
1242 | 1242 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1243 | 1243 | * @throws \EE_Error |
1244 | 1244 | */ |
1245 | - protected function _set_time_for( $time, $fieldname ) { |
|
1246 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1245 | + protected function _set_time_for($time, $fieldname) { |
|
1246 | + $this->_set_date_time('T', $time, $fieldname); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1257 | 1257 | * @throws \EE_Error |
1258 | 1258 | */ |
1259 | - protected function _set_date_for( $date, $fieldname ) { |
|
1260 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1259 | + protected function _set_date_for($date, $fieldname) { |
|
1260 | + $this->_set_date_time('D', $date, $fieldname); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | |
@@ -1271,26 +1271,26 @@ discard block |
||
1271 | 1271 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1272 | 1272 | * @throws \EE_Error |
1273 | 1273 | */ |
1274 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1275 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1276 | - $field->set_timezone( $this->_timezone ); |
|
1277 | - $field->set_date_format( $this->_dt_frmt ); |
|
1278 | - $field->set_time_format( $this->_tm_frmt ); |
|
1279 | - switch ( $what ) { |
|
1274 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1275 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1276 | + $field->set_timezone($this->_timezone); |
|
1277 | + $field->set_date_format($this->_dt_frmt); |
|
1278 | + $field->set_time_format($this->_tm_frmt); |
|
1279 | + switch ($what) { |
|
1280 | 1280 | case 'T' : |
1281 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1281 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1282 | 1282 | $datetime_value, |
1283 | - $this->_fields[ $fieldname ] |
|
1283 | + $this->_fields[$fieldname] |
|
1284 | 1284 | ); |
1285 | 1285 | break; |
1286 | 1286 | case 'D' : |
1287 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1287 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1288 | 1288 | $datetime_value, |
1289 | - $this->_fields[ $fieldname ] |
|
1289 | + $this->_fields[$fieldname] |
|
1290 | 1290 | ); |
1291 | 1291 | break; |
1292 | 1292 | case 'B' : |
1293 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1293 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1294 | 1294 | break; |
1295 | 1295 | } |
1296 | 1296 | $this->_clear_cached_property($fieldname); |
@@ -1312,17 +1312,17 @@ discard block |
||
1312 | 1312 | * @throws EE_Error |
1313 | 1313 | * @return string timestamp |
1314 | 1314 | */ |
1315 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1315 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1316 | 1316 | $timezone = EEH_DTT_Helper::get_timezone(); |
1317 | - if ( $timezone === $this->_timezone ) { |
|
1317 | + if ($timezone === $this->_timezone) { |
|
1318 | 1318 | return ''; |
1319 | 1319 | } |
1320 | 1320 | $original_timezone = $this->_timezone; |
1321 | - $this->set_timezone( $timezone ); |
|
1321 | + $this->set_timezone($timezone); |
|
1322 | 1322 | |
1323 | 1323 | $fn = (array) $field_name; |
1324 | - $args = array_merge( $fn, (array) $args ); |
|
1325 | - if ( ! method_exists( $this, $callback ) ) { |
|
1324 | + $args = array_merge($fn, (array) $args); |
|
1325 | + if ( ! method_exists($this, $callback)) { |
|
1326 | 1326 | throw new EE_Error( |
1327 | 1327 | sprintf( |
1328 | 1328 | __( |
@@ -1334,9 +1334,9 @@ discard block |
||
1334 | 1334 | ); |
1335 | 1335 | } |
1336 | 1336 | $args = (array) $args; |
1337 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1337 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1338 | 1338 | |
1339 | - $this->set_timezone( $original_timezone ); |
|
1339 | + $this->set_timezone($original_timezone); |
|
1340 | 1340 | return $return; |
1341 | 1341 | } |
1342 | 1342 | |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | * @return boolean | int |
1351 | 1351 | * @throws \EE_Error |
1352 | 1352 | */ |
1353 | - public function delete(){ |
|
1353 | + public function delete() { |
|
1354 | 1354 | /** |
1355 | 1355 | * Called just before the `EE_Base_Class::_delete` method call. |
1356 | 1356 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | * |
1360 | 1360 | * @param EE_Base_Class $model_object about to be 'deleted' |
1361 | 1361 | */ |
1362 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1362 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1363 | 1363 | $result = $this->_delete(); |
1364 | 1364 | /** |
1365 | 1365 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | * @param EE_Base_Class $model_object that was just 'deleted' |
1370 | 1370 | * @param boolean $result |
1371 | 1371 | */ |
1372 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1372 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1373 | 1373 | return $result; |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1395,22 +1395,22 @@ discard block |
||
1395 | 1395 | * @return bool | int |
1396 | 1396 | * @throws \EE_Error |
1397 | 1397 | */ |
1398 | - public function delete_permanently(){ |
|
1398 | + public function delete_permanently() { |
|
1399 | 1399 | /** |
1400 | 1400 | * Called just before HARD deleting a model object |
1401 | 1401 | * |
1402 | 1402 | * @param EE_Base_Class $model_object about to be 'deleted' |
1403 | 1403 | */ |
1404 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1405 | - $model=$this->get_model(); |
|
1406 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1404 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1405 | + $model = $this->get_model(); |
|
1406 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1407 | 1407 | $this->refresh_cache_of_related_objects(); |
1408 | 1408 | /** |
1409 | 1409 | * Called just after HARD deleting a model object |
1410 | 1410 | * @param EE_Base_Class $model_object that was just 'deleted' |
1411 | 1411 | * @param boolean $result |
1412 | 1412 | */ |
1413 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1413 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1414 | 1414 | return $result; |
1415 | 1415 | } |
1416 | 1416 | |
@@ -1423,18 +1423,18 @@ discard block |
||
1423 | 1423 | * @throws \EE_Error |
1424 | 1424 | */ |
1425 | 1425 | public function refresh_cache_of_related_objects() { |
1426 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1427 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1428 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1429 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1426 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1427 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1428 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1429 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1430 | 1430 | //this relation only stores a single model object, not an array |
1431 | 1431 | //but let's make it consistent |
1432 | - $related_objects = array( $related_objects ); |
|
1432 | + $related_objects = array($related_objects); |
|
1433 | 1433 | } |
1434 | - foreach( $related_objects as $related_object ) { |
|
1434 | + foreach ($related_objects as $related_object) { |
|
1435 | 1435 | //only refresh their cache if they're in memory |
1436 | - if( $related_object instanceof EE_Base_Class ) { |
|
1437 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1436 | + if ($related_object instanceof EE_Base_Class) { |
|
1437 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1438 | 1438 | } |
1439 | 1439 | } |
1440 | 1440 | } |
@@ -1454,17 +1454,17 @@ discard block |
||
1454 | 1454 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1455 | 1455 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1456 | 1456 | */ |
1457 | - public function save($set_cols_n_values=array()) { |
|
1457 | + public function save($set_cols_n_values = array()) { |
|
1458 | 1458 | /** |
1459 | 1459 | * Filters the fields we're about to save on the model object |
1460 | 1460 | * |
1461 | 1461 | * @param array $set_cols_n_values |
1462 | 1462 | * @param EE_Base_Class $model_object |
1463 | 1463 | */ |
1464 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1464 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1465 | 1465 | //set attributes as provided in $set_cols_n_values |
1466 | - foreach($set_cols_n_values as $column=>$value){ |
|
1467 | - $this->set($column,$value); |
|
1466 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1467 | + $this->set($column, $value); |
|
1468 | 1468 | } |
1469 | 1469 | /** |
1470 | 1470 | * Saving a model object. |
@@ -1472,8 +1472,8 @@ discard block |
||
1472 | 1472 | * Before we perform a save, this action is fired. |
1473 | 1473 | * @param EE_Base_Class $model_object the model object about to be saved. |
1474 | 1474 | */ |
1475 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1476 | - if( ! $this->allow_persist() ) { |
|
1475 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1476 | + if ( ! $this->allow_persist()) { |
|
1477 | 1477 | return 0; |
1478 | 1478 | } |
1479 | 1479 | //now get current attribute values |
@@ -1483,61 +1483,61 @@ discard block |
||
1483 | 1483 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1484 | 1484 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1485 | 1485 | //does this model have an autoincrement PK? |
1486 | - if($this->get_model()->has_primary_key_field()){ |
|
1487 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1486 | + if ($this->get_model()->has_primary_key_field()) { |
|
1487 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1488 | 1488 | //ok check if it's set, if so: update; if not, insert |
1489 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1490 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1489 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1490 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1491 | 1491 | } else { |
1492 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1493 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1494 | - if($results){ |
|
1492 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1493 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1494 | + if ($results) { |
|
1495 | 1495 | //if successful, set the primary key |
1496 | 1496 | //but don't use the normal SET method, because it will check if |
1497 | 1497 | //an item with the same ID exists in the mapper & db, then |
1498 | 1498 | //will find it in the db (because we just added it) and THAT object |
1499 | 1499 | //will get added to the mapper before we can add this one! |
1500 | 1500 | //but if we just avoid using the SET method, all that headache can be avoided |
1501 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1501 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1502 | 1502 | $this->_fields[$pk_field_name] = $results; |
1503 | 1503 | $this->_clear_cached_property($pk_field_name); |
1504 | - $this->get_model()->add_to_entity_map( $this ); |
|
1504 | + $this->get_model()->add_to_entity_map($this); |
|
1505 | 1505 | $this->_update_cached_related_model_objs_fks(); |
1506 | 1506 | } |
1507 | 1507 | } |
1508 | - }else{//PK is NOT auto-increment |
|
1508 | + } else {//PK is NOT auto-increment |
|
1509 | 1509 | //so check if one like it already exists in the db |
1510 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1511 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1510 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1511 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1512 | 1512 | throw new EE_Error( |
1513 | 1513 | sprintf( |
1514 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1514 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1515 | 1515 | get_class($this), |
1516 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1517 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1516 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1517 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1518 | 1518 | '<br />' |
1519 | 1519 | ) |
1520 | 1520 | ); |
1521 | 1521 | } |
1522 | 1522 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1523 | - }else{ |
|
1523 | + } else { |
|
1524 | 1524 | $results = $this->get_model()->insert($save_cols_n_values); |
1525 | 1525 | $this->_update_cached_related_model_objs_fks(); |
1526 | 1526 | } |
1527 | 1527 | } |
1528 | - }else{//there is NO primary key |
|
1528 | + } else {//there is NO primary key |
|
1529 | 1529 | $already_in_db = false; |
1530 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1530 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1531 | 1531 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1532 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1532 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1533 | 1533 | $already_in_db = true; |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - if( $already_in_db ){ |
|
1537 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1538 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1539 | - }else{ |
|
1540 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1536 | + if ($already_in_db) { |
|
1537 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1538 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1539 | + } else { |
|
1540 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1541 | 1541 | } |
1542 | 1542 | } |
1543 | 1543 | //restore the old assumption about values being prepared by the model object |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1551 | 1551 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1552 | 1552 | */ |
1553 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1553 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1554 | 1554 | return $results; |
1555 | 1555 | } |
1556 | 1556 | |
@@ -1565,15 +1565,15 @@ discard block |
||
1565 | 1565 | * @return void |
1566 | 1566 | * @throws \EE_Error |
1567 | 1567 | */ |
1568 | - protected function _update_cached_related_model_objs_fks(){ |
|
1569 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1570 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1571 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1568 | + protected function _update_cached_related_model_objs_fks() { |
|
1569 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1570 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1571 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1572 | 1572 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1573 | 1573 | $this->get_model()->get_this_model_name() |
1574 | 1574 | ); |
1575 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1576 | - if( $related_model_obj_in_cache->ID() ){ |
|
1575 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1576 | + if ($related_model_obj_in_cache->ID()) { |
|
1577 | 1577 | $related_model_obj_in_cache->save(); |
1578 | 1578 | } |
1579 | 1579 | } |
@@ -1594,21 +1594,21 @@ discard block |
||
1594 | 1594 | * @return int ID of new model object on save; 0 on failure+ |
1595 | 1595 | * @throws \EE_Error |
1596 | 1596 | */ |
1597 | - public function save_new_cached_related_model_objs(){ |
|
1597 | + public function save_new_cached_related_model_objs() { |
|
1598 | 1598 | //make sure this has been saved |
1599 | - if( ! $this->ID()){ |
|
1599 | + if ( ! $this->ID()) { |
|
1600 | 1600 | $id = $this->save(); |
1601 | - }else{ |
|
1601 | + } else { |
|
1602 | 1602 | $id = $this->ID(); |
1603 | 1603 | } |
1604 | 1604 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1605 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1605 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1606 | 1606 | |
1607 | 1607 | |
1608 | - if($this->_model_relations[$relationName]){ |
|
1608 | + if ($this->_model_relations[$relationName]) { |
|
1609 | 1609 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1610 | 1610 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1611 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1611 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1612 | 1612 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1613 | 1613 | //but ONLY if it DOES NOT exist in the DB |
1614 | 1614 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1617,8 +1617,8 @@ discard block |
||
1617 | 1617 | $this->_add_relation_to($related_model_obj, $relationName); |
1618 | 1618 | $related_model_obj->save_new_cached_related_model_objs(); |
1619 | 1619 | // } |
1620 | - }else{ |
|
1621 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1620 | + } else { |
|
1621 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1622 | 1622 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1623 | 1623 | //but ONLY if it DOES NOT exist in the DB |
1624 | 1624 | // if( ! $related_model_obj->ID()){ |
@@ -1639,8 +1639,8 @@ discard block |
||
1639 | 1639 | * @return \EEM_Base | \EEM_CPT_Base |
1640 | 1640 | */ |
1641 | 1641 | public function get_model() { |
1642 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1643 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1642 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1643 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1644 | 1644 | } |
1645 | 1645 | |
1646 | 1646 | |
@@ -1651,10 +1651,10 @@ discard block |
||
1651 | 1651 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1652 | 1652 | * @throws \EE_Error |
1653 | 1653 | */ |
1654 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1654 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1655 | 1655 | //TODO: will not work for Term_Relationships because they have no PK! |
1656 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1657 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1656 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1657 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1658 | 1658 | $id = $props_n_values[$primary_id_ref]; |
1659 | 1659 | return self::_get_model($classname)->get_from_entity_map($id); |
1660 | 1660 | } |
@@ -1675,37 +1675,37 @@ discard block |
||
1675 | 1675 | * @return mixed (EE_Base_Class|bool) |
1676 | 1676 | * @throws \EE_Error |
1677 | 1677 | */ |
1678 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1678 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1679 | 1679 | $existing = null; |
1680 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1681 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1682 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) |
|
1683 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1680 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1681 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1682 | + if (array_key_exists($primary_id_ref, $props_n_values) |
|
1683 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1684 | 1684 | ) { |
1685 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1686 | - $props_n_values[ $primary_id_ref ] |
|
1685 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1686 | + $props_n_values[$primary_id_ref] |
|
1687 | 1687 | ); |
1688 | 1688 | } |
1689 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1689 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1690 | 1690 | //no primary key on this model, but there's still a matching item in the DB |
1691 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1692 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1691 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1692 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1693 | 1693 | ); |
1694 | 1694 | } |
1695 | - if ( $existing ) { |
|
1695 | + if ($existing) { |
|
1696 | 1696 | |
1697 | 1697 | //set date formats if present before setting values |
1698 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1699 | - $existing->set_date_format( $date_formats[0] ); |
|
1700 | - $existing->set_time_format( $date_formats[1] ); |
|
1698 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1699 | + $existing->set_date_format($date_formats[0]); |
|
1700 | + $existing->set_time_format($date_formats[1]); |
|
1701 | 1701 | } else { |
1702 | 1702 | //set default formats for date and time |
1703 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1704 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1703 | + $existing->set_date_format(get_option('date_format')); |
|
1704 | + $existing->set_time_format(get_option('time_format')); |
|
1705 | 1705 | } |
1706 | 1706 | |
1707 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1708 | - $existing->set( $property, $field_value ); |
|
1707 | + foreach ($props_n_values as $property => $field_value) { |
|
1708 | + $existing->set($property, $field_value); |
|
1709 | 1709 | } |
1710 | 1710 | return $existing; |
1711 | 1711 | } else { |
@@ -1723,9 +1723,9 @@ discard block |
||
1723 | 1723 | * @throws EE_Error |
1724 | 1724 | * @return EEM_Base |
1725 | 1725 | */ |
1726 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1726 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1727 | 1727 | //find model for this class |
1728 | - if( ! $classname ){ |
|
1728 | + if ( ! $classname) { |
|
1729 | 1729 | throw new EE_Error( |
1730 | 1730 | sprintf( |
1731 | 1731 | __( |
@@ -1736,8 +1736,8 @@ discard block |
||
1736 | 1736 | ) |
1737 | 1737 | ); |
1738 | 1738 | } |
1739 | - $modelName=self::_get_model_classname($classname); |
|
1740 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1739 | + $modelName = self::_get_model_classname($classname); |
|
1740 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1741 | 1741 | } |
1742 | 1742 | |
1743 | 1743 | |
@@ -1748,10 +1748,10 @@ discard block |
||
1748 | 1748 | * @param null $timezone |
1749 | 1749 | * @return EEM_Base |
1750 | 1750 | */ |
1751 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1752 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1753 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1754 | - $model->set_timezone( $timezone ); |
|
1751 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1752 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1753 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1754 | + $model->set_timezone($timezone); |
|
1755 | 1755 | return $model; |
1756 | 1756 | } |
1757 | 1757 | |
@@ -1763,10 +1763,10 @@ discard block |
||
1763 | 1763 | * @param null $model_name |
1764 | 1764 | * @return string like EEM_Attendee |
1765 | 1765 | */ |
1766 | - private static function _get_model_classname( $model_name = null){ |
|
1767 | - if(strpos($model_name,"EE_")===0){ |
|
1768 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1769 | - }else{ |
|
1766 | + private static function _get_model_classname($model_name = null) { |
|
1767 | + if (strpos($model_name, "EE_") === 0) { |
|
1768 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1769 | + } else { |
|
1770 | 1770 | $model_classname = "EEM_".$model_name; |
1771 | 1771 | } |
1772 | 1772 | return $model_classname; |
@@ -1780,16 +1780,16 @@ discard block |
||
1780 | 1780 | * @throws EE_Error |
1781 | 1781 | * @return string |
1782 | 1782 | */ |
1783 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1784 | - if( ! $classname){ |
|
1783 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1784 | + if ( ! $classname) { |
|
1785 | 1785 | throw new EE_Error( |
1786 | 1786 | sprintf( |
1787 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1787 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1788 | 1788 | $classname |
1789 | 1789 | ) |
1790 | 1790 | ); |
1791 | 1791 | } |
1792 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1792 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | |
@@ -1803,12 +1803,12 @@ discard block |
||
1803 | 1803 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1804 | 1804 | * @throws \EE_Error |
1805 | 1805 | */ |
1806 | - public function ID(){ |
|
1806 | + public function ID() { |
|
1807 | 1807 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1808 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1809 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1810 | - }else{ |
|
1811 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1808 | + if ($this->get_model()->has_primary_key_field()) { |
|
1809 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1810 | + } else { |
|
1811 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1812 | 1812 | } |
1813 | 1813 | } |
1814 | 1814 | |
@@ -1826,38 +1826,38 @@ discard block |
||
1826 | 1826 | * @throws EE_Error |
1827 | 1827 | * @return EE_Base_Class the object the relation was added to |
1828 | 1828 | */ |
1829 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1829 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1830 | 1830 | //if this thing exists in the DB, save the relation to the DB |
1831 | - if( $this->ID() ){ |
|
1832 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1831 | + if ($this->ID()) { |
|
1832 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1833 | 1833 | //clear cache so future get_many_related and get_first_related() return new results. |
1834 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1835 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1836 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1834 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1835 | + if ($otherObject instanceof EE_Base_Class) { |
|
1836 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1837 | 1837 | } |
1838 | 1838 | } else { |
1839 | 1839 | //this thing doesn't exist in the DB, so just cache it |
1840 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1841 | - throw new EE_Error( sprintf( |
|
1842 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1840 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1841 | + throw new EE_Error(sprintf( |
|
1842 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1843 | 1843 | $otherObjectModelObjectOrID, |
1844 | - get_class( $this ) |
|
1844 | + get_class($this) |
|
1845 | 1845 | )); |
1846 | 1846 | } else { |
1847 | 1847 | $otherObject = $otherObjectModelObjectOrID; |
1848 | 1848 | } |
1849 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1849 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1850 | 1850 | } |
1851 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1851 | + if ($otherObject instanceof EE_Base_Class) { |
|
1852 | 1852 | //fix the reciprocal relation too |
1853 | - if( $otherObject->ID() ) { |
|
1853 | + if ($otherObject->ID()) { |
|
1854 | 1854 | //its saved so assumed relations exist in the DB, so we can just |
1855 | 1855 | //clear the cache so future queries use the updated info in the DB |
1856 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1856 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1857 | 1857 | } else { |
1858 | 1858 | |
1859 | 1859 | //it's not saved, so it caches relations like this |
1860 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1860 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1861 | 1861 | } |
1862 | 1862 | } |
1863 | 1863 | return $otherObject; |
@@ -1881,17 +1881,17 @@ discard block |
||
1881 | 1881 | * @return EE_Base_Class the relation was removed from |
1882 | 1882 | * @throws \EE_Error |
1883 | 1883 | */ |
1884 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1885 | - if ( $this->ID() ) { |
|
1884 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1885 | + if ($this->ID()) { |
|
1886 | 1886 | //if this exists in the DB, save the relation change to the DB too |
1887 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1888 | - $this->clear_cache( $relationName, $otherObject ); |
|
1887 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1888 | + $this->clear_cache($relationName, $otherObject); |
|
1889 | 1889 | } else { |
1890 | 1890 | //this doesn't exist in the DB, just remove it from the cache |
1891 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1891 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1892 | 1892 | } |
1893 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1894 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | + if ($otherObject instanceof EE_Base_Class) { |
|
1894 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1895 | 1895 | } |
1896 | 1896 | return $otherObject; |
1897 | 1897 | } |
@@ -1906,18 +1906,18 @@ discard block |
||
1906 | 1906 | * @return EE_Base_Class |
1907 | 1907 | * @throws \EE_Error |
1908 | 1908 | */ |
1909 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1910 | - if ( $this->ID() ) { |
|
1909 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1910 | + if ($this->ID()) { |
|
1911 | 1911 | //if this exists in the DB, save the relation change to the DB too |
1912 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1913 | - $this->clear_cache( $relationName, null, true ); |
|
1912 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1913 | + $this->clear_cache($relationName, null, true); |
|
1914 | 1914 | } else { |
1915 | 1915 | //this doesn't exist in the DB, just remove it from the cache |
1916 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1916 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1917 | 1917 | } |
1918 | - if( is_array( $otherObjects ) ) { |
|
1919 | - foreach ( $otherObjects as $otherObject ) { |
|
1920 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1918 | + if (is_array($otherObjects)) { |
|
1919 | + foreach ($otherObjects as $otherObject) { |
|
1920 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1921 | 1921 | } |
1922 | 1922 | } |
1923 | 1923 | return $otherObjects; |
@@ -1937,27 +1937,27 @@ discard block |
||
1937 | 1937 | * @throws \EE_Error |
1938 | 1938 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1939 | 1939 | */ |
1940 | - public function get_many_related($relationName,$query_params = array()){ |
|
1941 | - if($this->ID()){ |
|
1940 | + public function get_many_related($relationName, $query_params = array()) { |
|
1941 | + if ($this->ID()) { |
|
1942 | 1942 | //this exists in the DB, so get the related things from either the cache or the DB |
1943 | 1943 | //if there are query parameters, forget about caching the related model objects. |
1944 | - if( $query_params ){ |
|
1944 | + if ($query_params) { |
|
1945 | 1945 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1946 | - }else{ |
|
1946 | + } else { |
|
1947 | 1947 | //did we already cache the result of this query? |
1948 | 1948 | $cached_results = $this->get_all_from_cache($relationName); |
1949 | - if ( ! $cached_results ){ |
|
1949 | + if ( ! $cached_results) { |
|
1950 | 1950 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1951 | 1951 | //if no query parameters were passed, then we got all the related model objects |
1952 | 1952 | //for that relation. We can cache them then. |
1953 | - foreach($related_model_objects as $related_model_object){ |
|
1953 | + foreach ($related_model_objects as $related_model_object) { |
|
1954 | 1954 | $this->cache($relationName, $related_model_object); |
1955 | 1955 | } |
1956 | - }else{ |
|
1956 | + } else { |
|
1957 | 1957 | $related_model_objects = $cached_results; |
1958 | 1958 | } |
1959 | 1959 | } |
1960 | - }else{ |
|
1960 | + } else { |
|
1961 | 1961 | //this doesn't exist in the DB, so just get the related things from the cache |
1962 | 1962 | $related_model_objects = $this->get_all_from_cache($relationName); |
1963 | 1963 | } |
@@ -1975,8 +1975,8 @@ discard block |
||
1975 | 1975 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1976 | 1976 | * @return int |
1977 | 1977 | */ |
1978 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1979 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1978 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1979 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1980 | 1980 | } |
1981 | 1981 | |
1982 | 1982 | |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1991 | 1991 | * @return int |
1992 | 1992 | */ |
1993 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1993 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1994 | 1994 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1995 | 1995 | } |
1996 | 1996 | |
@@ -2004,33 +2004,33 @@ discard block |
||
2004 | 2004 | * @return EE_Base_Class (not an array, a single object) |
2005 | 2005 | * @throws \EE_Error |
2006 | 2006 | */ |
2007 | - public function get_first_related($relationName,$query_params = array()){ |
|
2008 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2007 | + public function get_first_related($relationName, $query_params = array()) { |
|
2008 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2009 | 2009 | |
2010 | 2010 | //if they've provided some query parameters, don't bother trying to cache the result |
2011 | 2011 | //also make sure we're not caching the result of get_first_related |
2012 | 2012 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2013 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2014 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2015 | - }else{ |
|
2013 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2014 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2015 | + } else { |
|
2016 | 2016 | //first, check if we've already cached the result of this query |
2017 | 2017 | $cached_result = $this->get_one_from_cache($relationName); |
2018 | - if ( ! $cached_result ){ |
|
2018 | + if ( ! $cached_result) { |
|
2019 | 2019 | |
2020 | 2020 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2021 | - $this->cache($relationName,$related_model_object); |
|
2022 | - }else{ |
|
2021 | + $this->cache($relationName, $related_model_object); |
|
2022 | + } else { |
|
2023 | 2023 | $related_model_object = $cached_result; |
2024 | 2024 | } |
2025 | 2025 | } |
2026 | - }else{ |
|
2026 | + } else { |
|
2027 | 2027 | $related_model_object = null; |
2028 | 2028 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2029 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2030 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2029 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2030 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2031 | 2031 | } |
2032 | 2032 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2033 | - if( ! $related_model_object){ |
|
2033 | + if ( ! $related_model_object) { |
|
2034 | 2034 | $related_model_object = $this->get_one_from_cache($relationName); |
2035 | 2035 | } |
2036 | 2036 | |
@@ -2052,12 +2052,12 @@ discard block |
||
2052 | 2052 | * @return int how many deleted |
2053 | 2053 | * @throws \EE_Error |
2054 | 2054 | */ |
2055 | - public function delete_related($relationName,$query_params = array()){ |
|
2056 | - if($this->ID()){ |
|
2057 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2058 | - }else{ |
|
2055 | + public function delete_related($relationName, $query_params = array()) { |
|
2056 | + if ($this->ID()) { |
|
2057 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2058 | + } else { |
|
2059 | 2059 | $count = count($this->get_all_from_cache($relationName)); |
2060 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2060 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2061 | 2061 | } |
2062 | 2062 | return $count; |
2063 | 2063 | } |
@@ -2076,13 +2076,13 @@ discard block |
||
2076 | 2076 | * @return int how many deleted (including those soft deleted) |
2077 | 2077 | * @throws \EE_Error |
2078 | 2078 | */ |
2079 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2080 | - if($this->ID()){ |
|
2081 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2082 | - }else{ |
|
2079 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2080 | + if ($this->ID()) { |
|
2081 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2082 | + } else { |
|
2083 | 2083 | $count = count($this->get_all_from_cache($relationName)); |
2084 | 2084 | } |
2085 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2085 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2086 | 2086 | return $count; |
2087 | 2087 | } |
2088 | 2088 | |
@@ -2098,7 +2098,7 @@ discard block |
||
2098 | 2098 | * @param string $field_name property to check |
2099 | 2099 | * @return bool TRUE if existing,FALSE if not. |
2100 | 2100 | */ |
2101 | - public function is_set( $field_name ) { |
|
2101 | + public function is_set($field_name) { |
|
2102 | 2102 | return isset($this->_fields[$field_name]); |
2103 | 2103 | } |
2104 | 2104 | |
@@ -2110,11 +2110,11 @@ discard block |
||
2110 | 2110 | * @throws EE_Error |
2111 | 2111 | * @return bool TRUE if existing, throw EE_Error if not. |
2112 | 2112 | */ |
2113 | - protected function _property_exists( $properties ) { |
|
2113 | + protected function _property_exists($properties) { |
|
2114 | 2114 | |
2115 | - foreach ( (array) $properties as $property_name ) { |
|
2115 | + foreach ((array) $properties as $property_name) { |
|
2116 | 2116 | //first make sure this property exists |
2117 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2117 | + if ( ! $this->_fields[$property_name]) { |
|
2118 | 2118 | throw new EE_Error( |
2119 | 2119 | sprintf( |
2120 | 2120 | __( |
@@ -2142,7 +2142,7 @@ discard block |
||
2142 | 2142 | $fields = $this->get_model()->field_settings(FALSE); |
2143 | 2143 | $properties = array(); |
2144 | 2144 | //remove prepended underscore |
2145 | - foreach ( $fields as $field_name => $settings ) { |
|
2145 | + foreach ($fields as $field_name => $settings) { |
|
2146 | 2146 | $properties[$field_name] = $this->get($field_name); |
2147 | 2147 | } |
2148 | 2148 | return $properties; |
@@ -2172,10 +2172,10 @@ discard block |
||
2172 | 2172 | * @throws EE_Error |
2173 | 2173 | * @return mixed whatever the plugin which calls add_filter decides |
2174 | 2174 | */ |
2175 | - public function __call($methodName,$args){ |
|
2176 | - $className=get_class($this); |
|
2177 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2178 | - if ( ! has_filter( $tagName ) ) { |
|
2175 | + public function __call($methodName, $args) { |
|
2176 | + $className = get_class($this); |
|
2177 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2178 | + if ( ! has_filter($tagName)) { |
|
2179 | 2179 | throw new EE_Error( |
2180 | 2180 | sprintf( |
2181 | 2181 | __( |
@@ -2188,7 +2188,7 @@ discard block |
||
2188 | 2188 | ) |
2189 | 2189 | ); |
2190 | 2190 | } |
2191 | - return apply_filters($tagName,null,$this,$args); |
|
2191 | + return apply_filters($tagName, null, $this, $args); |
|
2192 | 2192 | } |
2193 | 2193 | |
2194 | 2194 | |
@@ -2204,7 +2204,7 @@ discard block |
||
2204 | 2204 | * @throws \EE_Error |
2205 | 2205 | * NOTE: if the values haven't changed, returns 0 |
2206 | 2206 | */ |
2207 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2207 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2208 | 2208 | $query_params = array( |
2209 | 2209 | array( |
2210 | 2210 | 'EXM_key' => $meta_key, |
@@ -2212,17 +2212,17 @@ discard block |
||
2212 | 2212 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2213 | 2213 | ) |
2214 | 2214 | ); |
2215 | - if ( $previous_value !== null ) { |
|
2215 | + if ($previous_value !== null) { |
|
2216 | 2216 | $query_params[0]['EXM_value'] = $meta_value; |
2217 | 2217 | } |
2218 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2219 | - if ( ! $existing_rows_like_that ) { |
|
2220 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2218 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2219 | + if ( ! $existing_rows_like_that) { |
|
2220 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2221 | 2221 | } else { |
2222 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2223 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2222 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2223 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2224 | 2224 | } |
2225 | - return count( $existing_rows_like_that ); |
|
2225 | + return count($existing_rows_like_that); |
|
2226 | 2226 | } |
2227 | 2227 | } |
2228 | 2228 | |
@@ -2239,8 +2239,8 @@ discard block |
||
2239 | 2239 | * @return boolean |
2240 | 2240 | * @throws \EE_Error |
2241 | 2241 | */ |
2242 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2243 | - if ( $unique ) { |
|
2242 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2243 | + if ($unique) { |
|
2244 | 2244 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2245 | 2245 | array( |
2246 | 2246 | array( |
@@ -2250,7 +2250,7 @@ discard block |
||
2250 | 2250 | ) |
2251 | 2251 | ) |
2252 | 2252 | ); |
2253 | - if ( $existing_extra_meta ) { |
|
2253 | + if ($existing_extra_meta) { |
|
2254 | 2254 | return false; |
2255 | 2255 | } |
2256 | 2256 | } |
@@ -2277,7 +2277,7 @@ discard block |
||
2277 | 2277 | * @return int number of extra meta rows deleted |
2278 | 2278 | * @throws \EE_Error |
2279 | 2279 | */ |
2280 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2280 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2281 | 2281 | $query_params = array( |
2282 | 2282 | array( |
2283 | 2283 | 'EXM_key' => $meta_key, |
@@ -2285,10 +2285,10 @@ discard block |
||
2285 | 2285 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2286 | 2286 | ) |
2287 | 2287 | ); |
2288 | - if ( $meta_value !== null ) { |
|
2288 | + if ($meta_value !== null) { |
|
2289 | 2289 | $query_params[0]['EXM_value'] = $meta_value; |
2290 | 2290 | } |
2291 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2291 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2292 | 2292 | } |
2293 | 2293 | |
2294 | 2294 | |
@@ -2304,25 +2304,25 @@ discard block |
||
2304 | 2304 | * @return mixed single value if $single; array if ! $single |
2305 | 2305 | * @throws \EE_Error |
2306 | 2306 | */ |
2307 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2308 | - if($single){ |
|
2309 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2310 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2307 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2308 | + if ($single) { |
|
2309 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2310 | + if ($result instanceof EE_Extra_Meta) { |
|
2311 | 2311 | return $result->value(); |
2312 | - }else{ |
|
2312 | + } else { |
|
2313 | 2313 | return $default; |
2314 | 2314 | } |
2315 | - }else{ |
|
2316 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2317 | - if($results){ |
|
2315 | + } else { |
|
2316 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2317 | + if ($results) { |
|
2318 | 2318 | $values = array(); |
2319 | - foreach($results as $result){ |
|
2320 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2319 | + foreach ($results as $result) { |
|
2320 | + if ($result instanceof EE_Extra_Meta) { |
|
2321 | 2321 | $values[$result->ID()] = $result->value(); |
2322 | 2322 | } |
2323 | 2323 | } |
2324 | 2324 | return $values; |
2325 | - }else{ |
|
2325 | + } else { |
|
2326 | 2326 | return $default; |
2327 | 2327 | } |
2328 | 2328 | } |
@@ -2344,20 +2344,20 @@ discard block |
||
2344 | 2344 | * @return array |
2345 | 2345 | * @throws \EE_Error |
2346 | 2346 | */ |
2347 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2347 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2348 | 2348 | $return_array = array(); |
2349 | - if($one_of_each_key){ |
|
2349 | + if ($one_of_each_key) { |
|
2350 | 2350 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2351 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2352 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2351 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2352 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2353 | 2353 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2354 | 2354 | } |
2355 | 2355 | } |
2356 | - }else{ |
|
2356 | + } else { |
|
2357 | 2357 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2358 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2359 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2360 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2358 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2359 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2360 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2361 | 2361 | $return_array[$extra_meta_obj->key()] = array(); |
2362 | 2362 | } |
2363 | 2363 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2375,19 +2375,19 @@ discard block |
||
2375 | 2375 | * @return string |
2376 | 2376 | * @throws \EE_Error |
2377 | 2377 | */ |
2378 | - public function name(){ |
|
2378 | + public function name() { |
|
2379 | 2379 | //find a field that's not a text field |
2380 | 2380 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2381 | - if($field_we_can_use){ |
|
2381 | + if ($field_we_can_use) { |
|
2382 | 2382 | return $this->get($field_we_can_use->get_name()); |
2383 | - }else{ |
|
2383 | + } else { |
|
2384 | 2384 | $first_few_properties = $this->model_field_array(); |
2385 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2385 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2386 | 2386 | $name_parts = array(); |
2387 | - foreach( $first_few_properties as $name=> $value ){ |
|
2387 | + foreach ($first_few_properties as $name=> $value) { |
|
2388 | 2388 | $name_parts[] = "$name:$value"; |
2389 | 2389 | } |
2390 | - return implode(",",$name_parts); |
|
2390 | + return implode(",", $name_parts); |
|
2391 | 2391 | } |
2392 | 2392 | } |
2393 | 2393 | |
@@ -2400,11 +2400,11 @@ discard block |
||
2400 | 2400 | * @return boolean |
2401 | 2401 | * @throws \EE_Error |
2402 | 2402 | */ |
2403 | - public function in_entity_map(){ |
|
2404 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2403 | + public function in_entity_map() { |
|
2404 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2405 | 2405 | //well, if we looked, did we find it in the entity map? |
2406 | 2406 | return TRUE; |
2407 | - }else{ |
|
2407 | + } else { |
|
2408 | 2408 | return FALSE; |
2409 | 2409 | } |
2410 | 2410 | } |
@@ -2415,21 +2415,21 @@ discard block |
||
2415 | 2415 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2416 | 2416 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2417 | 2417 | */ |
2418 | - public function refresh_from_db(){ |
|
2419 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2420 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2421 | - }else{ |
|
2418 | + public function refresh_from_db() { |
|
2419 | + if ($this->ID() && $this->in_entity_map()) { |
|
2420 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2421 | + } else { |
|
2422 | 2422 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2423 | 2423 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2424 | 2424 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2425 | 2425 | //absolutely nothing in it for this ID |
2426 | - if( WP_DEBUG ) { |
|
2426 | + if (WP_DEBUG) { |
|
2427 | 2427 | throw new EE_Error( |
2428 | 2428 | sprintf( |
2429 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2429 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2430 | 2430 | $this->ID(), |
2431 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2432 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2431 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2432 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2433 | 2433 | ) |
2434 | 2434 | ); |
2435 | 2435 | } |
@@ -2443,11 +2443,11 @@ discard block |
||
2443 | 2443 | * (probably a bad assumption they have made, oh well) |
2444 | 2444 | * @return string |
2445 | 2445 | */ |
2446 | - public function __toString(){ |
|
2446 | + public function __toString() { |
|
2447 | 2447 | try { |
2448 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2449 | - } catch ( Exception $e ) { |
|
2450 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2448 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2449 | + } catch (Exception $e) { |
|
2450 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2451 | 2451 | return ''; |
2452 | 2452 | } |
2453 | 2453 | } |
@@ -2483,16 +2483,16 @@ discard block |
||
2483 | 2483 | * @throws \EE_Error |
2484 | 2484 | */ |
2485 | 2485 | public function __sleep() { |
2486 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2487 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2488 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2489 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2490 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2491 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2486 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2487 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2488 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2489 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2490 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2491 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2492 | 2492 | } |
2493 | 2493 | } |
2494 | 2494 | } |
2495 | - return array_keys( get_object_vars( $this ) ); |
|
2495 | + return array_keys(get_object_vars($this)); |
|
2496 | 2496 | } |
2497 | 2497 | |
2498 | 2498 |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * get event start date. Provide either the date format, or NULL to re-use the |
288 | 288 | * last-used format, or '' to use the default date format |
289 | 289 | * |
290 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
290 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
291 | 291 | * @return mixed string on success, FALSE on fail |
292 | 292 | */ |
293 | 293 | public function start_date( $dt_frmt = NULL ) { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * get end date. Provide either the date format, or NULL to re-use the |
311 | 311 | * last-used format, or '' to use the default date format |
312 | 312 | * |
313 | - * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
313 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
314 | 314 | * @return mixed string on success, FALSE on fail |
315 | 315 | */ |
316 | 316 | public function end_date( $dt_frmt = NULL ) { |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param string $dt_frmt - string representation of date format defaults to WP settings |
337 | 337 | * @param string $conjunction - conjunction junction what's your function ? this string joins the start date with |
338 | 338 | * the end date ie: Jan 01 "to" Dec 31 |
339 | - * @return mixed string on success, FALSE on fail |
|
339 | + * @return string string on success, FALSE on fail |
|
340 | 340 | * @throws \EE_Error |
341 | 341 | */ |
342 | 342 | public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param string $tm_format string representation of time format defaults to 'g:i a' |
409 | 409 | * @param string $conjunction conjunction junction what's your function ? |
410 | 410 | * this string joins the start date with the end date ie: Jan 01 "to" Dec 31 |
411 | - * @return mixed string on success, FALSE on fail |
|
411 | + * @return string string on success, FALSE on fail |
|
412 | 412 | * @throws \EE_Error |
413 | 413 | */ |
414 | 414 | public function time_range( $tm_format = null, $conjunction = ' - ' ) { |
@@ -456,14 +456,14 @@ |
||
456 | 456 | //start and end date are the same but times are different |
457 | 457 | case ( $this->start_date() === $this->end_date() ) : |
458 | 458 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
459 | - . $conjunction |
|
460 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
459 | + . $conjunction |
|
460 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
461 | 461 | break; |
462 | 462 | //all other conditions |
463 | 463 | default : |
464 | 464 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
465 | - . $conjunction |
|
466 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
465 | + . $conjunction |
|
466 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
467 | 467 | break; |
468 | 468 | } |
469 | 469 | return $output; |
@@ -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 |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
120 | 120 | */ |
121 | - public function set_start_date( $date ) { |
|
122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
121 | + public function set_start_date($date) { |
|
122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
133 | 133 | */ |
134 | - public function set_start_time( $time ) { |
|
135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
134 | + public function set_start_time($time) { |
|
135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
146 | 146 | */ |
147 | - public function set_end_date( $date ) { |
|
148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
147 | + public function set_end_date($date) { |
|
148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
159 | 159 | */ |
160 | - public function set_end_time( $time ) { |
|
161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
160 | + public function set_end_time($time) { |
|
161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param int $reg_limit |
172 | 172 | */ |
173 | - public function set_reg_limit( $reg_limit ) { |
|
174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
173 | + public function set_reg_limit($reg_limit) { |
|
174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param int $sold |
183 | 183 | */ |
184 | - public function set_sold( $sold ) { |
|
184 | + public function set_sold($sold) { |
|
185 | 185 | // sold can not go below zero |
186 | - $sold = max( 0, $sold ); |
|
187 | - $this->set( 'DTT_sold', $sold ); |
|
186 | + $sold = max(0, $sold); |
|
187 | + $this->set('DTT_sold', $sold); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | * increments sold by amount passed by $qty |
194 | 194 | * @param int $qty |
195 | 195 | */ |
196 | - public function increase_sold( $qty = 1 ) { |
|
196 | + public function increase_sold($qty = 1) { |
|
197 | 197 | $sold = $this->sold() + $qty; |
198 | - $this->set_sold( $sold ); |
|
198 | + $this->set_sold($sold); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -204,9 +204,9 @@ discard block |
||
204 | 204 | * decrements (subtracts) sold amount passed by $qty |
205 | 205 | * @param int $qty |
206 | 206 | */ |
207 | - public function decrease_sold( $qty = 1 ) { |
|
207 | + public function decrease_sold($qty = 1) { |
|
208 | 208 | $sold = $this->sold() - $qty; |
209 | - $this->set_sold( $sold ); |
|
209 | + $this->set_sold($sold); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * @return string |
217 | 217 | */ |
218 | 218 | public function name() { |
219 | - return $this->get( 'DTT_name' ); |
|
219 | + return $this->get('DTT_name'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return string |
227 | 227 | */ |
228 | 228 | public function description() { |
229 | - return $this->get( 'DTT_description' ); |
|
229 | + return $this->get('DTT_description'); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @return boolean TRUE if is primary, FALSE if not. |
237 | 237 | */ |
238 | 238 | public function is_primary() { |
239 | - return $this->get( 'DTT_is_primary' ); |
|
239 | + return $this->get('DTT_is_primary'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return int The order of the datetime for this event. |
247 | 247 | */ |
248 | 248 | public function order() { |
249 | - return $this->get( 'DTT_order' ); |
|
249 | + return $this->get('DTT_order'); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @return int |
257 | 257 | */ |
258 | 258 | public function parent() { |
259 | - return $this->get( 'DTT_parent' ); |
|
259 | + return $this->get('DTT_parent'); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
273 | 273 | * @return string|bool|void string on success, FALSE on fail |
274 | 274 | */ |
275 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
275 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
276 | 276 | $field_name = "DTT_EVT_{$start_or_end}"; |
277 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
278 | - if ( ! $echo ) { |
|
277 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
278 | + if ( ! $echo) { |
|
279 | 279 | return $dtt; |
280 | 280 | } |
281 | 281 | return ''; |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
291 | 291 | * @return mixed string on success, FALSE on fail |
292 | 292 | */ |
293 | - public function start_date( $dt_frmt = NULL ) { |
|
294 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
293 | + public function start_date($dt_frmt = NULL) { |
|
294 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * Echoes start_date() |
301 | 301 | * @param string $dt_frmt |
302 | 302 | */ |
303 | - public function e_start_date( $dt_frmt = NULL ) { |
|
304 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
303 | + public function e_start_date($dt_frmt = NULL) { |
|
304 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * @param null $dt_frmt - string representation of date format defaults to 'F j, Y' |
314 | 314 | * @return mixed string on success, FALSE on fail |
315 | 315 | */ |
316 | - public function end_date( $dt_frmt = NULL ) { |
|
317 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
316 | + public function end_date($dt_frmt = NULL) { |
|
317 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * Echoes the end date. See end_date() |
324 | 324 | * @param string $dt_frmt |
325 | 325 | */ |
326 | - public function e_end_date( $dt_frmt = NULL ) { |
|
327 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
326 | + public function e_end_date($dt_frmt = NULL) { |
|
327 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * @return mixed string on success, FALSE on fail |
340 | 340 | * @throws \EE_Error |
341 | 341 | */ |
342 | - public function date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
343 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
344 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
345 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
346 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
342 | + public function date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
343 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
344 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
345 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
346 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | * @param string $conjunction |
354 | 354 | * @throws \EE_Error |
355 | 355 | */ |
356 | - public function e_date_range( $dt_frmt = NULL, $conjunction = ' - ' ) { |
|
357 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
356 | + public function e_date_range($dt_frmt = NULL, $conjunction = ' - ') { |
|
357 | + echo $this->date_range($dt_frmt, $conjunction); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
366 | 366 | * @return mixed string on success, FALSE on fail |
367 | 367 | */ |
368 | - public function start_time( $tm_format = NULL ) { |
|
369 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
368 | + public function start_time($tm_format = NULL) { |
|
369 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | /** |
375 | 375 | * @param null $tm_format |
376 | 376 | */ |
377 | - public function e_start_time( $tm_format = NULL ) { |
|
378 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
377 | + public function e_start_time($tm_format = NULL) { |
|
378 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
387 | 387 | * @return mixed string on success, FALSE on fail |
388 | 388 | */ |
389 | - public function end_time( $tm_format = NULL ) { |
|
390 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
389 | + public function end_time($tm_format = NULL) { |
|
390 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | /** |
396 | 396 | * @param null $tm_format |
397 | 397 | */ |
398 | - public function e_end_time( $tm_format = NULL ) { |
|
399 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
398 | + public function e_end_time($tm_format = NULL) { |
|
399 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | * @return mixed string on success, FALSE on fail |
412 | 412 | * @throws \EE_Error |
413 | 413 | */ |
414 | - public function time_range( $tm_format = null, $conjunction = ' - ' ) { |
|
415 | - $tm_format = !empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
416 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
417 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
418 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
414 | + public function time_range($tm_format = null, $conjunction = ' - ') { |
|
415 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
416 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
417 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
418 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $conjunction |
426 | 426 | * @throws \EE_Error |
427 | 427 | */ |
428 | - public function e_time_range( $tm_format = NULL, $conjunction = ' - ' ) { |
|
429 | - echo $this->time_range( $tm_format, $conjunction ); |
|
428 | + public function e_time_range($tm_format = NULL, $conjunction = ' - ') { |
|
429 | + echo $this->time_range($tm_format, $conjunction); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -442,28 +442,28 @@ discard block |
||
442 | 442 | * @return string |
443 | 443 | * @throws \EE_Error |
444 | 444 | */ |
445 | - public function date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
446 | - $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
|
447 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
448 | - $full_format = $dt_format . ' ' . $tm_format; |
|
445 | + public function date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
446 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
447 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
448 | + $full_format = $dt_format.' '.$tm_format; |
|
449 | 449 | |
450 | 450 | //the range output depends on various conditions |
451 | - switch ( true ) { |
|
451 | + switch (true) { |
|
452 | 452 | //start date timestamp and end date timestamp are the same. |
453 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
454 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
453 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
454 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
455 | 455 | break; |
456 | 456 | //start and end date are the same but times are different |
457 | - case ( $this->start_date() === $this->end_date() ) : |
|
458 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
457 | + case ($this->start_date() === $this->end_date()) : |
|
458 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
459 | 459 | . $conjunction |
460 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
460 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
461 | 461 | break; |
462 | 462 | //all other conditions |
463 | 463 | default : |
464 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
464 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
465 | 465 | . $conjunction |
466 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
466 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
467 | 467 | break; |
468 | 468 | } |
469 | 469 | return $output; |
@@ -481,8 +481,8 @@ discard block |
||
481 | 481 | * @return void |
482 | 482 | * @throws \EE_Error |
483 | 483 | */ |
484 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
485 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
484 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
485 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
495 | 495 | * @return mixed string on success, FALSE on fail |
496 | 496 | */ |
497 | - public function start_date_and_time( $dt_format = NULL, $tm_format = NULL ) { |
|
498 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
497 | + public function start_date_and_time($dt_format = NULL, $tm_format = NULL) { |
|
498 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @param null $dt_frmt |
505 | 505 | * @param null $tm_format |
506 | 506 | */ |
507 | - public function e_start_date_and_time( $dt_frmt = NULL, $tm_format = NULL ) { |
|
508 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
507 | + public function e_start_date_and_time($dt_frmt = NULL, $tm_format = NULL) { |
|
508 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | * @param bool $round_up |
520 | 520 | * @return float|int|mixed |
521 | 521 | */ |
522 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
523 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
524 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
522 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
523 | + $start = $this->get_raw('DTT_EVT_start'); |
|
524 | + $end = $this->get_raw('DTT_EVT_end'); |
|
525 | 525 | $length_in_units = $end - $start; |
526 | - switch ( $units ) { |
|
526 | + switch ($units) { |
|
527 | 527 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
528 | 528 | /** @noinspection PhpMissingBreakStatementInspection */ |
529 | 529 | case 'days': |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $length_in_units /= 60; |
537 | 537 | case 'seconds': |
538 | 538 | default: |
539 | - $length_in_units = ceil( $length_in_units ); |
|
539 | + $length_in_units = ceil($length_in_units); |
|
540 | 540 | } |
541 | - if ( $round_up ) { |
|
542 | - $length_in_units = max( $length_in_units, 1 ); |
|
541 | + if ($round_up) { |
|
542 | + $length_in_units = max($length_in_units, 1); |
|
543 | 543 | } |
544 | 544 | return $length_in_units; |
545 | 545 | } |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | * @param bool | string $tm_format - string representation of time format defaults to 'g:i a' |
554 | 554 | * @return mixed string on success, FALSE on fail |
555 | 555 | */ |
556 | - public function end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
557 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
556 | + public function end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
557 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @param bool $dt_frmt |
564 | 564 | * @param bool $tm_format |
565 | 565 | */ |
566 | - public function e_end_date_and_time( $dt_frmt = FALSE, $tm_format = FALSE ) { |
|
567 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
566 | + public function e_end_date_and_time($dt_frmt = FALSE, $tm_format = FALSE) { |
|
567 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @return int |
576 | 576 | */ |
577 | 577 | public function start() { |
578 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
578 | + return $this->get_raw('DTT_EVT_start'); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | * @return int |
587 | 587 | */ |
588 | 588 | public function end() { |
589 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
589 | + return $this->get_raw('DTT_EVT_end'); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @return mixed int on success, FALSE on fail |
598 | 598 | */ |
599 | 599 | public function reg_limit() { |
600 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
600 | + return $this->get_raw('DTT_reg_limit'); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @return mixed int on success, FALSE on fail |
609 | 609 | */ |
610 | 610 | public function sold() { |
611 | - return $this->get_raw( 'DTT_sold' ); |
|
611 | + return $this->get_raw('DTT_sold'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -636,15 +636,15 @@ discard block |
||
636 | 636 | * the spaces remaining for this particular datetime, hence the flag. |
637 | 637 | * @return int |
638 | 638 | */ |
639 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
639 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
640 | 640 | // tickets remaining available for purchase |
641 | 641 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
642 | 642 | $dtt_remaining = $this->reg_limit() - $this->sold(); |
643 | - if ( ! $consider_tickets ) { |
|
643 | + if ( ! $consider_tickets) { |
|
644 | 644 | return $dtt_remaining; |
645 | 645 | } |
646 | 646 | $tickets_remaining = $this->tickets_remaining(); |
647 | - return min( $dtt_remaining, $tickets_remaining ); |
|
647 | + return min($dtt_remaining, $tickets_remaining); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
@@ -655,19 +655,19 @@ discard block |
||
655 | 655 | * @param array $query_params like EEM_Base::get_all's |
656 | 656 | * @return int |
657 | 657 | */ |
658 | - public function tickets_remaining( $query_params = array() ) { |
|
658 | + public function tickets_remaining($query_params = array()) { |
|
659 | 659 | $sum = 0; |
660 | - $tickets = $this->tickets( $query_params ); |
|
661 | - if ( ! empty( $tickets ) ) { |
|
662 | - foreach ( $tickets as $ticket ) { |
|
663 | - if ( $ticket instanceof EE_Ticket ) { |
|
660 | + $tickets = $this->tickets($query_params); |
|
661 | + if ( ! empty($tickets)) { |
|
662 | + foreach ($tickets as $ticket) { |
|
663 | + if ($ticket instanceof EE_Ticket) { |
|
664 | 664 | // get the actual amount of tickets that can be sold |
665 | - $qty = $ticket->qty( 'saleable' ); |
|
666 | - if ( $qty === EE_INF ) { |
|
665 | + $qty = $ticket->qty('saleable'); |
|
666 | + if ($qty === EE_INF) { |
|
667 | 667 | return EE_INF; |
668 | 668 | } |
669 | 669 | // no negative ticket quantities plz |
670 | - if ( $qty > 0 ) { |
|
670 | + if ($qty > 0) { |
|
671 | 671 | $sum += $qty; |
672 | 672 | } |
673 | 673 | } |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @param array $query_params like EEM_Base::get_all's |
685 | 685 | * @return int |
686 | 686 | */ |
687 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
688 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
687 | + public function sum_tickets_initially_available($query_params = array()) { |
|
688 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | * @return int |
698 | 698 | */ |
699 | 699 | public function total_tickets_available_at_this_datetime() { |
700 | - return $this->spaces_remaining( true ); |
|
700 | + return $this->spaces_remaining(true); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * @return boolean |
709 | 709 | */ |
710 | 710 | public function is_upcoming() { |
711 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
711 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | * @return boolean |
719 | 719 | */ |
720 | 720 | public function is_active() { |
721 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
721 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @return boolean |
729 | 729 | */ |
730 | 730 | public function is_expired() { |
731 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
731 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | |
@@ -739,16 +739,16 @@ discard block |
||
739 | 739 | */ |
740 | 740 | public function get_active_status() { |
741 | 741 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
742 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
742 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
743 | 743 | return EE_Datetime::sold_out; |
744 | 744 | } |
745 | - if ( $this->is_expired() ) { |
|
745 | + if ($this->is_expired()) { |
|
746 | 746 | return EE_Datetime::expired; |
747 | 747 | } |
748 | - if ( $this->is_upcoming() ) { |
|
748 | + if ($this->is_upcoming()) { |
|
749 | 749 | return EE_Datetime::upcoming; |
750 | 750 | } |
751 | - if ( $this->is_active() ) { |
|
751 | + if ($this->is_active()) { |
|
752 | 752 | return EE_Datetime::active; |
753 | 753 | } |
754 | 754 | return NULL; |
@@ -762,24 +762,24 @@ discard block |
||
762 | 762 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
763 | 763 | * @return string |
764 | 764 | */ |
765 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
766 | - if ( $use_dtt_name ) { |
|
765 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
766 | + if ($use_dtt_name) { |
|
767 | 767 | $dtt_name = $this->name(); |
768 | - if ( !empty( $dtt_name ) ) { |
|
768 | + if ( ! empty($dtt_name)) { |
|
769 | 769 | return $dtt_name; |
770 | 770 | } |
771 | 771 | } |
772 | 772 | //first condition is to see if the months are different |
773 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
774 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
773 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
774 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
775 | 775 | //next condition is if its the same month but different day |
776 | 776 | } |
777 | 777 | else { |
778 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
779 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
778 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
779 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
780 | 780 | } |
781 | 781 | else { |
782 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
782 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | return $display_date; |
@@ -793,8 +793,8 @@ discard block |
||
793 | 793 | *@param array $query_params see EEM_Base::get_all() |
794 | 794 | * @return EE_Ticket[] |
795 | 795 | */ |
796 | - public function tickets( $query_params = array() ) { |
|
797 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
796 | + public function tickets($query_params = array()) { |
|
797 | + return $this->get_many_related('Ticket', $query_params); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -804,21 +804,21 @@ discard block |
||
804 | 804 | * @param array $query_params like EEM_Base::get_all's |
805 | 805 | * @return EE_Ticket[] |
806 | 806 | */ |
807 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
807 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
808 | 808 | // first check if datetime is valid |
809 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
809 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
810 | 810 | return array(); |
811 | 811 | } |
812 | - if ( empty( $query_params ) ) { |
|
812 | + if (empty($query_params)) { |
|
813 | 813 | $query_params = array( |
814 | 814 | array( |
815 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
816 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
815 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
816 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
817 | 817 | 'TKT_deleted' => false |
818 | 818 | ) |
819 | 819 | ); |
820 | 820 | } |
821 | - return $this->tickets( $query_params ); |
|
821 | + return $this->tickets($query_params); |
|
822 | 822 | } |
823 | 823 | |
824 | 824 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | * @return EE_Event |
829 | 829 | */ |
830 | 830 | public function event() { |
831 | - return $this->get_first_related( 'Event' ); |
|
831 | + return $this->get_first_related('Event'); |
|
832 | 832 | } |
833 | 833 | |
834 | 834 | |
@@ -840,13 +840,13 @@ discard block |
||
840 | 840 | */ |
841 | 841 | public function update_sold() { |
842 | 842 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
843 | - array( array( |
|
843 | + array(array( |
|
844 | 844 | 'STS_ID' => EEM_Registration::status_id_approved, |
845 | 845 | 'REG_deleted' => 0, |
846 | 846 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
847 | - ) ) |
|
847 | + )) |
|
848 | 848 | ); |
849 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
849 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
850 | 850 | $this->save(); |
851 | 851 | return $count_regs_for_this_datetime; |
852 | 852 | } |