Completed
Branch BUG-8866-category-permalink (0af2d2)
by
unknown
22:53 queued 19s
created
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
 		$this->_shortcodes = array(
43 43
 			'[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'),
44 44
 			'[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'),
45
-			'[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>'
46
-				. '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
47
-				. '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
48
-				. '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
45
+			'[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>'
46
+				. '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>'
47
+				. '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>'
48
+				. '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>'
49 49
 				. '</ul>',
50
-			'[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso' )
50
+			'[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso')
51 51
 				. '<ul>'
52
-				. '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
53
-				. '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
54
-				. '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>',
52
+				. '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>'
53
+				. '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>'
54
+				. '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>',
55 55
 			'[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'),
56 56
 			'[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'),
57 57
 			'[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'),
58 58
 			'[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'),
59 59
 			'[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
60
-			'[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
61
-			'[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ),
62
-			'[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
63
-			'[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ),
60
+			'[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
61
+			'[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'),
62
+			'[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
63
+			'[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'),
64 64
 			'[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'),
65 65
 			'[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'),
66 66
 			'[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'),
@@ -71,54 +71,54 @@  discard block
 block discarded – undo
71 71
 			'[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'),
72 72
 			'[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'),
73 73
 			'[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'),
74
-			'[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' .
75
-				'<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' .
76
-				'<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>',
74
+			'[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'.
75
+				'<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'.
76
+				'<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>',
77 77
 			'[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'),
78 78
 			'[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'),
79 79
 			'[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'),
80 80
 			'[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'),
81
-			'[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso'),
82
-			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' )
81
+			'[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso'),
82
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>')
83 83
 			);
84 84
 	}
85 85
 
86 86
 
87
-	protected function _parser( $shortcode ) {
87
+	protected function _parser($shortcode) {
88 88
 
89
-		EE_Registry::instance()->load_helper( 'Template' );
89
+		EE_Registry::instance()->load_helper('Template');
90 90
 
91 91
 		//attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction.
92 92
 		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
93
-		$transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction;
93
+		$transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction;
94 94
 
95 95
 		//payment
96 96
 		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
97
-		$payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment;
97
+		$payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment;
98 98
 
99 99
 
100
-		if ( ! $transaction instanceof EE_Transaction )
100
+		if ( ! $transaction instanceof EE_Transaction)
101 101
 			return '';
102 102
 
103
-		switch ( $shortcode ) {
103
+		switch ($shortcode) {
104 104
 			case '[TXN_ID]' :
105 105
 				return $transaction->ID();
106 106
 				break;
107 107
 
108 108
 			case '[PAYMENT_URL]' :
109 109
 				$payment_url = $transaction->payment_overview_url();
110
-				return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
110
+				return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
111 111
 				break;
112 112
 
113 113
 			case '[INVOICE_LINK]' :
114 114
 				$invoice_url = $transaction->invoice_url();
115
-				$invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
116
-				return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' );
115
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
116
+				return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>');
117 117
 				break; /**/
118 118
 
119 119
 			case '[INVOICE_URL]' :
120 120
 				$invoice_url = $transaction->invoice_url();
121
-				return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
121
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
122 122
 				break;
123 123
 
124 124
 			case '[INVOICE_LOGO_URL]' :
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				break;
127 127
 
128 128
 			case '[INVOICE_LOGO]' :
129
-				return $this->_get_invoice_logo( TRUE );
129
+				return $this->_get_invoice_logo(TRUE);
130 130
 				break;
131 131
 
132 132
 			case '[INVOICE_PAYEE_NAME]' :
@@ -148,18 +148,18 @@  discard block
 block discarded – undo
148 148
 
149 149
 			case "[TOTAL_COST]" :
150 150
 				$total = $transaction->total();
151
-				return ! empty($total) ? EEH_Template::format_currency( $total ) : '';
151
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
152 152
 				break;
153 153
 
154 154
 			case "[PAYMENT_STATUS]" :
155 155
 				$status = $transaction->pretty_status();
156
-				return !empty($status) ? $status : __('Unknown', 'event_espresso');
156
+				return ! empty($status) ? $status : __('Unknown', 'event_espresso');
157 157
 				break; /**/
158 158
 
159 159
 			// note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity.
160 160
 			case "[TXN_STATUS]" :
161 161
 				$status = $transaction->pretty_status();
162
-				return !empty( $status ) ? $status : __('Unknown', 'event_espresso');
162
+				return ! empty($status) ? $status : __('Unknown', 'event_espresso');
163 163
 				break;
164 164
 
165 165
 			case "[TXN_STATUS_ID]" :
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 				break;
168 168
 
169 169
 			case "[PAYMENT_GATEWAY]" :
170
-				return $this->_get_payment_gateway( $transaction );
170
+				return $this->_get_payment_gateway($transaction);
171 171
 				break;
172 172
 
173 173
 			case "[AMOUNT_PAID]" :
174 174
 				$amount = $payment instanceof EE_Payment ? $payment->amount() : 0;
175
-				return EEH_Template::format_currency( $amount );
175
+				return EEH_Template::format_currency($amount);
176 176
 				break;
177 177
 
178 178
 			case "[TOTAL_AMOUNT_PAID]" :
179
-				return EEH_Template::format_currency( $transaction->paid() );
179
+				return EEH_Template::format_currency($transaction->paid());
180 180
 				break;
181 181
 
182 182
 			case "[TOTAL_OWING]" :
183 183
 				$total_owing = $transaction->remaining();
184
-				return EEH_Template::format_currency( $total_owing );
184
+				return EEH_Template::format_currency($total_owing);
185 185
 				break;
186 186
 
187 187
 			case "[TXN_SUBTOTAL]" :
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				break;
190 190
 
191 191
 			case "[TXN_TAX_SUBTOTAL]" :
192
-				return EEH_Template::format_currency($this->_get_subtotal( TRUE ));
192
+				return EEH_Template::format_currency($this->_get_subtotal(TRUE));
193 193
 				break;
194 194
 
195 195
 			case "[TKT_QTY_PURCHASED]" :
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 				break;
199 199
 
200 200
 			case "[TRANSACTION_ADMIN_URL]" :
201
-				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
202
-				$query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() );
203
-				$url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') );
201
+				require_once EE_CORE.'admin/EE_Admin_Page.core.php';
202
+				$query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID());
203
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
204 204
 				return $url;
205 205
 				break;
206 206
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 				//get primary_registration
209 209
 				$reg = $this->_data->primary_reg_obj;
210 210
 
211
-				if ( ! $reg instanceof EE_Registration ) {
211
+				if ( ! $reg instanceof EE_Registration) {
212 212
 					return '';
213 213
 				}
214 214
 				return $reg->receipt_url();
215 215
 				break;
216 216
 
217 217
 			case "[INVOICE_RECEIPT_SWITCHER_URL]" :
218
-				return $this->_get_invoice_receipt_switcher( FALSE );
218
+				return $this->_get_invoice_receipt_switcher(FALSE);
219 219
 				break;
220 220
 
221 221
 			case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" :
@@ -225,20 +225,20 @@  discard block
 block discarded – undo
225 225
 
226 226
 		}
227 227
 
228
-		if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) {
229
-			return $this->_get_custom_total_oweing( $shortcode );
228
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) {
229
+			return $this->_get_custom_total_oweing($shortcode);
230 230
 		}
231 231
 
232
-		if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) {
233
-			return $this->_get_invoice_payee_tax_number( $shortcode );
232
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) {
233
+			return $this->_get_invoice_payee_tax_number($shortcode);
234 234
 		}
235 235
 
236
-		if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) {
237
-			return $this->_get_payment_link_if_needed( $shortcode );
236
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) {
237
+			return $this->_get_payment_link_if_needed($shortcode);
238 238
 		}
239 239
 
240
-		if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) {
241
-			return $this->_get_payment_due_date( $shortcode, $transaction );
240
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
241
+			return $this->_get_payment_due_date($shortcode, $transaction);
242 242
 		}
243 243
 
244 244
 		return '';
@@ -255,22 +255,22 @@  discard block
 block discarded – undo
255 255
 	 *
256 256
 	 * @return string parsed.
257 257
 	 */
258
-	private function _get_custom_total_oweing( $shortcode ) {
259
-		$valid_shortcodes = array( 'transaction' );
260
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
258
+	private function _get_custom_total_oweing($shortcode) {
259
+		$valid_shortcodes = array('transaction');
260
+		$attrs = $this->_get_shortcode_attrs($shortcode);
261 261
 
262 262
 		//ensure default is set.
263 263
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
264 264
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
265 265
 
266
-		if ( $total_owing > 0 ) {
267
-			$owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' );
266
+		if ($total_owing > 0) {
267
+			$owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>');
268 268
 
269 269
 			//we need to re run this string through the parser to catch any shortcodes that are in it.
270 270
 			$this->_set_shortcode_helper();
271
-			$owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID );
271
+			$owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID);
272 272
 		} else {
273
-			$owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : '';
273
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
274 274
 		}
275 275
 
276 276
 		return $owing_content;
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 
279 279
 
280 280
 
281
-	private function _get_payment_gateway( $transaction ) {
282
-		$pm = $this->_get_payment_method( $transaction );
281
+	private function _get_payment_gateway($transaction) {
282
+		$pm = $this->_get_payment_method($transaction);
283 283
 		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
284 284
 	}
285 285
 
@@ -294,37 +294,37 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return string url or html
296 296
 	 */
297
-	private function _get_invoice_logo( $img_tags = FALSE ) {
297
+	private function _get_invoice_logo($img_tags = FALSE) {
298 298
 		//try to get the invoice payment method's logo for this transaction image first
299 299
 		$pm = $this->_get_payment_method();
300
-		if ( $pm instanceof EE_Payment_Method ){
301
-			$invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE );
302
-		}else{
300
+		if ($pm instanceof EE_Payment_Method) {
301
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE);
302
+		} else {
303 303
 			$invoice_logo_url = NULL;
304 304
 		}
305
-		if( empty( $invoice_logo_url ) ){
305
+		if (empty($invoice_logo_url)) {
306 306
 			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
307 307
 		}
308 308
 
309
-		if ( empty( $invoice_logo_url ) ) {
309
+		if (empty($invoice_logo_url)) {
310 310
 			return '';
311 311
 		}
312 312
 
313
-		if ( ! $img_tags ) {
313
+		if ( ! $img_tags) {
314 314
 			return $invoice_logo_url;
315 315
 		}
316 316
 
317 317
 		//image tags have been requested.
318
-		$image_size = getimagesize( $invoice_logo_url );
318
+		$image_size = getimagesize($invoice_logo_url);
319 319
 		
320 320
 		//if image is wider than 200px, set the wideth to 200
321
-		if ( $image_size[0] > 300 ) {
321
+		if ($image_size[0] > 300) {
322 322
 			$image_width = 300;
323
-		}else{
323
+		} else {
324 324
 			$image_width = $image_size[0];
325 325
 		}
326 326
 
327
-		return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
327
+		return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />';
328 328
 	}
329 329
 
330 330
 
@@ -341,26 +341,26 @@  discard block
 block discarded – undo
341 341
 	private function _get_invoice_payee_name() {
342 342
 		$payee_name = NULL;
343 343
 		$pm = $this->_get_payment_method();
344
-		if( $pm instanceof EE_Payment_Method ){
345
-			$payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE );
344
+		if ($pm instanceof EE_Payment_Method) {
345
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE);
346 346
 		}
347
-		$payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name;
347
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
348 348
 		return $payee_name;
349 349
 	}
350 350
 
351 351
 	/**
352 352
 	 * gets the payment method for this transaction. Otherwise gets a default one.
353 353
 	 */
354
-	private function _get_payment_method( $transaction = null ){
355
-		if( $transaction instanceof EE_Transaction ) {
354
+	private function _get_payment_method($transaction = null) {
355
+		if ($transaction instanceof EE_Transaction) {
356 356
 			$payment_method = $transaction->payment_method();
357
-			if ( empty( $payment_method ) ) {
358
-				return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
357
+			if (empty($payment_method)) {
358
+				return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
359 359
 			}
360 360
 			return $payment_method;
361
-		}else{
361
+		} else {
362 362
 			//get the first payment method we can find
363
-			return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
363
+			return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
364 364
 		}
365 365
 	}
366 366
 
@@ -377,10 +377,10 @@  discard block
 block discarded – undo
377 377
 	private function _get_invoice_payee_email() {
378 378
 		$payee_email = NULL;
379 379
 		$pm = $this->_get_payment_method();
380
-		if( $pm instanceof EE_Payment_Method ){
381
-			$payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE );
380
+		if ($pm instanceof EE_Payment_Method) {
381
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE);
382 382
 		}
383
-		$payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email;
383
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email;
384 384
 		return $payee_email;
385 385
 	}
386 386
 
@@ -396,24 +396,24 @@  discard block
 block discarded – undo
396 396
 	 *
397 397
 	 * @return string
398 398
 	 */
399
-	private function _get_invoice_payee_tax_number( $shortcode ) {
399
+	private function _get_invoice_payee_tax_number($shortcode) {
400 400
 		$payee_tax_number = NULL;
401 401
 		$pm = $this->_get_payment_method();
402
-		if( $pm instanceof EE_Payment_Method ){
403
-			$payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE );
402
+		if ($pm instanceof EE_Payment_Method) {
403
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE);
404 404
 		}
405
-		$payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
405
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
406 406
 
407
-		if ( empty( $payee_tax_number ) ) {
407
+		if (empty($payee_tax_number)) {
408 408
 			return '';
409 409
 		}
410 410
 
411 411
 		//any attributes?
412
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
412
+		$attrs = $this->_get_shortcode_attrs($shortcode);
413 413
 
414 414
 		//prefix?
415
-		$prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' );
416
-		return $prefix . $payee_tax_number;
415
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso');
416
+		return $prefix.$payee_tax_number;
417 417
 	}
418 418
 
419 419
 
@@ -430,22 +430,22 @@  discard block
 block discarded – undo
430 430
 	private function _get_invoice_payee_address() {
431 431
 		$payee_address = NULL;
432 432
 		$pm = $this->_get_payment_method();
433
-		if( $pm instanceof EE_Payment_Method ){
434
-			$payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE );
433
+		if ($pm instanceof EE_Payment_Method) {
434
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE);
435 435
 		}
436
-		if ( empty( $payee_address ) ) {
436
+		if (empty($payee_address)) {
437 437
 			$organization = EE_Registry::instance()->CFG->organization;
438
-			$payee_address = $organization->get_pretty( 'address_1' ) . '<br>';
439
-			$payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : '';
440
-			$payee_address .= $organization->get_pretty( 'city' ) . '<br>';
438
+			$payee_address = $organization->get_pretty('address_1').'<br>';
439
+			$payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : '';
440
+			$payee_address .= $organization->get_pretty('city').'<br>';
441 441
 
442 442
 			//state
443
-			$state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID );
444
-			$payee_address .= $state instanceof EE_State ? $state->name()  : '';
443
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
444
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
445 445
 
446 446
 			//Country
447
-			$payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : '';
448
-			$payee_address .= ! empty( $organization->zip ) ? $organization->zip : '';
447
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
448
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
449 449
 		}
450 450
 		return $payee_address;
451 451
 	}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 	private function _get_invoice_payment_instructions() {
464 464
 		$instructions = NULL;
465 465
 		$pm = $this->_get_payment_method();
466
-		return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : '';
466
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : '';
467 467
 	}
468 468
 
469 469
 
@@ -477,27 +477,27 @@  discard block
 block discarded – undo
477 477
 	 *
478 478
 	 * @return string
479 479
 	 */
480
-	protected function _get_invoice_receipt_switcher( $button = TRUE ) {
480
+	protected function _get_invoice_receipt_switcher($button = TRUE) {
481 481
 		$reg = $this->_data->primary_reg_obj;
482
-		$message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : '';
483
-		if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) {
482
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
483
+		if ( ! $reg instanceof EE_Registration || empty($message_type)) {
484 484
 			return'';
485 485
 		}
486 486
 
487
-		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type  ? true : false;
488
-		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' );
489
-		$switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label;
487
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
488
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso');
489
+		$switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label;
490 490
 		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
491 491
 
492
-		if ( ! $button ) {
492
+		if ( ! $button) {
493 493
 			return $switch_to_url;
494 494
 		}
495 495
 
496
-		if ( ! empty( $switch_to_url ) ) {
496
+		if ( ! empty($switch_to_url)) {
497 497
 
498 498
 		return  '
499
-<form method="post" action="' . $switch_to_url . '" >
500
-	<input class="print_button" type="submit" value="' . $switch_to_label . '" />
499
+<form method="post" action="' . $switch_to_url.'" >
500
+	<input class="print_button" type="submit" value="' . $switch_to_label.'" />
501 501
 </form>
502 502
 		';
503 503
 		}
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return string
519 519
 	 */
520
-	private function _get_receipt_url( EE_Transaction $transaction ) {
520
+	private function _get_receipt_url(EE_Transaction $transaction) {
521 521
 		//get primary_registration
522 522
 		$reg = $this->_data->primary_reg_obj;
523 523
 
524
-		if ( ! $reg instanceof EE_Registration ) {
524
+		if ( ! $reg instanceof EE_Registration) {
525 525
 			return '';
526 526
 		}
527 527
 
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 	 *
538 538
 	 * @return int
539 539
 	 */
540
-	private function _get_subtotal( $tax = FALSE ) {
541
-		$grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL;
540
+	private function _get_subtotal($tax = FALSE) {
541
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL;
542 542
 
543
-		if ( ! $grand_total instanceof EE_Line_Item ) {
543
+		if ( ! $grand_total instanceof EE_Line_Item) {
544 544
 			return 0;
545 545
 		}
546 546
 
@@ -559,27 +559,27 @@  discard block
 block discarded – undo
559 559
 	 *
560 560
 	 * @return string parsed.
561 561
 	 */
562
-	private function _get_payment_link_if_needed( $shortcode ) {
563
-		$valid_shortcodes = array( 'transaction' );
564
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
562
+	private function _get_payment_link_if_needed($shortcode) {
563
+		$valid_shortcodes = array('transaction');
564
+		$attrs = $this->_get_shortcode_attrs($shortcode);
565 565
 
566 566
 		//ensure default is set.
567 567
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
568 568
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
569 569
 
570
-		if ( $total_owing > 0 ) {
571
-			$class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout';
572
-			$custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
573
-			$container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p';
574
-			$opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : '';
575
-			$opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag;
576
-			$opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag;
577
-			$closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : '';
578
-			$content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag;
570
+		if ($total_owing > 0) {
571
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
572
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
573
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
574
+			$opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
575
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
576
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
577
+			$closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
578
+			$content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
579 579
 
580 580
 			//we need to re run this string through the parser to catch any shortcodes that are in it.
581 581
 			$this->_set_shortcode_helper();
582
-			$owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID );
582
+			$owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_context, $this->_GRP_ID);
583 583
 		} else {
584 584
 			return '';
585 585
 		}
@@ -599,31 +599,31 @@  discard block
 block discarded – undo
599 599
 	 * @param EE_Transaction $transaction
600 600
 	 * @return string
601 601
 	 */
602
-	protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) {
602
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) {
603 603
 		//if transaction is paid in full then we can just return an empty string
604
-		if ( $transaction->remaining() === 0 ) {
604
+		if ($transaction->remaining() === 0) {
605 605
 			return '';
606 606
 		}
607 607
 
608
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
609
-		$format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' );
610
-		$days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30;
611
-		$prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' );
612
-		$transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' );
608
+		$attrs = $this->_get_shortcode_attrs($shortcode);
609
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
610
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
611
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso');
612
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
613 613
 
614 614
 		//setup date due:
615 615
 		try {
616
-			if ( $transaction_created instanceof DateTime ) {
617
-				$date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format );
616
+			if ($transaction_created instanceof DateTime) {
617
+				$date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format);
618 618
 			} else {
619 619
 				throw new Exception();
620 620
 			}
621
-		} catch( Exception $e ) {
621
+		} catch (Exception $e) {
622 622
 			//format was likely invalid.
623 623
 			$date_due = 'Unable to calculate date due, likely the format string is invalid.';
624 624
 		}
625 625
 
626
-		return $prefix_text . $date_due;
626
+		return $prefix_text.$date_due;
627 627
 	}
628 628
 
629 629
 } //end EE_Transaction Shortcodes library
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Minimum_Where_Conditions.strategy.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,6 +7,10 @@  discard block
 block discarded – undo
7 7
 
8 8
 	protected $_post_type;
9 9
 	protected $_meta_field;
10
+
11
+	/**
12
+	 * @param string $post_type
13
+	 */
10 14
 	function __construct($post_type, $meta_field_to_chk = ''){
11 15
 		$this->_post_type = $post_type;
12 16
 		$this->_meta_field = $meta_field_to_chk;
@@ -27,7 +31,6 @@  discard block
 block discarded – undo
27 31
 	}
28 32
 	/**
29 33
 	 * Gets the where default where conditions for a custom post type model
30
-	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
31 34
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
32 35
 	 */
33 36
 	protected function _get_default_where_conditions() {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  *
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @since		 	   4.8.29.rc.010
16 16
  *
17 17
  */
18
-class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{
18
+class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions {
19 19
 
20 20
 	protected $_post_type;
21 21
 	protected $_meta_field;
22
-	function __construct($post_type, $meta_field_to_chk = ''){
22
+	function __construct($post_type, $meta_field_to_chk = '') {
23 23
 		$this->_post_type = $post_type;
24 24
 		$this->_meta_field = $meta_field_to_chk;
25 25
 	}
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 * @param string $column column name
30 30
 	 * @return EE_Model_Field_Base
31 31
 	 */
32
-	protected function _get_field_on_column($column){
32
+	protected function _get_field_on_column($column) {
33 33
 		$all_fields = $this->_model->field_settings(true);
34
-		foreach($all_fields as $field_name => $field_obj){
35
-			if($column == $field_obj->get_table_column()){
34
+		foreach ($all_fields as $field_name => $field_obj) {
35
+			if ($column == $field_obj->get_table_column()) {
36 36
 				return $field_obj;
37 37
 			}
38 38
 		}
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 /**
6 6
  *
7 7
  * Class EE_CPT_Minimum_Where_Conditions
8
-  * 
8
+ * 
9 9
  * Strategy specifically for adding where conditions specific to CPT models.
10 10
  * But only sets the minimum, so any row of the right type will get used
11 11
  *
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,6 @@
 block discarded – undo
17 17
 class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{
18 18
 	/**
19 19
 	 * Gets the where default where conditions for a custom post type model
20
-	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
21 20
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
22 21
 	 */
23 22
 	protected function _get_default_where_conditions() {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * * @since		 	   4.6.0
15 15
  *
16 16
  */
17
-class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{
17
+class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions {
18 18
 	/**
19 19
 	 * Gets the where default where conditions for a custom post type model
20 20
 	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		return array_merge( 
26 26
 			parent::_get_default_where_conditions(),
27 27
 			array( 
28
-				$status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
28
+				$status_field->get_name() => array('NOT IN', array('auto-draft', 'trash'))
29 29
 			)
30 30
 		);
31 31
 	}
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 /**
6 6
  *
7 7
  * Class EE_Default_Where_Conditions
8
-  * 
8
+ * 
9 9
  * Strategy specifically for adding where conditions specific to CPT models.
10 10
  *
11 11
  * @package         Event Espresso
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 3 patches
Braces   +69 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
3 5
 /**
4 6
  *
@@ -170,7 +172,7 @@  discard block
 block discarded – undo
170 172
 		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171 173
 			if($relation_obj instanceof EE_Belongs_To_Relation){
172 174
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
175
+			} else{
174 176
 				$this->_model_relations[$relation_name] = array();
175 177
 			}
176 178
 		}
@@ -215,7 +217,7 @@  discard block
 block discarded – undo
215 217
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216 218
 				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
217 219
 			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
220
+		} else{
219 221
 			return NULL;
220 222
 		}
221 223
 	}
@@ -264,7 +266,7 @@  discard block
 block discarded – undo
264 266
 					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
265 267
 				}
266 268
 
267
-			}else{
269
+			} else{
268 270
 				$this->_fields[$field_name] = $holder_of_value;
269 271
 			}
270 272
 
@@ -292,7 +294,7 @@  discard block
 block discarded – undo
292 294
 			}
293 295
 			//let's unset any cache for this field_name from the $_cached_properties property.
294 296
 			$this->_clear_cached_property( $field_name );
295
-		}else{
297
+		} else{
296 298
 			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 299
 		}
298 300
 
@@ -588,8 +590,9 @@  discard block
 block discarded – undo
588 590
 	 * @return void
589 591
 	 */
590 592
 	protected function _clear_cached_property( $property_name ) {
591
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
592
-			unset( $this->_cached_properties[ $property_name ] );
593
+		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
594
+					unset( $this->_cached_properties[ $property_name ] );
595
+		}
593 596
 	}
594 597
 
595 598
 
@@ -629,10 +632,10 @@  discard block
 block discarded – undo
629 632
 		if($clear_all){
630 633
 			$obj_removed = true;
631 634
 			$this->_model_relations[$relationName]  = null;
632
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
635
+		} elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
633 636
 			$obj_removed = $this->_model_relations[$relationName];
634 637
 			$this->_model_relations[$relationName]  = null;
635
-		}else{
638
+		} else{
636 639
 			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
637 640
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
638 641
 				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
@@ -646,20 +649,20 @@  discard block
 block discarded – undo
646 649
 					}
647 650
 					if($index_found_at){
648 651
 						$index_in_cache = $index_found_at;
649
-					}else{
652
+					} else{
650 653
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
651 654
 						//if it wasn't in it to begin with. So we're done
652 655
 						return $object_to_remove_or_index_into_array;
653 656
 					}
654 657
 				}
655
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
658
+			} elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
656 659
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
657 660
 				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
658 661
 					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
659 662
 						$index_in_cache = $index;
660 663
 					}
661 664
 				}
662
-			}else{
665
+			} else{
663 666
 				$index_in_cache = $object_to_remove_or_index_into_array;
664 667
 			}
665 668
 			//supposedly we've found it. But it could just be that the client code
@@ -668,7 +671,7 @@  discard block
 block discarded – undo
668 671
 					isset( $this->_model_relations[$relationName][$index_in_cache])){
669 672
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
670 673
 				unset($this->_model_relations[$relationName][$index_in_cache]);
671
-			}else{
674
+			} else{
672 675
 				//that thing was never cached anyways.
673 676
 				$obj_removed = NULL;
674 677
 			}
@@ -724,7 +727,7 @@  discard block
 block discarded – undo
724 727
 		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
725 728
 		if(is_array($cached_array_or_object)){
726 729
 			return array_shift($cached_array_or_object);
727
-		}else{
730
+		} else{
728 731
 			return $cached_array_or_object;
729 732
 		}
730 733
 	}
@@ -743,10 +746,10 @@  discard block
 block discarded – undo
743 746
 		$cached_array_or_object =  isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
744 747
 		if(is_array($cached_array_or_object)){
745 748
 			$objects = $cached_array_or_object;
746
-		}elseif($cached_array_or_object){
749
+		} elseif($cached_array_or_object){
747 750
 			//if the result is not an array, but exists, make it an array
748 751
 			$objects = array($cached_array_or_object);
749
-		}else{
752
+		} else{
750 753
 			//if nothing was found, return an empty array
751 754
 			$objects = array();
752 755
 		}
@@ -761,7 +764,7 @@  discard block
 block discarded – undo
761 764
 				if( $model_object->ID() ){
762 765
 					$model->add_to_entity_map( $model_object );
763 766
 				}
764
-			}else{
767
+			} else{
765 768
 				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
766 769
 			}
767 770
 		}
@@ -886,10 +889,10 @@  discard block
 block discarded – undo
886 889
 				if( $field_obj->is_nullable()){
887 890
 					//if the field allows nulls, then let it be null
888 891
 					$field_value = NULL;
889
-				}else{
892
+				} else{
890 893
 					$field_value = $field_obj->get_default_value();
891 894
 				}
892
-			}else{
895
+			} else{
893 896
 				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
894 897
 			}
895 898
 			$this->_fields[$field_name] = $field_value;
@@ -1009,15 +1012,17 @@  discard block
 block discarded – undo
1009 1012
 			$this->_tm_frmt = $in_tm_frmt;
1010 1013
 		}
1011 1014
 
1012
-		if ( $echo )
1013
-			$field->set_pretty_date_format( $in_dt_frmt );
1014
-		else
1015
-			$field->set_date_format( $in_dt_frmt );
1015
+		if ( $echo ) {
1016
+					$field->set_pretty_date_format( $in_dt_frmt );
1017
+		} else {
1018
+					$field->set_date_format( $in_dt_frmt );
1019
+		}
1016 1020
 
1017
-		if ( $echo )
1018
-			$field->set_pretty_time_format( $in_tm_frmt );
1019
-		else
1020
-			$field->set_time_format( $in_tm_frmt );
1021
+		if ( $echo ) {
1022
+					$field->set_pretty_time_format( $in_tm_frmt );
1023
+		} else {
1024
+					$field->set_time_format( $in_tm_frmt );
1025
+		}
1021 1026
 
1022 1027
 		//set timezone in field object
1023 1028
 		$field->set_timezone( $this->_timezone );
@@ -1240,8 +1245,9 @@  discard block
 block discarded – undo
1240 1245
 		EE_Registry::instance()->load_helper('DTT_Helper');
1241 1246
 		$timezone = EEH_DTT_Helper::get_timezone();
1242 1247
 
1243
-		if ( $timezone == $this->_timezone )
1244
-			return '';
1248
+		if ( $timezone == $this->_timezone ) {
1249
+					return '';
1250
+		}
1245 1251
 
1246 1252
 		$original_timezone = $this->_timezone;
1247 1253
 		$this->set_timezone( $timezone );
@@ -1249,8 +1255,9 @@  discard block
 block discarded – undo
1249 1255
 		$fn = (array) $field_name;
1250 1256
 		$args = array_merge( $fn, (array) $args );
1251 1257
 
1252
-		if ( !method_exists( $this, $callback ) )
1253
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1258
+		if ( !method_exists( $this, $callback ) ) {
1259
+					throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1260
+		}
1254 1261
 		$args = (array) $args;
1255 1262
 		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1256 1263
 
@@ -1397,7 +1404,7 @@  discard block
 block discarded – undo
1397 1404
 						$this->_update_cached_related_model_objs_fks();
1398 1405
 					}
1399 1406
 				}
1400
-			}else{//PK is NOT auto-increment
1407
+			} else{//PK is NOT auto-increment
1401 1408
 				//so check if one like it already exists in the db
1402 1409
 				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1403 1410
 					if( ! $this->in_entity_map() && WP_DEBUG ){
@@ -1412,12 +1419,12 @@  discard block
 block discarded – undo
1412 1419
 						);
1413 1420
 					}
1414 1421
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1415
-				}else{
1422
+				} else{
1416 1423
 					$results = $this->get_model()->insert($save_cols_n_values);
1417 1424
 					$this->_update_cached_related_model_objs_fks();
1418 1425
 				}
1419 1426
 			}
1420
-		}else{//there is NO primary key
1427
+		} else{//there is NO primary key
1421 1428
 			$already_in_db = false;
1422 1429
 			foreach($this->get_model()->unique_indexes() as $index){
1423 1430
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
@@ -1428,7 +1435,7 @@  discard block
 block discarded – undo
1428 1435
 			if( $already_in_db ){
1429 1436
 				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1430 1437
 				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1431
-			}else{
1438
+			} else{
1432 1439
 				$results = $this->get_model()->insert( $save_cols_n_values );
1433 1440
 			}
1434 1441
 		}
@@ -1480,7 +1487,7 @@  discard block
 block discarded – undo
1480 1487
 		//make sure this has been saved
1481 1488
 		if( ! $this->ID()){
1482 1489
 			$id = $this->save();
1483
-		}else{
1490
+		} else{
1484 1491
 			$id = $this->ID();
1485 1492
 		}
1486 1493
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
@@ -1499,7 +1506,7 @@  discard block
 block discarded – undo
1499 1506
 						$this->_add_relation_to($related_model_obj, $relationName);
1500 1507
 						$related_model_obj->save_new_cached_related_model_objs();
1501 1508
 //					}
1502
-				}else{
1509
+				} else{
1503 1510
 					foreach($this->_model_relations[$relationName] as $related_model_obj){
1504 1511
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1505 1512
 						//but ONLY if it DOES NOT exist in the DB
@@ -1558,13 +1565,13 @@  discard block
 block discarded – undo
1558 1565
 
1559 1566
 			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1560 1567
 				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1561
-			}else{
1568
+			} else{
1562 1569
 				$existing = null;
1563 1570
 			}
1564
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1571
+		} elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1565 1572
 			//no primary key on this model, but there's still a matching item in the DB
1566 1573
 				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1567
-		}else{
1574
+		} else{
1568 1575
 			$existing = null;
1569 1576
 		}
1570 1577
 		if ( $existing ) {
@@ -1622,7 +1629,7 @@  discard block
 block discarded – undo
1622 1629
 	private static function _get_model_classname( $model_name = null){
1623 1630
 		if(strpos($model_name,"EE_")===0){
1624 1631
 			$model_classname=str_replace("EE_","EEM_",$model_name);
1625
-		}else{
1632
+		} else{
1626 1633
 			$model_classname = "EEM_".$model_name;
1627 1634
 		}
1628 1635
 		return $model_classname;
@@ -1656,7 +1663,7 @@  discard block
 block discarded – undo
1656 1663
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1657 1664
 		if( $this->get_model()->has_primary_key_field() ) {
1658 1665
 			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1659
-		}else{
1666
+		} else{
1660 1667
 			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1661 1668
 		}
1662 1669
 	}
@@ -1784,7 +1791,7 @@  discard block
 block discarded – undo
1784 1791
 			//if there are query parameters, forget about caching the related model objects.
1785 1792
 			if( $query_params ){
1786 1793
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1787
-			}else{
1794
+			} else{
1788 1795
 				//did we already cache the result of this query?
1789 1796
 				$cached_results = $this->get_all_from_cache($relationName);
1790 1797
 				if ( ! $cached_results ){
@@ -1794,11 +1801,11 @@  discard block
 block discarded – undo
1794 1801
 					foreach($related_model_objects as $related_model_object){
1795 1802
 						$this->cache($relationName, $related_model_object);
1796 1803
 					}
1797
-				}else{
1804
+				} else{
1798 1805
 					$related_model_objects = $cached_results;
1799 1806
 				}
1800 1807
 			}
1801
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1808
+		} else{//this doesn't exist itn eh DB, so just get the related things from the cache
1802 1809
 			$related_model_objects = $this->get_all_from_cache($relationName);
1803 1810
 		}
1804 1811
 		return $related_model_objects;
@@ -1850,22 +1857,22 @@  discard block
 block discarded – undo
1850 1857
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1851 1858
 			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1852 1859
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1853
-			}else{
1860
+			} else{
1854 1861
 				//first, check if we've already cached the result of this query
1855 1862
 				$cached_result = $this->get_one_from_cache($relationName);
1856 1863
 				if ( ! $cached_result ){
1857 1864
 
1858 1865
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1859 1866
 					$this->cache($relationName,$related_model_object);
1860
-				}else{
1867
+				} else{
1861 1868
 					$related_model_object = $cached_result;
1862 1869
 				}
1863 1870
 			}
1864
-		}else{
1871
+		} else{
1865 1872
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1866 1873
 			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1867 1874
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1868
-			}else{
1875
+			} else{
1869 1876
 				$related_model_object = null;
1870 1877
 			}
1871 1878
 			//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
@@ -1891,7 +1898,7 @@  discard block
 block discarded – undo
1891 1898
 	public function delete_related($relationName,$query_params = array()){
1892 1899
 		if($this->ID()){
1893 1900
 			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1894
-		}else{
1901
+		} else{
1895 1902
 			$count = count($this->get_all_from_cache($relationName));
1896 1903
 			$this->clear_cache($relationName,NULL,TRUE);
1897 1904
 		}
@@ -1911,7 +1918,7 @@  discard block
 block discarded – undo
1911 1918
 	public function delete_related_permanently($relationName,$query_params = array()){
1912 1919
 		if($this->ID()){
1913 1920
 			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1914
-		}else{
1921
+		} else{
1915 1922
 			$count = count($this->get_all_from_cache($relationName));
1916 1923
 		}
1917 1924
 		$this->clear_cache($relationName,NULL,TRUE);
@@ -1946,8 +1953,9 @@  discard block
 block discarded – undo
1946 1953
 
1947 1954
 		foreach ( (array) $properties as $property_name ) {
1948 1955
 			//first make sure this property exists
1949
-			if ( ! $this->_fields[ $property_name ] )
1950
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1956
+			if ( ! $this->_fields[ $property_name ] ) {
1957
+							throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1958
+			}
1951 1959
 		}
1952 1960
 
1953 1961
 		return TRUE;
@@ -2027,7 +2035,7 @@  discard block
 block discarded – undo
2027 2035
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2028 2036
 		if( ! $existing_rows_like_that){
2029 2037
 			return $this->add_extra_meta($meta_key, $meta_value);
2030
-		}else{
2038
+		} else{
2031 2039
 			foreach( $existing_rows_like_that as $existing_row){
2032 2040
 				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2033 2041
 			}
@@ -2093,10 +2101,10 @@  discard block
 block discarded – undo
2093 2101
 			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2094 2102
 			if ( $result instanceof EE_Extra_Meta ){
2095 2103
 				return $result->value();
2096
-			}else{
2104
+			} else{
2097 2105
 				return $default;
2098 2106
 			}
2099
-		}else{
2107
+		} else{
2100 2108
 			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2101 2109
 			if($results){
2102 2110
 				$values = array();
@@ -2106,7 +2114,7 @@  discard block
 block discarded – undo
2106 2114
 					}
2107 2115
 				}
2108 2116
 				return $values;
2109
-			}else{
2117
+			} else{
2110 2118
 				return $default;
2111 2119
 			}
2112 2120
 		}
@@ -2132,7 +2140,7 @@  discard block
 block discarded – undo
2132 2140
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2133 2141
 				}
2134 2142
 			}
2135
-		}else{
2143
+		} else{
2136 2144
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2137 2145
 			foreach($extra_meta_objs as $extra_meta_obj){
2138 2146
 				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
@@ -2154,7 +2162,7 @@  discard block
 block discarded – undo
2154 2162
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2155 2163
 		if($field_we_can_use){
2156 2164
 			return $this->get($field_we_can_use->get_name());
2157
-		}else{
2165
+		} else{
2158 2166
 			$first_few_properties = $this->model_field_array();
2159 2167
 			$first_few_properties = array_slice($first_few_properties,0,3);
2160 2168
 			$name_parts = array();
@@ -2174,7 +2182,7 @@  discard block
 block discarded – undo
2174 2182
 		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2175 2183
 			//well, if we looked, did we find it in the entity map?
2176 2184
 			return TRUE;
2177
-		}else{
2185
+		} else{
2178 2186
 			return FALSE;
2179 2187
 		}
2180 2188
 	}
@@ -2188,7 +2196,7 @@  discard block
 block discarded – undo
2188 2196
 	public function refresh_from_db(){
2189 2197
 		if( $this->ID() && $this->in_entity_map() ){
2190 2198
 			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2191
-		}else{
2199
+		} else{
2192 2200
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2193 2201
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2194 2202
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
Please login to merge, or discard this patch.
Spacing   +480 added lines, -480 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				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))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				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))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
138
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		EE_Registry::instance()->load_helper('DTT_Helper');
138
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
139 139
 
140
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
140
+		if ( ! empty($date_formats) && is_array($date_formats)) {
141 141
 			$this->_dt_frmt = $date_formats[0];
142 142
 			$this->_tm_frmt = $date_formats[1];
143 143
 		} else {
144 144
 			//set default formats for date and time
145
-			$this->_dt_frmt = get_option( 'date_format' );
146
-			$this->_tm_frmt = get_option( 'time_format' );
145
+			$this->_dt_frmt = get_option('date_format');
146
+			$this->_tm_frmt = get_option('time_format');
147 147
 		}
148 148
 
149 149
 		//if db model is instantiating
150
-		if ( $bydb ){
150
+		if ($bydb) {
151 151
 			//client code has indicated these field values are from the database
152
-			foreach( $model_fields as $fieldName => $field ){
153
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
152
+			foreach ($model_fields as $fieldName => $field) {
153
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
154 154
 			}
155 155
 		} else {
156 156
 			//we're constructing a brand
157 157
 			//new instance of the model object. Generally, this means we'll need to do more field validation
158
-			foreach( $model_fields as $fieldName => $field ){
159
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
158
+			foreach ($model_fields as $fieldName => $field) {
159
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
160 160
 			}
161 161
 		}
162 162
 
163 163
 		//remember what values were passed to this constructor
164 164
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
165 165
 		//remember in entity mapper
166
-		if($model->has_primary_key_field() && $this->ID() && ! $bydb ){
166
+		if ($model->has_primary_key_field() && $this->ID() && ! $bydb) {
167 167
 			$model->add_to_entity_map($this);
168 168
 		}
169 169
 		//setup all the relations
170
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171
-			if($relation_obj instanceof EE_Belongs_To_Relation){
170
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
171
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
172 172
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
173
+			} else {
174 174
 				$this->_model_relations[$relation_name] = array();
175 175
 			}
176 176
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 * Action done at the end of each model object construction
179 179
 		 * @param EE_Base_Class $this the model object just created
180 180
 		 */
181
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
181
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
182 182
 	}
183 183
 
184 184
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param boolean $allow_persist
199 199
 	 * @return boolean
200 200
 	 */
201
-	function set_allow_persist( $allow_persist ) {
201
+	function set_allow_persist($allow_persist) {
202 202
 		return $this->_allow_persist = $allow_persist;
203 203
 	}
204 204
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @param string $field_name
212 212
 	 * @return mixed|null
213 213
 	 */
214
-	public function get_original( $field_name ){
215
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216
-				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
217
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
214
+	public function get_original($field_name) {
215
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
216
+				$field_settings = $this->get_Model()->field_settings_for($field_name)) {
217
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
218
+		} else {
219 219
 			return NULL;
220 220
 		}
221 221
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Base_Class $obj
226 226
 	 * @return string
227 227
 	 */
228
-	public function get_class($obj){
228
+	public function get_class($obj) {
229 229
 		return get_class($obj);
230 230
 	}
231 231
 
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 	 * @param	mixed 	$field_value
239 239
 	 * @param bool 	$use_default
240 240
 	 */
241
-	public function set( $field_name, $field_value, $use_default = FALSE ){
242
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
243
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
241
+	public function set($field_name, $field_value, $use_default = FALSE) {
242
+		$field_obj = $this->get_model()->field_settings_for($field_name);
243
+		if ($field_obj instanceof EE_Model_Field_Base) {
244 244
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
245
-			if ( $field_obj instanceof EE_Datetime_Field ) {
246
-				$field_obj->set_timezone( $this->_timezone );
247
-				$field_obj->set_date_format( $this->_dt_frmt );
248
-				$field_obj->set_time_format( $this->_tm_frmt );
245
+			if ($field_obj instanceof EE_Datetime_Field) {
246
+				$field_obj->set_timezone($this->_timezone);
247
+				$field_obj->set_date_format($this->_dt_frmt);
248
+				$field_obj->set_time_format($this->_tm_frmt);
249 249
 			}
250 250
 
251 251
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
252 252
 			//should the value be null?
253
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
253
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
254 254
 				$this->_fields[$field_name] = $field_obj->get_default_value();
255 255
 
256 256
 				/**
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
 				 * object.
261 261
 				 * @since 4.6.10+
262 262
 				 */
263
-				if ( $field_obj instanceof EE_Datetime_Field && ! is_null( $this->_fields[$field_name] ) && ! $this->_fields[$field_name] instanceof DateTime ) {
264
-					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
263
+				if ($field_obj instanceof EE_Datetime_Field && ! is_null($this->_fields[$field_name]) && ! $this->_fields[$field_name] instanceof DateTime) {
264
+					empty($this->_fields[$field_name]) ? $this->set($field_name, time()) : $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($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
273
+			if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
274 274
 				$field_name == $this->_get_primary_key_name(get_class($this)) &&
275
-				$field_value){
275
+				$field_value) {
276 276
 				//if so, we want all this object's fields to be filled either with
277 277
 				//what we've explicitly set on this model
278 278
 				//or what we have in the db
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
 				$fields_on_model = $this->_get_model(get_class($this))->field_settings();
281 281
 
282 282
 				$obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value);
283
-				foreach($fields_on_model as $field_obj){
284
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
285
-						&& $field_obj->get_name() != $field_name ){
283
+				foreach ($fields_on_model as $field_obj) {
284
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
285
+						&& $field_obj->get_name() != $field_name) {
286 286
 
287
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
287
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
288 288
 					}
289 289
 				}
290 290
 				//oh this model object has an ID? well make sure its in the entity mapper
291 291
 				$this->get_model()->add_to_entity_map($this);
292 292
 			}
293 293
 			//let's unset any cache for this field_name from the $_cached_properties property.
294
-			$this->_clear_cached_property( $field_name );
295
-		}else{
296
-			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  ) );
294
+			$this->_clear_cached_property($field_name);
295
+		} else {
296
+			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 297
 		}
298 298
 
299 299
 	}
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
 	 * @param mixed  $field_value  The value to set.
313 313
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
314 314
 	 */
315
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
316
-		if ( $this->get_model()->has_field( $field_name ) ) {
317
-			$this->set( $field_name, $field_value );
315
+	public function set_field_or_extra_meta($field_name, $field_value) {
316
+		if ($this->get_model()->has_field($field_name)) {
317
+			$this->set($field_name, $field_value);
318 318
 			return true;
319 319
 		} else {
320 320
 			//ensure this object is saved first so that extra meta can be properly related.
321 321
 			$this->save();
322
-			return $this->update_extra_meta( $field_name, $field_value );
322
+			return $this->update_extra_meta($field_name, $field_value);
323 323
 		}
324 324
 	}
325 325
 
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $field_name  expecting the fully qualified field name.
344 344
 	 * @return mixed|null  value for the field if found.  null if not found.
345 345
 	 */
346
-	public function get_field_or_extra_meta( $field_name ) {
347
-		if ( $this->get_model()->has_field( $field_name ) ) {
348
-			$column_value = $this->get( $field_name );
346
+	public function get_field_or_extra_meta($field_name) {
347
+		if ($this->get_model()->has_field($field_name)) {
348
+			$column_value = $this->get($field_name);
349 349
 		} else {
350 350
 			//This isn't a column in the main table, let's see if it is in the extra meta.
351
-			$column_value = $this->get_extra_meta( $field_name, true, null );
351
+			$column_value = $this->get_extra_meta($field_name, true, null);
352 352
 		}
353 353
 		return $column_value;
354 354
 	}
@@ -367,19 +367,19 @@  discard block
 block discarded – undo
367 367
 	 * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
368 368
 	 * @return void
369 369
 	 */
370
-	public function set_timezone( $timezone = '' ) {
370
+	public function set_timezone($timezone = '') {
371 371
 		EE_Registry::instance()->load_helper('DTT_Helper');
372
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
372
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
373 373
 		//make sure we clear all cached properties because they won't be relevant now
374 374
 		$this->_clear_cached_properties();
375 375
 
376 376
 		//make sure we update field settings and the date for all EE_Datetime_Fields
377
-		$model_fields = $this->get_model()->field_settings( false );
378
-		foreach ( $model_fields as $field_name => $field_obj ) {
379
-			if ( $field_obj instanceof EE_Datetime_Field ) {
380
-				$field_obj->set_timezone( $this->_timezone );
381
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
382
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
377
+		$model_fields = $this->get_model()->field_settings(false);
378
+		foreach ($model_fields as $field_name => $field_obj) {
379
+			if ($field_obj instanceof EE_Datetime_Field) {
380
+				$field_obj->set_timezone($this->_timezone);
381
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
382
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
383 383
 				}
384 384
 			}
385 385
 		}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @param string $format   should be a format recognizable by PHP date() functions.
410 410
 	 */
411
-	public function set_date_format( $format ) {
411
+	public function set_date_format($format) {
412 412
 		$this->_dt_frmt = $format;
413 413
 		//clear cached_properties because they won't be relevant now.
414 414
 		$this->_clear_cached_properties();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 * @since 4.6
425 425
 	 * @param string $format should be a format recognizable by PHP date() functions.
426 426
 	 */
427
-	public function set_time_format( $format ) {
427
+	public function set_time_format($format) {
428 428
 		$this->_tm_frmt = $format;
429 429
 		//clear cached_properties because they won't be relevant now.
430 430
 		$this->_clear_cached_properties();
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @return mixed string|array
443 443
 	 */
444
-	public function get_format( $full = true ) {
445
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
444
+	public function get_format($full = true) {
445
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
446 446
 	}
447 447
 
448 448
 
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 	 * @throws EE_Error
461 461
 	 * @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)
462 462
 	 */
463
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
463
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
464 464
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
465
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
465
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
466 466
 			return FALSE;
467 467
 		}
468 468
 		// also get "how" the object is related, or throw an error
469
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
470
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
469
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
470
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
471 471
 		}
472 472
 		// how many things are related ?
473
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
473
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
474 474
 			// 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
475 475
 			// so for these model objects just set it to be cached
476 476
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -478,26 +478,26 @@  discard block
 block discarded – undo
478 478
 		} else {
479 479
 			// 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.
480 480
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
481
-			if( ! is_array( $this->_model_relations[$relationName] )) {
481
+			if ( ! is_array($this->_model_relations[$relationName])) {
482 482
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
483
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
483
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
484 484
 			}
485 485
 			// first check for a cache_id which is normally empty
486
-			if ( ! empty( $cache_id )) {
486
+			if ( ! empty($cache_id)) {
487 487
 				// 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
488
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
488
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
489 489
 				$return = $cache_id;
490
-			} elseif ( $object_to_cache->ID() ) {
490
+			} elseif ($object_to_cache->ID()) {
491 491
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
492
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
492
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
493 493
 				$return = $object_to_cache->ID();
494 494
 			} else {
495 495
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
496 496
 				$this->_model_relations[$relationName][] = $object_to_cache;
497 497
 				  // move the internal pointer to the end of the array
498
-				end( $this->_model_relations[$relationName] );
498
+				end($this->_model_relations[$relationName]);
499 499
 				// and grab the key so that we can return it
500
-				$return = key( $this->_model_relations[$relationName] );
500
+				$return = key($this->_model_relations[$relationName]);
501 501
 			}
502 502
 
503 503
 		}
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 * @param null   $cache_type
516 516
 	 * @return void
517 517
 	 */
518
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
518
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
519 519
 		//first make sure this property exists
520 520
 		$this->get_model()->field_settings_for($fieldname);
521 521
 
522
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
522
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
523 523
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
524 524
 	}
525 525
 
@@ -534,34 +534,34 @@  discard block
 block discarded – undo
534 534
 	 *                                 It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used
535 535
 	 * @return mixed                whatever the value for the property is we're retrieving
536 536
 	 */
537
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
537
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
538 538
 		//verify the field exists
539 539
 		$this->get_model()->field_settings_for($fieldname);
540 540
 
541 541
 		$cache_type = $pretty ? 'pretty' : 'standard';
542
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
542
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
543 543
 
544
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
544
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
545 545
 			return $this->_cached_properties[$fieldname][$cache_type];
546 546
 		}
547 547
 
548 548
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
549
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
549
+		if ($field_obj instanceof EE_Model_Field_Base) {
550 550
 			/**
551 551
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
552 552
 			 * formats are correct.
553 553
 			 */
554
-			if ( $field_obj instanceof EE_Datetime_Field ) {
555
-				$field_obj->set_timezone( $this->_timezone );
556
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
557
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
554
+			if ($field_obj instanceof EE_Datetime_Field) {
555
+				$field_obj->set_timezone($this->_timezone);
556
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
557
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
558 558
 			}
559 559
 
560
-			if( ! isset($this->_fields[$fieldname])){
560
+			if ( ! isset($this->_fields[$fieldname])) {
561 561
 				$this->_fields[$fieldname] = NULL;
562 562
 			}
563
-			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] );
564
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
563
+			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]);
564
+			$this->_set_cached_property($fieldname, $value, $cache_type);
565 565
 			return $value;
566 566
 		}
567 567
 		return FALSE;
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
588 588
 	 * @return void
589 589
 	 */
590
-	protected function _clear_cached_property( $property_name ) {
591
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
592
-			unset( $this->_cached_properties[ $property_name ] );
590
+	protected function _clear_cached_property($property_name) {
591
+		if (isset($this->_cached_properties[$property_name]))
592
+			unset($this->_cached_properties[$property_name]);
593 593
 	}
594 594
 
595 595
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @param string $model_name name of the related thing, eg 'Attendee',
601 601
 	 * @return EE_Base_Class
602 602
 	 */
603
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
603
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
604 604
 		$other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone);
605 605
 		$model_obj = $other_model_instance->ensure_is_obj($object_or_id);
606 606
 		return $model_obj;
@@ -620,55 +620,55 @@  discard block
 block discarded – undo
620 620
 	 * @throws EE_Error
621 621
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
622 622
 	 */
623
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
623
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
624 624
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
625 625
 		$index_in_cache = '';
626
-		if( ! $relationship_to_model){
627
-			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this)));
626
+		if ( ! $relationship_to_model) {
627
+			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this)));
628 628
 		}
629
-		if($clear_all){
629
+		if ($clear_all) {
630 630
 			$obj_removed = true;
631 631
 			$this->_model_relations[$relationName]  = null;
632
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
632
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
633 633
 			$obj_removed = $this->_model_relations[$relationName];
634 634
 			$this->_model_relations[$relationName]  = null;
635
-		}else{
636
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
635
+		} else {
636
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
637 637
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
638
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
638
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
639 639
 					$index_found_at = NULL;
640 640
 					//find this object in the array even though it has a different key
641
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
642
-						if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) {
641
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
642
+						if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) {
643 643
 							$index_found_at = $index;
644 644
 							break;
645 645
 						}
646 646
 					}
647
-					if($index_found_at){
647
+					if ($index_found_at) {
648 648
 						$index_in_cache = $index_found_at;
649
-					}else{
649
+					} else {
650 650
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
651 651
 						//if it wasn't in it to begin with. So we're done
652 652
 						return $object_to_remove_or_index_into_array;
653 653
 					}
654 654
 				}
655
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
655
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
656 656
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
657
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
658
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
657
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
658
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
659 659
 						$index_in_cache = $index;
660 660
 					}
661 661
 				}
662
-			}else{
662
+			} else {
663 663
 				$index_in_cache = $object_to_remove_or_index_into_array;
664 664
 			}
665 665
 			//supposedly we've found it. But it could just be that the client code
666 666
 			//provided a bad index/object
667
-			if(isset( $this->_model_relations[$relationName]) &&
668
-					isset( $this->_model_relations[$relationName][$index_in_cache])){
667
+			if (isset($this->_model_relations[$relationName]) &&
668
+					isset($this->_model_relations[$relationName][$index_in_cache])) {
669 669
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
670 670
 				unset($this->_model_relations[$relationName][$index_in_cache]);
671
-			}else{
671
+			} else {
672 672
 				//that thing was never cached anyways.
673 673
 				$obj_removed = NULL;
674 674
 			}
@@ -687,24 +687,24 @@  discard block
 block discarded – undo
687 687
 	 * @param string                $current_cache_id   - the ID that was used when originally caching the object
688 688
 	 * @return boolean TRUE on success, FALSE on fail
689 689
 	 */
690
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
690
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
691 691
 		// verify that incoming object is of the correct type
692
-		$obj_class = 'EE_' . $relationName;
693
-		if ( $newly_saved_object instanceof $obj_class ) {
692
+		$obj_class = 'EE_'.$relationName;
693
+		if ($newly_saved_object instanceof $obj_class) {
694 694
 			/* @type EE_Base_Class $newly_saved_object*/
695 695
 			// now get the type of relation
696
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
696
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
697 697
 			// if this is a 1:1 relationship
698
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
698
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
699 699
 				// then just replace the cached object with the newly saved object
700 700
 				$this->_model_relations[$relationName] = $newly_saved_object;
701 701
 				return TRUE;
702 702
 			// or if it's some kind of sordid feral polyamorous relationship...
703
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
703
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
704 704
 				// then remove the current cached item
705
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
705
+				unset($this->_model_relations[$relationName][$current_cache_id]);
706 706
 				// and cache the newly saved object using it's new ID
707
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
707
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
708 708
 				return TRUE;
709 709
 			}
710 710
 		}
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	 * @param string $relationName
721 721
 	 * @return EE_Base_Class
722 722
 	 */
723
-	public function get_one_from_cache($relationName){
724
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
725
-		if(is_array($cached_array_or_object)){
723
+	public function get_one_from_cache($relationName) {
724
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
725
+		if (is_array($cached_array_or_object)) {
726 726
 			return array_shift($cached_array_or_object);
727
-		}else{
727
+		} else {
728 728
 			return $cached_array_or_object;
729 729
 		}
730 730
 	}
@@ -739,14 +739,14 @@  discard block
 block discarded – undo
739 739
 	 * @throws \EE_Error
740 740
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
741 741
 	 */
742
-	public function get_all_from_cache($relationName){
743
-		$cached_array_or_object =  isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
744
-		if(is_array($cached_array_or_object)){
742
+	public function get_all_from_cache($relationName) {
743
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
744
+		if (is_array($cached_array_or_object)) {
745 745
 			$objects = $cached_array_or_object;
746
-		}elseif($cached_array_or_object){
746
+		}elseif ($cached_array_or_object) {
747 747
 			//if the result is not an array, but exists, make it an array
748 748
 			$objects = array($cached_array_or_object);
749
-		}else{
749
+		} else {
750 750
 			//if nothing was found, return an empty array
751 751
 			$objects = array();
752 752
 		}
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 		//basically, if this model object was stored in the session, and these cached model objects
755 755
 		//already have IDs, let's make sure they're in their model's entity mapper
756 756
 		//otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
757
-		foreach( $objects as $model_object ){
758
-			$model = EE_Registry::instance()->load_model( $relationName );
759
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
757
+		foreach ($objects as $model_object) {
758
+			$model = EE_Registry::instance()->load_model($relationName);
759
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
760 760
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
761
-				if( $model_object->ID() ){
762
-					$model->add_to_entity_map( $model_object );
761
+				if ($model_object->ID()) {
762
+					$model->add_to_entity_map($model_object);
763 763
 				}
764
-			}else{
765
-				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
764
+			} else {
765
+				throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object)));
766 766
 			}
767 767
 		}
768 768
 		return $objects;
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @return array|EE_Base_Class[]
783 783
 	 */
784
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
785
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
786
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
787
-		if ( empty( $field ) || empty( $current_value ) ) {
784
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
785
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
786
+		$current_value = ! empty($field) ? $this->get($field) : null;
787
+		if (empty($field) || empty($current_value)) {
788 788
 			return array();
789 789
 		}
790
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
790
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
791 791
 	}
792 792
 
793 793
 
@@ -806,13 +806,13 @@  discard block
 block discarded – undo
806 806
 	 *
807 807
 	 * @return array|EE_Base_Class[]
808 808
 	 */
809
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
810
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
811
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
812
-		if ( empty( $field ) || empty( $current_value ) ) {
809
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
810
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
811
+		$current_value = ! empty($field) ? $this->get($field) : null;
812
+		if (empty($field) || empty($current_value)) {
813 813
 			return array();
814 814
 		}
815
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
815
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
816 816
 	}
817 817
 
818 818
 
@@ -830,13 +830,13 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @return array|EE_Base_Class
832 832
 	 */
833
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
834
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
835
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
836
-		if ( empty( $field ) || empty( $current_value ) ) {
833
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
834
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
835
+		$current_value = ! empty($field) ? $this->get($field) : null;
836
+		if (empty($field) || empty($current_value)) {
837 837
 			return array();
838 838
 		}
839
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
839
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
840 840
 	}
841 841
 
842 842
 
@@ -855,13 +855,13 @@  discard block
 block discarded – undo
855 855
 	 *
856 856
 	 * @return array|EE_Base_Class
857 857
 	 */
858
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
859
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
860
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
861
-		if ( empty( $field ) || empty( $current_value ) ) {
858
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
859
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
860
+		$current_value = ! empty($field) ? $this->get($field) : null;
861
+		if (empty($field) || empty($current_value)) {
862 862
 			return array();
863 863
 		}
864
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
864
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
865 865
 	}
866 866
 
867 867
 
@@ -875,25 +875,25 @@  discard block
 block discarded – undo
875 875
 	 * @param string $field_name
876 876
 	 * @param mixed  $field_value_from_db
877 877
 	 */
878
-	public function set_from_db($field_name,$field_value_from_db){
878
+	public function set_from_db($field_name, $field_value_from_db) {
879 879
 		$field_obj = $this->get_model()->field_settings_for($field_name);
880
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
880
+		if ($field_obj instanceof EE_Model_Field_Base) {
881 881
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
882 882
 			//eg, a CPT model object could have an entry in the posts table, but no
883 883
 			//entry in the meta table. Meaning that all its columns in the meta table
884 884
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
885
-			if($field_value_from_db === NULL ){
886
-				if( $field_obj->is_nullable()){
885
+			if ($field_value_from_db === NULL) {
886
+				if ($field_obj->is_nullable()) {
887 887
 					//if the field allows nulls, then let it be null
888 888
 					$field_value = NULL;
889
-				}else{
889
+				} else {
890 890
 					$field_value = $field_obj->get_default_value();
891 891
 				}
892
-			}else{
893
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
892
+			} else {
893
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
894 894
 			}
895 895
 			$this->_fields[$field_name] = $field_value;
896
-			$this->_clear_cached_property( $field_name );
896
+			$this->_clear_cached_property($field_name);
897 897
 		}
898 898
 	}
899 899
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	 * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
906 906
 	 * @return boolean
907 907
 	 */
908
-	public function get($field_name, $extra_cache_ref = NULL ){
909
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
908
+	public function get($field_name, $extra_cache_ref = NULL) {
909
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
910 910
 	}
911 911
 
912 912
 
@@ -936,11 +936,11 @@  discard block
 block discarded – undo
936 936
 	 *                    				     just null is returned (because that indicates that likely
937 937
 	 *                    				     this field is nullable).
938 938
 	 */
939
-	public function get_DateTime_object( $field_name ) {
940
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
939
+	public function get_DateTime_object($field_name) {
940
+		$field_settings = $this->get_model()->field_settings_for($field_name);
941 941
 
942
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
943
-			EE_Error::add_error( sprintf( __('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso' ), $field_name ), __FILE__, __FUNCTION__, __LINE__ );
942
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
943
+			EE_Error::add_error(sprintf(__('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso'), $field_name), __FILE__, __FUNCTION__, __LINE__);
944 944
 			return false;
945 945
 		}
946 946
 
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
957 957
 	 * @return void
958 958
 	 */
959
-	public function e($field_name, $extra_cache_ref = NULL){
959
+	public function e($field_name, $extra_cache_ref = NULL) {
960 960
 		echo $this->get_pretty($field_name, $extra_cache_ref);
961 961
 	}
962 962
 	/**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @param string $field_name
966 966
 	 * @return void
967 967
 	 */
968
-	public function f($field_name){
969
-		$this->e($field_name,'form_input');
968
+	public function f($field_name) {
969
+		$this->e($field_name, 'form_input');
970 970
 	}
971 971
 
972 972
 	/**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
976 976
 	 * @return mixed
977 977
 	 */
978
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
979
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
978
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
979
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
980 980
 	}
981 981
 
982 982
 
@@ -993,37 +993,37 @@  discard block
 block discarded – undo
993 993
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
994 994
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
995 995
 	 */
996
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
996
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
997 997
 
998
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
998
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
999 999
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1000 1000
 
1001 1001
 		//validate field for datetime and returns field settings if valid.
1002
-		$field = $this->_get_dtt_field_settings( $field_name );
1002
+		$field = $this->_get_dtt_field_settings($field_name);
1003 1003
 
1004 1004
 		//clear cached property if either formats are not null.
1005
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1006
-			$this->_clear_cached_property( $field_name );
1005
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1006
+			$this->_clear_cached_property($field_name);
1007 1007
 			//reset format properties because they are used in get()
1008 1008
 			$this->_dt_frmt = $in_dt_frmt;
1009 1009
 			$this->_tm_frmt = $in_tm_frmt;
1010 1010
 		}
1011 1011
 
1012
-		if ( $echo )
1013
-			$field->set_pretty_date_format( $in_dt_frmt );
1012
+		if ($echo)
1013
+			$field->set_pretty_date_format($in_dt_frmt);
1014 1014
 		else
1015
-			$field->set_date_format( $in_dt_frmt );
1015
+			$field->set_date_format($in_dt_frmt);
1016 1016
 
1017
-		if ( $echo )
1018
-			$field->set_pretty_time_format( $in_tm_frmt );
1017
+		if ($echo)
1018
+			$field->set_pretty_time_format($in_tm_frmt);
1019 1019
 		else
1020
-			$field->set_time_format( $in_tm_frmt );
1020
+			$field->set_time_format($in_tm_frmt);
1021 1021
 
1022 1022
 		//set timezone in field object
1023
-		$field->set_timezone( $this->_timezone );
1023
+		$field->set_timezone($this->_timezone);
1024 1024
 
1025 1025
 		//set the output returned
1026
-		switch ( $date_or_time ) {
1026
+		switch ($date_or_time) {
1027 1027
 
1028 1028
 			case 'D' :
1029 1029
 				$field->set_date_time_output('date');
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
 		}
1039 1039
 
1040 1040
 
1041
-		if ( $echo ) {
1042
-			$this->e( $field_name, $date_or_time );
1041
+		if ($echo) {
1042
+			$this->e($field_name, $date_or_time);
1043 1043
 			return '';
1044 1044
 		 }
1045
-		return $this->get( $field_name, $date_or_time );
1045
+		return $this->get($field_name, $date_or_time);
1046 1046
 	}
1047 1047
 
1048 1048
 
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 	 * @param  string $format     format for the date returned (if NULL we use default in dt_frmt property)
1053 1053
 	 * @return string            datetime value formatted
1054 1054
 	 */
1055
-	public function get_date( $field_name, $format = NULL ) {
1056
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1055
+	public function get_date($field_name, $format = NULL) {
1056
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1057 1057
 	}
1058 1058
 
1059 1059
 
@@ -1062,8 +1062,8 @@  discard block
 block discarded – undo
1062 1062
 	 * @param      $field_name
1063 1063
 	 * @param null $format
1064 1064
 	 */
1065
-	public function e_date( $field_name, $format = NULL ) {
1066
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1065
+	public function e_date($field_name, $format = NULL) {
1066
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1067 1067
 	}
1068 1068
 
1069 1069
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @param  string $format     format for the time returned ( if NULL we use default in tm_frmt property)
1074 1074
 	 * @return string             datetime value formatted
1075 1075
 	 */
1076
-	public function get_time( $field_name, $format = NULL ) {
1077
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1076
+	public function get_time($field_name, $format = NULL) {
1077
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	 * @param      $field_name
1084 1084
 	 * @param null $format
1085 1085
 	 */
1086
-	public function e_time( $field_name, $format = NULL ) {
1087
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1086
+	public function e_time($field_name, $format = NULL) {
1087
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1088 1088
 	}
1089 1089
 
1090 1090
 
@@ -1097,8 +1097,8 @@  discard block
 block discarded – undo
1097 1097
 	 * @param  string $tm_frmt    format for the time returned (if NULL we use default in tm_frmt property)
1098 1098
 	 * @return string             datetime value formatted
1099 1099
 	 */
1100
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1101
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1100
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1101
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1102 1102
 	}
1103 1103
 
1104 1104
 
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
 	 * @param null $dt_frmt
1109 1109
 	 * @param null $tm_frmt
1110 1110
 	 */
1111
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1112
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1111
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1112
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
 	 * @return string Date and time string in set locale or false if no field exists for the given
1125 1125
 	 *                         field name.
1126 1126
 	 */
1127
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1128
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1129
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1130
-		return date_i18n( $format, EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) );
1127
+	public function get_i18n_datetime($field_name, $format = NULL) {
1128
+		EE_Registry::instance()->load_helper('DTT_Helper');
1129
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1130
+		return date_i18n($format, EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone));
1131 1131
 	}
1132 1132
 
1133 1133
 
@@ -1139,14 +1139,14 @@  discard block
 block discarded – undo
1139 1139
 	 * @throws EE_Error
1140 1140
 	 * @return EE_Datetime_Field
1141 1141
 	 */
1142
-	protected function _get_dtt_field_settings( $field_name ) {
1142
+	protected function _get_dtt_field_settings($field_name) {
1143 1143
 		$field = $this->get_model()->field_settings_for($field_name);
1144 1144
 
1145 1145
 		//check if field is dtt
1146
-		if ( $field instanceof EE_Datetime_Field ) {
1146
+		if ($field instanceof EE_Datetime_Field) {
1147 1147
 			return $field;
1148 1148
 		} else {
1149
-			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) ) ) );
1149
+			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))));
1150 1150
 		}
1151 1151
 	}
1152 1152
 
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
 	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1168 1168
 	 * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1169 1169
 	 */
1170
-	protected function _set_time_for( $time, $fieldname ) {
1171
-		$this->_set_date_time( 'T', $time, $fieldname );
1170
+	protected function _set_time_for($time, $fieldname) {
1171
+		$this->_set_date_time('T', $time, $fieldname);
1172 1172
 	}
1173 1173
 
1174 1174
 
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1183 1183
 	 * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1184 1184
 	 */
1185
-	protected function _set_date_for( $date, $fieldname ) {
1186
-		$this->_set_date_time( 'D', $date, $fieldname );
1185
+	protected function _set_date_for($date, $fieldname) {
1186
+		$this->_set_date_time('D', $date, $fieldname);
1187 1187
 	}
1188 1188
 
1189 1189
 
@@ -1199,21 +1199,21 @@  discard block
 block discarded – undo
1199 1199
 	 * @param string|DateTime $datetime_value A valid Date or Time string (or DateTime object)
1200 1200
 	 * @param string $fieldname     the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1201 1201
 	 */
1202
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1203
-		$field = $this->_get_dtt_field_settings( $fieldname );
1204
-		$field->set_timezone( $this->_timezone );
1205
-		$field->set_date_format( $this->_dt_frmt );
1206
-		$field->set_time_format( $this->_tm_frmt );
1202
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1203
+		$field = $this->_get_dtt_field_settings($fieldname);
1204
+		$field->set_timezone($this->_timezone);
1205
+		$field->set_date_format($this->_dt_frmt);
1206
+		$field->set_time_format($this->_tm_frmt);
1207 1207
 
1208
-		switch ( $what ) {
1208
+		switch ($what) {
1209 1209
 			case 'T' :
1210
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] );
1210
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]);
1211 1211
 				break;
1212 1212
 			case 'D' :
1213
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] );
1213
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]);
1214 1214
 				break;
1215 1215
 			case 'B' :
1216
-				$this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value );
1216
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1217 1217
 				break;
1218 1218
 		}
1219 1219
 
@@ -1236,25 +1236,25 @@  discard block
 block discarded – undo
1236 1236
 	 * @throws EE_Error
1237 1237
 	 * @return string timestamp
1238 1238
 	 */
1239
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1239
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1240 1240
 		EE_Registry::instance()->load_helper('DTT_Helper');
1241 1241
 		$timezone = EEH_DTT_Helper::get_timezone();
1242 1242
 
1243
-		if ( $timezone == $this->_timezone )
1243
+		if ($timezone == $this->_timezone)
1244 1244
 			return '';
1245 1245
 
1246 1246
 		$original_timezone = $this->_timezone;
1247
-		$this->set_timezone( $timezone );
1247
+		$this->set_timezone($timezone);
1248 1248
 
1249 1249
 		$fn = (array) $field_name;
1250
-		$args = array_merge( $fn, (array) $args );
1250
+		$args = array_merge($fn, (array) $args);
1251 1251
 
1252
-		if ( !method_exists( $this, $callback ) )
1253
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1252
+		if ( ! method_exists($this, $callback))
1253
+			throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback));
1254 1254
 		$args = (array) $args;
1255
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1255
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1256 1256
 
1257
-		$this->set_timezone( $original_timezone );
1257
+		$this->set_timezone($original_timezone);
1258 1258
 		return $return;
1259 1259
 	}
1260 1260
 
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 	 *
1269 1269
 	 * @return boolean | int
1270 1270
 	 */
1271
-	public function delete(){
1271
+	public function delete() {
1272 1272
 		/**
1273 1273
 		 * Called just before the `EE_Base_Class::_delete` method call.
1274 1274
 		 * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 		 *
1278 1278
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1279 1279
 		 */
1280
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1280
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1281 1281
 		$result = $this->_delete();
1282 1282
 		/**
1283 1283
 		 * Called just after the `EE_Base_Class::_delete` method call.
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1288 1288
 		 * @param boolean $result
1289 1289
 		 */
1290
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1290
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1291 1291
 		return $result;
1292 1292
 	}
1293 1293
 
@@ -1310,22 +1310,22 @@  discard block
 block discarded – undo
1310 1310
 	 * Deletes this model object permanently from db (but keep in mind related models my block the delete and return an error)
1311 1311
 	 * @return bool | int
1312 1312
 	 */
1313
-	public function delete_permanently(){
1313
+	public function delete_permanently() {
1314 1314
 		/**
1315 1315
 		 * Called just before HARD deleting a model object
1316 1316
 		 *
1317 1317
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1318 1318
 		 */
1319
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1320
-		$model=$this->get_model();
1321
-		$result=$model->delete_permanently_by_ID($this->ID());
1319
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1320
+		$model = $this->get_model();
1321
+		$result = $model->delete_permanently_by_ID($this->ID());
1322 1322
 		$this->refresh_cache_of_related_objects();
1323 1323
 		/**
1324 1324
 		 * Called just after HARD deleting a model object
1325 1325
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1326 1326
 		 * @param boolean $result
1327 1327
 		 */
1328
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1328
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1329 1329
 		return $result;
1330 1330
 	}
1331 1331
 
@@ -1334,18 +1334,18 @@  discard block
 block discarded – undo
1334 1334
          * related model objects
1335 1335
          */
1336 1336
         public function refresh_cache_of_related_objects() {
1337
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1338
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1339
-                    $related_objects = $this->_model_relations[ $relation_name ];
1340
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1337
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1338
+                if ( ! empty($this->_model_relations[$relation_name])) {
1339
+                    $related_objects = $this->_model_relations[$relation_name];
1340
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1341 1341
                         //this relation only stores a single model object, not an array
1342 1342
                         //but let's make it consistent
1343
-                        $related_objects = array( $related_objects );
1343
+                        $related_objects = array($related_objects);
1344 1344
                     }
1345
-                    foreach( $related_objects as $related_object ) {
1345
+                    foreach ($related_objects as $related_object) {
1346 1346
                         //only refresh their cache if they're in memory
1347
-                        if( $related_object instanceof EE_Base_Class ) {
1348
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1347
+                        if ($related_object instanceof EE_Base_Class) {
1348
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1349 1349
                         }
1350 1350
                     }
1351 1351
                 }
@@ -1365,17 +1365,17 @@  discard block
 block discarded – undo
1365 1365
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1366 1366
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1367 1367
 	 */
1368
-	public function save($set_cols_n_values=array()) {
1368
+	public function save($set_cols_n_values = array()) {
1369 1369
 		/**
1370 1370
 		 * Filters the fields we're about to save on the model object
1371 1371
 		 *
1372 1372
 		 * @param array $set_cols_n_values
1373 1373
 		 * @param EE_Base_Class $model_object
1374 1374
 		 */
1375
-		$set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1375
+		$set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1376 1376
 		//set attributes as provided in $set_cols_n_values
1377
-		foreach($set_cols_n_values as $column=>$value){
1378
-			$this->set($column,$value);
1377
+		foreach ($set_cols_n_values as $column=>$value) {
1378
+			$this->set($column, $value);
1379 1379
 		}
1380 1380
 		/**
1381 1381
 		 * Saving a model object.
@@ -1383,8 +1383,8 @@  discard block
 block discarded – undo
1383 1383
 		 * Before we perform a save, this action is fired.
1384 1384
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1385 1385
 		 */
1386
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1387
-		if( ! $this->allow_persist() ) {
1386
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1387
+		if ( ! $this->allow_persist()) {
1388 1388
 			return 0;
1389 1389
 		}
1390 1390
 		//now get current attribute values
@@ -1394,61 +1394,61 @@  discard block
 block discarded – undo
1394 1394
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1395 1395
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1396 1396
 		//does this model have an autoincrement PK?
1397
-		if($this->get_model()->has_primary_key_field()){
1398
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1397
+		if ($this->get_model()->has_primary_key_field()) {
1398
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1399 1399
 				//ok check if it's set, if so: update; if not, insert
1400
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1401
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1400
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1401
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1402 1402
 				} else {
1403
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1404
-					$results = $this->get_model()->insert( $save_cols_n_values, true);
1405
-					if($results){
1403
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1404
+					$results = $this->get_model()->insert($save_cols_n_values, true);
1405
+					if ($results) {
1406 1406
 						//if successful, set the primary key
1407 1407
 						//but don't use the normal SET method, because it will check if
1408 1408
 						//an item with the same ID exists in the mapper & db, then
1409 1409
 						//will find it in the db (because we just added it) and THAT object
1410 1410
 						//will get added to the mapper before we can add this one!
1411 1411
 						//but if we just avoid using the SET method, all that headache can be avoided
1412
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1412
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1413 1413
 						$this->_fields[$pk_field_name] = $results;
1414 1414
 						$this->_clear_cached_property($pk_field_name);
1415
-						$this->get_model()->add_to_entity_map( $this );
1415
+						$this->get_model()->add_to_entity_map($this);
1416 1416
 						$this->_update_cached_related_model_objs_fks();
1417 1417
 					}
1418 1418
 				}
1419
-			}else{//PK is NOT auto-increment
1419
+			} else {//PK is NOT auto-increment
1420 1420
 				//so check if one like it already exists in the db
1421
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1422
-					if( ! $this->in_entity_map() && WP_DEBUG ){
1421
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1422
+					if ( ! $this->in_entity_map() && WP_DEBUG) {
1423 1423
 						throw new EE_Error(
1424 1424
 							sprintf(
1425
-								__( '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' ),
1425
+								__('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'),
1426 1426
 								get_class($this),
1427
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1428
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1427
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1428
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1429 1429
 								'<br />'
1430 1430
 							)
1431 1431
 						);
1432 1432
 					}
1433 1433
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1434
-				}else{
1434
+				} else {
1435 1435
 					$results = $this->get_model()->insert($save_cols_n_values);
1436 1436
 					$this->_update_cached_related_model_objs_fks();
1437 1437
 				}
1438 1438
 			}
1439
-		}else{//there is NO primary key
1439
+		} else {//there is NO primary key
1440 1440
 			$already_in_db = false;
1441
-			foreach($this->get_model()->unique_indexes() as $index){
1441
+			foreach ($this->get_model()->unique_indexes() as $index) {
1442 1442
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1443
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1443
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1444 1444
 					$already_in_db = true;
1445 1445
 				}
1446 1446
 			}
1447
-			if( $already_in_db ){
1448
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1449
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1450
-			}else{
1451
-				$results = $this->get_model()->insert( $save_cols_n_values );
1447
+			if ($already_in_db) {
1448
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1449
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1450
+			} else {
1451
+				$results = $this->get_model()->insert($save_cols_n_values);
1452 1452
 			}
1453 1453
 		}
1454 1454
 		//restore the old assumption about values being prepared by the model object
@@ -1461,7 +1461,7 @@  discard block
 block discarded – undo
1461 1461
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1462 1462
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1463 1463
 		 */
1464
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1464
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1465 1465
 		return $results;
1466 1466
 	}
1467 1467
 
@@ -1473,13 +1473,13 @@  discard block
 block discarded – undo
1473 1473
 	 * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated)
1474 1474
 	 * @return void
1475 1475
 	 */
1476
-	protected function _update_cached_related_model_objs_fks(){
1477
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1478
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1479
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1480
-					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() );
1481
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1482
-					if( $related_model_obj_in_cache->ID() ){
1476
+	protected function _update_cached_related_model_objs_fks() {
1477
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1478
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1479
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1480
+					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name());
1481
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1482
+					if ($related_model_obj_in_cache->ID()) {
1483 1483
 						$related_model_obj_in_cache->save();
1484 1484
 					}
1485 1485
 				}
@@ -1495,21 +1495,21 @@  discard block
 block discarded – undo
1495 1495
 	 * and this object and properly setup
1496 1496
 	 * @return int ID of new model object on save; 0 on failure+
1497 1497
 	 */
1498
-	public function save_new_cached_related_model_objs(){
1498
+	public function save_new_cached_related_model_objs() {
1499 1499
 		//make sure this has been saved
1500
-		if( ! $this->ID()){
1500
+		if ( ! $this->ID()) {
1501 1501
 			$id = $this->save();
1502
-		}else{
1502
+		} else {
1503 1503
 			$id = $this->ID();
1504 1504
 		}
1505 1505
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1506
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1506
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1507 1507
 
1508 1508
 
1509
-			if($this->_model_relations[$relationName]){
1509
+			if ($this->_model_relations[$relationName]) {
1510 1510
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1511 1511
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1512
-				if($relationObj instanceof EE_Belongs_To_Relation){
1512
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1513 1513
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1514 1514
 					//but ONLY if it DOES NOT exist in the DB
1515 1515
 					/* @var $related_model_obj EE_Base_Class */
@@ -1518,8 +1518,8 @@  discard block
 block discarded – undo
1518 1518
 						$this->_add_relation_to($related_model_obj, $relationName);
1519 1519
 						$related_model_obj->save_new_cached_related_model_objs();
1520 1520
 //					}
1521
-				}else{
1522
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1521
+				} else {
1522
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1523 1523
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1524 1524
 						//but ONLY if it DOES NOT exist in the DB
1525 1525
 //						if( ! $related_model_obj->ID()){
@@ -1540,8 +1540,8 @@  discard block
 block discarded – undo
1540 1540
 	 * @return \EEM_Base | \EEM_CPT_Base
1541 1541
 	 */
1542 1542
 	public function get_model() {
1543
-		$modelName = self::_get_model_classname( get_class($this) );
1544
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1543
+		$modelName = self::_get_model_classname(get_class($this));
1544
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1545 1545
 	}
1546 1546
 
1547 1547
 
@@ -1551,10 +1551,10 @@  discard block
 block discarded – undo
1551 1551
 	 * @param $classname
1552 1552
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1553 1553
 	 */
1554
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1554
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1555 1555
 		//TODO: will not work for Term_Relationships because they have no PK!
1556
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1557
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1556
+		$primary_id_ref = self::_get_primary_key_name($classname);
1557
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1558 1558
 			$id = $props_n_values[$primary_id_ref];
1559 1559
 			return self::_get_model($classname)->get_from_entity_map($id);
1560 1560
 		}
@@ -1571,24 +1571,24 @@  discard block
 block discarded – undo
1571 1571
 	 * @param null    $timezone
1572 1572
 	 * @return mixed (EE_Base_Class|bool)
1573 1573
 	 */
1574
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) {
1575
-		if( self::_get_model( $classname )->has_primary_key_field()){
1576
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1574
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL) {
1575
+		if (self::_get_model($classname)->has_primary_key_field()) {
1576
+			$primary_id_ref = self::_get_primary_key_name($classname);
1577 1577
 
1578
-			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1579
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1580
-			}else{
1578
+			if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1579
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]);
1580
+			} else {
1581 1581
 				$existing = null;
1582 1582
 			}
1583
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1583
+		}elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1584 1584
 			//no primary key on this model, but there's still a matching item in the DB
1585
-				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1586
-		}else{
1585
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values));
1586
+		} else {
1587 1587
 			$existing = null;
1588 1588
 		}
1589
-		if ( $existing ) {
1590
-			foreach ( $props_n_values as $property => $field_value ) {
1591
-				$existing->set( $property, $field_value );
1589
+		if ($existing) {
1590
+			foreach ($props_n_values as $property => $field_value) {
1591
+				$existing->set($property, $field_value);
1592 1592
 			}
1593 1593
 			return $existing;
1594 1594
 		} else {
@@ -1606,13 +1606,13 @@  discard block
 block discarded – undo
1606 1606
 	 * @throws EE_Error
1607 1607
 	 * @return EEM_Base
1608 1608
 	 */
1609
-	protected static function  _get_model( $classname, $timezone = NULL ){
1609
+	protected static function  _get_model($classname, $timezone = NULL) {
1610 1610
 		//find model for this class
1611
-		if( ! $classname ){
1612
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname));
1611
+		if ( ! $classname) {
1612
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname));
1613 1613
 		}
1614
-		$modelName=self::_get_model_classname($classname);
1615
-		return self::_get_model_instance_with_name($modelName, $timezone );
1614
+		$modelName = self::_get_model_classname($classname);
1615
+		return self::_get_model_instance_with_name($modelName, $timezone);
1616 1616
 	}
1617 1617
 
1618 1618
 
@@ -1623,10 +1623,10 @@  discard block
 block discarded – undo
1623 1623
 	 * @param null   $timezone
1624 1624
 	 * @return EEM_Base
1625 1625
 	 */
1626
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1627
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1628
-		$model = EE_Registry::instance()->load_model( $model_classname );
1629
-		$model->set_timezone( $timezone );
1626
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1627
+		$model_classname = str_replace('EEM_', '', $model_classname);
1628
+		$model = EE_Registry::instance()->load_model($model_classname);
1629
+		$model->set_timezone($timezone);
1630 1630
 		return $model;
1631 1631
 	}
1632 1632
 
@@ -1638,10 +1638,10 @@  discard block
 block discarded – undo
1638 1638
 	 * @param null $model_name
1639 1639
 	 * @return string like EEM_Attendee
1640 1640
 	 */
1641
-	private static function _get_model_classname( $model_name = null){
1642
-		if(strpos($model_name,"EE_")===0){
1643
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1644
-		}else{
1641
+	private static function _get_model_classname($model_name = null) {
1642
+		if (strpos($model_name, "EE_") === 0) {
1643
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1644
+		} else {
1645 1645
 			$model_classname = "EEM_".$model_name;
1646 1646
 		}
1647 1647
 		return $model_classname;
@@ -1655,11 +1655,11 @@  discard block
 block discarded – undo
1655 1655
 	 * @throws EE_Error
1656 1656
 	 * @return string
1657 1657
 	 */
1658
-	protected static function _get_primary_key_name( $classname = NULL ){
1659
-		if( ! $classname){
1660
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname));
1658
+	protected static function _get_primary_key_name($classname = NULL) {
1659
+		if ( ! $classname) {
1660
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname));
1661 1661
 		}
1662
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1662
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1663 1663
 	}
1664 1664
 
1665 1665
 
@@ -1671,12 +1671,12 @@  discard block
 block discarded – undo
1671 1671
 	 * Usually defaults for integer primary keys are 0; string primary keys are usually NULL).
1672 1672
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1673 1673
 	 */
1674
-	public function ID(){
1674
+	public function ID() {
1675 1675
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1676
-		if( $this->get_model()->has_primary_key_field() ) {
1677
-			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1678
-		}else{
1679
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1676
+		if ($this->get_model()->has_primary_key_field()) {
1677
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1678
+		} else {
1679
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1680 1680
 		}
1681 1681
 	}
1682 1682
 
@@ -1694,38 +1694,38 @@  discard block
 block discarded – undo
1694 1694
 	 * @throws EE_Error
1695 1695
 	 * @return EE_Base_Class the object the relation was added to
1696 1696
 	 */
1697
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1697
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1698 1698
 		//if this thing exists in the DB, save the relation to the DB
1699
-		if( $this->ID() ){
1700
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1699
+		if ($this->ID()) {
1700
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1701 1701
 			//clear cache so future get_many_related and get_first_related() return new results.
1702
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1703
-                        if( $otherObject instanceof EE_Base_Class ) {
1704
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1702
+			$this->clear_cache($relationName, $otherObject, TRUE);
1703
+                        if ($otherObject instanceof EE_Base_Class) {
1704
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1705 1705
                         }
1706 1706
 		} else {
1707 1707
 			//this thing doesn't exist in the DB,  so just cache it
1708
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1709
-				throw new EE_Error( sprintf(
1710
-					__( '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' ),
1708
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1709
+				throw new EE_Error(sprintf(
1710
+					__('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'),
1711 1711
 					$otherObjectModelObjectOrID,
1712
-					get_class( $this )
1712
+					get_class($this)
1713 1713
 				));
1714 1714
 			} else {
1715 1715
 				$otherObject = $otherObjectModelObjectOrID;
1716 1716
 			}
1717
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1717
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1718 1718
 		}
1719
-                if( $otherObject instanceof EE_Base_Class ) {
1719
+                if ($otherObject instanceof EE_Base_Class) {
1720 1720
                     //fix the reciprocal relation too
1721
-                    if( $otherObject->ID() ) {
1721
+                    if ($otherObject->ID()) {
1722 1722
                             //its saved so assumed relations exist in the DB, so we can just
1723 1723
                             //clear the cache so future queries use the updated info in the DB
1724
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1724
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1725 1725
                     } else {
1726 1726
 
1727 1727
                             //it's not saved, so it caches relations like this
1728
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1728
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1729 1729
                     }
1730 1730
                 }
1731 1731
 		return $otherObject;
@@ -1748,17 +1748,17 @@  discard block
 block discarded – undo
1748 1748
 	 * 				Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table.
1749 1749
 	 * @return EE_Base_Class the relation was removed from
1750 1750
 	 */
1751
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1752
-		if ( $this->ID() ) {
1751
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1752
+		if ($this->ID()) {
1753 1753
 			//if this exists in the DB, save the relation change to the DB too
1754
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1755
-			$this->clear_cache( $relationName, $otherObject );
1754
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1755
+			$this->clear_cache($relationName, $otherObject);
1756 1756
 		} else {
1757 1757
 			//this doesn't exist in the DB, just remove it from the cache
1758
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1758
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1759 1759
 		}
1760
-                if( $otherObject instanceof EE_Base_Class ) {
1761
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1760
+                if ($otherObject instanceof EE_Base_Class) {
1761
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1762 1762
                 }
1763 1763
 		return $otherObject;
1764 1764
 	}
@@ -1769,18 +1769,18 @@  discard block
 block discarded – undo
1769 1769
 	 * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions)
1770 1770
 	 * @return EE_Base_Class
1771 1771
 	 */
1772
-	public function _remove_relations($relationName,$where_query_params = array()){
1773
-		if ( $this->ID() ) {
1772
+	public function _remove_relations($relationName, $where_query_params = array()) {
1773
+		if ($this->ID()) {
1774 1774
 			//if this exists in the DB, save the relation change to the DB too
1775
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1776
-			$this->clear_cache( $relationName, null, true );
1775
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1776
+			$this->clear_cache($relationName, null, true);
1777 1777
 		} else {
1778 1778
 			//this doesn't exist in the DB, just remove it from the cache
1779
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1779
+			$otherObjects = $this->clear_cache($relationName, null, true);
1780 1780
 		}
1781
-                if( is_array( $otherObjects ) ) {
1782
-                    foreach ( $otherObjects as $otherObject ) {
1783
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1781
+                if (is_array($otherObjects)) {
1782
+                    foreach ($otherObjects as $otherObject) {
1783
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1784 1784
                     }
1785 1785
                 }
1786 1786
 		return $otherObjects;
@@ -1798,26 +1798,26 @@  discard block
 block discarded – undo
1798 1798
 	 * @return EE_Base_Class[] Results not necessarily indexed by IDs, because some results might not have primary keys
1799 1799
 	 * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1800 1800
 	 */
1801
-	public function get_many_related($relationName,$query_params = array()){
1802
-		if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB
1801
+	public function get_many_related($relationName, $query_params = array()) {
1802
+		if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB
1803 1803
 			//if there are query parameters, forget about caching the related model objects.
1804
-			if( $query_params ){
1804
+			if ($query_params) {
1805 1805
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1806
-			}else{
1806
+			} else {
1807 1807
 				//did we already cache the result of this query?
1808 1808
 				$cached_results = $this->get_all_from_cache($relationName);
1809
-				if ( ! $cached_results ){
1809
+				if ( ! $cached_results) {
1810 1810
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1811 1811
 					//if no query parameters were passed, then we got all the related model objects
1812 1812
 					//for that relation. We can cache them then.
1813
-					foreach($related_model_objects as $related_model_object){
1813
+					foreach ($related_model_objects as $related_model_object) {
1814 1814
 						$this->cache($relationName, $related_model_object);
1815 1815
 					}
1816
-				}else{
1816
+				} else {
1817 1817
 					$related_model_objects = $cached_results;
1818 1818
 				}
1819 1819
 			}
1820
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1820
+		} else {//this doesn't exist itn eh DB, so just get the related things from the cache
1821 1821
 			$related_model_objects = $this->get_all_from_cache($relationName);
1822 1822
 		}
1823 1823
 		return $related_model_objects;
@@ -1834,8 +1834,8 @@  discard block
 block discarded – undo
1834 1834
 	 * @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;
1835 1835
 	 * @return int
1836 1836
 	 */
1837
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1838
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1837
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1838
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1839 1839
 	}
1840 1840
 
1841 1841
 
@@ -1849,7 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1850 1850
 	 * @return int
1851 1851
 	 */
1852
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1852
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1853 1853
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1854 1854
 	}
1855 1855
 
@@ -1861,34 +1861,34 @@  discard block
 block discarded – undo
1861 1861
 	 * @param array  $query_params  like EEM_Base::get_all
1862 1862
 	 * @return EE_Base_Class (not an array, a single object)
1863 1863
 	 */
1864
-	public function get_first_related($relationName,$query_params = array()){
1865
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
1864
+	public function get_first_related($relationName, $query_params = array()) {
1865
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
1866 1866
 
1867 1867
 			//if they've provided some query parameters, don't bother trying to cache the result
1868 1868
 			//also make sure we're not caching the result of get_first_related
1869 1869
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1870
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1871
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1872
-			}else{
1870
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1871
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1872
+			} else {
1873 1873
 				//first, check if we've already cached the result of this query
1874 1874
 				$cached_result = $this->get_one_from_cache($relationName);
1875
-				if ( ! $cached_result ){
1875
+				if ( ! $cached_result) {
1876 1876
 
1877 1877
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1878
-					$this->cache($relationName,$related_model_object);
1879
-				}else{
1878
+					$this->cache($relationName, $related_model_object);
1879
+				} else {
1880 1880
 					$related_model_object = $cached_result;
1881 1881
 				}
1882 1882
 			}
1883
-		}else{
1883
+		} else {
1884 1884
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1885
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1886
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1887
-			}else{
1885
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1886
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1887
+			} else {
1888 1888
 				$related_model_object = null;
1889 1889
 			}
1890 1890
 			//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
1891
-			if( ! $related_model_object){
1891
+			if ( ! $related_model_object) {
1892 1892
 				$related_model_object = $this->get_one_from_cache($relationName);
1893 1893
 			}
1894 1894
 
@@ -1907,12 +1907,12 @@  discard block
 block discarded – undo
1907 1907
 	 * @param array $query_params like EEM_Base::get_all's
1908 1908
 	 * @return int how many deleted
1909 1909
 	 */
1910
-	public function delete_related($relationName,$query_params = array()){
1911
-		if($this->ID()){
1912
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1913
-		}else{
1910
+	public function delete_related($relationName, $query_params = array()) {
1911
+		if ($this->ID()) {
1912
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
1913
+		} else {
1914 1914
 			$count = count($this->get_all_from_cache($relationName));
1915
-			$this->clear_cache($relationName,NULL,TRUE);
1915
+			$this->clear_cache($relationName, NULL, TRUE);
1916 1916
 		}
1917 1917
 		return $count;
1918 1918
 	}
@@ -1927,13 +1927,13 @@  discard block
 block discarded – undo
1927 1927
 	 * @param array $query_params like EEM_Base::get_all's
1928 1928
 	 * @return int how many deleted (including those soft deleted)
1929 1929
 	 */
1930
-	public function delete_related_permanently($relationName,$query_params = array()){
1931
-		if($this->ID()){
1932
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1933
-		}else{
1930
+	public function delete_related_permanently($relationName, $query_params = array()) {
1931
+		if ($this->ID()) {
1932
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1933
+		} else {
1934 1934
 			$count = count($this->get_all_from_cache($relationName));
1935 1935
 		}
1936
-		$this->clear_cache($relationName,NULL,TRUE);
1936
+		$this->clear_cache($relationName, NULL, TRUE);
1937 1937
 		return $count;
1938 1938
 	}
1939 1939
 
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
 	 * @param  string $field_name property to check
1950 1950
 	 * @return bool            				  TRUE if existing,FALSE if not.
1951 1951
 	 */
1952
-	public function is_set( $field_name ) {
1952
+	public function is_set($field_name) {
1953 1953
 		return isset($this->_fields[$field_name]);
1954 1954
 	}
1955 1955
 
@@ -1961,12 +1961,12 @@  discard block
 block discarded – undo
1961 1961
 	 * @throws EE_Error
1962 1962
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
1963 1963
 	 */
1964
-	protected function _property_exists( $properties ) {
1964
+	protected function _property_exists($properties) {
1965 1965
 
1966
-		foreach ( (array) $properties as $property_name ) {
1966
+		foreach ((array) $properties as $property_name) {
1967 1967
 			//first make sure this property exists
1968
-			if ( ! $this->_fields[ $property_name ] )
1969
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1968
+			if ( ! $this->_fields[$property_name])
1969
+				throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name));
1970 1970
 		}
1971 1971
 
1972 1972
 		return TRUE;
@@ -1983,7 +1983,7 @@  discard block
 block discarded – undo
1983 1983
 		$fields = $this->get_model()->field_settings(FALSE);
1984 1984
 		$properties = array();
1985 1985
 		//remove prepended underscore
1986
-		foreach ( $fields as $field_name => $settings ) {
1986
+		foreach ($fields as $field_name => $settings) {
1987 1987
 			$properties[$field_name] = $this->get($field_name);
1988 1988
 		}
1989 1989
 		return $properties;
@@ -2013,14 +2013,14 @@  discard block
 block discarded – undo
2013 2013
 	 * @throws EE_Error
2014 2014
 	 * @return mixed whatever the plugin which calls add_filter decides
2015 2015
 	 */
2016
-	public function __call($methodName,$args){
2017
-		$className=get_class($this);
2018
-		$tagName="FHEE__{$className}__{$methodName}";
2019
-		if(!has_filter($tagName)){
2020
-			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"),
2021
-										$methodName,$className,$tagName));
2016
+	public function __call($methodName, $args) {
2017
+		$className = get_class($this);
2018
+		$tagName = "FHEE__{$className}__{$methodName}";
2019
+		if ( ! has_filter($tagName)) {
2020
+			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"),
2021
+										$methodName, $className, $tagName));
2022 2022
 		}
2023
-		return apply_filters($tagName,null,$this,$args);
2023
+		return apply_filters($tagName, null, $this, $args);
2024 2024
 	}
2025 2025
 
2026 2026
 
@@ -2035,22 +2035,22 @@  discard block
 block discarded – undo
2035 2035
 	 * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row)
2036 2036
 	 * NOTE: if the values haven't changed, returns 0
2037 2037
 	 */
2038
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2039
-		$query_params  = array(array(
2038
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2039
+		$query_params = array(array(
2040 2040
 			'EXM_key'=>$meta_key,
2041 2041
 			'OBJ_ID'=>$this->ID(),
2042 2042
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
2043
-		if($previous_value !== NULL){
2043
+		if ($previous_value !== NULL) {
2044 2044
 			$query_params[0]['EXM_value'] = $meta_value;
2045 2045
 		}
2046 2046
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2047
-		if( ! $existing_rows_like_that){
2047
+		if ( ! $existing_rows_like_that) {
2048 2048
 			return $this->add_extra_meta($meta_key, $meta_value);
2049
-		}else{
2050
-			foreach( $existing_rows_like_that as $existing_row){
2051
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2049
+		} else {
2050
+			foreach ($existing_rows_like_that as $existing_row) {
2051
+				$existing_row->save(array('EXM_value' => $meta_value));
2052 2052
 			}
2053
-			return count( $existing_rows_like_that );
2053
+			return count($existing_rows_like_that);
2054 2054
 		}
2055 2055
 	}
2056 2056
 
@@ -2063,10 +2063,10 @@  discard block
 block discarded – undo
2063 2063
 	 * @param boolean $unique
2064 2064
 	 * @return boolean
2065 2065
 	 */
2066
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2067
-		if($unique){
2068
-			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this)))));
2069
-			if($existing_extra_meta){
2066
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2067
+		if ($unique) {
2068
+			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this)))));
2069
+			if ($existing_extra_meta) {
2070 2070
 				return false;
2071 2071
 			}
2072 2072
 		}
@@ -2086,12 +2086,12 @@  discard block
 block discarded – undo
2086 2086
 	 * @param string $meta_value
2087 2087
 	 * @return int number of extra meta rows deleted
2088 2088
 	 */
2089
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2090
-		$query_params  = array(array(
2089
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2090
+		$query_params = array(array(
2091 2091
 			'EXM_key'=>$meta_key,
2092 2092
 			'OBJ_ID'=>$this->ID(),
2093 2093
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
2094
-		if($meta_value !== NULL){
2094
+		if ($meta_value !== NULL) {
2095 2095
 			$query_params[0]['EXM_value'] = $meta_value;
2096 2096
 		}
2097 2097
 		$count_deleted = EEM_Extra_Meta::instance()->delete($query_params);
@@ -2107,25 +2107,25 @@  discard block
 block discarded – undo
2107 2107
 	 * @param mixed $default if we don't find anything, what should we return?
2108 2108
 	 * @return mixed single value if $single; array if ! $single
2109 2109
 	 */
2110
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2111
-		if($single){
2112
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2113
-			if ( $result instanceof EE_Extra_Meta ){
2110
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2111
+		if ($single) {
2112
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2113
+			if ($result instanceof EE_Extra_Meta) {
2114 2114
 				return $result->value();
2115
-			}else{
2115
+			} else {
2116 2116
 				return $default;
2117 2117
 			}
2118
-		}else{
2119
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2120
-			if($results){
2118
+		} else {
2119
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2120
+			if ($results) {
2121 2121
 				$values = array();
2122
-				foreach($results as $result){
2123
-					if ( $result instanceof EE_Extra_Meta ){
2122
+				foreach ($results as $result) {
2123
+					if ($result instanceof EE_Extra_Meta) {
2124 2124
 						$values[$result->ID()] = $result->value();
2125 2125
 					}
2126 2126
 				}
2127 2127
 				return $values;
2128
-			}else{
2128
+			} else {
2129 2129
 				return $default;
2130 2130
 			}
2131 2131
 		}
@@ -2142,20 +2142,20 @@  discard block
 block discarded – undo
2142 2142
 	 * @param boolean $one_of_each_key
2143 2143
 	 * @return array
2144 2144
 	 */
2145
-	public function all_extra_meta_array($one_of_each_key = true){
2145
+	public function all_extra_meta_array($one_of_each_key = true) {
2146 2146
 		$return_array = array();
2147
-		if($one_of_each_key){
2147
+		if ($one_of_each_key) {
2148 2148
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2149
-			foreach($extra_meta_objs as $extra_meta_obj){
2150
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2149
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2150
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2151 2151
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2152 2152
 				}
2153 2153
 			}
2154
-		}else{
2154
+		} else {
2155 2155
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2156
-			foreach($extra_meta_objs as $extra_meta_obj){
2157
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2158
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2156
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2157
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2158
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2159 2159
 						$return_array[$extra_meta_obj->key()] = array();
2160 2160
 					}
2161 2161
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2168,19 +2168,19 @@  discard block
 block discarded – undo
2168 2168
 	 * Gets a pretty nice displayable nice for this model object. Often overridden
2169 2169
 	 * @return string
2170 2170
 	 */
2171
-	public function name(){
2171
+	public function name() {
2172 2172
 		//find a field that's not a text field
2173 2173
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2174
-		if($field_we_can_use){
2174
+		if ($field_we_can_use) {
2175 2175
 			return $this->get($field_we_can_use->get_name());
2176
-		}else{
2176
+		} else {
2177 2177
 			$first_few_properties = $this->model_field_array();
2178
-			$first_few_properties = array_slice($first_few_properties,0,3);
2178
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2179 2179
 			$name_parts = array();
2180
-			foreach( $first_few_properties as $name=> $value ){
2180
+			foreach ($first_few_properties as $name=> $value) {
2181 2181
 				$name_parts[] = "$name:$value";
2182 2182
 			}
2183
-			return implode(",",$name_parts);
2183
+			return implode(",", $name_parts);
2184 2184
 		}
2185 2185
 	}
2186 2186
 
@@ -2189,11 +2189,11 @@  discard block
 block discarded – undo
2189 2189
 	 * Checks if this model object has been proven to already be in the entity map
2190 2190
 	 * @return boolean
2191 2191
 	 */
2192
-	public function in_entity_map(){
2193
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2192
+	public function in_entity_map() {
2193
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2194 2194
 			//well, if we looked, did we find it in the entity map?
2195 2195
 			return TRUE;
2196
-		}else{
2196
+		} else {
2197 2197
 			return FALSE;
2198 2198
 		}
2199 2199
 	}
@@ -2204,21 +2204,21 @@  discard block
 block discarded – undo
2204 2204
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2205 2205
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2206 2206
 	 */
2207
-	public function refresh_from_db(){
2208
-		if( $this->ID() && $this->in_entity_map() ){
2209
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2210
-		}else{
2207
+	public function refresh_from_db() {
2208
+		if ($this->ID() && $this->in_entity_map()) {
2209
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2210
+		} else {
2211 2211
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2212 2212
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2213 2213
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2214 2214
 			//absolutely nothing in it for this ID
2215
-			if( WP_DEBUG ) {
2215
+			if (WP_DEBUG) {
2216 2216
 				throw new EE_Error(
2217 2217
 					sprintf(
2218
-						__( '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' ),
2218
+						__('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'),
2219 2219
 						$this->ID(),
2220
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2221
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2220
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2221
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2222 2222
 					)
2223 2223
 				);
2224 2224
 			}
@@ -2230,8 +2230,8 @@  discard block
 block discarded – undo
2230 2230
 	 * (probably a bad assumption they have made, oh well)
2231 2231
 	 * @return string
2232 2232
 	 */
2233
-	public function __toString(){
2234
-		return sprintf( '%s (%s)', $this->name(), $this->ID() );
2233
+	public function __toString() {
2234
+		return sprintf('%s (%s)', $this->name(), $this->ID());
2235 2235
 	}
2236 2236
 
2237 2237
 	/**
@@ -2263,16 +2263,16 @@  discard block
 block discarded – undo
2263 2263
 	 * @return array
2264 2264
 	 */
2265 2265
 	public function __sleep() {
2266
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2267
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2268
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2269
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2270
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2271
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2266
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2267
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2268
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2269
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2270
+						$this->get_one_from_cache($relation_name)->ID()) {
2271
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2272 2272
 				}
2273 2273
 			}
2274 2274
 		}
2275
-		return array_keys( get_object_vars( $this ) );
2275
+		return array_keys(get_object_vars($this));
2276 2276
 	}
2277 2277
 
2278 2278
 
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -47,25 +47,25 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 	/**
50
-    *	date format
51
-	*
52
-    *	pattern or format for displaying dates
53
-	*
54
-	*	@access	protected
55
-    *	@var string
56
-    */
50
+	 *	date format
51
+	 *
52
+	 *	pattern or format for displaying dates
53
+	 *
54
+	 *	@access	protected
55
+	 *	@var string
56
+	 */
57 57
 	protected $_dt_frmt;
58 58
 
59 59
 
60 60
 
61
-    /**
62
-    *	time format
63
-	*
64
-    *	pattern or format for displaying time
65
-	*
66
-	*	@access	protected
67
-    *	@var string
68
-    */
61
+	/**
62
+	 *	time format
63
+	 *
64
+	 *	pattern or format for displaying time
65
+	 *
66
+	 *	@access	protected
67
+	 *	@var string
68
+	 */
69 69
 	protected $_tm_frmt;
70 70
 
71 71
 
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 
206 206
 
207 207
 		/**
208
-	 * Gets the field's original value when this object was constructed during this request.
209
-	 * This can be helpful when determining if a model object has changed or not
210
-	 *
211
-	 * @param string $field_name
212
-	 * @return mixed|null
213
-	 */
208
+		 * Gets the field's original value when this object was constructed during this request.
209
+		 * This can be helpful when determining if a model object has changed or not
210
+		 *
211
+		 * @param string $field_name
212
+		 * @return mixed|null
213
+		 */
214 214
 	public function get_original( $field_name ){
215 215
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216 216
 				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
@@ -1329,28 +1329,28 @@  discard block
 block discarded – undo
1329 1329
 		return $result;
1330 1330
 	}
1331 1331
 
1332
-        /**
1333
-         * When this model object is deleted, it may still be cached on related model objects. This clears the cache of
1334
-         * related model objects
1335
-         */
1336
-        public function refresh_cache_of_related_objects() {
1337
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1338
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1339
-                    $related_objects = $this->_model_relations[ $relation_name ];
1340
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1341
-                        //this relation only stores a single model object, not an array
1342
-                        //but let's make it consistent
1343
-                        $related_objects = array( $related_objects );
1344
-                    }
1345
-                    foreach( $related_objects as $related_object ) {
1346
-                        //only refresh their cache if they're in memory
1347
-                        if( $related_object instanceof EE_Base_Class ) {
1332
+		/**
1333
+		 * When this model object is deleted, it may still be cached on related model objects. This clears the cache of
1334
+		 * related model objects
1335
+		 */
1336
+		public function refresh_cache_of_related_objects() {
1337
+			foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1338
+				if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1339
+					$related_objects = $this->_model_relations[ $relation_name ];
1340
+					if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1341
+						//this relation only stores a single model object, not an array
1342
+						//but let's make it consistent
1343
+						$related_objects = array( $related_objects );
1344
+					}
1345
+					foreach( $related_objects as $related_object ) {
1346
+						//only refresh their cache if they're in memory
1347
+						if( $related_object instanceof EE_Base_Class ) {
1348 1348
 							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1349
-                        }
1350
-                    }
1351
-                }
1352
-            }
1353
-        }
1349
+						}
1350
+					}
1351
+				}
1352
+			}
1353
+		}
1354 1354
 
1355 1355
 
1356 1356
 
@@ -1713,9 +1713,9 @@  discard block
 block discarded – undo
1713 1713
 			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1714 1714
 			//clear cache so future get_many_related and get_first_related() return new results.
1715 1715
 			$this->clear_cache( $relationName, $otherObject, TRUE );
1716
-                        if( $otherObject instanceof EE_Base_Class ) {
1717
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1718
-                        }
1716
+						if( $otherObject instanceof EE_Base_Class ) {
1717
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1718
+						}
1719 1719
 		} else {
1720 1720
 			//this thing doesn't exist in the DB,  so just cache it
1721 1721
 			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
@@ -1729,18 +1729,18 @@  discard block
 block discarded – undo
1729 1729
 			}
1730 1730
 			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1731 1731
 		}
1732
-                if( $otherObject instanceof EE_Base_Class ) {
1733
-                    //fix the reciprocal relation too
1734
-                    if( $otherObject->ID() ) {
1735
-                            //its saved so assumed relations exist in the DB, so we can just
1736
-                            //clear the cache so future queries use the updated info in the DB
1737
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1738
-                    } else {
1739
-
1740
-                            //it's not saved, so it caches relations like this
1741
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1742
-                    }
1743
-                }
1732
+				if( $otherObject instanceof EE_Base_Class ) {
1733
+					//fix the reciprocal relation too
1734
+					if( $otherObject->ID() ) {
1735
+							//its saved so assumed relations exist in the DB, so we can just
1736
+							//clear the cache so future queries use the updated info in the DB
1737
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1738
+					} else {
1739
+
1740
+							//it's not saved, so it caches relations like this
1741
+							$otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1742
+					}
1743
+				}
1744 1744
 		return $otherObject;
1745 1745
 	}
1746 1746
 
@@ -1770,9 +1770,9 @@  discard block
 block discarded – undo
1770 1770
 			//this doesn't exist in the DB, just remove it from the cache
1771 1771
 			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1772 1772
 		}
1773
-                if( $otherObject instanceof EE_Base_Class ) {
1774
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1775
-                }
1773
+				if( $otherObject instanceof EE_Base_Class ) {
1774
+					$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1775
+				}
1776 1776
 		return $otherObject;
1777 1777
 	}
1778 1778
 
@@ -1791,11 +1791,11 @@  discard block
 block discarded – undo
1791 1791
 			//this doesn't exist in the DB, just remove it from the cache
1792 1792
 			$otherObjects = $this->clear_cache( $relationName, null, true );
1793 1793
 		}
1794
-                if( is_array( $otherObjects ) ) {
1795
-                    foreach ( $otherObjects as $otherObject ) {
1796
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1797
-                    }
1798
-                }
1794
+				if( is_array( $otherObjects ) ) {
1795
+					foreach ( $otherObjects as $otherObject ) {
1796
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1797
+					}
1798
+				}
1799 1799
 		return $otherObjects;
1800 1800
 	}
1801 1801
 
Please login to merge, or discard this patch.
core/db_models/EEM_CPT_Base.model.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_publish - the wp post status for published cpts
@@ -69,55 +69,55 @@  discard block
 block discarded – undo
69 69
 	 * @param string $timezone
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	protected function __construct( $timezone = NULL ){
72
+	protected function __construct($timezone = NULL) {
73 73
 
74 74
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
75 75
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
76 76
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
77 77
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
78 78
 		//must also be new EE_HABTM_Relation('Term_Relationship');
79
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
79
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
80 80
 		$primary_table_name = NULL;
81 81
 		//add  the common _status field to all CPT primary tables.
82
-		foreach ( $this->_tables as $alias => $table_obj ) {
83
-			if ( $table_obj instanceof EE_Primary_Table ) {
82
+		foreach ($this->_tables as $alias => $table_obj) {
83
+			if ($table_obj instanceof EE_Primary_Table) {
84 84
 				$primary_table_name = $alias;
85 85
 			}
86 86
 		}
87 87
 		//set default wp post statuses if child has not already set.
88
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
88
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
89 89
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
90 90
 		}
91
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
92
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
91
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
92
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
93 93
 		}
94
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
95
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
94
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
95
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
96 96
 		}
97 97
 
98
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
99
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
98
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
99
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
100 100
 		}
101 101
 
102
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
102
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
103 103
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
104 104
 		}
105 105
 
106
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
107
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
106
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
107
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
108 108
 		}
109
-		if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) {
109
+		if ( ! isset($this->_model_relations['Post_Meta'])) {
110 110
 			//don't block deletes though because we want to maintain the current behaviour
111
-			$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
111
+			$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
112 112
 		}
113
-		if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){
113
+		if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
114 114
 			//nothing was set during child constructor, so set default
115
-			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() );
115
+			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type());
116 116
 		}
117
-		if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) {
117
+		if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
118 118
 			//nothing was set during child constructor, so set default
119 119
 			//it's ok for child classes to specify this, but generally this is more DRY
120
-			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() );
120
+			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type());
121 121
 		}
122 122
 		parent::__construct($timezone);
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function public_event_stati() {
132 132
 		// @see wp-includes/post.php
133
-		return get_post_stati( array( 'public' => TRUE ));
133
+		return get_post_stati(array('public' => TRUE));
134 134
 	}
135 135
 
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return string
142 142
 	 * @throws EE_Error
143 143
 	 */
144
-	public function deleted_field_name(){
144
+	public function deleted_field_name() {
145 145
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
146 146
 	}
147 147
 
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 * @return string
153 153
 	 * @throws EE_Error
154 154
 	 */
155
-	public function post_status_field_name(){
155
+	public function post_status_field_name() {
156 156
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
157
-		if($field){
157
+		if ($field) {
158 158
 			return $field->get_name();
159
-		}else{
160
-			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
159
+		} else {
160
+			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
161 161
 		}
162 162
 	}
163 163
 
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param array $query_params like EEM_Base::get_all's $query_params
169 169
 	 * @return array like EEM_Base::get_all's $query_params
170 170
 	 */
171
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
172
-		$post_status_field_name=$this->post_status_field_name();
173
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
171
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
172
+		$post_status_field_name = $this->post_status_field_name();
173
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
174 174
 		return $query_params;
175 175
 	}
176 176
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array $query_params
182 182
 	 * @return array
183 183
 	 */
184
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
185
-		$query_params[ 'default_where_conditions' ] = 'minimum';
184
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
185
+		$query_params['default_where_conditions'] = 'minimum';
186 186
 		return $query_params;
187 187
 	}
188 188
 
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	 * @param array $query_params like EEM_Base::get_all
195 195
 	 * @return boolean success
196 196
 	 */
197
-	function delete_or_restore($delete=true,$query_params = array()){
198
-		$post_status_field_name=$this->post_status_field_name();
197
+	function delete_or_restore($delete = true, $query_params = array()) {
198
+		$post_status_field_name = $this->post_status_field_name();
199 199
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
200 200
 		$new_status = $delete ? self::post_status_trashed : 'draft';
201
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
201
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
202 202
 			return TRUE;
203 203
 		} else {
204 204
 			return FALSE;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function meta_table() {
217 217
 		$meta_table = $this->_get_other_tables();
218
-		$meta_table = reset( $meta_table );
218
+		$meta_table = reset($meta_table);
219 219
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
220 220
 	}
221 221
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
228 228
 	 * @return array
229 229
 	 */
230
-	public function get_meta_table_fields( $all = FALSE ) {
230
+	public function get_meta_table_fields($all = FALSE) {
231 231
 		$all_fields = $fields_to_return = array();
232
-		foreach ( $this->_tables as $alias => $table_obj ) {
233
-			if ( $table_obj instanceof EE_Secondary_Table )
234
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
232
+		foreach ($this->_tables as $alias => $table_obj) {
233
+			if ($table_obj instanceof EE_Secondary_Table)
234
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
235 235
 		}
236 236
 
237
-		if ( !$all ) {
238
-			foreach ( $all_fields as $name => $obj ) {
239
-				if ( $obj instanceof EE_DB_Only_Field_Base )
237
+		if ( ! $all) {
238
+			foreach ($all_fields as $name => $obj) {
239
+				if ($obj instanceof EE_DB_Only_Field_Base)
240 240
 					continue;
241 241
 				$fields_to_return[] = $name;
242 242
 			}
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 	 * @param int $parent_term_taxonomy_id
260 260
 	 * @return EE_Term_Taxonomy
261 261
 	 */
262
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
262
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
263 263
 		//create term
264
-		require_once( EE_MODELS . 'EEM_Term.model.php');
264
+		require_once(EE_MODELS.'EEM_Term.model.php');
265 265
 		//first, check for a term by the same name or slug
266 266
 		$category_slug = sanitize_title($category_name);
267
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
268
-		if( ! $term ){
267
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
268
+		if ( ! $term) {
269 269
 			$term = EE_Term::new_instance(array(
270 270
 				'name'=>$category_name,
271 271
 				'slug'=>$category_slug
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 			$term->save();
274 274
 		}
275 275
 		//make sure there's a term-taxonomy entry too
276
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
277
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
276
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
277
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
278 278
 		/** @var $term_taxonomy EE_Term_Taxonomy */
279
-		if( ! $term_taxonomy ){
279
+		if ( ! $term_taxonomy) {
280 280
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
281 281
 				'term_id'=>$term->ID(),
282 282
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				'parent'=>$parent_term_taxonomy_id
286 286
 			));
287 287
 			$term_taxonomy->save();
288
-		}else{
288
+		} else {
289 289
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
290 290
 			$term_taxonomy->save();
291 291
 		}
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 	 * @param string $category_name name of the event category (term)
301 301
 	 * @return bool
302 302
 	 */
303
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
303
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
304 304
 		//find the term_taxonomy by that name
305
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
305
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
306 306
 		/** @var $term_taxonomy EE_Term_Taxonomy */
307
-		if( $term_taxonomy ){
307
+		if ($term_taxonomy) {
308 308
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
309 309
 			$term_taxonomy->save();
310 310
 		}
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 * @param string|array $attr Optional. Query string or array of attributes.
325 325
 	 * @return string HTML image element
326 326
 	 */
327
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
328
-		return get_the_post_thumbnail( $id, $size, $attr );
327
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
328
+		return get_the_post_thumbnail($id, $size, $attr);
329 329
 	}
330 330
 
331 331
 
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
339 339
 	 * @return array
340 340
 	 */
341
-	public function get_post_statuses(){
341
+	public function get_post_statuses() {
342 342
 		global $wp_post_statuses;
343 343
 		$statuses = array();
344
-		foreach($wp_post_statuses as $post_status => $args_object){
344
+		foreach ($wp_post_statuses as $post_status => $args_object) {
345 345
 			$statuses[$post_status] = $args_object->label;
346 346
 		}
347 347
 		return $statuses;
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	public function get_status_array() {
357 357
 		$statuses = $this->get_post_statuses();
358 358
 		//first the global filter
359
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
359
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
360 360
 		//now the class specific filter
361
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
361
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
362 362
 		return $statuses;
363 363
 	}
364 364
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function get_custom_post_statuses() {
372 372
 		$new_stati = array();
373
-		foreach ( $this->_custom_stati as $status => $props ) {
373
+		foreach ($this->_custom_stati as $status => $props) {
374 374
 			$new_stati[$status] = $props['label'];
375 375
 		}
376 376
 		return $new_stati;
@@ -386,24 +386,24 @@  discard block
 block discarded – undo
386 386
 	 * @param WP_Post|array $post
387 387
 	 * @return EE_CPT_Base
388 388
 	 */
389
-	public function instantiate_class_from_post_object_orig($post){
390
-		$post = (array)$post;
389
+	public function instantiate_class_from_post_object_orig($post) {
390
+		$post = (array) $post;
391 391
 		$has_all_necessary_fields_for_table = true;
392 392
 		//check if the post has fields on the meta table already
393
-		foreach($this->_get_other_tables() as $table_obj){
393
+		foreach ($this->_get_other_tables() as $table_obj) {
394 394
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
395
-			foreach($fields_for_that_table as $field_obj){
396
-				if( ! isset($post[$field_obj->get_table_column()])
397
-					&& ! isset($post[$field_obj->get_qualified_column()])){
395
+			foreach ($fields_for_that_table as $field_obj) {
396
+				if ( ! isset($post[$field_obj->get_table_column()])
397
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
398 398
 					$has_all_necessary_fields_for_table = false;
399 399
 				}
400 400
 			}
401 401
 		}
402 402
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
403
-		if( ! $has_all_necessary_fields_for_table){
403
+		if ( ! $has_all_necessary_fields_for_table) {
404 404
 
405 405
 			return $this->get_one_by_ID($post['ID']);
406
-		}else{
406
+		} else {
407 407
 			return $this->instantiate_class_from_array_or_object($post);
408 408
 		}
409 409
 	}
@@ -414,30 +414,30 @@  discard block
 block discarded – undo
414 414
 	 * @param null $post
415 415
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
416 416
 	 */
417
-	public function instantiate_class_from_post_object( $post = NULL ){
418
-		if ( empty( $post )) {
417
+	public function instantiate_class_from_post_object($post = NULL) {
418
+		if (empty($post)) {
419 419
 			global $post;
420 420
 		}
421
-		$post = (array)$post;
421
+		$post = (array) $post;
422 422
 		$tables_needing_to_be_queried = array();
423 423
 		//check if the post has fields on the meta table already
424
-		foreach($this->get_tables() as $table_obj){
424
+		foreach ($this->get_tables() as $table_obj) {
425 425
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
426
-			foreach($fields_for_that_table as $field_obj){
427
-				if( ! isset($post[$field_obj->get_table_column()])
428
-					&& ! isset($post[$field_obj->get_qualified_column()])){
426
+			foreach ($fields_for_that_table as $field_obj) {
427
+				if ( ! isset($post[$field_obj->get_table_column()])
428
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
429 429
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
430 430
 				}
431 431
 			}
432 432
 		}
433 433
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
434
-		if( $tables_needing_to_be_queried){
435
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
434
+		if ($tables_needing_to_be_queried) {
435
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
436 436
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
437 437
 				$table_to_query = reset($tables_needing_to_be_queried);
438
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
439
-				if ( ! empty( $missing_data )) {
440
-					$post = array_merge( $post, $missing_data );
438
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
439
+				if ( ! empty($missing_data)) {
440
+					$post = array_merge($post, $missing_data);
441 441
 				}
442 442
 			} else {
443 443
 				return $this->get_one_by_ID($post['ID']);
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 	 * @throws EE_Error
455 455
 	 * @return string
456 456
 	 */
457
-	public function post_type(){
457
+	public function post_type() {
458 458
 		$post_type_field = NULL;
459
-		foreach($this->field_settings(true) as $field_obj){
460
-			if($field_obj instanceof EE_WP_Post_Type_Field){
461
-				$post_type_field = $field_obj;break;
459
+		foreach ($this->field_settings(true) as $field_obj) {
460
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
461
+				$post_type_field = $field_obj; break;
462 462
 			}
463 463
 		}
464
-		if($post_type_field == NULL){
465
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
464
+		if ($post_type_field == NULL) {
465
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
466 466
 		}
467 467
 		return $post_type_field->get_default_value();
468 468
 	}
Please login to merge, or discard this patch.
modules/core_rest_api/EED_Core_Rest_Api.module.php 2 patches
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @return EED_Core_Rest_Api
23 23
 	 */
24 24
 	public static function instance() {
25
-		return parent::get_instance( __CLASS__ );
25
+		return parent::get_instance(__CLASS__);
26 26
 	}
27 27
 
28 28
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
 	public static function set_hooks_both() {
55
-		add_action( 'rest_api_init', array( 'EED_Core_REST_API', 'register_routes' ) );
56
-		add_filter( 'rest_route_data', array( 'EED_Core_REST_API', 'hide_old_endpoints' ), 10, 2 );
57
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
55
+		add_action('rest_api_init', array('EED_Core_REST_API', 'register_routes'));
56
+		add_filter('rest_route_data', array('EED_Core_REST_API', 'hide_old_endpoints'), 10, 2);
57
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
58 58
 	}
59 59
 
60 60
 
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
64 64
 	 */
65 65
 	public static function register_routes() {
66
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
67
-			foreach( $relative_urls as $endpoint => $routes ) {
68
-				foreach( $routes as $route ) {
66
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
67
+			foreach ($relative_urls as $endpoint => $routes) {
68
+				foreach ($routes as $route) {
69 69
 					register_rest_route(
70 70
 						$namespace,
71 71
 						$endpoint,
72 72
 						array(
73
-							'callback' => $route[ 'callback' ],
74
-							'methods' => $route[ 'methods' ],
75
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
73
+							'callback' => $route['callback'],
74
+							'methods' => $route['methods'],
75
+							'args' => isset($route['args']) ? $route['args'] : array(),
76 76
 						)
77 77
 					);
78 78
 				}
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	 * }
90 90
 	 */
91 91
 	public static function get_ee_route_data() {
92
-		$ee_routes = get_option( self::saved_routes_option_names, null );
93
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
92
+		$ee_routes = get_option(self::saved_routes_option_names, null);
93
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
94 94
 			self::save_ee_routes();
95
-			$ee_routes = get_option( self::saved_routes_option_names, array() );
95
+			$ee_routes = get_option(self::saved_routes_option_names, array());
96 96
 		}
97 97
 		return $ee_routes;
98 98
 	}
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 * @return void
104 104
 	 */
105 105
 	public static function save_ee_routes() {
106
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
106
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
107 107
 			$instance = self::instance();
108 108
 			$routes = array_replace_recursive(
109 109
 				$instance->_register_config_routes(),
110 110
 				$instance->_register_meta_routes(),
111 111
 				$instance->_register_model_routes()
112 112
 			);
113
-			update_option( self::saved_routes_option_names, $routes, true );
113
+			update_option(self::saved_routes_option_names, $routes, true);
114 114
 		}
115 115
 	}
116 116
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return array @see get_ee_route_data
120 120
 	 */
121 121
 	protected function _register_model_routes() {
122
-		EE_Registry::instance()->load_helper( 'Inflector' );
122
+		EE_Registry::instance()->load_helper('Inflector');
123 123
 		$models_to_register = apply_filters(
124 124
 			'FHEE__EED_Core_REST_API___register_model_routes',
125 125
 			EE_Registry::instance()->non_abstract_db_models
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 		unset($models_to_register['Extra_Meta']);
129 129
 		unset($models_to_register['Extra_Join']);
130 130
 		$model_routes = array( );
131
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
131
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
132 132
 
133
-			foreach ( $models_to_register as $model_name => $model_classname ) {
133
+			foreach ($models_to_register as $model_name => $model_classname) {
134 134
 				//yes we could just register one route for ALL models, but then they wouldn't show up in the index
135
-				$ee_namespace = self::ee_api_namespace . $version;
136
-				$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
137
-				$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
138
-				$model_routes[ $ee_namespace ][ $plural_model_route ] = array(
135
+				$ee_namespace = self::ee_api_namespace.$version;
136
+				$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
137
+				$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
138
+				$model_routes[$ee_namespace][$plural_model_route] = array(
139 139
 						array(
140 140
 							'callback' => array(
141 141
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
142 142
 								'handle_request_get_all' ),
143 143
 							'methods' => WP_REST_Server::READABLE,
144 144
 							'hidden_endpoint' => $hidden_endpoint,
145
-							'args' => $this->_get_read_query_params( $model_name ),
145
+							'args' => $this->_get_read_query_params($model_name),
146 146
 							'_links' => array(
147
-								'self' => rest_url( $ee_namespace . $singular_model_route ),
147
+								'self' => rest_url($ee_namespace.$singular_model_route),
148 148
 							)
149 149
 						),
150 150
 //						array(
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 //							'hidden_endpoint' => $hidden_endpoint
156 156
 //						)
157 157
 					);
158
-				$model_routes[ $ee_namespace ][ $singular_model_route ] = array(
158
+				$model_routes[$ee_namespace][$singular_model_route] = array(
159 159
 						array(
160 160
 							'callback' => array(
161 161
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 								'include' => array(
167 167
 									'required' => false,
168 168
 									'default' => '*',
169
-									'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
169
+									'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
170 170
 								),
171 171
 							)
172 172
 						),
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
 //							),
180 180
 				);
181 181
 				//@todo: also handle  DELETE for a single item
182
-				$model = EE_Registry::instance()->load_model( $model_classname );
183
-				foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
182
+				$model = EE_Registry::instance()->load_model($model_classname);
183
+				foreach ($model->relation_settings() as $relation_name => $relation_obj) {
184 184
 					$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
185 185
 						$relation_name,
186 186
 						$relation_obj
187 187
 					);
188
-					$model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
188
+					$model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
189 189
 							array(
190 190
 								'callback' => array(
191 191
 									'EventEspresso\core\libraries\rest_api\controllers\model\Read',
192 192
 									'handle_request_get_related' ),
193 193
 								'methods' => WP_REST_Server::READABLE,
194 194
 								'hidden_endpoint' => $hidden_endpoint,
195
-								'args' => $this->_get_read_query_params( $relation_name ),
195
+								'args' => $this->_get_read_query_params($relation_name),
196 196
 							),
197 197
 //							array(
198 198
 //								'callback' => array(
@@ -215,47 +215,47 @@  discard block
 block discarded – undo
215 215
 	 * @param string $model_name eg 'Event' or 'Venue'
216 216
 	 * @return array describing the args acceptable when querying this model
217 217
 	 */
218
-	protected function _get_read_query_params( $model_name ) {
219
-		$model = EE_Registry::instance()->load_model( $model_name );
218
+	protected function _get_read_query_params($model_name) {
219
+		$model = EE_Registry::instance()->load_model($model_name);
220 220
 		$default_orderby = array();
221
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
222
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
221
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
222
+			$default_orderby[$key_field->get_name()] = 'ASC';
223 223
 		}
224 224
 		return array(
225 225
 			'where' => array(
226 226
 				'required' => false,
227 227
 				'default' => array(),
228
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ),
228
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'),
229 229
 				),
230 230
 			'limit' => array(
231 231
 				'required' => false,
232 232
 				'default' => 50,
233
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' )
233
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso')
234 234
 			),
235 235
 			'order_by' => array(
236 236
 				'required' => false,
237 237
 				'default' => $default_orderby,
238
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' )
238
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso')
239 239
 			),
240 240
 			'group_by' => array(
241 241
 				'required' => false,
242 242
 				'default' => null,
243
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' )
243
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso')
244 244
 			),
245 245
 			'having' => array(
246 246
 				'required' => false,
247 247
 				'default' => null,
248
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' )
248
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso')
249 249
 			),
250 250
 			'caps' => array(
251 251
 				'required' => false,
252 252
 				'default' => EEM_Base::caps_read,
253
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' )
253
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso')
254 254
 			),
255 255
 			'include' => array(
256 256
 				'required' => false,
257 257
 				'default' => '*',
258
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
258
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
259 259
 			),
260 260
 		);
261 261
 	}
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	protected function _register_config_routes() {
268 268
 		$config_routes = array();
269
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
270
-			$config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array(
269
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
270
+			$config_routes[self::ee_api_namespace.$version]['config'] = array(
271 271
 					array(
272 272
 						'callback' => array(
273 273
 							'EventEspresso\core\libraries\rest_api\controllers\config\Read',
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	protected function _register_meta_routes() {
288 288
 		$meta_routes = array();
289
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
290
-			$meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array(
289
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
290
+			$meta_routes[self::ee_api_namespace.$version]['/resources'] = array(
291 291
 				array(
292 292
 					'callback' => array(
293 293
 						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 	 * @param array $route_data
309 309
 	 * @return array
310 310
 	 */
311
-	public function hide_old_endpoints( $route_data ) {
312
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
313
-			foreach( $relative_urls as $endpoint => $routes ) {
314
-				foreach( $routes as $route ) {
315
-					if( $route[ 'hidden_endpoint' ] ) {
316
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
317
-						unset( $route_data[ $full_route ] );
311
+	public function hide_old_endpoints($route_data) {
312
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
313
+			foreach ($relative_urls as $endpoint => $routes) {
314
+				foreach ($routes as $route) {
315
+					if ($route['hidden_endpoint']) {
316
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
317
+						unset($route_data[$full_route]);
318 318
 					}
319 319
 				}
320 320
 			}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @return array
335 335
 	 */
336 336
 	public static function version_compatibilities() {
337
-		return apply_filters( 'FHEE__EED_Core_REST_API__version_compatibilities', array( '4.8.29' => '4.8.29' ) );
337
+		return apply_filters('FHEE__EED_Core_REST_API__version_compatibilities', array('4.8.29' => '4.8.29'));
338 338
 	}
339 339
 
340 340
 	/**
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 	public static function versions_served() {
349 349
 		$version_compatibilities = EED_Core_Rest_Api::version_compatibilities();
350 350
 		$versions_served = array();
351
-		$lowest_compatible_version = $version_compatibilities[ EED_Core_Rest_Api::core_version() ];
351
+		$lowest_compatible_version = $version_compatibilities[EED_Core_Rest_Api::core_version()];
352 352
 		//for each version of core we have ever served:
353
-		foreach( array_keys( EED_Core_Rest_Api::version_compatibilities() ) as $possibly_served_version ) {
353
+		foreach (array_keys(EED_Core_Rest_Api::version_compatibilities()) as $possibly_served_version) {
354 354
 			//if it's not above the current core version, and it's compatible with the current version of core
355
-			if(
355
+			if (
356 356
 				$possibly_served_version < EED_Core_Rest_Api::core_version()
357 357
 				&& $possibly_served_version >= $lowest_compatible_version
358 358
 			) {
359
-				$versions_served[ $possibly_served_version ] = true;
360
-			}else {
361
-				$versions_served[ $possibly_served_version ] = false;
359
+				$versions_served[$possibly_served_version] = true;
360
+			} else {
361
+				$versions_served[$possibly_served_version] = false;
362 362
 			}
363 363
 		}
364 364
 		return $versions_served;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @return string
372 372
 	 */
373 373
 	public static function core_version() {
374
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
374
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
375 375
 	}
376 376
 
377 377
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param  WP $WP
384 384
 	 * @return    void
385 385
 	 */
386
-	public function run( $WP ) {
386
+	public function run($WP) {
387 387
 
388 388
 	}
389 389
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -357,7 +357,7 @@
 block discarded – undo
357 357
 				&& $possibly_served_version >= $lowest_compatible_version
358 358
 			) {
359 359
 				$versions_served[ $possibly_served_version ] = true;
360
-			}else {
360
+			} else {
361 361
 				$versions_served[ $possibly_served_version ] = false;
362 362
 			}
363 363
 		}
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket.model.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Ticket.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Ticket.class.php');
26 26
 
27 27
 class EEM_Ticket extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 	 *		@access private
36 36
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
37 37
 	 */
38
-	protected function __construct( $timezone ) {
39
-		$this->singular_item = __('Ticket','event_espresso');
40
-		$this->plural_item = __('Tickets','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Ticket', 'event_espresso');
40
+		$this->plural_item = __('Tickets', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Ticket'=>array(
47
-				'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')),
48
-				'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'),
47
+				'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')),
48
+				'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'),
49 49
 				'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''),
50
-				'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ),
51
-				'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ),
52
-				'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ),
53
-				'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ),
54
-				'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ),
50
+				'TKT_description'=>new EE_Full_HTML_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''),
51
+				'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone),
52
+				'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone),
53
+				'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0),
54
+				'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF),
55 55
 				'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0),
56 56
 				'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0),
57
-				'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF),
58
-				'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ),
59
-				'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ),
60
-				'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false),
61
-				'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ),
57
+				'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF),
58
+				'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF),
59
+				'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false),
60
+				'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false),
61
+				'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false),
62 62
 				'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0),
63
-				'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ),
63
+				'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0),
64 64
 				'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false),
65
-				'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ),
66
-				'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 )
65
+				'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE),
66
+				'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0)
67 67
 			));
68 68
 		$this->_model_relations = array(
69 69
 			'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 		);
76 76
 
77 77
 		//this model is generally available for reading
78
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event');
78
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event');
79 79
 		//account for default tickets in the caps
80
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
81
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
82
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' );
83
-		parent::__construct( $timezone );
80
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
81
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
82
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event');
83
+		parent::__construct($timezone);
84 84
 	}
85 85
 
86 86
 
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function get_all_default_tickets() {
93 93
 		/** @type EE_Ticket[] $tickets */
94
-		$tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) );
94
+		$tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')));
95 95
 		//we need to set the start date and end date to today's date and the start of the default dtt
96
-		return $this->_set_default_dates( $tickets );
96
+		return $this->_set_default_dates($tickets);
97 97
 	}
98 98
 
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @param EE_Ticket[] $tickets
104 104
 	 * @return EE_Ticket[]
105 105
 	 */
106
-	private function _set_default_dates( $tickets ) {
107
-		foreach ( $tickets as $ticket ) {
108
-			$ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) );
109
-			$ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) );
110
-			$ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) );
106
+	private function _set_default_dates($tickets) {
107
+		foreach ($tickets as $ticket) {
108
+			$ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true));
109
+			$ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30));
110
+			$ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone));
111 111
 		}
112 112
 
113 113
 		return $tickets;
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param array $query_params
123 123
 	 * @return int
124 124
 	 */
125
-	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){
126
-		return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params );
125
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
126
+		return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params);
127 127
 	}
128 128
 
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @param EE_Ticket[] $tickets
134 134
 	 * @return void
135 135
 	 */
136
-	public function update_tickets_sold($tickets){
137
-		foreach($tickets as $ticket){
136
+	public function update_tickets_sold($tickets) {
137
+		foreach ($tickets as $ticket) {
138 138
 			/* @var  $ticket EE_Ticket */
139 139
 			$ticket->update_tickets_sold();
140 140
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
modules/gateways/Invoice/lib/templates/receipt_body.template.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -36,53 +36,53 @@  discard block
 block discarded – undo
36 36
 						<h2 id="invoice-hdr"><?php _e('Order Confirmation', 'event_espresso')?></h2>
37 37
 						<h3 id="invoice-date"><?php _e('Date:', 'event_espresso')?> <span class="plain-text">[registration_date]</span></h3>
38 38
 						<h3 id="invoice-txn-id"><?php _e('Transaction ID:', 'event_espresso')?> <span class="plain-text">[transaction_id]</span></h3>
39
-						<h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso')?> <span class="<?php echo $transaction->status_ID()?> plain-text"><?php echo $transaction->pretty_status();?></span></h3>
39
+						<h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso')?> <span class="<?php echo $transaction->status_ID()?> plain-text"><?php echo $transaction->pretty_status(); ?></span></h3>
40 40
 					</div>
41 41
 				</td>
42 42
 			</tr>
43 43
 		</table>
44 44
 		<div class="events">
45
-		<?php foreach($events_for_txn as $event_id => $event){
46
-			?><h3 class="section-title event-name"><img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png';?>"><?php _e("Event Name:","event_espresso")?> <span class="plain-text"><?php echo $event->name();?></span> <span class="small-text link">[ <a href='<?php echo $event->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></h3>
47
-			<?php if (strlen($event->description()>1)){?><p class="event-description"><?php $event->description()?></p><?php }?>
45
+		<?php foreach ($events_for_txn as $event_id => $event) {
46
+			?><h3 class="section-title event-name"><img class="icon" src="<?php echo EE_IMAGES_URL.'calendar_year-24x24.png'; ?>"><?php _e("Event Name:", "event_espresso")?> <span class="plain-text"><?php echo $event->name(); ?></span> <span class="small-text link">[ <a href='<?php echo $event->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></h3>
47
+			<?php if (strlen($event->description() > 1)) {?><p class="event-description"><?php $event->description()?></p><?php }?>
48 48
 			<ul class="tickets-per-event">
49
-			<?php foreach($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item){
49
+			<?php foreach ($ticket_line_items_per_event[$event_id] as $line_item_id => $line_item) {
50 50
 				$ticket = $line_item->ticket();
51
-				$taxable_html = $ticket->taxable() ? '*': '';
51
+				$taxable_html = $ticket->taxable() ? '*' : '';
52 52
 				$subitems = $line_item->children();
53
-				$ticket_uses = $ticket->get_pretty('TKT_uses',  __("any", "event_espresso"));
53
+				$ticket_uses = $ticket->get_pretty('TKT_uses', __("any", "event_espresso"));
54 54
 			?>
55 55
 				<li class="event-ticket">
56 56
 					<div class="ticket-details">
57 57
 						<table class="invoice-amount">
58 58
 							<thead>
59 59
 								<tr class="header_row">
60
-									<th class="name-column"><?php _e("Ticket", "event_espresso");?></th>
61
-									<th colspan="2" class="desc-column"><?php _e("Description", "event_espresso");?></th>
62
-									<th class="number-column item_c"><?php _e("Quantity", "event_espresso");?></th>
63
-									<th class="number-column item_c"><?php _e("Price", "event_espresso");?></th>
64
-									<th class="number-column item_r"><?php _e("Total", "event_espresso");?></th>
60
+									<th class="name-column"><?php _e("Ticket", "event_espresso"); ?></th>
61
+									<th colspan="2" class="desc-column"><?php _e("Description", "event_espresso"); ?></th>
62
+									<th class="number-column item_c"><?php _e("Quantity", "event_espresso"); ?></th>
63
+									<th class="number-column item_c"><?php _e("Price", "event_espresso"); ?></th>
64
+									<th class="number-column item_r"><?php _e("Total", "event_espresso"); ?></th>
65 65
 								</tr>
66 66
 							</thead>
67 67
 							<tbody>
68
-								<?php if( count($subitems) < 2){?>
68
+								<?php if (count($subitems) < 2) {?>
69 69
 								<tr class="item">
70 70
 									<td><?php echo $line_item->name().$taxable_html?></td>
71
-									<td colspan="2"><?php echo $line_item->desc();?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td>
71
+									<td colspan="2"><?php echo $line_item->desc(); ?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td>
72 72
 									<td class="item_c"><?php echo $line_item->quantity()?></td>
73 73
 									<td class="item_c"><?php echo $line_item->unit_price_no_code()?></td>
74 74
 									<td class="item_r"><?php echo $line_item->total_no_code()?></td>
75 75
 								</tr>
76
-								<?php }else{?>
76
+								<?php } else {?>
77 77
 									<tr class="item">
78 78
 										<td class="aln-left"><?php echo $line_item->name().$taxable_html?></td>
79
-										<td colspan="2"><?php echo $line_item->desc();?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td>
79
+										<td colspan="2"><?php echo $line_item->desc(); ?><p class="ticket-note"><?php echo sprintf(__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), $ticket_uses); ?></p></td>
80 80
 										<td class="item_c"><?php echo $line_item->quantity()?></td>
81 81
 										<td class="item_c"><?php echo $line_item->unit_price_no_code()?></td>
82 82
 										<td class="item_r"><?php echo $line_item->total_no_code()?></td>
83 83
 									</tr>
84
-									<?php foreach($subitems as $sub_line_item){
85
-										$is_percent = $sub_line_item->is_percent();?>
84
+									<?php foreach ($subitems as $sub_line_item) {
85
+										$is_percent = $sub_line_item->is_percent(); ?>
86 86
 										<tr class="subitem-row">
87 87
 											<td class="subitem"><?php echo $sub_line_item->name()?></td>
88 88
 											<td colspan="2"><?php echo $sub_line_item->desc()?></td>
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 									<?php } ?>
94 94
 									<tr class="total_tr odd">
95 95
 										<td colspan="4"></td>
96
-										<td class="total" nowrap="nowrap"><?php _e("Ticket Total:", "event_espresso");?></td>
96
+										<td class="total" nowrap="nowrap"><?php _e("Ticket Total:", "event_espresso"); ?></td>
97 97
 										<td class="item_r"><?php echo $line_item->total_no_code()?></td>
98 98
 									</tr>
99 99
 								<?php }?>
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 					<div class="reg-details-for-ticket">
105 105
 						<div class="ticket-time-and-place-details">
106 106
 							<div class="ticket-time-details">
107
-								<h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'clock-16x16.png';?>"><?php echo _n("Date/Time:","Dates/Times:",count($ticket->datetimes()), "event_espresso");?></h4>
107
+								<h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'clock-16x16.png'; ?>"><?php echo _n("Date/Time:", "Dates/Times:", count($ticket->datetimes()), "event_espresso"); ?></h4>
108 108
 								<ul class="event-dates">
109
-									<?php foreach($ticket->datetimes_ordered() as $datetime){
109
+									<?php foreach ($ticket->datetimes_ordered() as $datetime) {
110 110
 										/* @var $datetime EE_Datetime */ ?>
111 111
 									<li><?php
112
-										echo $datetime->name() ? '<b>'.$datetime->name().' </b>' : '' ;
113
-										echo sprintf(__("%s - %s (%s)", "event_espresso"),$datetime->start_date_and_time(),$datetime->end_date_and_time(),$datetime->get_timezone());
112
+										echo $datetime->name() ? '<b>'.$datetime->name().' </b>' : '';
113
+										echo sprintf(__("%s - %s (%s)", "event_espresso"), $datetime->start_date_and_time(), $datetime->end_date_and_time(), $datetime->get_timezone());
114 114
 										echo $datetime->description() ? '<p class="ticket-note">'.$datetime->description().'</p>' : '' ?></li>
115 115
 									<?php }?>
116 116
 								</ul>
117 117
 							</div>
118
-							<?php if ($event->venues()){?>
118
+							<?php if ($event->venues()) {?>
119 119
 							<div class="ticket-place-details">
120
-								<h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'location-pin-16x16.png';?>"><?php echo _n("Venue:","Venues:",count($event->venues()), "event_espresso");?></h4>
120
+								<h4 class="sub-section-title no-bottom-margin"><img class="icon" src="<?php echo EE_IMAGES_URL.'location-pin-16x16.png'; ?>"><?php echo _n("Venue:", "Venues:", count($event->venues()), "event_espresso"); ?></h4>
121 121
 								<ul class="event-venues">
122
-									<?php foreach($event->venues() as $venue){?>
122
+									<?php foreach ($event->venues() as $venue) {?>
123 123
 									<li><?php echo $venue->name()?> <span class="small-text">[ <a href='<?php echo $venue->get_permalink()?>'><?php _e('view', 'event_espresso'); ?></a> ]</span></li>
124 124
 									<?php } ?>
125 125
 								</ul>
@@ -127,34 +127,34 @@  discard block
 block discarded – undo
127 127
 							<?php }?>
128 128
 						</div>
129 129
 						<div class="ticket-registrations-area">
130
-							<h4 class="sub-section-title"><img class="icon" src="<?php echo EE_IMAGES_URL.'users-16x16.png';?>"><?php echo __("Registration Details", "event_espresso");?> <span class="small-text link">[ <a class="print_button noPrint" href="<?php echo $edit_reg_info_url; ?>"><?php _e('edit', 'event_espresso'); ?></a> ]</span></h4>
130
+							<h4 class="sub-section-title"><img class="icon" src="<?php echo EE_IMAGES_URL.'users-16x16.png'; ?>"><?php echo __("Registration Details", "event_espresso"); ?> <span class="small-text link">[ <a class="print_button noPrint" href="<?php echo $edit_reg_info_url; ?>"><?php _e('edit', 'event_espresso'); ?></a> ]</span></h4>
131 131
 							<ul class="ticket-registrations-list">
132
-								<?php foreach($registrations_per_line_item[$line_item_id] as $registration){
132
+								<?php foreach ($registrations_per_line_item[$line_item_id] as $registration) {
133 133
 									/* @var $registration EE_Registration */
134 134
 									$attendee = $registration->attendee();
135
-									$answers = $registration->answers(array('order_by'=>array('Question.Question_Group_Question.QGQ_order'=>'ASC')));?>
135
+									$answers = $registration->answers(array('order_by'=>array('Question.Question_Group_Question.QGQ_order'=>'ASC'))); ?>
136 136
 								<li class="ticket-registration">
137 137
 									<table class="registration-details">
138 138
 										<tr class="odd">
139
-											<th><?php echo 	_e("Registration Code:", "event_espresso");?></th>
140
-											<td><?php echo $registration->reg_code();?> - <span class="<?php echo $registration->status_ID()?>"><?php echo $registration->pretty_status()?></span></td>
139
+											<th><?php echo 	_e("Registration Code:", "event_espresso"); ?></th>
140
+											<td><?php echo $registration->reg_code(); ?> - <span class="<?php echo $registration->status_ID()?>"><?php echo $registration->pretty_status()?></span></td>
141 141
 										</tr>
142 142
 										<?php
143
-										foreach($event->question_groups() as $question_group){
144
-											?><tr><th><?php $question_group->e('QSG_name');?></th><td></td></tr><?php
143
+										foreach ($event->question_groups() as $question_group) {
144
+											?><tr><th><?php $question_group->e('QSG_name'); ?></th><td></td></tr><?php
145 145
 											$has_personal_info = false;
146
-											foreach($question_group->questions() as $question){
147
-												if( in_array($question->system_ID(),$questions_to_skip)){
146
+											foreach ($question_group->questions() as $question) {
147
+												if (in_array($question->system_ID(), $questions_to_skip)) {
148 148
 													$has_personal_info = true;
149 149
 													continue;
150 150
 												}
151 151
 												?><tr>
152 152
 														<th><?php echo $question->display_text()?></th>
153
-														<td><?php echo $registration->answer_value_to_question($question);?></td>
153
+														<td><?php echo $registration->answer_value_to_question($question); ?></td>
154 154
 												</tr><?php
155 155
 											}
156
-											if($has_personal_info){
157
-												?><tr><th><?php	_e('Attendee', 'event_espresso');?></th><td><?php echo sprintf(__('%s (%s)', "event_espresso"),$attendee->full_name(),$attendee->email())?></td></tr><?php
156
+											if ($has_personal_info) {
157
+												?><tr><th><?php	_e('Attendee', 'event_espresso'); ?></th><td><?php echo sprintf(__('%s (%s)', "event_espresso"), $attendee->full_name(), $attendee->email())?></td></tr><?php
158 158
 											}
159 159
 										}
160 160
 										?>
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 		<?php }?>
172 172
 		</div>
173 173
 		<div class="taxes">
174
-			<?php if ($tax_total_line_item && $tax_total_line_item->children()){?>
175
-				<h3 class="section-title"><?php _e("Taxes",'event_espresso')?></h3>
174
+			<?php if ($tax_total_line_item && $tax_total_line_item->children()) {?>
175
+				<h3 class="section-title"><?php _e("Taxes", 'event_espresso')?></h3>
176 176
 				<table class="invoice-amount">
177 177
 
178 178
 					<thead>
179 179
 						<tr class="header_row">
180
-							<th class="left ticket_th"><?php _e("Tax Name", "event_espresso");?></th>
181
-							<th class="left"><?php _e('Description', 'event_espresso');?></th>
180
+							<th class="left ticket_th"><?php _e("Tax Name", "event_espresso"); ?></th>
181
+							<th class="left"><?php _e('Description', 'event_espresso'); ?></th>
182 182
 							<th class="event_th item_c"><?php _e('Rate', 'event_espresso'); ?></th>
183 183
 							<th class="subtotal_th"><?php _e('Tax Amount', 'event_espresso'); ?></th>
184 184
 						</tr>
185 185
 					</thead>
186 186
 					<tbody>
187 187
 						<?php
188
-						foreach($tax_total_line_item->children() as $child_tax){?>
188
+						foreach ($tax_total_line_item->children() as $child_tax) {?>
189 189
 						<tr>
190 190
 							<td><?php echo $child_tax->name()?></td>
191 191
 							<td><?php echo $child_tax->desc()?></td>
@@ -195,26 +195,26 @@  discard block
 block discarded – undo
195 195
 						<?php } ?>
196 196
 						<tr class="total_tr odd">
197 197
 							<td class="total_tr" colspan="2"></td>
198
-							<td class="total"><?php	_e("Tax Total:", "event_espresso");?></td>
198
+							<td class="total"><?php	_e("Tax Total:", "event_espresso"); ?></td>
199 199
 							<td class="item_r"><?php echo $tax_total_line_item->total_no_code()?></td>
200 200
 						</tr>
201 201
 					</tbody>
202 202
 
203 203
 				</table>
204 204
 			<?php }?>
205
-			<p><?php _e("* taxable items", "event_espresso");?></p>
205
+			<p><?php _e("* taxable items", "event_espresso"); ?></p>
206 206
 		</div>
207 207
 		<div class="grand-total-dv">
208
-		<h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"),EEH_Template::format_currency($total_cost));?></h2>
208
+		<h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"), EEH_Template::format_currency($total_cost)); ?></h2>
209 209
 		</div>
210 210
 		<div class="payment-dv">
211
-			<h3 class="section-title"><?php _e("Payments",'event_espresso')?></h3>
211
+			<h3 class="section-title"><?php _e("Payments", 'event_espresso')?></h3>
212 212
 			<p>[instructions]</p>
213 213
 			<table class="invoice-amount">
214 214
 				<thead>
215 215
 					<tr class="header_row">
216 216
 						<th><span class=""><?php _e('Payment Method', 'event_espresso'); ?></span></th>
217
-						<th class='left datetime_th'><?php _e("Date",'event_espresso')?></th>
217
+						<th class='left datetime_th'><?php _e("Date", 'event_espresso')?></th>
218 218
 						<th><span class=""><?php _e('Transaction Id / Cheque #', 'event_espresso'); ?></span></th>
219 219
 						<th><span class=""><?php _e('P.O. / S.O.#', 'event_espresso'); ?></span></th>
220 220
 						<th><span class=""><?php _e('Status', 'event_espresso'); ?></span></th>
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 				<tbody>
225 225
 					<?php
226 226
 					$c = false;
227
-					if(!empty($payments)){
227
+					if ( ! empty($payments)) {
228 228
 
229
-						foreach($payments as $payment){
229
+						foreach ($payments as $payment) {
230 230
 							/* @var $payment EE_Payment */?>
231
-						<tr class='item <?php echo (($c = !$c) ? ' odd' : '')?>'>
231
+						<tr class='item <?php echo (($c = ! $c) ? ' odd' : '')?>'>
232 232
 							<td><?php $payment->e('PAY_gateway')?></td>
233 233
 							<td><?php echo $payment->timestamp()?></td>
234 234
 							<td><?php $payment->e('PAY_txn_id_chq_nmbr')?></td>
@@ -237,17 +237,17 @@  discard block
 block discarded – undo
237 237
 							<td class='item_r'><?php echo $payment->amount_no_code()?></td>
238 238
 						</tr>
239 239
 						<?php }
240
-					}else{?>
240
+					} else {?>
241 241
 						<tr class='item'>
242
-							<td class='aln-cntr' colspan="6"><?php _e("No approved payments have been received.",'event_espresso')?> </td>
242
+							<td class='aln-cntr' colspan="6"><?php _e("No approved payments have been received.", 'event_espresso')?> </td>
243 243
 						</tr>
244 244
 					<?php }
245
-					?><tr class="item" ><td class='aln-cntr' colspan="6"><?php if($amount_owed){?><a class="noPrint" href='<?php echo $retry_payment_url?>'><?php _e("Please make a payment.", "event_espresso");}?></a></td></tr>
245
+					?><tr class="item" ><td class='aln-cntr' colspan="6"><?php if ($amount_owed) {?><a class="noPrint" href='<?php echo $retry_payment_url?>'><?php _e("Please make a payment.", "event_espresso"); }?></a></td></tr>
246 246
 				</tbody>
247 247
 				<tfoot>
248 248
 					<tr class='total_tr'><td colspan="4">&nbsp;</td>
249
-						<td class="item_r"><?php _e('Total Paid','event_espresso')?></td>
250
-						<td class="item_r"><?php echo EEH_Template::format_currency($amount_pd,false,false)?> </td>
249
+						<td class="item_r"><?php _e('Total Paid', 'event_espresso')?></td>
250
+						<td class="item_r"><?php echo EEH_Template::format_currency($amount_pd, false, false)?> </td>
251 251
 					</tr>
252 252
 					<?php //echo $discount; ?>
253 253
 					<tr class="total_tr odd">
@@ -259,20 +259,20 @@  discard block
 block discarded – undo
259 259
 			</table>
260 260
 		</div>
261 261
 		<div class="additional-info-dv">
262
-			<h3 class="section-title"><?php _e("Additional Information:", "event_espresso");?></h3>
262
+			<h3 class="section-title"><?php _e("Additional Information:", "event_espresso"); ?></h3>
263 263
 			<div class="additional-info">
264
-				<?php if($venues_for_events){?>
265
-				<h2><?php echo _n("Venue Details:", "Venues Details:", "event_espresso",count($venues_for_events));?></h2>
264
+				<?php if ($venues_for_events) {?>
265
+				<h2><?php echo _n("Venue Details:", "Venues Details:", "event_espresso", count($venues_for_events)); ?></h2>
266 266
 				<table class="venue-list">
267
-					<?php foreach($venues_for_events as $venue){?>
267
+					<?php foreach ($venues_for_events as $venue) {?>
268 268
 						<tr class="venue-details">
269 269
 							<td class="venue-details-part venue-address-dv">
270 270
 								<h3><a href='<?php echo $venue->get_permalink()?>'><?php
271 271
 									echo $venue->name()
272 272
 								?></a></h3>
273 273
 								<p><?php echo $venue->description()?></p>
274
-								<?php echo  EEH_Address::format($venue);?></td>
275
-							<?php if($venue->enable_for_gmap()){?>
274
+								<?php echo  EEH_Address::format($venue); ?></td>
275
+							<?php if ($venue->enable_for_gmap()) {?>
276 276
 								<td class="venue-details-part venue-image-dv"><?php echo EEH_Venue_View::espresso_google_static_map($venue)?></td>
277 277
 							<?php } ?>
278 278
 						</tr>
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 				</table>
281 281
 				<?php } ?>
282 282
 
283
-				<?php if($shameless_plug){?>
283
+				<?php if ($shameless_plug) {?>
284 284
 				<div class='aln-cntr'><?php
285
-					printf(__("Powered by %sEvent Espresso %s", "event_espresso"),"<a href='https://eventespresso.com'>","</a>");
285
+					printf(__("Powered by %sEvent Espresso %s", "event_espresso"), "<a href='https://eventespresso.com'>", "</a>");
286 286
 				?></div>
287 287
 				<?php } ?>
288 288
 			</div>
Please login to merge, or discard this patch.
core/libraries/messages/defaults/default/html_receipt_content.template.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 			</td>
24 24
 			<td>
25 25
 				<div id="invoice-info">
26
-					<h2 id="invoice-hdr"><?php _e( 'Order Confirmation', 'event_espresso' ) ?></h2>
26
+					<h2 id="invoice-hdr"><?php _e('Order Confirmation', 'event_espresso') ?></h2>
27 27
 
28
-					<h3 id="invoice-date"><?php _e( 'Date:', 'event_espresso' ) ?>
28
+					<h3 id="invoice-date"><?php _e('Date:', 'event_espresso') ?>
29 29
 						<span class="plain-text">[PRIMARY_REGISTRANT_REGISTRATION_DATE]</span></h3>
30 30
 
31
-					<h3 id="invoice-txn-id"><?php _e( 'Transaction ID:', 'event_espresso' ) ?>
31
+					<h3 id="invoice-txn-id"><?php _e('Transaction ID:', 'event_espresso') ?>
32 32
 						<span class="plain-text">[TXN_ID]</span></h3>
33 33
 
34
-					<h3 id="invoice-txn-status"><?php _e( 'Status:', 'event_espresso' ) ?>
34
+					<h3 id="invoice-txn-status"><?php _e('Status:', 'event_espresso') ?>
35 35
 						<span class="[TXN_STATUS_ID] plain-text">[TXN_STATUS]</span></h3>
36 36
 				</div>
37 37
 			</td>
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 		[EVENT_LIST]
42 42
 	</div>
43 43
 	<div class="taxes">
44
-		<h3 class="section-title"><?php _e( "Additional Charges/Discounts", 'event_espresso' ) ?></h3>
44
+		<h3 class="section-title"><?php _e("Additional Charges/Discounts", 'event_espresso') ?></h3>
45 45
 		<table class="invoice-amount">
46 46
 			<thead>
47 47
 				<tr class="header_row">
48
-					<th class="left ticket_th"><?php _e( "Name", "event_espresso" ); ?></th>
49
-					<th class="left"><?php _e( 'Description', 'event_espresso' ); ?></th>
50
-					<th class="event_th item_c"><?php _e( 'Quantity', 'event_espresso' ); ?></th>
51
-					<th class="event_th item_c"><?php _e( 'Unit Price', 'event_espresso' ); ?></th>
52
-					<th class="subtotal_th"><?php _e( 'Total', 'event_espresso' ); ?></th>
48
+					<th class="left ticket_th"><?php _e("Name", "event_espresso"); ?></th>
49
+					<th class="left"><?php _e('Description', 'event_espresso'); ?></th>
50
+					<th class="event_th item_c"><?php _e('Quantity', 'event_espresso'); ?></th>
51
+					<th class="event_th item_c"><?php _e('Unit Price', 'event_espresso'); ?></th>
52
+					<th class="subtotal_th"><?php _e('Total', 'event_espresso'); ?></th>
53 53
 				</tr>
54 54
 			</thead>
55 55
 			<tbody>
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
 		</table>
61 61
 	</div>
62 62
 	<div class="taxes">
63
-		<h3 class="section-title"><?php _e( "Taxes", 'event_espresso' ) ?></h3>
64
-		<p><?php printf( __( '%s*%s Taxable items. The total amount collected for taxes is reflected in the total(s) below.', 'event_espresso' ), '<strong>', '</strong>' ); ?></p>
63
+		<h3 class="section-title"><?php _e("Taxes", 'event_espresso') ?></h3>
64
+		<p><?php printf(__('%s*%s Taxable items. The total amount collected for taxes is reflected in the total(s) below.', 'event_espresso'), '<strong>', '</strong>'); ?></p>
65 65
 		<table class="invoice-amount">
66 66
 			<thead>
67 67
 				<tr class="header_row">
68
-					<th class="left ticket_th"><?php _e( "Tax Name", "event_espresso" ); ?></th>
69
-					<th class="left"><?php _e( 'Description', 'event_espresso' ); ?></th>
70
-					<th class="event_th item_c"><?php _e( 'Rate', 'event_espresso' ); ?></th>
71
-					<th class="subtotal_th"><?php _e( 'Tax Amount', 'event_espresso' ); ?></th>
68
+					<th class="left ticket_th"><?php _e("Tax Name", "event_espresso"); ?></th>
69
+					<th class="left"><?php _e('Description', 'event_espresso'); ?></th>
70
+					<th class="event_th item_c"><?php _e('Rate', 'event_espresso'); ?></th>
71
+					<th class="subtotal_th"><?php _e('Tax Amount', 'event_espresso'); ?></th>
72 72
 				</tr>
73 73
 			</thead>
74 74
 			<tbody>
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 		</table>
80 80
 	</div>
81 81
 	<div class="grand-total-dv">
82
-		<h2 class="grand-total"><?php printf( __( "Grand Total: %s", "event_espresso" ), '[TOTAL_COST]' ); ?></h2>
82
+		<h2 class="grand-total"><?php printf(__("Grand Total: %s", "event_espresso"), '[TOTAL_COST]'); ?></h2>
83 83
 	</div>
84 84
 	<div class="payment-dv">
85
-		<h3 class="section-title"><?php _e( "Payments", 'event_espresso' ) ?></h3>
85
+		<h3 class="section-title"><?php _e("Payments", 'event_espresso') ?></h3>
86 86
 		<table class="invoice-amount">
87 87
 			<thead>
88 88
 				<tr class="header_row">
89
-					<th><span class=""><?php _e( 'Payment Method', 'event_espresso' ); ?></span></th>
90
-					<th class='left datetime_th'><?php _e( "Date", 'event_espresso' ) ?></th>
91
-					<th><span class=""><?php _e( 'Transaction Id / Cheque #', 'event_espresso' ); ?></span></th>
92
-					<th><span class=""><?php _e( 'P.O. / S.O.#', 'event_espresso' ); ?></span></th>
93
-					<th><span class=""><?php _e( 'Status', 'event_espresso' ); ?></span></th>
94
-					<th><?php _e( 'Amount', 'event_espresso' ); ?></th>
89
+					<th><span class=""><?php _e('Payment Method', 'event_espresso'); ?></span></th>
90
+					<th class='left datetime_th'><?php _e("Date", 'event_espresso') ?></th>
91
+					<th><span class=""><?php _e('Transaction Id / Cheque #', 'event_espresso'); ?></span></th>
92
+					<th><span class=""><?php _e('P.O. / S.O.#', 'event_espresso'); ?></span></th>
93
+					<th><span class=""><?php _e('Status', 'event_espresso'); ?></span></th>
94
+					<th><?php _e('Amount', 'event_espresso'); ?></th>
95 95
 				</tr>
96 96
 			</thead>
97 97
 			<tbody>
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
 			<tfoot>
106 106
 				<tr class='total_tr'>
107 107
 					<td colspan="4">&nbsp;</td>
108
-					<td class="item_r"><?php _e( 'Total Paid', 'event_espresso' ) ?></td>
108
+					<td class="item_r"><?php _e('Total Paid', 'event_espresso') ?></td>
109 109
 					<td class="item_r">[TOTAL_AMOUNT_PAID]</td>
110 110
 				</tr>
111 111
 				<tr class="total_tr odd">
112 112
 					<td colspan="4">&nbsp;</td>
113
-					<td class="total" id="total_currency"><?php _e( 'Amount Owed:', 'event_espresso' ); ?></td>
113
+					<td class="total" id="total_currency"><?php _e('Amount Owed:', 'event_espresso'); ?></td>
114 114
 					<td class="total">[TOTAL_OWING]</td>
115 115
 				</tr>
116 116
 			</tfoot>
117 117
 		</table>
118 118
 	</div>
119 119
 	<div class="additional-info-dv">
120
-		<h3 class="section-title"><?php _e( "Additional Information:", "event_espresso" ); ?></h3>
120
+		<h3 class="section-title"><?php _e("Additional Information:", "event_espresso"); ?></h3>
121 121
 		<div class="additional-info">
122
-			<h2><?php _e( "Venue Details:", "event_espresso" ); ?></h2>
122
+			<h2><?php _e("Venue Details:", "event_espresso"); ?></h2>
123 123
 			<table class="venue-list">
124 124
 				<tr class="venue-details">
125 125
 					<td class="venue-details-part venue-address-dv">
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					<td class="venue-details-part venue-image-dv">[GOOGLE_MAP_IMAGE]</td>
132 132
 				</tr>
133 133
 			</table>
134
-			<div class='aln-cntr'><?php printf( __( "Powered by %sEvent Espresso %s", "event_espresso" ), "<a href='https://eventespresso.com'>", "</a>" ); ?></div>
134
+			<div class='aln-cntr'><?php printf(__("Powered by %sEvent Espresso %s", "event_espresso"), "<a href='https://eventespresso.com'>", "</a>"); ?></div>
135 135
 		</div>
136 136
 	</div>
137 137
 </div>
Please login to merge, or discard this patch.